revno: 7526
committer: Victor Stinner <vstinner@python.org>
branch nick: brz
timestamp: Thu 2020-11-19 13:13:38 +0100
message:
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.
diff:
=== modified file 'breezy/_static_tuple_c.c'
--- breezy/_static_tuple_c.c 2019-11-18 01:30:13 +0000
+++ breezy/_static_tuple_c.c 2020-11-19 12:13:38 +0000
@@ -97,7 +97,7 @@
self->flags |= STATIC_TUPLE_INTERNED_FLAG;
// The two references in the dict do not count, so that the StaticTuple
// object does not become immortal just because it was interned.
- Py_REFCNT(self) -= 1;
+ Py_SET_REFCNT(self, Py_REFCNT(self) - 1);
return self;
}
@@ -116,7 +116,7 @@
if (_StaticTuple_is_interned(self)) {
/* revive dead object temporarily for Discard */
- Py_REFCNT(self) = 2;
+ Py_SET_REFCNT(self, 2);
if (SimpleSet_Discard(_interned_tuples, (PyObject*)self) != 1)
Py_FatalError("deletion of interned StaticTuple failed");
self->flags &= ~STATIC_TUPLE_INTERNED_FLAG;
=== modified file 'breezy/python-compat.h'
--- breezy/python-compat.h 2019-03-05 07:56:11 +0000
+++ breezy/python-compat.h 2020-11-19 12:13:38 +0000
@@ -119,4 +119,8 @@
#define strtoull _strtoui64
#endif
+#if PY_VERSION_HEX < 0x030900A4
+# define Py_SET_REFCNT(obj, refcnt) ((Py_REFCNT(obj) = (refcnt)), (void)0)
+#endif
+
#endif /* _BZR_PYTHON_COMPAT_H */