[Python-bugs-list] [Bug #110924] support Unicode for Python source code

noreply@sourceforge.net noreply@sourceforge.net
Wed, 4 Oct 2000 09:01:03 -0700


Bug #110924, was updated on 2000-Aug-02 08:17
Here is a current snapshot of the bug.

Project: Python
Category: Parser/Compiler
Status: Closed
Resolution: Fixed
Bug Group: Feature Request
Priority: 1
Summary: support Unicode for Python source code

Details: exec u"print 42"
doesn't work.

Follow-Ups:

Date: 2000-Aug-09 02:35
By: effbot

Comment:
python doesn't support 16-bit source code -- so what exactly do you want exec to do?
-------------------------------------------------------

Date: 2000-Aug-17 05:17
By: none

Comment:
That's exactly my point. Python should support Unicode
everywhere, in __str__ and __repr__, exec and eval, in open(), as a format for the source code (which would result in all variable names to be Unicode)...

Currenly working with Unicode (e.g. for XML) is a mess, because it's supported nowhere.

exec "a='ü'" seems to work and seems to treat the string as iso-8859-1 (or not at all)

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

Date: 2000-Sep-07 15:03
By: jhylton

Comment:
Please do triage on this bug.
-------------------------------------------------------

Date: 2000-Sep-08 05:21
By: lemburg

Comment:
I don't think that the situation is that bad. You can't program
Python in Unicode, but this doesn't stop you from using it
in your Python programs.

Note that __str__ and __repr__ do support Unicode (it gets converted
to an 8-bit string using the default encoding).

There's currently not much need to have exec or eval() automatically
apply any conversion... you can always use str() around the argument
to make it support both 8-bit strings and Unicode.

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

Date: 2000-Sep-16 15:18
By: bwarsaw

Comment:
Reassigning to Guido for final disposal, but I believe this should be marked either as "not a bug" or added to PEP 42.
-------------------------------------------------------

Date: 2000-Sep-16 19:51
By: gvanrossum

Comment:
There's an Accepted patch for this by Marc-Andre Lemburg.
Assigned to Marc-Andre so he can close the bug when he applies the patch.

(Marc-Andre: if you don't have time to apply the patch, let me know and I'll take care of it.)
-------------------------------------------------------

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.

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

Date: 2000-Oct-04 09:01
By: none

Comment:
This doesn't solve the problem,
it only hides it.

When I set the defaultencoding to
"utf16" in site.py, I get the following error:

>>> exec u"a = 42"
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
TypeError: expected string without null bytes

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

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