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.

classification
Title: [regression] symtable.Symbol.is_local() is no longer True for bound global symbols
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9, Python 3.8, Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: CendioOssman, pablogsal
Priority: normal Keywords: patch

Created on 2020-09-23 12:22 by CendioOssman, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 22391 merged pablogsal, 2020-09-23 22:20
PR 22528 merged pablogsal, 2020-10-03 19:48
PR 22529 merged pablogsal, 2020-10-03 19:48
Messages (5)
msg377373 - (view) Author: Pierre Ossman (CendioOssman) Date: 2020-09-23 12:22
So Issue40196 (and PR 19391) broke things for us here as Symbol.is_local() no longer works properly for symbols on the global/module scope.

Previously it would return True for all global symbols that were bound. Now it only returns True when the symbol is not used in any other scope. This means we cannot tell the difference between globals that are from the module itself, and globals that come in via imports.

This also seems to contradict this part of the language reference:

"(The variables of the module code block are local and global.)"

https://docs.python.org/3/reference/executionmodel.html

I don't see any clean workaround as there is no Symbol.is_bound() that could be used instead.

(inb4 https://xkcd.com/1172/)
msg377428 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-09-23 22:21
Hi Cendio Ossman and thanks for the report.

Indeed, there are a bunch of problems here taking into account the language reference "The variables of the module code block are local and global". PR 22391 fixes those and also the repr-generation for module-level that was also broken
msg377901 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-10-03 19:45
New changeset fb0a4651f1be4ad936f8277478f73f262d8eeb72 by Pablo Galindo in branch 'master':
bpo-41840: Report module-level globals as both local and global in the symtable module (GH-22391)
https://github.com/python/cpython/commit/fb0a4651f1be4ad936f8277478f73f262d8eeb72
msg377903 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-10-03 20:23
New changeset 7b7aa94e51a396365df41f86b7b64a3b74481a6c by Pablo Galindo in branch '3.9':
[3.9] bpo-41840: Report module-level globals as both local and global in the symtable module (GH-22391). (GH-22528)
https://github.com/python/cpython/commit/7b7aa94e51a396365df41f86b7b64a3b74481a6c
msg377904 - (view) Author: Pablo Galindo Salgado (pablogsal) * (Python committer) Date: 2020-10-03 21:50
New changeset fd22823991380de2a309221748fc41cf0ba6ed40 by Pablo Galindo in branch '3.8':
[3.8] bpo-41840: Report module-level globals as both local and global in the symtable module (GH-22391). (GH-22529)
https://github.com/python/cpython/commit/fd22823991380de2a309221748fc41cf0ba6ed40
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 86006
2020-10-03 21:50:03pablogsalsetmessages: + msg377904
2020-10-03 21:49:56pablogsalsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-10-03 20:23:06pablogsalsetmessages: + msg377903
2020-10-03 19:48:51pablogsalsetpull_requests: + pull_request21534
2020-10-03 19:48:02pablogsalsetpull_requests: + pull_request21533
2020-10-03 19:45:59pablogsalsetmessages: + msg377901
2020-09-23 22:21:45pablogsalsetmessages: + msg377428
2020-09-23 22:20:01pablogsalsetkeywords: + patch
stage: patch review
pull_requests: + pull_request21432
2020-09-23 15:52:57xtreaksetnosy: + pablogsal
2020-09-23 12:22:04CendioOssmancreate