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: Compiler module doesn't handle global statement correctly
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: nascheme Nosy List: dcjim, dsuch, jhylton, nascheme, nnorwitz
Priority: normal Keywords:

Created on 2004-07-27 22:15 by dcjim, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (5)
msg21831 - (view) Author: Jim Fulton (dcjim) (Python triager) Date: 2004-07-27 22:15
If we don't use the compiler module:

>>> code = 'global x\nx=1'
>>> d1={'__builtins__': {}}; d2={}; exec code in d1, d2
>>> d1, d2
({'__builtins__': {}, 'x': 1}, {})

with the compiler module:

>>> code = compiler.compile('global x\nx=1', 'd', 'exec') 
>>> d1={'__builtins__': {}}; d2={}; exec code in d1, d2
>>> d1, d2
({'__builtins__': {}}, {'x': 1})

global is ignored
msg21832 - (view) Author: Jim Fulton (dcjim) (Python triager) Date: 2004-07-28 14:01
Logged In: YES 
user_id=73023

Also in 2.3
msg21833 - (view) Author: Dariusz Suchojad (dsuch) Date: 2005-04-29 22:04
Logged In: YES 
user_id=954779

Hi, I have submitted a simple fix some time ago
python.org/sf/1090482, do you think it is correct?
msg21834 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2006-02-25 22:01
Logged In: YES 
user_id=33168

FYI
msg81328 - (view) Author: Neil Schemenauer (nascheme) * (Python committer) Date: 2009-02-07 00:58
Fixed in SVN rev 69394 (finally).  This was done by having the symbol
table differentiate between explicit and implicit globals.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40653
2009-02-07 00:59:01naschemesetstatus: open -> closed
assignee: jhylton -> nascheme
resolution: fixed
messages: + msg81328
nosy: + nascheme
2004-07-27 22:15:57dcjimcreate