Roundup Tracker - Issues

Message7672

Author schlatterbeck
Recipients rouilj, schlatterbeck
Date 2022-11-24.10:44:08
Message-id <20221124104405.xmkzbte4pjuwazda@runtux.com>
In-reply-to <1669255029.16.0.384338663827.issue2551241@roundup.psfhosted.org>
On Thu, Nov 24, 2022 at 01:57:09AM +0000, John Rouillard wrote:
> 
> https://www.psycopg.org/docs/errors.html maps the 2.8+ exceptions
> to their base exceptions. So we can use the base exceptions instead.
> 
>   from psycopg2 import InternalError as InFailedSqlTransaction, \
>                        ProgrammingError as SyntaxError
>   UndefinedObject = SyntaxError
> 
> >>> from psycopg2 import InternalError as InFailedSqlTransaction, \
> ...                        ProgrammingError as SyntaxError
> >>> UndefinedObject = SyntaxError
> >>> UndefinedObject
> <class 'psycopg2.ProgrammingError'>
> >>> SyntaxError
> <class 'psycopg2.ProgrammingError'>
> >>> InFailedSqlTransaction
> <class 'psycopg2.InternalError'>
> 
> I think that will do. It's not as targeted as the original errors, but
> should do the trick with the older psycopg2.

Looks like this works sort of.

I still get some failing tests in test/test_indexer.py
roundup/backends/indexer_postgresql_fts.py we have
- In find, line 123 it catches 'SyntaxError' and re-raises
  IndexerQueryError but the test in
  postgresqlFtsIndexerTest.test_invalid_language expects ValueError
- In add_text, the try/except line 73 only catches ValueError and
  several tests test for this.

So add_text should probably also catch SyntaxError and Re-raise
IndexerQueryError (and it should probably rollback?) and we might want
to make IndexerQueryError inherit from ValueError? Or fix the tests so
that they look for either ValueError or IndexerQueryError?

I currently do not see how
postgresqlFtsIndexerTest.test_invalid_language will ever get a
ValueError (line 570) because this is caught in find and re-raised as
IndexerQueryError.

Ralf
-- 
Dr. Ralf Schlatterbeck                  Tel:   +43/2243/26465-16
Open Source Consulting                  www:   www.runtux.com
Reichergasse 131, A-3411 Weidling       email: office@runtux.com
History
Date User Action Args
2022-11-24 10:44:08schlatterbecksetrecipients: + schlatterbeck, rouilj
2022-11-24 10:44:08schlatterbecklinkissue2551241 messages
2022-11-24 10:44:08schlatterbeckcreate