breezy fails to build on Python 3.10: issue with Py_REFCNT()

Bug #1904868 reported by Victor Stinner
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Breezy
Fix Released
High
Victor Stinner
Fedora
Confirmed
Undecided

Bug Description

On Python 3.10, Py_REFCNT() macro can no longer be used as an l-value, whereas breezy/_static_tuple_c.c uses it to set the reference count of an object:
    Py_REFCNT(self) -= 1;
and
    Py_REFCNT(self) = 2;

The new Py_SET_REFCNT() function must be used instead. For backward compatibility, this macro can be used to define Py_SET_REFCNT() on Python 3.8 and older.

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

Then replace:
    Py_REFCNT(self) -= 1;
with:
    Py_SET_REFCNT(self, Py_REFCNT(self) - 1);

And replace:
    Py_REFCNT(self) = 2;
with:
    Py_SET_REFCNT(self, 2);

Copy of What's New in Python 3.10:
"""
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
"""

Python issue where the Py_REFCNT() macro has been changed:
https://bugs.python.org/issue39573

Downstream Fedora issue for breezy on Python 3.10:
https://bugzilla.redhat.com/show_bug.cgi?id=1890880

Revision history for this message
Victor Stinner (vstinner) wrote :

I attach a fix as a patch.

I failed to create a brz branch.

The "bzr push lp:~vstinner/brz/brz" command fails with:

<email address hidden>: Permission denied (publickey).
ConnectionReset reading response for b'BzrDir.open_2.1', retrying
<email address hidden>: Permission denied (publickey).

"ssh -v <email address hidden>" fails with:

debug1: Offering public key: /home/vstinner/.ssh/id_rsa RSA SHA256:2Ikqg/9eDjHfxObh+4wk6E4u5JhguaHpFG/V04e0yIo agent
debug1: send_pubkey_test: no mutual signature algorithm

I tested 2 different RSA keys (registered in my Launchpad account).

Revision history for this message
Jelmer Vernooij (jelmer) wrote : Re: [Bug 1904868] Re: breezy fails to build on Python 3.10: issue with Py_REFCNT()

On Thu, Nov 19, 2020 at 12:36:20PM -0000, Victor Stinner wrote:
> I attach a fix as a patch.

> ** Patch added: "Port brz to Python 3.10"
> https://bugs.launchpad.net/brz/+bug/1904868/+attachment/5435974/+files/brz-python310.patch
Thanks for the patch - I'll submit that to the 3.1 and 3.2 series for
Breezy.

> I failed to create a brz branch.
>
> The "bzr push lp:~vstinner/brz/brz" command fails with:
>
> <email address hidden>: Permission denied (publickey).
> ConnectionReset reading response for b'BzrDir.open_2.1', retrying
> <email address hidden>: Permission denied (publickey).

>
> "ssh -v <email address hidden>" fails with:
>
> debug1: Offering public key: /home/vstinner/.ssh/id_rsa RSA SHA256:2Ikqg/9eDjHfxObh+4wk6E4u5JhguaHpFG/V04e0yIo agent
> debug1: send_pubkey_test: no mutual signature algorithm
>
> I tested 2 different RSA keys (registered in my Launchpad account).
Not really sure what's going on there - if you care about debugging
this further, the best place to ask is probably
https://answers.launchpad.net/launchpad or the launchpad users list.

I know Launchpad uses some variant of the twisted SSH implementation,
but I am fuzzy on the details.

Breezy has integration for Launchpad (and other hosting platforms)
and is hosted on Launchpad, but is otherwise a separate project.

Jelmer

Jelmer Vernooij (jelmer)
Changed in brz:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → Victor Stinner (vstinner)
milestone: none → 3.1.1
Revision history for this message
Victor Stinner (vstinner) wrote :

> New → Fix Committed

Great, that was quick! Thank you :-)

Changed in fedora:
importance: Unknown → Undecided
status: Unknown → Confirmed
Jelmer Vernooij (jelmer)
Changed in brz:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.