[Python-bugs-list] [ python-Bugs-650653 ] str.translate does not check table len

noreply@sourceforge.net noreply@sourceforge.net
Sun, 08 Dec 2002 18:11:39 -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
>>>

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=650653&group_id=5470