mirror of
https://github.com/psycopg/psycopg2.git
synced 2025-11-10 20:57:34 +03:00
Make all library code compatible with both Python 2 and Python 3. Helps
move to modern Python idioms. Can now write for Python 3 (with
workarounds for Python 2) instead of the other way around.
In the future, when it is eventually time to drop Python 2, the library
will be in a better position to remove workarounds
Added a very small comparability module compat.py where required. It
includes definitions for:
- text_type -- A type. str on Python 3. unicode on Python 2.
- string_types -- A tuple. Contains only str on Python 3. Contains str &
unicode on Python 2.
11 lines
176 B
Python
11 lines
176 B
Python
import sys
|
|
|
|
if sys.version_info[0] == 2:
|
|
# Python 2
|
|
string_types = basestring,
|
|
text_type = unicode
|
|
else:
|
|
# Python 3
|
|
string_types = str,
|
|
text_type = str
|