Opened 15 years ago

Closed 15 years ago

#9585 closed (fixed)

r9398 broke test suite on Python2.3/2.4

Reported by: Karen Tracey Owned by: nobody
Component: Testing framework Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

r9398 added code to the test suite that uses .path on the result of urlparse.urlparse. It works something like this:

Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from urlparse import urlparse
>>> parsed = urlparse("http://docs.python.org/search.html?q=urlparse&check_keywords=yes&area=default")
>>> type(parsed)
<class 'urlparse.ParseResult'>
>>> parsed.path
'/search.html'
>>> 

Unfortunately prior to Python 2.5 (?) the return value from urlparse.urlparse was a simple tuple, not a urlparse.ParseResult, so the test usage of .path on the return value of urlparse causes errors:

Python 2.4.4 (#2, Jul 31 2008, 23:57:57) 
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from urlparse import urlparse
>>> parsed = urlparse("http://docs.python.org/search.html?q=urlparse&check_keywords=yes&area=default")
>>> type(parsed)
<type 'tuple'>
>>> parsed.path
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
AttributeError: 'tuple' object has no attribute 'path'
>>> 

Attachments (1)

9585.diff (3.0 KB ) - added by Karen Tracey 15 years ago.

Download all attachments as: .zip

Change History (4)

by Karen Tracey, 15 years ago

Attachment: 9585.diff added

comment:1 by Karen Tracey, 15 years ago

I've attached a quick-fix patch for anyone needing to run the test suite on 2.3/2.4, but I expect we might want to do something prettier for a real fix.

comment:2 by Malcolm Tredinnick, 15 years ago

Triage Stage: UnreviewedReady for checkin

This is the right fix. The return result is intended to be treated like a tuple (partly precisely for backwards-compatibility with earlier Python code). I would prefer to use "4" instead of "-2" for the query access, though, since then you're not relying on the length of the tuple (and "4" is the documented value).

comment:3 by Russell Keith-Magee, 15 years ago

Resolution: fixed
Status: newclosed

(In [9465]) Fixed #9585 -- Corrected code committed in [9398] that wasn't compatible with Python 2.3/2.4. Thanks to Karen Tracey for the report and fix.

Note: See TracTickets for help on using tickets.
Back to Top