py26compat.py 710 B

12345678910111213141516171819202122232425262728293031
  1. """
  2. Compatibility Support for Python 2.6 and earlier
  3. """
  4. import sys
  5. try:
  6. from urllib.parse import splittag
  7. except ImportError:
  8. from urllib import splittag
  9. def strip_fragment(url):
  10. """
  11. In `Python 8280 <http://bugs.python.org/issue8280>`_, Python 2.7 and
  12. later was patched to disregard the fragment when making URL requests.
  13. Do the same for Python 2.6 and earlier.
  14. """
  15. url, fragment = splittag(url)
  16. return url
  17. if sys.version_info >= (2, 7):
  18. strip_fragment = lambda x: x
  19. try:
  20. from importlib import import_module
  21. except ImportError:
  22. def import_module(module_name):
  23. return __import__(module_name, fromlist=['__name__'])