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: u'%c' % large value: broken result
Type: Stage:
Components: Unicode Versions: Python 2.2
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: lemburg Nosy List: gvanrossum, lemburg, mwh
Priority: normal Keywords:

Created on 2002-08-11 04:35 by gvanrossum, last changed 2022-04-10 16:05 by admin. This issue is now closed.

Messages (8)
msg11896 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-08-11 04:35
The unicode implementation of '%c' % x does no range
checking on x, and out-of-range values can cause weird
effects. You might want to implement the same range
checking as 8-bit strings use, restricting x to values
in range(256). Or you might want to implement
unichr(x), restricting x to values in range(0xffff).
But right now it's a mess:

>>> u'%c' % 100
u'd'
>>> u'%c' % 300
u','
>>> u'%c' % 900
u'\uff84'
>>> u'%c' % -900
u'|'
>>> 
msg11897 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2002-08-11 12:23
Logged In: YES 
user_id=38388

Fix checked in. u"%c" will now apply the same checks as
unichr().
msg11898 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-10-07 11:20
Logged In: YES 
user_id=6656

Maybe this is a dead horse already...

2.2.2 candidate?
msg11899 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2002-10-07 11:44
Logged In: YES 
user_id=38388

I agree: this is a 2.2.2 candidate.
msg11900 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-10-07 11:48
Logged In: YES 
user_id=6656

My word, it applied to release22-maint without conflicting!
 This hasn't happened to me very much of late.

It was just changes to unicodeobject.c and test_unicode.py,
right?
msg11901 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-10-07 11:52
Logged In: YES 
user_id=6656

Well, I can answer part of that question: no, there's
bltinmodule.c and unicodeobject.h too.

Sometimes I hate cvs...
msg11902 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2002-10-07 11:57
Logged In: YES 
user_id=38388

You found the answer yourself :-)
msg11903 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2002-10-07 12:34
Logged In: YES 
user_id=6656

There was Misc/NEWS too (logmerge.py to the rescue!).

Anyway, this is fixed on the branch. I'd close the bug, only
I never got round to reopening it...
History
Date User Action Args
2022-04-10 16:05:34adminsetgithub: 37013
2002-08-11 04:35:01gvanrossumcreate