/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_static_tuple_c.c

  • Committer: Jelmer Vernooij
  • Author(s): Victor Stinner
  • Date: 2020-11-19 12:13:38 UTC
  • mto: (7490.40.118 work)
  • mto: This revision was merged to the branch mainline in revision 7532.
  • Revision ID: jelmer@jelmer.uk-20201119121338-cxm1x4fj5y3bmbau
Port to Python 3.10

Set static tuple reference count using Py_SET_REFCNT() rather than using
Py_REFCNT().

Define Py_SET_REFCNT() for Python 3.8 and older in python-compat.h.

On Python 3.10, Py_REFCNT() can no longer be used as an l-value to set an
object reference count: Py_SET_REFCNT() must be used for that.
See https://bugs.python.org/issue39573 for more details.

Fix issue #1904868.

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
    self->flags |= STATIC_TUPLE_INTERNED_FLAG;
98
98
    // The two references in the dict do not count, so that the StaticTuple
99
99
    // object does not become immortal just because it was interned.
100
 
    Py_REFCNT(self) -= 1;
 
100
    Py_SET_REFCNT(self, Py_REFCNT(self) - 1);
101
101
    return self;
102
102
}
103
103
 
116
116
 
117
117
    if (_StaticTuple_is_interned(self)) {
118
118
        /* revive dead object temporarily for Discard */
119
 
        Py_REFCNT(self) = 2;
 
119
        Py_SET_REFCNT(self, 2);
120
120
        if (SimpleSet_Discard(_interned_tuples, (PyObject*)self) != 1)
121
121
            Py_FatalError("deletion of interned StaticTuple failed");
122
122
        self->flags &= ~STATIC_TUPLE_INTERNED_FLAG;