First round of Python 3 compatibility fixes.

This commit is contained in:
Murtuza Zabuawala
2015-11-06 10:23:19 +00:00
committed by Dave Page
parent da6043e7a5
commit 209ee78b25
11 changed files with 41 additions and 43 deletions

View File

@@ -12,7 +12,7 @@ from Crypto.Cipher import AES
from Crypto import Random
import base64
padding_string = '}'
padding_string = b'}'
def encrypt(plaintext, key):

View File

@@ -9,8 +9,9 @@
from abc import ABCMeta, abstractmethod, abstractproperty
from flask import session
from .registry import DriverRegistry
import six
@six.add_metaclass(DriverRegistry)
class BaseDriver(object):
"""
class BaseDriver(object):
@@ -40,7 +41,6 @@ class BaseDriver(object):
session, which has not been pinged from more than the idle timeout
configuration.
"""
__metaclass__ = DriverRegistry
@abstractproperty
def Version(cls):
@@ -58,7 +58,7 @@ class BaseDriver(object):
def gc(self):
pass
@six.add_metaclass(ABCMeta)
class BaseConnection(object):
"""
class BaseConnection(object)
@@ -113,7 +113,6 @@ class BaseConnection(object):
connection object for better memory management, and connection pool
management.
"""
__metaclass__ = ABCMeta
@abstractmethod
def connect(self, **kwargs):

View File

@@ -111,9 +111,12 @@ class Connection(BaseConnection):
)
except psycopg2.Error as e:
msg = e.pgerror if e.pgerror else e.message \
if e.message else e.diag.message_detail \
if e.diag.message_detail else str(e)
if e.pgerror:
msg = e.pgerror
elif e.diag.message_detail:
msg = e.diag.message_detail
else:
msg = str(e)
return False, msg