classification
Title: python3 FAQ mentions unicode()
Type: Stage:
Components: Documentation Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, ezio.melotti, georg.brandl, ohnobinki, terry.reedy
Priority: normal Keywords:

Created on 2010-05-12 06:14 by ohnobinki, last changed 2010-05-21 20:36 by georg.brandl. This issue is now closed.

Messages (3)
msg105574 - (view) Author: Nathan Phillip Brink (ohnobinki) Date: 2010-05-12 06:14
http://docs.python.org/py3k/faq/programming.html#what-does-unicodeerror-ascii-decoding-encoding-error-ordinal-not-in-range-128-mean

When I try to use unicode() from within python3, the call fails. I would actually expect that the FAQ should contain more information concerning the merging of the unicode and str classes. It would be nice if, when this FAQ entry is updated, there is a short discussion on making the code compatible with both python2 and python3, as it appears that's the only way python3 adaption will ever happen.
msg105747 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2010-05-14 19:34
Yes, the faq entry has example code like
 "value = unicode(value, "utf-8")"
This whole section now applies when 'value' is a bytes or bytearray object and one calls str(value).

For portability, one should in 2.6/7 use unicode strings as much as possible and the bytes and unicode functions but not the str function. Then 2to3.py will change 'unicode' to 'str'. This should be a separate FAQ entry (if not already), for both 2.x and 3.x, with more complete advice from MLV (from whom I am parroting the above).
msg106261 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-05-21 20:36
This was due to a review of the programming FAQ not yet having been merged to the 3.1 branch.  Now fixed in r81407.
History
Date User Action Args
2010-05-21 20:36:34georg.brandlsetstatus: open -> closed

nosy: + georg.brandl
messages: + msg106261

resolution: fixed
2010-05-14 19:34:32terry.reedysetnosy: + terry.reedy
messages: + msg105747
2010-05-12 20:11:06giampaolo.rodolasetnosy: + ezio.melotti
2010-05-12 06:14:29ohnobinkicreate