This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Clarify unicode.(en|de)code.() docstrings
Type: Stage:
Components: Interpreter Core Versions: Python 2.5
process
Status: closed Resolution: rejected
Dependencies: Superseder:
Assigned To: Nosy List: brett.cannon, hyeshik.chang
Priority: normal Keywords: patch

Created on 2005-04-04 19:47 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
encode_decode_docstring.diff brett.cannon, 2005-04-04 19:47 Clarify docstrings for unicode(en|de)code()
Messages (3)
msg48151 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-04-04 19:47
I was reading the docstrings for unicode.encode() and
unicode.decode() and they were making no sense to me
since I kept expecting ``unicode("hi",
"utf-8").encode("utf-16")`` to return a unicode object,
just with an internal representation of UTF-16.  Then I
started playing with them some more and I realized the
methods encoded and decoded into and out of a byte
stream.  Then it made sense.

Attached is a patch to mention that they are working
with byte streams.  I also capitalized the first words
in all the sentences.
msg48152 - (view) Author: Hyeshik Chang (hyeshik.chang) * (Python committer) Date: 2005-04-05 02:56
Logged In: YES 
user_id=55188

That's not true. While the most unicode codecs are doing
such, some doesn't.  It's up to each codec's design what it
gets in its unicode.decode and what it returns in its
unicode.encode.

eg:

>>> u'hello, \uAC00!'.encode('breaker')
u'hello, \xea\xb0\x80!'
>>> _.decode('breaker')
u'hello, \uac00!'


class Codec(codecs.Codec):
....def encode(self, data, errors='strict'):
........return
data.encode('utf-8').decode('iso8859-1'),len(data)
....def decode(self, data, errors='strict'):
........return data.encode('iso8859-1').decode('utf-8'),
len(data)
msg48153 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2005-04-05 22:31
Logged In: YES 
user_id=357491

That figures.  OK, closed as rejected.
History
Date User Action Args
2022-04-11 14:56:10adminsetgithub: 41805
2005-04-04 19:47:08brett.cannoncreate