Skip to content

Commit a409ab2

Browse files
Address reviews
1 parent 13486cb commit a409ab2

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

Lib/test/test_free_threading/test_type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ class Bar:
106106
thing = Foo()
107107
def work():
108108
foo = thing
109-
for _ in range(10000):
109+
for _ in range(5000):
110110
foo.__class__ = Bar
111111
type(foo)
112112
foo.__class__ = Foo

Objects/typeobject.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6607,7 +6607,7 @@ compatible_for_assignment(PyTypeObject* oldto, PyTypeObject* newto, const char*
66076607

66086608

66096609
static int
6610-
object_set_class_world_stopped(PyObject *self, PyTypeObject *newto, PyTypeObject **oldto_p)
6610+
object_set_class_world_stopped(PyObject *self, PyTypeObject *newto)
66116611
{
66126612
PyTypeObject *oldto = Py_TYPE(self);
66136613

@@ -6682,13 +6682,7 @@ object_set_class_world_stopped(PyObject *self, PyTypeObject *newto, PyTypeObject
66826682
}
66836683
}
66846684

6685-
// If we raced after materialization and replaced the dict
6686-
// then the materialized dict should no longer have the
6687-
// inline values in which case detach is a nop.
6688-
// Note: we don't need to lock here because the world should be stopped.
6689-
6690-
assert(_PyObject_GetManagedDict(self) == dict ||
6691-
dict->ma_values != _PyObject_InlineValues(self));
6685+
assert(_PyObject_GetManagedDict(self) == dict);
66926686

66936687
if (_PyDict_DetachFromObject(dict, self) < 0) {
66946688
return -1;
@@ -6701,8 +6695,6 @@ object_set_class_world_stopped(PyObject *self, PyTypeObject *newto, PyTypeObject
67016695

67026696
Py_SET_TYPE(self, newto);
67036697

6704-
*oldto_p = oldto;
6705-
67066698
return 0;
67076699
}
67086700
else {
@@ -6734,12 +6726,10 @@ object_set_class(PyObject *self, PyObject *value, void *closure)
67346726

67356727
#ifdef Py_GIL_DISABLED
67366728
PyInterpreterState *interp = _PyInterpreterState_GET();
6737-
// The real Py_TYPE(self) (`oldto`) may have changed from
6738-
// underneath us in another thread, so we stop the world.
67396729
_PyEval_StopTheWorld(interp);
67406730
#endif
6741-
PyTypeObject *oldto;
6742-
int res = object_set_class_world_stopped(self, newto, &oldto);
6731+
PyTypeObject *oldto = Py_TYPE(self);
6732+
int res = object_set_class_world_stopped(self, newto);
67436733
#ifdef Py_GIL_DISABLED
67446734
_PyEval_StartTheWorld(interp);
67456735
#endif

0 commit comments

Comments
 (0)