2016-02-06 09:37:19 +00:00
|
|
|
"""
|
|
|
|
Compatibility Support for Python 2.6 and earlier
|
|
|
|
"""
|
|
|
|
|
|
|
|
import sys
|
|
|
|
|
2016-02-22 11:13:36 +00:00
|
|
|
try:
|
2017-10-13 12:49:49 +00:00
|
|
|
from urllib.parse import splittag
|
2016-02-22 11:13:36 +00:00
|
|
|
except ImportError:
|
2017-10-13 12:49:49 +00:00
|
|
|
from urllib import splittag
|
|
|
|
|
2016-02-06 09:37:19 +00:00
|
|
|
|
|
|
|
def strip_fragment(url):
|
2017-10-13 12:49:49 +00:00
|
|
|
"""
|
|
|
|
In `Python 8280 <http://bugs.python.org/issue8280>`_, Python 2.7 and
|
|
|
|
later was patched to disregard the fragment when making URL requests.
|
|
|
|
Do the same for Python 2.6 and earlier.
|
|
|
|
"""
|
|
|
|
url, fragment = splittag(url)
|
|
|
|
return url
|
|
|
|
|
|
|
|
|
|
|
|
if sys.version_info >= (2, 7):
|
|
|
|
strip_fragment = lambda x: x
|
|
|
|
|
|
|
|
try:
|
|
|
|
from importlib import import_module
|
|
|
|
except ImportError:
|
|
|
|
|
|
|
|
def import_module(module_name):
|
|
|
|
return __import__(module_name, fromlist=['__name__'])
|