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.

classification
Title: urllib2 CacheFTPHandler doesn't work on multiple dirs
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mhammond Nosy List: jjlee, mhammond, theller
Priority: high Keywords: patch

Created on 2003-11-30 21:51 by jjlee, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cache_ftp.patch jjlee, 2003-11-30 21:51
cache_ftp_test.py jjlee, 2003-11-30 21:53
Messages (9)
msg44969 - (view) Author: John J Lee (jjlee) Date: 2003-11-30 21:51
This is a fix for bug 738973. 
 
Where are functional tests supposed to go?  Is the 
__name__ == "__main__" block the official place?  The 
urllib2 functional tests are quite out of date, thanks to 
shifting URLs, so I'd like to fix them, but need to know 
where to do it. 
msg44970 - (view) Author: John J Lee (jjlee) Date: 2003-11-30 21:53
Logged In: YES 
user_id=261020

 
msg44971 - (view) Author: John J Lee (jjlee) Date: 2004-05-04 22:13
Logged In: YES 
user_id=261020

For now at least, should probably just stick the test in the
if __name__ == "__main__"  block of urllib2 without its
unittest wrapper.
msg44972 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2004-05-05 12:23
Logged In: YES 
user_id=14198

The password is being dropped from the cache - I can't see
how this could possibly hurt though.  This all looks
reasonable to me, and fails (then works) as described.  I
will check this in in a couple of days to make sure noone
objects.  I won't check the test code in though - ideally,
it should go in the main test directory, but only if the
'network' resource is enabled - but I don't see that as a
blocking issue.
msg44973 - (view) Author: John J Lee (jjlee) Date: 2004-05-05 17:43
Logged In: YES 
user_id=261020

Thanks Mark 
 
FWIW, the idea of having the test in __main__ is that it's a 
functional test, not a unit test.  But when I raised this issue on 
python-dev (thread ends at message whose URL is below), I 
left more confused than when I arrived, so feel free to put them 
where you like ;-) 
 
http://mail.python.org/pipermail/python-dev/2003-December/040861.html 
 
msg44974 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2004-05-05 18:09
Logged In: YES 
user_id=11105

The problem with test code in the __main__ block is that
py2exe, for example, concludes that the unittest module is
needed.

If that is done, imo it would be better to write the main
block in this way, so that at least this is compiled away
with -O or -OO:

if __name__ == '__main__':
    if __debug__:
        import unittest
        # test code...
msg44975 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2004-05-09 08:58
Logged In: YES 
user_id=14198

Actually, wouldn't it be better to store 'dirs' directly in
the dict?

ie, instead of:
+        key = user, host, port, '/'.join(dirs)

just do:
+        key = user, host, port, dirs

Then the only assumption we make is that it is hashable.
msg44976 - (view) Author: John J Lee (jjlee) Date: 2004-05-09 13:07
Logged In: YES 
user_id=261020

OK.  dirs is a list, though, so it should be:

+        key = user, host, port, tuple(dirs)
msg44977 - (view) Author: Mark Hammond (mhammond) * (Python committer) Date: 2004-05-10 07:38
Logged In: YES 
user_id=14198

Re the tuple() - I think your original patch is better.  I
haven't done anything with the tests, but I encourage you to
pursue a patch to the test suite when the network resource
is enabled, and basically ignore other implications until
they happen :)  These tests would only go in 2.4.

Fixed on 2.3 branch:
Checking in urllib2.py;
new revision: 1.53.6.6; previous revision: 1.53.6.5

Fixed on trunk:
new revision: 1.66; previous revision: 1.65
History
Date User Action Args
2022-04-11 14:56:01adminsetgithub: 39633
2003-11-30 21:51:02jjleecreate