Re: What's our minimum supported Python version? - Mailing list pgsql-hackers

From Tom Lane
Subject Re: What's our minimum supported Python version?
Date
Msg-id 984535.1745334295@sss.pgh.pa.us
Whole thread Raw
In response to Re: What's our minimum supported Python version?  (Daniel Gustafsson <daniel@yesql.se>)
Responses Re: What's our minimum supported Python version?
List pgsql-hackers
Daniel Gustafsson <daniel@yesql.se> writes:
>> On 19 Apr 2025, at 18:17, Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> The reason I bring this up is that I found out the hard way
>> that src/test/modules/oauth_validator fails on RHEL8, because
>> its oauth_server.py script is not compatible with the 3.6.8
>> version of Python supplied by this distro.

> Do you have the error message/log for the failure handy?

The first problem is that this Python version seems not to
like assignments embedded in if statements:

  File "t/oauth_server.py", line 319
    if err := self._get_param("error_code", None):
            ^
SyntaxError: invalid syntax

I was able to work around that with the attached quick hack.
But then I get

Traceback (most recent call last):
  File "t/oauth_server.py", line 19, in <module>
    class OAuthHandler(http.server.BaseHTTPRequestHandler):
  File "t/oauth_server.py", line 26, in OAuthHandler
    JsonObject = dict[str, object]  # TypeAlias is not available until 3.10
TypeError: 'type' object is not subscriptable

which I have no idea how to work around.

            regards, tom lane

diff --git a/src/test/modules/oauth_validator/t/oauth_server.py b/src/test/modules/oauth_validator/t/oauth_server.py
index 5bc30be87fd..133fe496cfc 100755
--- a/src/test/modules/oauth_validator/t/oauth_server.py
+++ b/src/test/modules/oauth_validator/t/oauth_server.py
@@ -316,11 +316,13 @@ class OAuthHandler(http.server.BaseHTTPRequestHandler):
         return resp

     def token(self) -> JsonObject:
-        if err := self._get_param("error_code", None):
+        err = self._get_param("error_code", None)
+        if err:
             self._response_code = self._get_param("error_status", 400)

             resp = {"error": err}
-            if desc := self._get_param("error_desc", ""):
+            desc = self._get_param("error_desc", "")
+            if desc:
                 resp["error_description"] = desc

             return resp

pgsql-hackers by date:

Previous
From: Pavel Borisov
Date:
Subject: Re: Fortify float4 and float8 regression tests by ordering test results
Next
From: Tom Lane
Date:
Subject: Re: [PATCH] contrib/xml2: xslt_process() should report XSLT-related error details