This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2017年07月03日 19:21 by OswinC, last changed 2022年04月11日 14:58 by admin. This issue is now closed.
| Pull Requests | |||
|---|---|---|---|
| URL | Status | Linked | Edit |
| PR 2180 | merged | OswinC, 2017年07月03日 19:21 | |
| PR 2181 | merged | OswinC, 2017年07月03日 19:22 | |
| PR 2182 | merged | OswinC, 2017年07月03日 19:22 | |
| PR 3001 | merged | lukasz.langa, 2017年08月04日 17:59 | |
| Messages (5) | |||
|---|---|---|---|
| msg297609 - (view) | Author: Yuan Chao Chou (OswinC) * | Date: 2017年07月03日 19:21 | |
When Parser/asdl_c.py is composing the content of Python/Python-ast.c, it uses "value" to name the variables in inner blocks, which can shadow the variables named the same in outer blocks. It would be a good practice to avoid the shadowing naming to prevent the variables from being misused. |
|||
| msg299208 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2017年07月26日 04:53 | |
What actually omits warnings about this? |
|||
| msg299210 - (view) | Author: Yuan Chao Chou (OswinC) * | Date: 2017年07月26日 06:26 | |
This can be repro by setting -Wshadow-compatible-local when using gcc to compile Python-ast.c. An example on my machine: ➜ cpython git:(69c0db5050) ✗ gcc-7 -Wshadow-compatible-local -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I./Include -I. -I/usr/local/opt/readline/include -I/usr/local/opt/openssl/include -I/Users/python/.pyenv/versions/3.6.1/include -I/usr/local/include -I/Users/python/.pyenv/versions/3.6.1/include/python3.6m -c Python/Python-ast.c -o build/temp.macosx-10.12-x86_64-3.6/Python-ast.o Python/Python-ast.c: In function 'obj2ast_stmt': Python/Python-ast.c:4586:25: warning: declaration of 'value' shadows a previous local [-Wshadow=compatible-local] expr_ty value; ^~~~~ Python/Python-ast.c:4570:17: note: shadowed declaration is here expr_ty value; ^~~~~ |
|||
| msg299754 - (view) | Author: Łukasz Langa (lukasz.langa) * (Python committer) | Date: 2017年08月04日 17:52 | |
The actual change is just three lines in asdl_c.py. Python-ast.c is generated. |
|||
| msg299755 - (view) | Author: Łukasz Langa (lukasz.langa) * (Python committer) | Date: 2017年08月04日 18:00 | |
Thanks! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:58:48 | admin | set | github: 75024 |
| 2017年08月04日 18:00:35 | lukasz.langa | set | status: open -> closed resolution: fixed messages: + msg299755 stage: resolved |
| 2017年08月04日 17:59:28 | lukasz.langa | set | pull_requests: + pull_request3037 |
| 2017年08月04日 17:52:51 | lukasz.langa | set | nosy:
+ lukasz.langa messages: + msg299754 |
| 2017年08月02日 01:51:16 | OswinC | set | title: A shadowing variable naming emitted for Python-ast.c -> Fix a variable shadowing warning in Python-ast.c |
| 2017年07月26日 06:26:47 | OswinC | set | messages: + msg299210 |
| 2017年07月26日 04:53:41 | benjamin.peterson | set | messages: + msg299208 |
| 2017年07月08日 18:38:06 | brett.cannon | set | priority: normal -> low |
| 2017年07月08日 18:37:59 | brett.cannon | set | type: compile error -> enhancement |
| 2017年07月08日 03:00:08 | terry.reedy | set | nosy:
+ brett.cannon, ncoghlan, benjamin.peterson, yselivanov |
| 2017年07月03日 19:22:56 | OswinC | set | pull_requests: + pull_request2619 |
| 2017年07月03日 19:22:42 | OswinC | set | pull_requests: + pull_request2618 |
| 2017年07月03日 19:21:37 | OswinC | set | pull_requests: + pull_request2617 |
| 2017年07月03日 19:21:00 | OswinC | create | |