Eryk Sun added the comment:

> windows version run success!

Trying to decode a non-ASCII unicode string should raise an exception on any 
platform:

    Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40)
    [MSC v.1500 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> a=u"\ufffd"
    >>> a.decode("utf=8")
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "C:\Program Files\Python27\lib\encodings\utf_8.py",
      line 16, in decode
        return codecs.utf_8_decode(input, errors, True)
    UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd'
    in position 0: ordinal not in range(128)

Unless you've modified the default encoding to something other than ASCII. For 
example:

    Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40)
    [MSC v.1500 64 bit (AMD64)] on win32
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import sys, inspect, sitecustomize
    >>> print inspect.getsource(sitecustomize)
    import sys
    sys.setdefaultencoding('utf-8')

    >>> sys.getdefaultencoding()
    'utf-8'
    >>> a=u"\ufffd"
    >>> a.decode("utf=8")
    u'\ufffd'

----------
nosy: +eryksun
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue29945>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to