Vladimir Marangozov wrote: > > Seen on c.l.py (import site fails due to eval on an unicode string): > > ~/python/Python-2.0b1>python -U > 'import site' failed; use -v for traceback > Python 2.0b1 (#2, Sep 7 2000, 12:59:53) > [GCC egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)] on linux2 > Type "copyright", "credits" or "license" for more information. > >>> eval (u"1+2") > Traceback (most recent call last): > File "<stdin>", line 1, in ? > TypeError: eval() argument 1 must be string or code object > >>> > > The offending eval is in os.py > > Traceback (most recent call last): > File "./Lib/site.py", line 60, in ? > import sys, os > File "./Lib/os.py", line 331, in ? > if _exists("fork") and not _exists("spawnv") and _exists("execv"): > File "./Lib/os.py", line 325, in _exists > eval(name) Note that many thing fail when Python is started with -U... that switch was introduced to be able to get an idea of which parts of the standard fail to work in a mixed string/Unicode environment. In the above case, I guess the eval() could be replaced by some other logic which does a try: except NameError: check. -- Marc-Andre Lemburg ______________________________________________________________________ Business: http://www.lemburg.com/ Python Pages: http://www.lemburg.com/python/
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4