File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
Misc/NEWS.d/next/Core_and_Builtins Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change 1+ Make the :func: `compile ` builtin function deterministic by sorting
2+ :attr: `~class.__static_attributes__ ` before writing to bytecode.
Original file line number Diff line number Diff line change @@ -911,7 +911,14 @@ PyObject *
911911_PyCompile_StaticAttributesAsTuple (compiler * c )
912912{
913913 assert (c -> u -> u_static_attributes );
914- return PySequence_Tuple (c -> u -> u_static_attributes );
914+ PyObject * static_attributes_unsorted = PySequence_List (c -> u -> u_static_attributes );
915+ if (static_attributes_unsorted == NULL ) {
916+ return NULL ;
917+ }
918+ PyList_Sort (static_attributes_unsorted );
919+ PyObject * static_attributes = PySequence_Tuple (static_attributes_unsorted );
920+ Py_DECREF (static_attributes_unsorted );
921+ return static_attributes ;
915922}
916923
917924int
You can’t perform that action at this time.
0 commit comments