[Python-bugs-list] [ python-Bugs-650653 ] str.translate does not check table len
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 11 Dec 2002 04:40:46 -0800
Bugs item #650653, was opened at 2002-12-08 17:11
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=650653&group_id=5470
Category: Python Interpreter Core
Group: Python 2.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Greg Chapman (glchapman)
Assigned to: Nobody/Anonymous (nobody)
Summary: str.translate does not check table len
Initial Comment:
If you call str.translate without supplying the optional
deletechars parameter, translate does not check to see if
the table parameter has length 256. For example:
Python 2.2.2 (#37, Oct 14 2002, 17:02:34) [MSC 32 bit
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more
information.
>>> s = 'hello'
>>> s.translate('')
'\x00\x00\x00\x00\x00'
>>> s.translate('', '5')
Traceback (most recent call last):
File "<stdin>", line 1, in ?
ValueError: translation table must be 256 characters long
>>>
----------------------------------------------------------------------
>Comment By: Greg Chapman (glchapman)
Date: 2002-12-11 03:40
Message:
Logged In: YES
user_id=86307
Here's a patch using the latest stringobject.c (which I
downloaded from the CVS browser, so the date of the original
file is wrong. The original should be rev. 2.198).
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-12-10 10:12
Message:
Logged In: YES
user_id=21627
Would you like to develop a patch?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=650653&group_id=5470