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.
Created on 2013年05月08日 00:50 by pitrou, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| urllib-request-format-type-bug.patch | rock, 2013年07月18日 15:02 | review | ||
| Messages (11) | |||
|---|---|---|---|
| msg188699 - (view) | Author: Antoine Pitrou (pitrou) * (Python committer) | Date: 2013年05月08日 00:50 | |
The following error appeared on some buildbots: http://buildbot.python.org/all/builders/x86%20Gentoo%203.x/builds/4195/steps/test/logs/stdio ====================================================================== ERROR: test_ftp (test.test_urllib2net.OtherNetworkTests) ---------------------------------------------------------------------- Traceback (most recent call last): File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/urllib/request.py", line 2337, in retrfile self.ftp.cwd(file) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/ftplib.py", line 622, in cwd return self.voidcmd(cmd) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/ftplib.py", line 272, in voidcmd return self.voidresp() File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/ftplib.py", line 245, in voidresp resp = self.getresp() File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/ftplib.py", line 240, in getresp raise error_perm(resp) ftplib.error_perm: 550 Failed to change directory. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/test_urllib2net.py", line 112, in test_ftp self._test_urls(urls, self._extra_handlers()) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/test_urllib2net.py", line 218, in _test_urls f = urlopen(url, req, TIMEOUT) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/test_urllib2net.py", line 33, in wrapped return _retry_thrice(func, exc, *args, **kwargs) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/test/test_urllib2net.py", line 23, in _retry_thrice return func(*args, **kwargs) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/urllib/request.py", line 462, in open response = self._open(req, data) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/urllib/request.py", line 480, in _open '_open', req) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/urllib/request.py", line 440, in _call_chain result = func(*args) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/urllib/request.py", line 1464, in ftp_open fp, retrlen = fw.retrfile(file, type) File "/var/lib/buildslave/3.x.murray-gentoo/build/Lib/urllib/request.py", line 2339, in retrfile raise URLError('ftp error: %d' % reason) from reason TypeError: %d format: a number is required, not error_perm |
|||
| msg193301 - (view) | Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) | Date: 2013年07月18日 14:55 | |
I cannot reproduce the issue on Ubuntu.
As for the second exception I think it's safe to just do:
- raise URLError('ftp error: %d' % reason) from reason
+ raise URLError('ftp error: %s' % reason) from reason
(will commit that later)
|
|||
| msg193303 - (view) | Author: Rock Lee (rock) | Date: 2013年07月18日 15:02 | |
Bug in urllib/request.py.
format string formatted error type variable
2373 except ftplib.error_perm as reason:
2374 raise URLError('ftp error: %d' % reason) from reason
variable reason here is a instance of class ftplib.error_perm.
We need to passed in a integer object.
Patch supplied.
|
|||
| msg193304 - (view) | Author: Rock Lee (rock) | Date: 2013年07月18日 15:03 | |
Fixed like this:
raise URLError('ftp error: %d' % int(str(reason)[:3])) from reason
I think this is the original author's intention.
Actually, need to fix two places in urllib/request.py
|
|||
| msg193305 - (view) | Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) | Date: 2013年07月18日 15:07 | |
That's not safe as a misbehaving FTP server might not send a response code at all (highly unlikely but still...). Furthermore having the complete server response (response code + accompaining message) is a lot more helpful. |
|||
| msg193307 - (view) | Author: Rock Lee (rock) | Date: 2013年07月18日 15:13 | |
yes, the malformed server could do evil things. If we need to cover this situation, we need to some extra fixes in this file. Maybe the exception message look like this is the better one ? ftplib.error_perm: 550 Failed to change directory |
|||
| msg193308 - (view) | Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) | Date: 2013年07月18日 15:21 | |
I think "raise URLError('ftp error: %s' % reason) from reason" is just fine.
|
|||
| msg193309 - (view) | Author: Rock Lee (rock) | Date: 2013年07月18日 15:34 | |
Yes, the simplest fix is just replace '%d' to '%s'. Line 2362 and 2374 all need to modify. |
|||
| msg193529 - (view) | Author: Rock Lee (rock) | Date: 2013年07月22日 12:27 | |
Any progress for this issue? I changed the title of the issue. |
|||
| msg201447 - (view) | Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) | Date: 2013年10月27日 11:36 | |
Giampaolo's suggestion LGTM. |
|||
| msg201846 - (view) | Author: R. David Murray (r.david.murray) * (Python committer) | Date: 2013年10月31日 20:26 | |
This was changed to %r by Benjamin Peterson in 27e470952085. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:45 | admin | set | github: 62133 |
| 2013年10月31日 20:26:31 | r.david.murray | set | status: open -> closed resolution: out of date messages: + msg201846 stage: needs patch -> resolved |
| 2013年10月27日 11:38:14 | serhiy.storchaka | set | nosy:
+ georg.brandl |
| 2013年10月27日 11:36:45 | serhiy.storchaka | set | nosy:
+ serhiy.storchaka messages: + msg201447 |
| 2013年07月31日 06:51:30 | Arfrever | set | nosy:
+ Arfrever |
| 2013年07月22日 12:27:18 | rock | set | messages:
+ msg193529 title: test_ftp failure / ftplib error formatting issue -> format str bug in urllib request.py |
| 2013年07月18日 15:34:04 | rock | set | messages: + msg193309 |
| 2013年07月18日 15:21:52 | giampaolo.rodola | set | messages: + msg193308 |
| 2013年07月18日 15:13:13 | rock | set | messages: + msg193307 |
| 2013年07月18日 15:07:40 | giampaolo.rodola | set | messages: + msg193305 |
| 2013年07月18日 15:03:41 | rock | set | messages: + msg193304 |
| 2013年07月18日 15:02:25 | rock | set | files:
+ urllib-request-format-type-bug.patch nosy: + rock messages: + msg193303 keywords: + patch |
| 2013年07月18日 14:55:10 | giampaolo.rodola | set | messages: + msg193301 |
| 2013年07月18日 14:46:41 | ezio.melotti | set | nosy:
+ ezio.melotti |
| 2013年05月08日 00:50:24 | pitrou | create | |