Skip to content

Commit b0655bc

Browse files
committed
* Backport pythongh-78214: marshal: Stabilize FLAG_REF usage. Closes: #1010368.
1 parent 99b2210 commit b0655bc

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

debian/changelog

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
python3.10 (3.10.4-4) unstable; urgency=medium
2+
3+
* Source-only upload.
4+
* Backport gh-78214: marshal: Stabilize FLAG_REF usage. Closes: #1010368.
5+
6+
-- Matthias Klose <doko@debian.org> Fri, 13 May 2022 14:08:11 +0200
7+
18
python3.10 (3.10.4-3) unstable; urgency=medium
29

310
* Build a python3.10-nopie package, diverting the python3.10

debian/patches/gh-78214.diff

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
``marshal.dumps()`` uses ``FLAG_REF`` for all interned strings. This makes
2+
output more deterministic and helps reproducible build.
3+
4+
diff --git a/Python/marshal.c b/Python/marshal.c
5+
index bbe67e3379fd9..90a4405091800 100644
6+
--- a/Python/marshal.c
7+
+++ b/Python/marshal.c
8+
@@ -298,9 +298,14 @@ w_ref(PyObject *v, char *flag, WFILE *p)
9+
if (p->version < 3 || p->hashtable == NULL)
10+
return 0; /* not writing object references */
11+
12+
- /* if it has only one reference, it definitely isn't shared */
13+
- if (Py_REFCNT(v) == 1)
14+
+ /* If it has only one reference, it definitely isn't shared.
15+
+ * But we use TYPE_REF always for interned string, to PYC file stable
16+
+ * as possible.
17+
+ */
18+
+ if (Py_REFCNT(v) == 1 &&
19+
+ !(PyUnicode_CheckExact(v) && PyUnicode_CHECK_INTERNED(v))) {
20+
return 0;
21+
+ }
22+
23+
entry = _Py_hashtable_get_entry(p->hashtable, v);
24+
if (entry != NULL) {

debian/patches/series

+1
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ destshared-location.diff
3939
fix-py_compile.diff
4040
reproducible-pyc.diff
4141
fix-ia64.diff
42+
gh-78214.diff

0 commit comments

Comments
 (0)