[issue4315] On some Python builds, exec in a function can't create shadows of variables if these are declared "global" in another function of the same module
New submission from Silas S. Brown <[EMAIL PROTECTED]>: Here's the example code: setting1 = "val1" setting2 = "val2" def dummy(): global setting1 def f(x): d ={"setting1":setting1,"setting2":setting2} exec(x) in d return d['setting1'], d['setting2'] print f("setting1=setting2='new'") Expected result: ('new', 'new') Actual result: ('val1', 'new') The presence of "global setting1" in a different function effectively stops a shadowed setting1 from being created by the exec. Workaround: Add a real assignment before the exec, i.e.: def f(x): setting1 = 0 exec(x) return setting1, setting2 or do the exec in a dictionary instead of in the current scope. Observed in: Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) on Cygwin Python 2.5.2 on 2.6.26-gentoo-r1 (by Christopher Faylor http://www.cygwin.com/ml/cygwin/2008-11/msg00168.html ) Not observed in: Python 2.5.1 (r251:54863, Aug 1 2008, 00:32:16) on SUSE Linux Python 2.4.4 (#2, Apr 17 2008, 01:58:28) (Debian etch, ARM) Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22) (Ubuntu) -- components: None messages: 75829 nosy: ssb22 severity: normal status: open title: On some Python builds, exec in a function can't create shadows of variables if these are declared "global" in another function of the same module type: behavior versions: Python 2.5 ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4315> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4315] On some Python builds, exec in a function can't create shadows of variables if these are declared "global" in another function of the same module
Silas S. Brown <[EMAIL PROTECTED]> added the comment: Sorry, I accidentally posted the workaround code instead of the bug example. This is what I should have posted: setting1 = "val1" setting2 = "val2" def dummy(): global setting1 def f(x): exec(x) return setting1,setting2 print f("setting1='new' ; setting2='new'") Expected result: ('new', 'new') Actual result: ('val1', 'new') The presence of "global setting1" in a different function effectively stops a shadowed setting1 from being created by the exec. Workaround: Add a real assignment before the exec, i.e.: def f(x): setting1 = 0 exec(x) return setting1, setting2 or do the exec in a dictionary instead of in the current scope, i.e.: def f(x): d ={"setting1":setting1,"setting2":setting2} exec(x) in d return d['setting1'], d['setting2'] Observed in: Python 2.5.1 (r251:54863, May 18 2007, 16:56:43) on Cygwin Python 2.5.2 on 2.6.26-gentoo-r1 (by Christopher Faylor http://www.cygwin.com/ml/cygwin/2008-11/msg00168.html ) Not observed in: Python 2.5.1 (r251:54863, Aug 1 2008, 00:32:16) on SUSE Linux Python 2.4.4 (#2, Apr 17 2008, 01:58:28) (Debian etch, ARM) Python 2.5.2 (r252:60911, Jul 31 2008, 17:31:22) (Ubuntu) ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4315> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1384175] random module - Provider DLL failed to initialize correctly
Silas S. Brown added the comment: I got a very similar error on an Otek Pocket PC running Windows Mobile 2003 SE and the latest version of pythonce from pythonce.sourceforge.net. The error is: File "C:\devl\release\PythonCE-2.5-20061219\Python-2.5-wince\Lib\random.py", line 108, in seed : [Error 87] Provider DLL failed to initialize correctly Although this was thrown up at the "import random" at the start of my program, the actual change I made that resulted in this error was much later in the program, and it was to change the lines try: justSynthesize=raw_input("Say: ") except EOFError: break into try: justSynthesize=raw_input(cond(winCEsound,"".join(warnings_printed)+cond(warnings_printed,"\n",""),"")+"Say: ") # (WinCE uses an input box so need to repeat the warnings if any) except EOFError: break where "cond" is an "if a then b else c" function. A little more investigation showed that the culprit was the comment! Removing the comment after the raw_input() call (or putting it on a different line) causes the program to work again. I confirmed that adding any raw_input() call to any function, with a prompt parameter and a comment afterwards, causes this error to happen on the "import random" near the top of the program. This is a very strange bug. -- nosy: +ssb22 ___ Python tracker <http://bugs.python.org/issue1384175> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1384175] random module - Provider DLL failed to initialize correctly
Silas S. Brown added the comment: After further investigation I'm suspecting that this issue is actually due to the process running out of RAM. ___ Python tracker <http://bugs.python.org/issue1384175> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com