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:
@@ -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):
|
||||
|
||||
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user