Skip to content

Commit 4eff27b

Browse files
committed
Regions: Freeze InterpreterLocal and SharedField on creation
1 parent e2e5a71 commit 4eff27b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Modules/_immutablemodule.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,13 @@ interpreterlocal_init(PyObject *self, PyObject *args, PyObject *kwds)
296296
il->default_value = Py_NewRef(default_or_factory);
297297
il->factory = NULL;
298298
}
299+
300+
// FIXME(regions): This freezes self directly, while we
301+
// can't set movability on a per-object level
302+
if (_PyImmutability_Freeze(self) < 0) {
303+
return -1;
304+
}
305+
299306
return 0;
300307
}
301308

@@ -483,6 +490,13 @@ sharedfield_init(PyObject *self, PyObject *args, PyObject *kwds)
483490
}
484491

485492
sf->value = Py_NewRef(initial);
493+
494+
// FIXME(regions): This freezes self directly, while we
495+
// can't set movability on a per-object level
496+
if (_PyImmutability_Freeze(self) < 0) {
497+
return -1;
498+
}
499+
486500
return 0;
487501
}
488502

0 commit comments

Comments
 (0)