Message95238
Note that on Py2.6, when, for example, a string is assigned to u.start
and u.end a TypeError is raised, and the value is then set to -1:
>>> u=UnicodeTranslateError(u'x', 1, 5, 'bah')
>>> u.start = 'foo'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: an integer is required
>>> u.end = 'bar'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: an integer is required
>>> str(u)
"can't translate characters in position -1--2: bah"
>>> u.start, u.end
(-1, -1)
Is it possible to change the values assigning an int (or even a float
that is then converted to int).
On py3k the behavior is different; as Trundle said, it segfaults easily,
and trying to change the value of u.start and u.end returns a different
error:
>>> u.start = 'foo'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
SystemError: Objects/longobject.c:441: bad argument to internal function
Also note that on both the versions there's no check on these values
either, it's easy to have a segfault doing this:
>>> u = UnicodeTranslateError(u'x', 1, 5, 'bah')
>>> u.start = 2**30
>>> u.end = 2**30+1
>>> str(u)
(if the char is only one, Python will try to read it and display it) |
|
Date |
User |
Action |
Args |
2009-11-14 12:29:07 | ezio.melotti | set | recipients:
+ ezio.melotti, arigo, eric.smith, Trundle |
2009-11-14 12:29:07 | ezio.melotti | set | messageid: <1258201747.8.0.369838581096.issue7309@psf.upfronthosting.co.za> |
2009-11-14 12:29:06 | ezio.melotti | link | issue7309 messages |
2009-11-14 12:29:05 | ezio.melotti | create | |
|