-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
bpo-31107: Fix copyreg mangled slot names calculation. #2989
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA (this might be simply due to a missing "GitHub Name" entry in your b.p.o account settings). This is necessary for legal reasons before we can look at your contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. Thanks again to your contribution and we look forward to looking at it! |
Lib/copyreg.py
Outdated
@@ -128,7 +128,7 @@ class found there. (This assumes classes don't modify their | |||
continue | |||
# mangled names | |||
elif name.startswith('__') and not name.endswith('__'): | |||
names.append('_%s%s' % (c.__name__, name)) | |||
names.append('_%s%s' % (c.__name__.lstrip('_'), name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name shouldn't be mangled if c.__name__.lstrip('_')
is an empty string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, I wasn't aware of that case.
Please add a NEWS entry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a NEWS entry and a test with an underscore only class name.
Lib/copyreg.py
Outdated
@@ -128,7 +128,7 @@ class found there. (This assumes classes don't modify their | |||
continue | |||
# mangled names | |||
elif name.startswith('__') and not name.endswith('__'): | |||
names.append('_%s%s' % (c.__name__, name)) | |||
names.append('_%s%s' % (c.__name__.lstrip('_'), name)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, I wasn't aware of that case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Please sign the PSF contributor agreement and add your name into Misc/ACKS
.
Thanks for the review @serhiy-storchaka. I signed the PSF contributor agreement yesterday and my GitHub is linked to my bugs.python.org account. Does it take some time for @the-knights-who-say-ni to notice? |
Usually it takes a one working day (as in this case). |
Thank you for your contribution @ShaneHarvey! Do you mind to backport these changes to 3.6 and 2.7? |
Sure I can backport it to those branches. |
GH-3003 is a backport of this pull request to the 3.6 branch. |
GH-3004 is a backport of this pull request to the 2.7 branch. |
https://bugs.python.org/issue31107
https://bugs.python.org/issue31107