Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b0cc912

Browse files
committed
Fix issue #16270: urllib may hang when used for retrieving files via FTP by using a context manager.
1 parent 2ee776b commit b0cc912

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

Lib/urllib/request.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2326,13 +2326,7 @@ def retrfile(self, file, type):
23262326
return (ftpobj, retrlen)
23272327

23282328
def endtransfer(self):
2329-
if not self.busy:
2330-
return
23312329
self.busy = 0
2332-
try:
2333-
self.ftp.voidresp()
2334-
except ftperrors():
2335-
pass
23362330

23372331
def close(self):
23382332
self.keepalive = False

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ Core and Builtins
4343
Library
4444
-------
4545

46+
- Issue #16270: urllib may hang when used for retrieving files via FTP by using
47+
a context manager. Patch by Giampaolo Rodola'.
48+
4649
- Issue #16176: Properly identify Windows 8 via platform.platform()
4750

4851
- Issue #16114: The subprocess module no longer provides a misleading error

0 commit comments

Comments
 (0)