1# -*- coding: utf-8 -*- 2''' 3 flask_login._compat 4 ------------------- 5 A module providing tools for cross-version compatibility. 6''' 7 8 9import sys 10 11 12PY2 = sys.version_info[0] == 2 13 14 15if not PY2: # pragma: no cover 16 unicode = str # needed for pyflakes in py3 17 18 19if PY2: # pragma: nocover 20 21 from urlparse import urlparse, urlunparse 22 23 def iteritems(d): 24 return d.iteritems() 25 26 def itervalues(d): 27 return d.itervalues() 28 29 text_type = unicode 30 31else: # pragma: nocover 32 33 from urllib.parse import urlparse, urlunparse 34 35 def iteritems(d): 36 return iter(d.items()) 37 38 def itervalues(d): 39 return iter(d.values()) 40 41 text_type = str 42 43 44__all__ = [ 45 'PY2', 46 'unicode', 47 'urlparse', 48 'urlunparse', 49 'iteritems', 50 'itervalues', 51 'text_type', 52] 53