diff options
author | Brian May <brian@linuxpenguins.xyz> | 2019-03-04 17:37:25 +1100 |
---|---|---|
committer | Emilio Pozuelo Monfort <pochu@debian.org> | 2020-07-29 10:12:59 +0200 |
commit | eeb259f4ef0315712b327830afac28f5acf27867 (patch) | |
tree | be7f1c6c56c0942fd4679c1896827777a7c5a6d8 /lib | |
parent | ab1038c1c65e020c7b0a3a943119fe3d237b7ae8 (diff) |
Use urllib urllib instead of urllib2
Diffstat (limited to 'lib')
-rw-r--r-- | lib/python/debian_support.py | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/python/debian_support.py b/lib/python/debian_support.py index 00ffc89a58..a8a2c0ffed 100644 --- a/lib/python/debian_support.py +++ b/lib/python/debian_support.py @@ -25,7 +25,10 @@ import re import sys import tempfile import types -import urllib2 +try: + from urllib.request import urlopen +except ImportError: + from urllib2 import urlopen from cStringIO import StringIO try: @@ -291,7 +294,7 @@ def downloadGunzipLines(remote): Returns the lines in the file.""" - data = urllib2.urlopen(remote, timeout=TIMEOUT) + data = urlopen(remote, timeout=TIMEOUT) try: gfile = gzip.GzipFile(fileobj=StringIO(data.read())) try: @@ -336,7 +339,7 @@ def updateFile(remote, local, verbose=None): re_whitespace=re.compile('\s+') try: - index_url = urllib2.urlopen(index_name, timeout=TIMEOUT) + index_url = urlopen(index_name, timeout=TIMEOUT) index_fields = list(PackageFile(index_name, index_url)) except ParseError: if verbose: |