Roundup Tracker - Issues

Message7493

Author rouilj
Recipients marcus.priesch, rouilj, schlatterbeck
Date 2022-05-03.14:41:47
Message-id <20220503144144.BFC946A0289@pe15.cs.umb.edu>
In-reply-to <1651577795.25.0.549293703088.issue2551201@roundup.psfhosted.org>
Hi Ralf:

In message <1651577795.25.0.549293703088.issue2551201@roundup.psfhosted.org>,
Ralf Schlatterbeck writes:
>All (most?) of the postgres indexer tests and two tests in
>test/test_postgresql.py fail because older psycopg2 versions don't
>have an 'errors' module:
> [...]
>I'll look into this if we can get the same results with older postgres
>versions.
>
>Note that this happens for me only with python3 (which uses psycopg2
>from the distribution) not with python2 where I seem to have
>installed a psycopg2 module by hand via pip (and not using the one
>shipped by debian oldstable).
>
>So the question is if we want to fix this or recommend to use a newer
>psycopg2?

From what I can find, psycopg2 version 2.8 released on Apr 4, 2019
introduced the errors module. So that's three years ago.
redhat/debian/ubuntu etc. have a 5 year (free/full support) cycle on
their (lts) releases. While it would be nice to support back to 2017
versions of psycopg2, the question is how much of a mess will it be
for how much gain.

For example:

  except SyntaxError:
    do syntax error stuff

I think has to become:

  except psycopg2.Error:
             if pgcode == psycopg2.errorcodes.SYNTAX_ERROR:
	        do syntax error stuff

Is there a way in python to make this work:

  except SyntaxError:
    do syntax error stuff
  except psycopg2.Error as e:
             if e.pgcode == psycopg2.errorcodes.SYNTAX_ERROR:
	        jump to SyntaxError exception above

I don't think there is. But this would allow us to easily identify and
remove the compatibility code in 2 years. Some type of mapping shim
that intercepted psycopg2.Error and regenerated it as (our own)
SyntaxError exception would also work. We simply remove the imported
shim in a couple of years.

By the time these changes get released (this July?), there will only
be a year and a half or so of life in them. Any compatibility code we
add won't be tested (exception handling code in general is not well
tested).

My take on this is to not change any code. Instead add a minimum
required version of psycopg2 to the notes.

We have a good workaround. Install psycopg2 version 2.8 or newer in a
virtual env via pip. This preserves the system version.

Thoughts?
History
Date User Action Args
2022-05-03 14:41:47rouiljsetrecipients: + rouilj, schlatterbeck, marcus.priesch
2022-05-03 14:41:47rouiljlinkissue2551201 messages
2022-05-03 14:41:47rouiljcreate