1414import ssl
1515
1616from operator import attrgetter , itemgetter , is_ , is_not
17- from itertools import repeat , chain , islice
17+ from itertools import repeat , islice
1818from functools import partial
1919
2020from abc import abstractmethod , abstractproperty
@@ -1800,7 +1800,7 @@ def __exit__(self, typ, value, tb):
18001800 "invalid transaction block exit detected" ,
18011801 source = 'DRIVER' ,
18021802 details = {
1803- 'INTERFACE ' : \
1803+ 'DRIVER ' : \
18041804 'Connection was in an error-state, ' \
18051805 'but no exception was raised.'
18061806 },
@@ -1833,7 +1833,7 @@ def __exit__(self, typ, value, tb):
18331833 #
18341834 # But the occurrence of this exception means it's not in an active
18351835 # transaction, which means no cleanup other than raise is necessary.
1836- err .details ['INTERFACE ' ] = \
1836+ err .details ['DRIVER ' ] = \
18371837 "The prepared transaction was not " \
18381838 "prepared prior to the block's exit."
18391839 raise
@@ -1887,7 +1887,7 @@ def start(self):
18871887 err = pg_exc .OperationError (
18881888 "transactions cannot be restarted" ,
18891889 details = {
1890- 'INTERFACE ' : \
1890+ 'DRIVER ' : \
18911891 'Create a new transaction object instead of re-using an old one.'
18921892 }
18931893 )
@@ -1970,7 +1970,7 @@ def commit(self):
19701970 err = pg_exc .OperationError (
19711971 "commit attempted on transaction with unexpected state" ,
19721972 details = {
1973- 'INTERFACE ' : "Transaction was " + repr (self .state ) + \
1973+ 'DRIVER ' : "Transaction was " + repr (self .state ) + \
19741974 " , but it must be 'prepared' or 'open' in order to commit."
19751975 }
19761976 )
@@ -1988,7 +1988,7 @@ def commit(self):
19881988 err = pg_exc .OperationError (
19891989 "savepoint configured with global identifier" ,
19901990 details = {
1991- 'INTERFACE ' : \
1991+ 'DRIVER ' : \
19921992 "Don't configure savepoint transactions with global identifiers."
19931993 }
19941994 )
@@ -2881,9 +2881,6 @@ def __init__(self,
28812881 sslkeyfile : "filepath" = None ,
28822882 sslrootcrtfile : "filepath" = None ,
28832883 sslrootcrlfile : "filepath" = None ,
2884-
2885- path : list = None ,
2886- role : str = None ,
28872884 ** kw
28882885 ):
28892886 super ().__init__ (** kw )
@@ -2920,8 +2917,6 @@ def __init__(self,
29202917 tnkw ['user' ] = self .user
29212918 if self .database is not None :
29222919 tnkw ['database' ] = self .database
2923- ## PostgreSQLs that don't recognize this will barf.
2924- #tnkw['standard_conforming_strings'] = True
29252920
29262921 self ._startup_parameters = tnkw
29272922# class Connector
@@ -2999,11 +2994,11 @@ def __init__(self,
29992994 ** kw
30002995 ):
30012996 if ipv != self .ipv :
3002- raise TypeError ("` ipv` keyword must be `4` " )
2997+ raise TypeError ("' ipv' keyword must be '4' " )
30032998 if host is None :
3004- raise TypeError ("` host` is a required keyword and cannot be ` None` " )
2999+ raise TypeError ("' host' is a required keyword and cannot be ' None' " )
30053000 if port is None :
3006- raise TypeError ("` port` is a required keyword and cannot be ` None` " )
3001+ raise TypeError ("' port' is a required keyword and cannot be ' None' " )
30073002 self .host = host
30083003 self .port = int (port )
30093004 # constant socket connector
@@ -3028,11 +3023,11 @@ def __init__(self,
30283023 ** kw
30293024 ):
30303025 if ipv != self .ipv :
3031- raise TypeError ("` ipv` keyword must be `6` " )
3026+ raise TypeError ("' ipv' keyword must be '6' " )
30323027 if host is None :
3033- raise TypeError ("` host` is a required keyword and cannot be ` None` " )
3028+ raise TypeError ("' host' is a required keyword and cannot be ' None' " )
30343029 if port is None :
3035- raise TypeError ("` port` is a required keyword and cannot be ` None` " )
3030+ raise TypeError ("' port' is a required keyword and cannot be ' None' " )
30363031 self .host = host
30373032 self .port = int (port )
30383033 # constant socket connector
@@ -3051,7 +3046,7 @@ def socket_factory_sequence(self):
30513046
30523047 def __init__ (self , unix = None , ** kw ):
30533048 if unix is None :
3054- raise TypeError ("` unix` is a required keyword and cannot be ` None` " )
3049+ raise TypeError ("' unix' is a required keyword and cannot be ' None' " )
30553050 self .unix = unix
30563051 # constant socket connector
30573052 self ._socketcreator = SocketCreator (
@@ -3088,12 +3083,12 @@ def __init__(self,
30883083 ** kw
30893084 ):
30903085 if host is None :
3091- raise TypeError ("` host` is a required keyword" )
3086+ raise TypeError ("' host' is a required keyword" )
30923087 if port is None :
3093- raise TypeError ("` port` is a required keyword" )
3088+ raise TypeError ("' port' is a required keyword" )
30943089
30953090 if address_family is not None and ipv is not None :
3096- raise TypeError ("` ipv` and ` address_family` on mutually exclusive" )
3091+ raise TypeError ("' ipv' and ' address_family' on mutually exclusive" )
30973092
30983093 if ipv is None :
30993094 self ._address_family = address_family or socket .AF_UNSPEC
@@ -3102,7 +3097,7 @@ def __init__(self,
31023097 elif ipv == 6 :
31033098 self ._address_family = socket .AF_INET6
31043099 else :
3105- raise TypeError ("unknown IP version selected: ` ipv` = " + repr (ipv ))
3100+ raise TypeError ("unknown IP version selected: ' ipv' = " + repr (ipv ))
31063101 self .host = host
31073102 self .port = port
31083103 super ().__init__ (** kw )
@@ -3127,13 +3122,13 @@ def select(self,
31273122 """
31283123 if unix is not None :
31293124 if host is not None :
3130- raise TypeError ("` unix` and ` host` keywords are exclusive" )
3125+ raise TypeError ("' unix' and ' host' keywords are exclusive" )
31313126 if port is not None :
3132- raise TypeError ("` unix` and ` port` keywords are exclusive" )
3127+ raise TypeError ("' unix' and ' port' keywords are exclusive" )
31333128 return self .Unix
31343129 else :
31353130 if host is None or port is None :
3136- raise TypeError ("` host` and ` port` , or ` unix` must be supplied" )
3131+ raise TypeError ("' host' and ' port' , or ' unix' must be supplied" )
31373132 # We have a host and a port.
31383133 # If it's an IP address, IP4 or IP6 should be selected.
31393134 if ':' in host :
@@ -3184,14 +3179,7 @@ def connect(self, **kw) -> Connection:
31843179 `postgresql.driver.pq3.Host`
31853180 Keywords that apply to host-based connections(resolving connector).
31863181 """
3187- cid = list (kw .items ())
3188- cid .sort ()
3189- cid = tuple (cid )
3190- if cid in self ._connectors :
3191- c = self ._connectors [cid ]
3192- else :
3193- c = self ._connectors [cid ] = self .create (** kw )
3194- return c ()
3182+ return self .create (** kw )()
31953183
31963184 def ife_snapshot_text (self ):
31973185 return 'postgresql.driver.pq3'
@@ -3203,11 +3191,12 @@ def throw_warnings(self, src, first, obj):
32033191
32043192 def print_messages (self , src , first , obj ):
32053193 "use ife_sever() to stop this"
3206- if isinstance (obj , pg_api . Message ) and not isinstance (obj , pg_exc . Warning ):
3194+ if not isinstance (obj , pg_exc . Warning ) and isinstance (obj , pg_api . Message ):
32073195 sys .stderr .write (str (obj ))
32083196
32093197 def __init__ (self , typio = TypeIO ):
3210- self ._connectors = dict ()
3211- self .ife_connect (self .throw_warnings , self .print_messages )
32123198 self .typio = typio
3213- default = Driver ()
3199+ self .ife_connect (
3200+ self .throw_warnings ,
3201+ self .print_messages
3202+ )
0 commit comments