Skip to content

Commit 6c5faab

Browse files
committed
Add a workaround for failing tests rather than change marshal.c
1 parent cc01a30 commit 6c5faab

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

Lib/test/test_importlib/test_abc.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,9 @@ def verify_code(self, code_object, *, bytecode_written=False):
801801
data.extend(self.init._pack_uint32(0))
802802
data.extend(self.init._pack_uint32(self.loader.source_mtime))
803803
data.extend(self.init._pack_uint32(self.loader.source_size))
804+
# Make sure theres > 1 reference to code_object so that the
805+
# marshaled representation below matches the cached representation
806+
l = [code_object]
804807
data.extend(marshal.dumps(code_object))
805808
self.assertEqual(self.loader.written[self.cached], bytes(data))
806809

Python/marshal.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,12 +384,11 @@ w_ref(PyObject *v, char *flag, WFILE *p)
384384
if (p->version < 3 || p->hashtable == NULL)
385385
return 0; /* not writing object references */
386386

387-
/* If it has only one reference, it definitely isn't shared. But we use
388-
* TYPE_REF always for interned string and code objects, to PYC file stable
387+
/* If it has only one reference, it definitely isn't shared.
388+
* But we use TYPE_REF always for interned string, to PYC file stable
389389
* as possible.
390390
*/
391391
if (Py_REFCNT(v) == 1 &&
392-
!PyCode_Check(v) &&
393392
!(PyUnicode_CheckExact(v) && PyUnicode_CHECK_INTERNED(v))) {
394393
return 0;
395394
}

0 commit comments

Comments
 (0)