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.

classification
Title: "/".join() throws OverflowError
Type: Stage:
Components: Library (Lib) Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: tim.peters Nosy List: calvin, georg.brandl, hyeshik.chang, tim.peters
Priority: normal Keywords:

Created on 2006-06-08 20:58 by calvin, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
patch-unicodejoin.diff hyeshik.chang, 2006-06-08 22:40 patch
Messages (4)
msg28748 - (view) Author: Bastian Kleineidam (calvin) Date: 2006-06-08 20:58
I noticed a regression in string.join() behaviour:

Running under Python 2.4 works:
$ python2.4
Python 2.4.4c0 (#2, Apr 22 2006, 22:39:06) 
[GCC 4.0.3 (Debian 4.0.3-1)] on linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> "/".join([u"", u"2"])
u'/2'
>>> 

Running under Python 2.5 SVN build fails:
$ python2.5
Python 2.5a2 (trunk:46757, Jun  8 2006, 22:20:31) 
[GCC 4.1.2 20060604 (prerelease) (Debian 4.1.1-2)] on
linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> "/".join([u"", u"2"])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OverflowError: join() is too long for a Python string
>>> 
msg28749 - (view) Author: Hyeshik Chang (hyeshik.chang) * (Python committer) Date: 2006-06-08 22:40
Logged In: YES 
user_id=55188

That occurrs when join sequence includes a zero-length
unicode object after Tim's r46084. 
I attached a patch but can't sure that it's correct fix yet. :)
msg28750 - (view) Author: Tim Peters (tim.peters) * (Python committer) Date: 2006-06-09 00:34
Logged In: YES 
user_id=31435

Fudge -- sorry about that!  Your fix is fine.  Adding two
non-negative signed integers of the same width indeed
overflows if and only if the computed result is negative.  I
was hallucinating when I imagined that a 0 result also
indicated overflow (something related to that is a correct
fast test when dealing with unsigned integers, but we're not
here).
msg28751 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-06-10 06:45
Logged In: YES 
user_id=849994

I applied the fix in rev. 46812. I also added the new test
to the 2.4 branch in rev. 46813.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43475
2006-06-08 20:58:34calvincreate