
This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.
Created on2019-02-20 15:23 byserhiy.storchaka, last changed2022-04-11 14:59 byadmin. This issue is nowclosed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 11957 | closed | pablogsal,2019-02-20 16:53 | |
| PR 11958 | merged | matrixise,2019-02-20 17:01 | |
| Messages (11) | |||
|---|---|---|---|
| msg336100 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2019-02-20 15:23 | |
All ways of assigning to __debug__ are forbidden:>>> __debug__ = 1 File "<stdin>", line 1SyntaxError: cannot assign to __debug__>>> for __debug__ in []: pass... File "<stdin>", line 1SyntaxError: cannot assign to __debug__>>> with cm() as __debug__: pass... File "<stdin>", line 1SyntaxError: cannot assign to __debug__>>> class __debug__: pass... File "<stdin>", line 1SyntaxError: cannot assign to __debug__>>> def __debug__(): pass... File "<stdin>", line 1SyntaxError: cannot assign to __debug__>>> def foo(__debug__): pass... File "<stdin>", line 1SyntaxError: cannot assign to __debug__>>> import __debug__ File "<stdin>", line 1SyntaxError: cannot assign to __debug__The only exception is the assignment operator.>>> (__debug__ := 'spam')'spam'>>> globals()['__debug__']'spam'This looks like a bug. | |||
| msg336103 -(view) | Author: Stéphane Wirtel (matrixise)*![]() | Date: 2019-02-20 15:39 | |
An idea for the fix? a direction where I could find the solution? ;-) | |||
| msg336104 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2019-02-20 15:41 | |
You need to add for the target of the assignment operator the same check as for other targets. | |||
| msg336108 -(view) | Author: Stéphane Wirtel (matrixise)*![]() | Date: 2019-02-20 16:07 | |
ok, I will check for the assignment operator in the code.maybe in the AST (Python-ast.c) but I think not | |||
| msg336110 -(view) | Author: Stéphane Wirtel (matrixise)*![]() | Date: 2019-02-20 16:17 | |
ok, I found the commit of @emily8f59ee01be3d83d5513a9a3f654a237d77d80d9aand will try to find the assignment operator := | |||
| msg336112 -(view) | Author: Emily Morehouse (emilyemorehouse)*![]() | Date: 2019-02-20 16:41 | |
You should look inPython/ast.c. The naming convention follows some form of "named expression" (e.g. NamedExpr, ast_for_namedexpr).I'll have more time to look later this week, but let me know if you have any questions. | |||
| msg336113 -(view) | Author: Stéphane Wirtel (matrixise)*![]() | Date: 2019-02-20 16:44 | |
Hi @emilyThank you for your help.In fact, I have started to read Python-ast.c and ast.c, they are the main files for this kind of operations.Thank you again, | |||
| msg336115 -(view) | Author: Serhiy Storchaka (serhiy.storchaka)*![]() | Date: 2019-02-20 16:50 | |
Look at compile.c. The code for restricting other assignments is located here. | |||
| msg336119 -(view) | Author: Pablo Galindo Salgado (pablogsal)*![]() | Date: 2019-02-20 17:01 | |
When I started working on this I did not notice the extra comments here. I will close my PR so Stéphane can do the PR. | |||
| msg336124 -(view) | Author: Stéphane Wirtel (matrixise)*![]() | Date: 2019-02-20 17:09 | |
Thank you Pablo, if I see you at PyCon, maybe we could drink a good beer ;-) | |||
| msg336197 -(view) | Author: Pablo Galindo Salgado (pablogsal)*![]() | Date: 2019-02-21 10:11 | |
New changeset3ad91673057d410bf9f8c53df6bb8aa18c4b68ca by Pablo Galindo (Stéphane Wirtel) in branch 'master':bpo-36052: Raise a SyntaxError when assigning a value to __debug__ with := (GH-11958)https://github.com/python/cpython/commit/3ad91673057d410bf9f8c53df6bb8aa18c4b68ca | |||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:59:11 | admin | set | github: 80233 |
| 2019-02-21 10:12:23 | pablogsal | set | status: open -> closed resolution: fixed stage: patch review -> resolved |
| 2019-02-21 10:11:57 | pablogsal | set | messages: +msg336197 |
| 2019-02-20 17:09:53 | matrixise | set | messages: +msg336124 |
| 2019-02-20 17:01:19 | pablogsal | set | nosy: +pablogsal messages: +msg336119 |
| 2019-02-20 17:01:17 | matrixise | set | pull_requests: +pull_request11985 |
| 2019-02-20 16:53:11 | pablogsal | set | keywords: +patch stage: patch review pull_requests: +pull_request11984 |
| 2019-02-20 16:50:19 | serhiy.storchaka | set | messages: +msg336115 |
| 2019-02-20 16:47:51 | matrixise | set | assignee:matrixise |
| 2019-02-20 16:44:14 | matrixise | set | messages: +msg336113 |
| 2019-02-20 16:41:17 | emilyemorehouse | set | messages: +msg336112 |
| 2019-02-20 16:17:01 | matrixise | set | messages: +msg336110 |
| 2019-02-20 16:07:01 | matrixise | set | messages: +msg336108 |
| 2019-02-20 15:41:40 | serhiy.storchaka | set | messages: +msg336104 |
| 2019-02-20 15:39:07 | matrixise | set | nosy: +matrixise messages: +msg336103 |
| 2019-02-20 15:23:36 | serhiy.storchaka | create | |