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.

Title: unicode-internal encoder reports wrong length
Type: Stage:
Components: Unicode Versions: Python 3.0
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: doerwalter, vstinner
Priority: normal Keywords: patch

Created on 2008-08-30 13:05 by doerwalter, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
issue3739.patch vstinner, 2009-05-04 20:00
Messages (4)
msg72193 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2008-08-30 13:05
The encoder for the "unicode-internal" codec reports the wrong length:

Python 3.0b3+ (py3k, Aug 30 2008, 11:55:21) 
[GCC 4.0.1 (Apple Inc. build 5484)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import codecs
>>> codecs.getencoder("unicode-internal")("a")
(b'a\x00', 2)

I would have expected it to output:

(b'a\x00', 1)

msg87161 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-05-04 20:00
Patch fixing unicode-internal encoder for unicode string input: return 
the length of the input string (number of characters) and not the 
internal size (number of bytes needed to store the text). I wrote a 
small test, I hope that it will be enough (to test the function).

If the input is not an unicode string, return the number of bytes (I 
leaved this case unchanged).
msg87335 - (view) Author: Walter Dörwald (doerwalter) * (Python committer) Date: 2009-05-06 14:45
Checked in:
r72404,72406 (trunk)
r72408 (py3k)

As IMHO this is somewhat between a feature and a bugfix, I didn't check
it into release26-maint and release30-maint.
msg87336 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2009-05-06 15:14
> I didn't check it into release26-maint and release30-maint.

I agree and anyway this encoder is not really important (it looks to 
be unused...). Thanks for the commit.
Date User Action Args
2022-04-11 14:56:38adminsetgithub: 47989
2009-05-06 15:14:01vstinnersetmessages: + msg87336
2009-05-06 14:45:28doerwaltersetstatus: open -> closed
resolution: fixed
messages: + msg87335
2009-05-04 20:00:13vstinnersetfiles: + issue3739.patch

nosy: + vstinner
messages: + msg87161

keywords: + patch
2008-08-30 13:05:18doerwaltercreate