Staging
v0.8.1
v0.8.1
https://github.com/python/cpython
Revision fde0041089de2d13e7c473200fb74d3956203987 authored by Miss Islington (bot) on 18 February 2020, 03:05:14 UTC, committed by GitHub on 18 February 2020, 03:05:14 UTC
Test when find_good_parse_start should return 0. Co-authored-by: Terry Jan Reedy <tjreedy@udel.edu> (cherry picked from commit ffda25f6b825f3dee493b6f0746266a4dd6989f0) Co-authored-by: Cheryl Sabella <cheryl.sabella@gmail.com>
1 parent 3c57ca6
Tip revision: fde0041089de2d13e7c473200fb74d3956203987 authored by Miss Islington (bot) on 18 February 2020, 03:05:14 UTC
bpo-39663: IDLE: Add additional tests for pyparse (GH-18536)
bpo-39663: IDLE: Add additional tests for pyparse (GH-18536)
Tip revision: fde0041
urlretrieve.py
# Simple Python script to download a file. Used as a fallback
# when other more reliable methods fail.
#
from __future__ import print_function
import sys
try:
from requests import get
except ImportError:
try:
from urllib.request import urlretrieve
USING = "urllib.request.urlretrieve"
except ImportError:
try:
from urllib import urlretrieve
USING = "urllib.retrieve"
except ImportError:
print("Python at", sys.executable, "is not suitable",
"for downloading files.", file=sys.stderr)
sys.exit(2)
else:
USING = "requests.get"
def urlretrieve(url, filename):
r = get(url, stream=True)
r.raise_for_status()
with open(filename, 'wb') as f:
for chunk in r.iter_content(chunk_size=1024):
f.write(chunk)
return filename
if __name__ == '__main__':
if len(sys.argv) != 3:
print("Usage: urlretrieve.py [url] [filename]", file=sys.stderr)
sys.exit(1)
URL = sys.argv[1]
FILENAME = sys.argv[2]
print("Downloading from", URL, "to", FILENAME, "using", USING)
urlretrieve(URL, FILENAME)
Computing file changes ...