-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
bpo-17422:language reference should specify restrictions on class namespace #18559
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
Conversation
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.
Thanks @ananthan-123. No need to request reviews from 3 triagers and 4 core developers though, that's bordering on spam (especially if they have nothing to do with the issue/patch). One request should be fine, maybe a second if the first person doesn't respond after a week or two.
A few things I spotted here (I'm assuming that the wording in Eric's original patch from 7 years ago is correct):
Misc/NEWS.d/next/Documentation/2020-02-19-11-13-47.bpo-17422.g7_9zz.rst
Outdated
Show resolved
Hide resolved
Co-Authored-By: Brandt Bucher <brandtbucher@gmail.com>
…7_9zz.rst Co-Authored-By: Brandt Bucher <brandtbucher@gmail.com>
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.
Looks good now. @ericsnowcurrently, care to review the content for this? It's your issue.
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.
Sorry, one more thing...
Misc/NEWS.d/next/Documentation/2020-02-19-11-13-47.bpo-17422.g7_9zz.rst
Outdated
Show resolved
Hide resolved
…7_9zz.rst Co-Authored-By: Brandt Bucher <brandtbucher@gmail.com>
@@ -0,0 +1 @@ | |||
Language reference should specify restrictions on class namespace. |
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.
Please attribute the patch to its author here.
@gvanrossum: Please replace |
Thanks @ananthan-123 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.7. |
Thanks @ananthan-123 for the PR, and @gvanrossum for merging it 🌮🎉.. I'm working now to backport this PR to: 3.8. |
GH-18610 is a backport of this pull request to the 3.8 branch. |
…mespace (pythonGH-18559) The language reference now specifies restrictions on class namespaces. Adapted from a patch by Ethan Furman. (cherry picked from commit fbe2e0b) Co-authored-by: ananthan-123 <ananthakrishnan15.2001@gmail.com>
GH-18611 is a backport of this pull request to the 3.7 branch. |
|
||
If the metaclass has no ``__prepare__`` attribute, then the class namespace | ||
is initialised as an empty ordered mapping. |
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.
Per PEP 520, the default class namespace must be an ordered mapping and the original text here was purposefully phrased. While we've talked about requiring "dict" to be ordered (in the language reference), that hasn't happened. So changing the language spec text here to "dict" is inappropriate without a PEP. Note that elsewhere in the language reference the "ordered mapping" phrasing still exists.
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.
Um, dict
is required to be ordered. Since 3.7. See the 3.7. what's new doc "the insertion-order preservation nature of dict objects has been declared to be an official part of the Python language spec."
If after that has sunk in you still think this PR is wrong, please submit a new PR to fix it! (Sorry for landing prematurely.)
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.
Per my comment on the bpo I think @ericsnowcurrently is right but for the wrong reasons. I have opened a PR correcting the wording. #18682
https://bugs.python.org/issue17422