[Python-bugs-list] [Bug #113890] eval() fails with unicode string

noreply@sourceforge.net noreply@sourceforge.net
Tue, 19 Sep 2000 14:07:45 -0700


Bug #113890, was updated on 2000-Sep-08 08:22
Here is a current snapshot of the bug.

Project: Python
Category: Core
Status: Closed
Resolution: Fixed
Bug Group: None
Priority: 5
Summary: eval() fails with unicode string

Details: Python 2.0b1 (#3, Sep  6 2000, 12:34:06) 
[GCC 2.95.2 19991024 (release)] on sunos5
Type "copyright", "credits" or "license" for more information.
>>> eval("1+2)
  File "<stdin>", line 1
    eval("1+2)
             ^
SyntaxError: invalid token
>>> eval("1+2")
3
>>> eval(u"1+2")
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: eval() argument 1 must be string or code object


Follow-Ups:

Date: 2000-Sep-08 08:35
By: lemburg

Comment:
It would be fairly straight forward to fix this by having
eval() and exec auto-convert the input to an 8-bit string
using the default encoding.

Should we proceed this way ?

-------------------------------------------------------

Date: 2000-Sep-19 14:07
By: lemburg

Comment:
exec and eval() now also accept Unicode as code parameter.

This is implemented by having the two APIs convert Unicode
to a string using the default encoding prior to processing the
code string.

-------------------------------------------------------

For detailed info, follow this link:
http://sourceforge.net/bugs/?func=detailbug&bug_id=113890&group_id=5470