Bug 1890880

Summary: breezy fails to build with Python 3.10: Py_REFCNT= needs to be replaced with Py_SET_REFCNT
Product: [Fedora] Fedora Reporter: Tomáš Hrnčiar <thrnciar>
Component: breezyAssignee: Ondřej Pohořelský <opohorel>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: mhroncok, opohorel, python-sig, thrnciar, vstinner
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-11-24 09:45:55 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: 1890881    

Description Tomáš Hrnčiar 2020-10-23 07:54:04 UTC
breezy fails to build with Python 3.10.0a1.

breezy/_static_tuple_c.c: In function ‘StaticTuple_Intern’:
breezy/_static_tuple_c.c:100:21: error: lvalue required as left operand of assignment
  100 |     Py_REFCNT(self) -= 1;
      |                     ^~
breezy/_static_tuple_c.c: In function ‘StaticTuple_dealloc’:
breezy/_static_tuple_c.c:119:25: error: lvalue required as left operand of assignment
  119 |         Py_REFCNT(self) = 2;
      |                         ^

  Cannot build extension "breezy._static_tuple_c".
  Use "build_ext --allow-python-fallback" to use slower python implementations instead.

error: command '/usr/bin/gcc' failed with exit code 1

For the build logs, see:
https://copr-be.cloud.fedoraproject.org/results/@python/python3.10/fedora-rawhide-x86_64/01716273-breezy/

For all our attempts to build breezy with Python 3.10, see:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/package/breezy/

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.10:
https://copr.fedorainfracloud.org/coprs/g/python/python3.10/

Let us know here if you have any questions.

Python 3.10 will be included in Fedora 35. To make that update smoother, we're building Fedora packages with early pre-releases of Python 3.10.
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 Miro Hrončok 2020-10-23 08:03:42 UTC
https://docs.python.org/3.10/whatsnew/3.10.html#id2

Since Py_REFCNT() is changed to the inline static function, Py_REFCNT(obj) = new_refcnt must be replaced with Py_SET_REFCNT(obj, new_refcnt): see Py_SET_REFCNT() (available since Python 3.9). For backward compatibility, this macro can be used:

#if PY_VERSION_HEX < 0x030900A4
#  define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0)
#endif

https://bugs.python.org/issue39573

Comment 2 Miro Hrončok 2020-10-26 11:49:12 UTC
For the record, this is **not** fixed in breezy 3.1.0:

[breezy (3.1.0)]$ rg Py_REFCNT breezy-3.1.0
breezy-3.1.0/breezy/_static_tuple_c.c
100:    Py_REFCNT(self) -= 1;
119:        Py_REFCNT(self) = 2;

Comment 3 Victor Stinner 2020-11-19 11:05:35 UTC
I reported the issue to breezy upstream: https://bugs.launchpad.net/brz/+bug/1904868

Comment 4 Victor Stinner 2020-11-19 20:14:34 UTC
My fix got merged into the 3.1 branch: https://bazaar.launchpad.net/~brz/brz/3.1/revision/7647

Comment 5 Tomáš Hrnčiar 2020-11-20 07:37:05 UTC
Thank you for the patch Victor. I can confirm that breezy builds alright in our Copr: https://copr.fedorainfracloud.org/coprs/g/python/python3.10/build/1776306/