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.

Author ezio.melotti
Recipients Trundle, arigo, eric.smith, ezio.melotti
Date 2009-11-14.12:29:05
SpamBayes Score 5.551115e-17
Marked as misclassified No
Message-id <1258201747.8.0.369838581096.issue7309@psf.upfronthosting.co.za>
In-reply-to
Content
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)
History
Date User Action Args
2009-11-14 12:29:07ezio.melottisetrecipients: + ezio.melotti, arigo, eric.smith, Trundle
2009-11-14 12:29:07ezio.melottisetmessageid: <1258201747.8.0.369838581096.issue7309@psf.upfronthosting.co.za>
2009-11-14 12:29:06ezio.melottilinkissue7309 messages
2009-11-14 12:29:05ezio.melotticreate