Updates:
Summary: sympify(u"α") does not work
Labels: -Priority-Medium Priority-High Milestone-Release0.7.0
Comment #1 on issue 1763 by [email protected]: sympify(u"α") does not
work
http://code.google.com/p/sympy/issues/detail?id=1763
Actually, "α" is garbage and we shouldn't do anything with it: that's a
bytestream
containing whatever value the system's encoding gives to the unicode
character alpha.
That the interpreter allows such nonsense is a Python 2.* bug. Python 3.*
is much
more sensible (recall that a Python 3.* string is Python 2.*'s unicode,
while Python
3.*'s bytes is Python 2.*'s string):
Python 3.1.1+ (r311:74480, Nov 2 2009, 14:49:22)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "α"
'α'
>>> b"α"
File "<stdin>", line 1
SyntaxError: bytes can only contain ASCII literal characters.
For comparison:
Python 2.6.4 (r264:75706, Nov 2 2009, 14:38:03)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> "α"
'\xce\xb1'
>>> u"α"
u'\u03b1'
>>> print u"α"
α
On the other hand, u"α" is a sensible value and sympify should definitely do
something with it, but doesn't:
In [56]: sympify(u"α")
---------------------------------------------------------------------------
UnicodeEncodeError Traceback (most recent call last)
/media/sda2/Boulot/Projets/sympy-git/<ipython console> in <module>()
/media/sda2/Boulot/Projets/sympy-git/sympy/core/sympify.pyc in sympify(a,
locals,
convert_xor)
109 # and try to parse it. If it fails, then we have no
luck and
110 # return an exception
--> 111 a = str(a)
112
113 if convert_xor:
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-1:
ordinal
not in range(128)
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.