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

Skip to content

Commit ee4ec51

Browse files
committed
Fix for Python 2
urllib requests aren't context handlers in Python 2
1 parent 2a75d55 commit ee4ec51

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

doc/make.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,13 @@ def fetch_depsy_badge():
107107
The downside is that the badge only updates when the documentation
108108
is rebuilt."""
109109
try:
110-
with six.moves.urllib.request.urlopen(DEPSY_URL) as request:
110+
request = six.moves.urllib.request.urlopen(DEPSY_URL)
111+
try:
111112
data = request.read().decode('utf-8')
112113
with open(DEPSY_PATH, 'w') as output:
113114
output.write(data)
115+
finally:
116+
request.close()
114117
except six.moves.urllib.error.URLError:
115118
shutil.copyfile(DEPSY_DEFAULT, DEPSY_PATH)
116119

0 commit comments

Comments
 (0)