Opened 16 years ago
Closed 16 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)
Change History (4)
by , 16 years ago
comment:1 by , 16 years ago
comment:2 by , 16 years ago
Triage Stage: | Unreviewed → 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 by , 16 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
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.