diff options
author | Jon Dufresne <jon.dufresne@gmail.com> | 2017-12-10 18:35:41 -0800 |
---|---|---|
committer | Jon Dufresne <jon.dufresne@gmail.com> | 2017-12-11 20:26:58 -0800 |
commit | 8ad2098b74ee90f341e69937a1503e29decf4594 (patch) | |
tree | ca6bb581c11fcb1a4cbe56b24aa9b83662293f3a /lib/extensions.py | |
parent | f35465231f76039fae8677d48beacbdd2479095a (diff) | |
download | psycopg2-8ad2098b74ee90f341e69937a1503e29decf4594.tar.gz |
Drop 2to3 build step; make all code compatible with all Pythons
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.
Diffstat (limited to 'lib/extensions.py')
-rw-r--r-- | lib/extensions.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/extensions.py b/lib/extensions.py index d15f76c..8644e41 100644 --- a/lib/extensions.py +++ b/lib/extensions.py @@ -163,7 +163,7 @@ def make_dsn(dsn=None, **kwargs): kwargs['dbname'] = kwargs.pop('database') # Drop the None arguments - kwargs = {k: v for (k, v) in kwargs.iteritems() if v is not None} + kwargs = {k: v for (k, v) in kwargs.items() if v is not None} if dsn is not None: tmp = parse_dsn(dsn) @@ -171,7 +171,7 @@ def make_dsn(dsn=None, **kwargs): kwargs = tmp dsn = " ".join(["%s=%s" % (k, _param_escape(str(v))) - for (k, v) in kwargs.iteritems()]) + for (k, v) in kwargs.items()]) # verify that the returned dsn is valid parse_dsn(dsn) @@ -216,7 +216,7 @@ del Range # When the encoding is set its name is cleaned up from - and _ and turned # uppercase, so an encoding not respecting these rules wouldn't be found in the # encodings keys and would raise an exception with the unicode typecaster -for k, v in encodings.items(): +for k, v in list(encodings.items()): k = k.replace('_', '').replace('-', '').upper() encodings[k] = v |