homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author brandtbucher
Recipients FFY00, brandtbucher, jefferyto, methane, obfusk, pablogsal, rhettinger, serhiy.storchaka
Date 2021年08月23日.19:10:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1629745853.62.0.594283834401.issue37596@roundup.psfhosted.org>
In-reply-to
Content
This rough proof-of-concept seems to have the desired effect:
diff --git a/Python/marshal.c b/Python/marshal.c
index 1260704c74..70f9c4b109 100644
--- a/Python/marshal.c
+++ b/Python/marshal.c
@@ -503,9 +503,23 @@ w_complex_object(PyObject *v, char flag, WFILE *p)
 W_TYPE(TYPE_SET, p);
 n = PySet_GET_SIZE(v);
 W_SIZE(n, p);
- while (_PySet_NextEntry(v, &pos, &value, &hash)) {
+ PyObject *pairs = PyList_New(0);
+ for (Py_ssize_t i = 0; _PySet_NextEntry(v, &pos, &value, &hash); i++) {
+ PyObject *pair = PyTuple_New(2);
+ PyObject *dump = PyMarshal_WriteObjectToString(value, p->version);
+ PyTuple_SET_ITEM(pair, 0, dump);
+ Py_INCREF(value);
+ PyTuple_SET_ITEM(pair, 1, value);
+ PyList_Append(pairs, pair);
+ Py_DECREF(pair);
+ }
+ PyList_Sort(pairs);
+ for (Py_ssize_t i = 0; i < n; i++) {
+ PyObject *pair = PyList_GET_ITEM(pairs, i);
+ PyObject *value = PyTuple_GET_ITEM(pair, 1);
 w_object(value, p);
 }
+ Py_DECREF(pairs);
 }
 else if (PyCode_Check(v)) {
 PyCodeObject *co = (PyCodeObject *)v;
I can clean it up and convert it to a PR if we decide we want to go this route.
History
Date User Action Args
2021年08月23日 19:10:53brandtbuchersetrecipients: + brandtbucher, rhettinger, methane, serhiy.storchaka, pablogsal, FFY00, jefferyto, obfusk
2021年08月23日 19:10:53brandtbuchersetmessageid: <1629745853.62.0.594283834401.issue37596@roundup.psfhosted.org>
2021年08月23日 19:10:53brandtbucherlinkissue37596 messages
2021年08月23日 19:10:53brandtbuchercreate

AltStyle によって変換されたページ (->オリジナル) /