Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Python 3.13 #1695

Merged
merged 6 commits into from
Jul 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- {python: "3.10", postgres: "14"}
- {python: "3.11", postgres: "15"}
- {python: "3.12", postgres: "16"}
- {python: "3.13-dev", postgres: "16"}

# Opposite extremes of the supported Py/PG range, other architecture
- {python: "3.7", postgres: "16", architecture: "x86"}
Expand All @@ -27,6 +28,7 @@ jobs:
- {python: "3.10", postgres: "13", architecture: "x86"}
- {python: "3.11", postgres: "11", architecture: "x86"}
- {python: "3.12", postgres: "10", architecture: "x86"}
- {python: "3.13-dev", postgres: "10", architecture: "x86"}

env:
PSYCOPG2_TESTDB: postgres
Expand Down
6 changes: 6 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
Current release
---------------

What's new in psycopg 2.9.10 (unreleased)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Add support for Python 3.13.


What's new in psycopg 2.9.9
^^^^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down
5 changes: 4 additions & 1 deletion psycopg/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
Programming Language :: Python :: 3.10
Programming Language :: Python :: 3.11
Programming Language :: Python :: 3.12
Programming Language :: Python :: 3.13
Programming Language :: Python :: 3 :: Only
Programming Language :: Python :: Implementation :: CPython
Programming Language :: C
Expand Down
15 changes: 13 additions & 2 deletions tests/test_ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from . import testutils
import unittest
import sys

import psycopg2
import psycopg2.extras
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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():
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = {3.7,3.8,3.9,3.10,3.11,3.12}
envlist = {3.7,3.8,3.9,3.10,3.11,3.12,3.13}

[testenv]
commands = make check
Expand Down