Closed 90385fda-a349-46bd-a09b-c4b95e77b648 closed 19 years ago
If Win32 has a proxy enabled, ftp urls will NOT work in urllib.
Here is a trace:
Traceback (most recent call last):
File
"C:\Python22\lib\site-packages\Pythonwin\pywin\framework\scriptutils.py",
line 301, in RunScript
exec codeObject in __main__.__dict__
File "C:\Python22\Lib\urllib.py", line 1457, in ?
main()
File "C:\Python22\Lib\urllib.py", line 1448, in main
test(args)
File "C:\Python22\Lib\urllib.py", line 1410, in test
fn, h = urlretrieve(url, None, reporthook)
File "C:\Python22\Lib\urllib.py", line 80, in urlretrieve
return _urlopener.retrieve(url, filename,
reporthook, data)
File "C:\Python22\Lib\urllib.py", line 210, in retrieve
fp = self.open(url, data)
File "C:\Python22\Lib\urllib.py", line 178, in open
return getattr(self, name)(url)
File "C:\Python22\Lib\urllib.py", line 438, in open_ftp
host, path = splithost(url)
File "C:\Python22\Lib\urllib.py", line 944, in splithost
match = _hostprog.match(url)
TypeError: expected string or buffer
If the Win32 proxy is removed, it resumes working. In urllib splithost, url is None or an empty tuple (instead of the actual url.)
To reproduce, just enable a proxy on Win32 and execute the "urllib.py -t" selftest. Disable the proxy and it will be restored.
I haven't got the setup to check if web_proxy or ftp_proxy on Posix machines causes the same problem.
Logged In: YES user_id=95087
This is _NOT_ a bug under Linux Python 2.2--it works just fine there. (Makes me curious why it would behave differently under Windows, but I'm not sure where to look yet.)
Logged In: YES user_id=95087
\<bold>Is this bold?\</bold>
Logged In: YES user_id=6380
Medberry, can you see if the patch from SF bug 503031 (http://www.python.org/sf/503031) solves your problem?
Logged In: YES user_id=57665
Problem is that open_ftp() does not check if the "url" argument is a string or a tuple. When ftp_proxy is set it is a tuple, thus always causes the open() call to fail. This is not specific for Win32.
open_http() starts with this check: if type(url) is types.StringType: open_ftp() should do something similar.
This is unrelated to bug 503031.
Logged In: YES user_id=752496
Please, could you verify if this problem persists in Python 2.3.4 or 2.4?
If yes, in which version? Can you provide a test case?
If the problem is solved, from which version?
Note that if you fail to answer in one month, I'll close this bug as "Won't fix".
Thank you!
. Facundo
Logged In: YES user_id=752496
Deprecated. Reopen only if still happens in 2.3 or newer.
. Facundo
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = None closed_at =
created_at =
labels = ['library']
title = 'urllib ftp broken if Win32 proxy'
updated_at =
user = 'https://bugs.python.org/medberry'
```
bugs.python.org fields:
```python
activity =
actor = 'facundobatista'
assignee = 'none'
closed = True
closed_date = None
closer = None
components = ['Library (Lib)']
creation =
creator = 'medberry'
dependencies = []
files = []
hgrepos = []
issue_num = 532007
keywords = []
message_count = 7.0
messages = ['9781', '9782', '9783', '9784', '9785', '9786', '9787']
nosy_count = 4.0
nosy_names = ['gvanrossum', 'facundobatista', 'medberry', 'vimboss']
pr_nums = []
priority = 'normal'
resolution = 'wont fix'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue532007'
versions = ['Python 2.2']
```