pgAdmin4 should work with python 3.7, Fixes #3458

This commit is contained in:
Akshay Joshi 2018-08-06 15:35:03 +05:30
parent cb8a288f85
commit 52fc0846cd
6 changed files with 25 additions and 21 deletions

View File

@ -33,6 +33,7 @@ Bug fixes
| `Bug #3446 <https://redmine.postgresql.org/issues/3446>`_ - Various procedure/function related fixes for EPAS/PG 11. | `Bug #3446 <https://redmine.postgresql.org/issues/3446>`_ - Various procedure/function related fixes for EPAS/PG 11.
| `Bug #3448 <https://redmine.postgresql.org/issues/3448>`_ - Exclude system columns in Import/Export. | `Bug #3448 <https://redmine.postgresql.org/issues/3448>`_ - Exclude system columns in Import/Export.
| `Bug #3457 <https://redmine.postgresql.org/issues/3457>`_ - Fix debugging of procedures in EPAS packages. | `Bug #3457 <https://redmine.postgresql.org/issues/3457>`_ - Fix debugging of procedures in EPAS packages.
| `Bug #3458 <https://redmine.postgresql.org/issues/3458>`_ - pgAdmin4 should work with python 3.7.
| `Bug #3468 <https://redmine.postgresql.org/issues/3468>`_ - Support SSH tunneling with keys that don't have a passphrase. | `Bug #3468 <https://redmine.postgresql.org/issues/3468>`_ - Support SSH tunneling with keys that don't have a passphrase.
| `Bug #3471 <https://redmine.postgresql.org/issues/3471>`_ - Ensure the SSH tunnel port number is honoured. | `Bug #3471 <https://redmine.postgresql.org/issues/3471>`_ - Ensure the SSH tunnel port number is honoured.
| `Bug #3526 <https://redmine.postgresql.org/issues/3526>`_ - COST statement should not be automatically duplicated after creating trigger function. | `Bug #3526 <https://redmine.postgresql.org/issues/3526>`_ - COST statement should not be automatically duplicated after creating trigger function.

View File

@ -1391,7 +1391,7 @@ def start_query_download_tool(trans_id):
did=trans_obj.did, did=trans_obj.did,
conn_id=conn_id, conn_id=conn_id,
auto_reconnect=False, auto_reconnect=False,
async=False async_=False
) )
sync_conn.connect(autocommit=False) sync_conn.connect(autocommit=False)

View File

