From 16e37537607e5634ef6521d5d82092844d5f8a0ba0f607fedda135973b8e2118 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Mon, 28 Oct 2024 21:56:27 +0000 Subject: [PATCH 1/2] - add py313-tests.patch OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-psycopg2?expand=0&rev=97 --- py313-tests.patch | 52 +++++++++++++++++++++++++++++++++++++++++ python-psycopg2.changes | 5 ++++ python-psycopg2.spec | 3 ++- 3 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 py313-tests.patch diff --git a/py313-tests.patch b/py313-tests.patch new file mode 100644 index 0000000..a8d9181 --- /dev/null +++ b/py313-tests.patch @@ -0,0 +1,52 @@ +From 3b9aa7cf9f3b000407dc0ee8e77fbcf54fa04d7f Mon Sep 17 00:00:00 2001 +From: Karolina Surma +Date: Wed, 24 Apr 2024 09:56:08 +0200 +Subject: [PATCH] Fix tests with Python 3.13 + +The textual representation of addresses has changed, adapt the code to +expect different values on Python 3.13+. +See: https://github.com/python/cpython/commit/f22bf8e3cf899896cf587099d292 +--- + tests/test_ipaddress.py | 15 +++++++++++++-- + 1 file changed, 13 insertions(+), 2 deletions(-) + +diff --git a/tests/test_ipaddress.py b/tests/test_ipaddress.py +index 4a2339ef9..3f8036900 100755 +--- a/tests/test_ipaddress.py ++++ b/tests/test_ipaddress.py +@@ -18,6 +18,7 @@ + + from . import testutils + import unittest ++import sys + + import psycopg2 + import psycopg2.extras +@@ -68,7 +69,12 @@ def test_inet_adapt(self): + self.assertEquals(cur.fetchone()[0], '127.0.0.1/24') + + cur.execute("select %s", [ip.ip_interface('::ffff:102:300/128')]) +- self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') ++ ++ # The texual representation of addresses has changed in Python 3.13 ++ if sys.version_info >= (3, 13): ++ self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128') ++ else: ++ self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') + + @testutils.skip_if_crdb("cidr") + def test_cidr_cast(self): +@@ -109,7 +115,12 @@ def test_cidr_adapt(self): + self.assertEquals(cur.fetchone()[0], '127.0.0.0/24') + + cur.execute("select %s", [ip.ip_network('::ffff:102:300/128')]) +- self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') ++ ++ # The texual representation of addresses has changed in Python 3.13 ++ if sys.version_info >= (3, 13): ++ self.assertEquals(cur.fetchone()[0], '::ffff:1.2.3.0/128') ++ else: ++ self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128') + + + def test_suite(): diff --git a/python-psycopg2.changes b/python-psycopg2.changes index c99c02e..bd853f1 100644 --- a/python-psycopg2.changes +++ b/python-psycopg2.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Oct 28 21:56:17 UTC 2024 - Dirk Müller + +- add py313-tests.patch + ------------------------------------------------------------------- Wed Jan 3 10:10:03 UTC 2024 - Dirk Müller diff --git a/python-psycopg2.spec b/python-psycopg2.spec index 8e62431..b3e62ab 100644 --- a/python-psycopg2.spec +++ b/python-psycopg2.spec @@ -24,6 +24,7 @@ Summary: Python-PostgreSQL Database Adapter License: LGPL-3.0-or-later AND (LGPL-3.0-or-later OR ZPL-2.0) AND SUSE-GPL-2.0-with-openssl-exception URL: https://www.psycopg.org/ Source: https://files.pythonhosted.org/packages/source/p/psycopg2/psycopg2-%{version}.tar.gz +Patch1: https://github.com/psycopg/psycopg2/commit/3b9aa7cf9f3b000407dc0ee8e77fbcf54fa04d7f.patch#/py313-tests.patch BuildRequires: %{python_module devel >= 3.7} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} @@ -52,7 +53,7 @@ UPDATEs. psycopg2 also provide asychronous operations and support for coroutine libraries. %prep -%setup -q -n psycopg2-%{version} +%autosetup -p1 -n psycopg2-%{version} %build export CFLAGS="%{optflags} -fno-strict-aliasing" From 1c0bc8f6b45bbe2b602f2af1d51e7fb180fe384d8b1c498d6c4054869f3ed4c5 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Tue, 29 Oct 2024 05:08:38 +0000 Subject: [PATCH 2/2] - Drop patch py313-tests.patch, included in: - Add patch support-python-313.patch: * Support Python 3.13. OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-psycopg2?expand=0&rev=98 --- python-psycopg2.changes | 7 +++++ python-psycopg2.spec | 5 +-- py313-tests.patch => support-python-313.patch | 31 ++++++++++++++++++- 3 files changed, 40 insertions(+), 3 deletions(-) rename py313-tests.patch => support-python-313.patch (63%) diff --git a/python-psycopg2.changes b/python-psycopg2.changes index bd853f1..d4c8550 100644 --- a/python-psycopg2.changes +++ b/python-psycopg2.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Tue Oct 29 05:08:18 UTC 2024 - Steve Kowalik + +- Drop patch py313-tests.patch, included in: +- Add patch support-python-313.patch: + * Support Python 3.13. + ------------------------------------------------------------------- Mon Oct 28 21:56:17 UTC 2024 - Dirk Müller diff --git a/python-psycopg2.spec b/python-psycopg2.spec index b3e62ab..b846ec8 100644 --- a/python-psycopg2.spec +++ b/python-psycopg2.spec @@ -24,7 +24,8 @@ Summary: Python-PostgreSQL Database Adapter License: LGPL-3.0-or-later AND (LGPL-3.0-or-later OR ZPL-2.0) AND SUSE-GPL-2.0-with-openssl-exception URL: https://www.psycopg.org/ Source: https://files.pythonhosted.org/packages/source/p/psycopg2/psycopg2-%{version}.tar.gz -Patch1: https://github.com/psycopg/psycopg2/commit/3b9aa7cf9f3b000407dc0ee8e77fbcf54fa04d7f.patch#/py313-tests.patch +# PATCH-FIX-UPSTREAM gh#psycopg/psycopg2#1695 +Patch0: support-python-313.patch BuildRequires: %{python_module devel >= 3.7} BuildRequires: %{python_module pip} BuildRequires: %{python_module setuptools} @@ -73,6 +74,6 @@ export CFLAGS="%{optflags} -fno-strict-aliasing" %license LICENSE %doc AUTHORS NEWS README.rst %{python_sitearch}/psycopg2/ -%{python_sitearch}/psycopg2-%{version}*-info +%{python_sitearch}/psycopg2-%{version}.dist-info %changelog diff --git a/py313-tests.patch b/support-python-313.patch similarity index 63% rename from py313-tests.patch rename to support-python-313.patch index a8d9181..5464e1a 100644 --- a/py313-tests.patch +++ b/support-python-313.patch @@ -1,7 +1,36 @@ +From 829a7a2be93f5d0fb1edbc0feb104181f208efc6 Mon Sep 17 00:00:00 2001 +From: Karolina Surma +Date: Wed, 24 Apr 2024 09:50:32 +0200 +Subject: [PATCH 1/6] _PyInterpreterState_Get() has become public in Python + 3.13 + +Since 3.13.0a1 it has been renamed to PyInterpreterStateGet() +Source: https://github.com/python/cpython/pull/106321 +--- + psycopg/utils.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/psycopg/utils.c b/psycopg/utils.c +index 16be9062a..1dfb87d0b 100644 +--- a/psycopg/utils.c ++++ b/psycopg/utils.c +@@ -392,7 +392,10 @@ psyco_set_error(PyObject *exc, cursorObject *curs, const char *msg) + static int + psyco_is_main_interp(void) + { +-#if PY_VERSION_HEX >= 0x03080000 ++#if PY_VERSION_HEX >= 0x030d0000 ++ /* tested with Python 3.13.0a6 */ ++ return PyInterpreterState_Get() == PyInterpreterState_Main(); ++#elif PY_VERSION_HEX >= 0x03080000 + /* tested with Python 3.8.0a2 */ + return _PyInterpreterState_Get() == PyInterpreterState_Main(); + #else + From 3b9aa7cf9f3b000407dc0ee8e77fbcf54fa04d7f Mon Sep 17 00:00:00 2001 From: Karolina Surma Date: Wed, 24 Apr 2024 09:56:08 +0200 -Subject: [PATCH] Fix tests with Python 3.13 +Subject: [PATCH 2/6] Fix tests with Python 3.13 The textual representation of addresses has changed, adapt the code to expect different values on Python 3.13+.