Issue1780767

classification
Title: Fix for [ 1768075 ] %c formats values outside of the
Type: Severity: normal
Components: None Versions:
Milestone:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pjenvey Nosy List: pjenvey, rajesh_battala
Priority: normal Keywords: patch

Created on 2007-08-24.04:51:46 by rajesh_battala, last changed 2008-11-10.02:54:12 by pjenvey.

Files
File name Uploaded Description Edit Remove
patch_formatting.diff rajesh_battala, 2007-08-24.04:51:46 patch file
Messages
msg2820 (view) Author: rajesh battala (rajesh_battala) Date: 2007-08-24.04:51:46
hi
i am attaching the diff for the fix of this bug.

the test cases are working fine

thanks
msg2821 (view) Author: Philip Jenvey (pjenvey) Date: 2007-09-11.04:22:44
this looks good, only issue I see is you're using tabs and the code base prefers white space
msg2822 (view) Author: Philip Jenvey (pjenvey) Date: 2007-09-11.04:49:04
Actually I spoke too soon, there's one issue -- this patch will break formatting unicode chars with values larger than 255:

Jython 2.3a0 on java1.5.0_07
Type "copyright", "credits" or "license" for more information.
>>> u'%c' % 256
Traceback (innermost last):
  File "<console>", line 1, in ?
OverflowError: unsigned byte integer is greater than maximum

Without the patch jython *appears* to handle these values as CPython does, but I suspect there may be more involved, as the exception raised by CPython when the unicode formatting fails seems to suggest that CPython runs the value through something similar to unichr():

Python 2.4.4 (#1, Aug 19 2007, 19:54:52) 
[GCC 4.0.1 (Apple Computer, Inc. build 5367)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> u'%c' % 256
u'\u0100'
>>> u'%c' % -1
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
OverflowError: %c arg not in range(0x10000) (narrow Python build)
>>> unichr(-1)
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
ValueError: unichr() arg not in range(0x10000) (narrow Python build)
msg3769 (view) Author: Philip Jenvey (pjenvey) Date: 2008-11-10.02:54:11
this was applied in r4320, however I forgot to fix my other concern until 
r5562
History
Date User Action Args
2008-11-10 02:54:12pjenveysetstatus: open -> closed
resolution: fixed
messages: + msg3769
title: Fix for [ 1768075 ] %c formats values outside of the -> Fix for [ 1768075 ] %c formats values outside of the
2007-08-24 04:51:46rajesh_battalacreate