@ -149,7 +149,7 @@ class Connection(BaseConnection):
- greater than or equal to 10. - greater than or equal to 10.
""" """
def __init__(self, manager, conn_id, db, auto_reconnect=True, async=0, def __init__(self, manager, conn_id, db, auto_reconnect=True, async_=0,
use_binary_placeholder=False, array_to_string=False): use_binary_placeholder=False, array_to_string=False):
assert (manager is not None) assert (manager is not None)
assert (conn_id is not None) assert (conn_id is not None)
@ -159,7 +159,7 @@ class Connection(BaseConnection):
self.db = db if db is not None else manager.db self.db = db if db is not None else manager.db
self.conn = None self.conn = None
self.auto_reconnect = auto_reconnect self.auto_reconnect = auto_reconnect
self.async = async self.async_ = async_
self.__async_cursor = None self.__async_cursor = None
self.__async_query_id = None self.__async_query_id = None
self.__backend_pid = None self.__backend_pid = None
@ -189,7 +189,7 @@ class Connection(BaseConnection):
res = dict() res = dict()
res['conn_id'] = self.conn_id res['conn_id'] = self.conn_id
res['database'] = self.db res['database'] = self.db
res['async'] = self.async res['async_'] = self.async_
res['wasConnected'] = self.wasConnected res['wasConnected'] = self.wasConnected
res['auto_reconnect'] = self.auto_reconnect res['auto_reconnect'] = self.auto_reconnect
res['use_binary_placeholder'] = self.use_binary_placeholder res['use_binary_placeholder'] = self.use_binary_placeholder
@ -202,7 +202,7 @@ class Connection(BaseConnection):
self.conn_id, self.db, self.conn_id, self.db,
'Connected' if self.conn and not self.conn.closed else 'Connected' if self.conn and not self.conn.closed else
"Disconnected", "Disconnected",
self.async self.async_
) )
def __str__(self): def __str__(self):
@ -210,7 +210,7 @@ class Connection(BaseConnection):
self.conn_id, self.db, self.conn_id, self.db,
'Connected' if self.conn and not self.conn.closed else 'Connected' if self.conn and not self.conn.closed else
"Disconnected", "Disconnected",
self.async self.async_
) )
def connect(self, **kwargs): def connect(self, **kwargs):
@ -302,7 +302,7 @@ class Connection(BaseConnection):
database=database, database=database,
user=user, user=user,
password=password, password=password,
async=self.async, async_=self.async_,
passfile=get_complete_file_path(passfile), passfile=get_complete_file_path(passfile),
sslmode=manager.ssl_mode, sslmode=manager.ssl_mode,
sslcert=get_complete_file_path(manager.sslcert), sslcert=get_complete_file_path(manager.sslcert),
@ -316,7 +316,7 @@ class Connection(BaseConnection):
# If connection is asynchronous then we will have to wait # If connection is asynchronous then we will have to wait
# until the connection is ready to use. # until the connection is ready to use.
if self.async == 1: if self.async_ == 1:
self._wait(pg_conn) self._wait(pg_conn)
except psycopg2.Error as e: except psycopg2.Error as e:
@ -385,7 +385,7 @@ class Connection(BaseConnection):
# autocommit flag does not work with asynchronous connections. # autocommit flag does not work with asynchronous connections.
# By default asynchronous connection runs in autocommit mode. # By default asynchronous connection runs in autocommit mode.
if self.async == 0: if self.async_ == 0:
if 'autocommit' in kwargs and kwargs['autocommit'] is False: if 'autocommit' in kwargs and kwargs['autocommit'] is False:
self.conn.autocommit = False self.conn.autocommit = False
else: else:
@ -641,7 +641,7 @@ WHERE
""" """
This function executes the query using cursor's execute function, This function executes the query using cursor's execute function,
but in case of asynchronous connection we need to wait for the but in case of asynchronous connection we need to wait for the
transaction to be completed. If self.async is 1 then it is a transaction to be completed. If self.async_ is 1 then it is a
blocking call. blocking call.
Args: Args:
@ -658,7 +658,7 @@ WHERE
params = self.escape_params_sqlascii(params) params = self.escape_params_sqlascii(params)
cur.execute(query, params) cur.execute(query, params)
if self.async == 1: if self.async_ == 1:
self._wait(cur.connection) self._wait(cur.connection)
def execute_on_server_as_csv(self, def execute_on_server_as_csv(self,

View File

@ -208,6 +208,9 @@ class DictCursor(_cursor):
def __iter__(self): def __iter__(self):
it = _cursor.__iter__(self) it = _cursor.__iter__(self)
yield self._dict_tuple(next(it)) try:
while 1:
yield self._dict_tuple(next(it)) yield self._dict_tuple(next(it))
while 1:
yield self._dict_tuple(next(it))
except StopIteration:
pass

View File

@ -153,7 +153,7 @@ class ServerManager(object):
def connection( def connection(
self, database=None, conn_id=None, auto_reconnect=True, did=None, self, database=None, conn_id=None, auto_reconnect=True, did=None,
async=None, use_binary_placeholder=False, array_to_string=False async_=None, use_binary_placeholder=False, array_to_string=False
): ):
if database is not None: if database is not None:
if hasattr(str, 'decode') and \ if hasattr(str, 'decode') and \
@ -206,12 +206,12 @@ WHERE db.oid = {0}""".format(did))
if my_id in self.connections: if my_id in self.connections:
return self.connections[my_id] return self.connections[my_id]
else: else:
if async is None: if async_ is None:
async = 1 if conn_id is not None else 0 async_ = 1 if conn_id is not None else 0
else: else:
async = 1 if async is True else 0 async_ = 1 if async_ is True else 0
self.connections[my_id] = Connection( self.connections[my_id] = Connection(
self, my_id, database, auto_reconnect, async, self, my_id, database, auto_reconnect, async_,
use_binary_placeholder=use_binary_placeholder, use_binary_placeholder=use_binary_placeholder,
array_to_string=array_to_string array_to_string=array_to_string
) )
@ -256,7 +256,7 @@ WHERE db.oid = {0}""".format(did))
conn_info = connections[conn_id] conn_info = connections[conn_id]
conn = self.connections[conn_info['conn_id']] = Connection( conn = self.connections[conn_info['conn_id']] = Connection(
self, conn_info['conn_id'], conn_info['database'], self, conn_info['conn_id'], conn_info['database'],
conn_info['auto_reconnect'], conn_info['async'], conn_info['auto_reconnect'], conn_info['async_'],
use_binary_placeholder=conn_info['use_binary_placeholder'], use_binary_placeholder=conn_info['use_binary_placeholder'],
array_to_string=conn_info['array_to_string'] array_to_string=conn_info['array_to_string']
) )

View File

@ -4,13 +4,13 @@ from collections import defaultdict
import sqlparse import sqlparse
from sqlparse.tokens import Name from sqlparse.tokens import Name
white_space_regex = re.compile('\\s+', re.MULTILINE) white_space_regex = re.compile(r'\\s+', re.MULTILINE)
def _compile_regex(keyword): def _compile_regex(keyword):
# Surround the keyword with word boundaries and replace interior whitespace # Surround the keyword with word boundaries and replace interior whitespace
# with whitespace wildcards # with whitespace wildcards
pattern = '\\b' + re.sub(white_space_regex, '\\s+', keyword) + '\\b' pattern = r'\\b' + re.sub(white_space_regex, r'\\s+', keyword) + r'\\b'
return re.compile(pattern, re.MULTILINE | re.IGNORECASE) return re.compile(pattern, re.MULTILINE | re.IGNORECASE)