diff options
author | Jelle Zijlstra <jelle.zijlstra@gmail.com> | 2024-10-01 01:53:17 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-01 01:53:17 (GMT) |
commit | b99c6620b282b9ccac1018c86310aa5324fca753 (patch) | |
tree | 78449db5af97002ecd8c5f5440e8f651a5ed32c4 /Python/compile.c | |
parent | b843974ab4e50994e7bbb58b80afefb20236ada7 (diff) | |
download | cpython-b99c6620b282b9ccac1018c86310aa5324fca753.zip cpython-b99c6620b282b9ccac1018c86310aa5324fca753.tar.gz cpython-b99c6620b282b9ccac1018c86310aa5324fca753.tar.bz2 |
[3.13] gh-124442: make `__static_attributes__` deterministic by sorting (GH-124492) (#124738)
* [3.13] gh-124442: make `__static_attributes__` deterministic by sorting (GH-124492)
(cherry picked from commit 04c837d9d8a474777ef9c1412fbba14f0682366c)
Co-authored-by: Kira <kp2pml30@gmail.com>
Signed-off-by: kp2pml30 <kp2pml30@gmail.com>
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
Diffstat (limited to 'Python/compile.c')
-rw-r--r-- | Python/compile.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/Python/compile.c b/Python/compile.c index 7752a68..7d93f2a 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -2544,7 +2544,18 @@ compiler_class_body(struct compiler *c, stmt_ty s, int firstlineno) return ERROR; } assert(c->u->u_static_attributes); - PyObject *static_attributes = PySequence_Tuple(c->u->u_static_attributes); + PyObject *static_attributes_unsorted = PySequence_List(c->u->u_static_attributes); + if (static_attributes_unsorted == NULL) { + compiler_exit_scope(c); + return ERROR; + } + if (PyList_Sort(static_attributes_unsorted) != 0) { + compiler_exit_scope(c); + Py_DECREF(static_attributes_unsorted); + return ERROR; + } + PyObject *static_attributes = PySequence_Tuple(static_attributes_unsorted); + Py_DECREF(static_attributes_unsorted); if (static_attributes == NULL) { compiler_exit_scope(c); return ERROR; |