From: | Jelte Fennema-Nio <postgres(at)jeltef(dot)nl> |
---|---|
To: | Jacob Champion <jacob(dot)champion(at)enterprisedb(dot)com> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Subject: | Re: [PATCH] Support older Pythons in oauth_server.py |
Date: | 2025-04-22 22:17:07 |
Message-ID: | CAGECzQSDfqy3Uw=_rox7j9+hGv0afNMsv41jSTty3JRCrfS42Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 22 Apr 2025 at 21:26, Jacob Champion
<jacob(dot)champion(at)enterprisedb(dot)com> wrote:
> - str.removeprefix/suffix() (3.9)
The way you replaced this does not have the same behaviour in the case
where the prefix/suffix is not part of the string. removeprefix/suffix
will not remove any characters in that case, but your code will always
remove the number of characters that the suffix/prefix is long. Maybe
your other checks and definition of the OAuth spec ensure that these
prefixes/suffixes are present when you remove them, but the code is
not the same in the general case (you'd need to add a hasprefix/suffix
check before removing the characters.
+ # Strip off the magic path segment. (The more readable
+ # str.removeprefix()/removesuffix() aren't available until Py3.9.)
if self._alt_issuer:
# The /alternate issuer uses IETF-style .well-known URIs.
if self.path.startswith("/.well-known/"):
- self.path = self.path.removesuffix("/alternate")
+ self.path = self.path[: -len("/alternate")]
else:
- self.path = self.path.removeprefix("/alternate")
+ self.path = self.path[len("/alternate") :]
elif self._parameterized:
- self.path = self.path.removeprefix("/param")
+ self.path = self.path[len("/param") :]
From | Date | Subject | |
---|---|---|---|
Next Message | Tomas Vondra | 2025-04-22 22:24:39 | Re: Enable data checksums by default |
Previous Message | Tom Lane | 2025-04-22 22:03:58 | Re: What's our minimum supported Python version? |