8000 bpo-29762: More use "raise from None". by serhiy-storchaka · Pull Request #569 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

bpo-29762: More use "raise from None". #569

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

serhiy-storchaka
Copy link
Member

This hides unwanted implementation details from tracebacks.

This hides unwanted implementation details from tracebacks.
@serhiy-storchaka serhiy-storchaka added the type-feature A feature request or enhancement label Mar 8, 2017
Copy link
@wm75 wm75 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally, I think this is a good idea, but only if there is absolutely no loss of information, which happens at least for two of your changes (see comments, there may be others that I've missed)

@@ -134,7 +134,7 @@ def decode_generalized_number(extended, extpos, bias, errors):
char = ord(extended[extpos])
except IndexError:
if errors == "strict":
raise UnicodeError("incomplete punicode string")
raise UnicodeError("incomplete punicode string") from None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

information about extpos is lost here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. And there are other bugs in this codec.

Lib/mailbox.py Outdated
@@ -201,7 +201,7 @@ def _string_to_bytes(self, message):
return message.encode('ascii')
except UnicodeError:
raise ValueError("String input must be ASCII-only; "
"use bytes or a Message instead")
"use bytes or a Message instead") from None
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

information about problematic character in the string is lost

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.