Code

Opened 5 years ago

Closed 5 years ago

#9585 closed (fixed)

r9398 broke test suite on Python2.3/2.4

Reported by: kmtracey 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: UI/UX:

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 kmtracey 5 years ago.

Download all attachments as: .zip

Change History (4)

Changed 5 years ago by kmtracey

comment:1 Changed 5 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 5 years ago by mtredinnick

  • Triage Stage changed from Unreviewed to Ready 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 Changed 5 years ago by russellm

  • Resolution set to fixed
  • Status changed from new to closed

(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.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.