Skip to content

Commit 1a3bcd5

Browse files
author
James William Pye
committed
Explicitly derive the source of ClientNotice and ClientError objects.
1 parent ba60d82 commit 1a3bcd5

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

postgresql/driver/pq3.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,12 +2016,17 @@ def _decode_pq_message(self, msg):
20162016
dmsg[k] = v
20172017
return dmsg
20182018

2019-
def _convert_pq_message(self, msg, source = 'SERVER'):
2019+
def _convert_pq_message(self, msg, source = None):
20202020
'create a message, warning or error'
20212021
dmsg = self._decode_pq_message(msg)
20222022
m = dmsg.pop('message')
20232023
c = dmsg.pop('code')
20242024
sev = dmsg['severity'].upper()
2025+
if source is None:
2026+
if type(msg) in (element.ClientNotice, element.ClientError):
2027+
source = 'CLIENT'
2028+
else:
2029+
source = 'SERVER'
20252030
if sev in ('ERROR', 'PANIC', 'FATAL'):
20262031
mo = pg_exc.ErrorLookup(c)(
20272032
m, code = c, details = dmsg, source = source

0 commit comments

Comments
 (0)