Resolving the python 2 -> python 3 mess - Mailing list pgsql-hackers
From | Tom Lane |
---|---|
Subject | Resolving the python 2 -> python 3 mess |
Date | |
Msg-id | 6341.1581958178@sss.pgh.pa.us Whole thread Raw |
Responses |
Re: Resolving the python 2 -> python 3 mess
Re: Resolving the python 2 -> python 3 mess Re: Resolving the python 2 -> python 3 mess |
List | pgsql-hackers |
We've had multiple previous discussions of $SUBJECT (eg [1][2]), without any resolution of what to do exactly. Thinking about this some more, I had an idea that I don't think has been discussed. To wit: 1. On platforms where Python 2.x is still supported, recommend that packagers continue to build both plpython2 and plpython3, same as now. 2. On platforms where Python 2.x is no longer supported, transparently map plpythonu and plpython2u to plpython3u. "Transparent" meaning that dump/reload or pg_upgrade of existing plpythonu/plpython2u functions will work, but when you run them, what you actually get is Python 3.x. For existing functions that don't use any obsolete Python syntax (which one would hope is a pretty large percentage), this is a zero-effort conversion for users. If a function does use obsolete constructs, it will get a parse failure when executed, and the user will have to update it to Python 3 syntax. I propose that we make that case reasonably painless by providing the conversion script I posted in [3] (or another one if somebody's got a better one), bundled as a separately-installable extension. A possible gotcha in this approach is if there are any python 2/3 incompatibilities that would not manifest as syntax errors or obvious runtime errors, but would allow old code to execute and silently do the wrong thing. One would hope that the Python crowd weren't dumb enough to do that, but I don't know whether it's true. If there are nasty cases like that, maybe what we have to do is allow plpythonu/plpython2u functions to be dumped and reloaded into a python-3-only install, but refuse to execute them until they've been converted. In either case, to allow dump/reload or pg_upgrade to work without ugly hacks, what we need to do is provide a stub version of plpython2.so. (The extension definitions that sit on top of it then don't need to change.) The stub would either redirect calls to plpython3.so if we prefer that approach, or throw errors if we prefer that approach. I envision adding a configure option that enables build and install of this stub library while doing a plpython3 build; packagers not planning to build a "real" plpython2 should ask for the stub instead. The end result given the first approach is that "plpythonu" and "plpython2u" and "plpython3u" all work and mean the same thing. Over some long time period we might want to deprecate and remove the "plpython2u" alias, but there would be no hurry about it. The work involved in making this happen seems fairly minimal, and practical to get done in time for PG 13. Perhaps there'd even be a case for back-patching it, though I'm not going to advocate for that here. Thoughts? regards, tom lane [1] https://www.postgresql.org/message-id/flat/5351890.TdMePpdHBD%40nb.usersys.redhat.com [2] https://www.postgresql.org/message-id/flat/CAKmB1PGDAy9mXxSTqUchYEi4iJAA6NKVj4P5BtAzvQ9wSDUwJw%40mail.gmail.com [3] https://www.postgresql.org/message-id/11546.1566584867%40sss.pgh.pa.us
pgsql-hackers by date: