You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It looks like all the exception messages end with a newline char. That's inconsistent with both the Python standard library and all the third-party libraries I've worked with.
I searched the psycopg python files and didn't find the error messages, so I assume those (and the newline) come from the Postgres library.
I solved the problem by adding [:-1] to the exception messages. Would it make sense to make that change in psycopg?
The text was updated successfully, but these errors were encountered:
It may make sense or not. The messages are multiline: if they were a single line I would agree with you, but being multiline it's a bit like a file: some conventions assume a final newline, some don't.
try:
cur.execute("select noway")
exceptExceptionase:
passstr(e)
'column "noway" does not exist\nLINE 1: select noway\n ^\n'
Maybe if I started the library from scratch I would strip these, and maybe I wouldn't even use the entire message but only the primary.
e.diag.message_primary'column "noway" does not exist'
However now there is code used to the trailing whiteline written since the last century: I don't feel like changing this in a backward-compatible library. So I guess it's a thing for a mythical psycopg3.
One remark: your solution is brittle: if we "fixed" psycopg you would start chopping the last character of the message - and this is the exact reason why I don't want to change this behaviour out of the blue. I advise you to use .rstrip() instead.
It looks like all the exception messages end with a newline char. That's inconsistent with both the Python standard library and all the third-party libraries I've worked with.
I searched the psycopg python files and didn't find the error messages, so I assume those (and the newline) come from the Postgres library.
I solved the problem by adding
[:-1]
to the exception messages. Would it make sense to make that change in psycopg?The text was updated successfully, but these errors were encountered: