fix ValueError in f_locals.pop('self') Python 3.13+

The error
ValueError: cannot remove local variables from FrameLocalsProxy

is caused by PEP 667 – Consistent views of namespaces
peps.python.org/pep-0667
implemented in Python 3.13
This commit is contained in:
Mark Zhitomirski committed 2025-10-31 00:13:49 +04:00
1 parent bc3b595cc3
commit 0cfde115ff
5 files changed
+14 -7

No files matched your search

+2 -1
View File
@@ -8,8 +8,9 @@ class Structure:
@staticmethod
def _init():
locs = sys._getframe(1).f_locals
self = locs.pop('self')
self = locs['self']
for name, val in locs.items():
if name == 'self': continue
setattr(self, name, val)
def __setattr__(self, name, value):
+2 -1
View File
@@ -9,8 +9,9 @@ class Structure:
@staticmethod
def _init():
locs = sys._getframe(1).f_locals
self = locs.pop('self')
self = locs['self']
for name, val in locs.items():
if name == 'self': continue
setattr(self, name, val)
def __setattr__(self, name, value):