Commit 1ffd9e2f authored by Jason Madden's avatar Jason Madden Committed by Julien Muchembled

The monkey patch for urllib.request._urlopener does nothing on Python 3.

(cherry picked from commit f1589378)
parent 5f1f7d23
Pipeline #19035 passed with stage
in 0 seconds
......@@ -20,25 +20,8 @@ except ImportError:
try:
# Python 3
from urllib.request import FancyURLopener, URLopener, urlretrieve
from urllib.request import urlretrieve
from urllib.parse import urlparse
from urllib import request
import warnings
class PatchedURLopener(FancyURLopener):
http_error_default = URLopener.http_error_default
def __init__(self, *args, **kwargs):
with warnings.catch_warnings():
warnings.simplefilter('ignore')
# This creates a DeprecationWarning on 3.6:
# PatchedURLopener style of invoking requests is deprecated.
# Use newer urlopen functions/methods.
# Said warning breaks our doctests.
super(PatchedURLopener, self).__init__(*args, **kwargs)
request._urlopener = PatchedURLopener() # Ook! Monkey patch!
except ImportError:
# Python 2
import base64
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment