Bug 2245673

Summary: python-psycopg2 fails to build with Python 3.13: error: implicit declaration of function ‘_PyInterpreterState_Get’; did you mean ‘PyInterpreterState_Get’
Product: [Fedora] Fedora Reporter: Karolina Surma <ksurma>
Component: python-psycopg2Assignee: Ales Nezbeda <anezbeda>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: urgent Docs Contact:
Priority: unspecified    
Version: rawhideCC: anezbeda, devrim, fjanus, hhorak, ksurma, mhroncok, osloup, praiskup
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: python-psycopg2-2.9.9-5.fc41 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2024-06-05 07:52:06 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 2244836    

Description Karolina Surma 2023-10-23 14:58:45 UTC
python-psycopg2 fails to build with Python 3.13.0a1.

psycopg/connection_int.c:395:14: error: implicit declaration of function ‘isalnum’ [-Werror=implicit-function-declaration]
  395 |         if (!isalnum(*i)) {
      |              ^~~~~~~
psycopg/connection_int.c:35:1: note: include ‘<ctype.h>’ or provide a declaration of ‘isalnum’
   34 | #include "psycopg/notify.h"
  +++ |+#include <ctype.h>
   35 | 
psycopg/connection_int.c:399:20: error: implicit declaration of function ‘toupper’ [-Werror=implicit-function-declaration]
  399 |             *j++ = toupper(*i++);
      |                    ^~~~~~~

https://docs.python.org/3.13/whatsnew/3.13.html

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.13/fedora-rawhide-x86_64/06551100-python-psycopg2/

For all our attempts to build python-psycopg2 with Python 3.13, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/package/python-psycopg2/

Testing and mass rebuild of packages is happening in copr.
You can follow these instructions to test locally in mock if your package builds with Python 3.13:
https://copr.fedorainfracloud.org/coprs/g/python/python3.13/

Let us know here if you have any questions.

Python 3.13 is planned to be included in Fedora 41.
To make that update smoother, we're building Fedora packages with all pre-releases of Python 3.13.
A build failure prevents us from testing all dependent packages (transitive [Build]Requires),
so if this package is required a lot, it's important for us to get it fixed soon.

We'd appreciate help from the people who know this package best,
but if you don't want to work on this now, let us know so we can try to work around it on our side.

Comment 1 Aoife Moloney 2024-02-15 23:00:35 UTC
This bug appears to have been reported against 'rawhide' during the Fedora Linux 40 development cycle.
Changing version to 40.

Comment 2 Karolina Surma 2024-04-23 12:50:45 UTC
The failure is different now with alpha6:

psycopg/utils.c: In function ‘psyco_is_main_interp’:
psycopg/utils.c:397:12: error: implicit declaration of function ‘_PyInterpreterState_Get’; did you mean ‘PyInterpreterState_Get’? [-Wimplicit-function-declaration]
  397 |     return _PyInterpreterState_Get() == PyInterpreterState_Main();
      |            ^~~~~~~~~~~~~~~~~~~~~~~
      |            PyInterpreterState_Get
psycopg/utils.c:397:38: warning: comparison between pointer and integer
  397 |     return _PyInterpreterState_Get() == PyInterpreterState_Main();
      |                                      ^~
error: command '/usr/bin/gcc' failed with exit code 1

Comment 3 Karolina Surma 2024-04-23 13:12:38 UTC
After a naive sed removing the underscore two tests fail:

======================================================================
FAIL: test_cidr_adapt (tests.test_ipaddress.NetworkingTestCase.test_cidr_adapt)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/psycopg2-2.9.9/tests/test_ipaddress.py", line 112, in test_cidr_adapt
    self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '::ffff:1.2.3.0/128' != '::ffff:102:300/128'
- ::ffff:1.2.3.0/128
?         ^ ^ ^
+ ::ffff:102:300/128
?         ^ ^ ^


======================================================================
FAIL: test_inet_adapt (tests.test_ipaddress.NetworkingTestCase.test_inet_adapt)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/builddir/build/BUILD/psycopg2-2.9.9/tests/test_ipaddress.py", line 71, in test_inet_adapt
    self.assertEquals(cur.fetchone()[0], '::ffff:102:300/128')
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: '::ffff:1.2.3.0/128' != '::ffff:102:300/128'
- ::ffff:1.2.3.0/128
?         ^ ^ ^
+ ::ffff:102:300/128
?         ^ ^ ^


----------------------------------------------------------------------
Ran 742 tests in 20.673s

Comment 4 Karolina Surma 2024-04-24 08:36:06 UTC
Upstream PR: https://github.com/psycopg/psycopg2/pull/1695