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
There are inconsitencies in the treatment of True, False, None, and __debug__ keywords in the docs #78645
Comments
The identifiers True, False, None and __debug__ are keywords in the language. For example
>>> __debug__ = __debug__
SyntaxError: assignment to keyword
See also: https://github.com/jfine2358/py-jfine2358/blob/master/docs/none-is-special.md Credit: The __debug__ problem arises from Steve D'Aprano's message https://mail.python.org/pipermail/python-ideas/2018-August/052917.html |
I'm happy to work on improving the text here. I'm new to contributing to Python. I'm being mentored to work on bpo-34431. Once I'm done with that, I'll be better placed to contributed to this issue. |
I've removed 2.7 since those constants are not keywords in 2.7 (although None and __debug__ do raise syntax errors even in 2.7, they are not keywords there). Which is almost certainly why the docs treat them inconsistently (leftovers from before they weren't keywords). We only update docs for the actively maintained versions, so I've removed everything before 3.6. I also tried to clarify the issue in the title. I don't know why you mention NotImplemented, that's not a keyword. The issue with __debug__ and keywords.py probably requires a code change, since that file is auto-generated. Please open a separate issue for that. Thanks for wanting to improve python! |
Hi @david, Maybe we could remove 3.6 from the list because 3.6 is in security mode and not bugfix. Is there a security issue with this bug? |
__debug__ is not a keyword. And the error message has been changed in 3.8. But it is a special enough. You can not use this name in any assignment context: >>> __debug__ = 1
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> for __debug__ in []: pass
...
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> with cm() as __debug__: pass
...
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> class __debug__: pass
...
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> def __debug__(): pass
...
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> def foo(__debug__): pass
...
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__
>>> import __debug__
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__ You can not even assign to an attribute named __debug__! >>> x.__debug__ = 1
File "<stdin>", line 1
SyntaxError: cannot assign to __debug__ The assignment operator is the only exception here, and this looks like a bug. |
The issue about the assigment operator is closed https://bugs.python.org/issue36052 could we close this issue? thank you |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: