- Timestamp:
- 08/11/25 18:20:48 (5 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/frams.py
r1199 r1343 42 42 if dontinit: 43 43 return 44 44 45 if isinstance(arg, int): 45 46 self._initFromInt(arg) … … 53 54 raise ctypes.ArgumentError("Can't make ExtValue from '%s' (%s)" % (str(arg), type(arg))) 54 55 56 # Bypass our custom __setattr__ (just like a regular self.myfield=... assignment here, it would cause infinite recursion because our custom __setattr__ creates another ExtValue object) by calling object.__setattr__ directly: 57 # object.__setattr__(self, 'debuginfo', "typ=%s, class=%s, arg=%s" % (str(self._type()), str(self._class()), str(arg))) # for debugging the order of deletion/destruction of ExtValue objects 58 55 59 56 60 def __del__(self): 57 c_api.extFree(self.__ptr) 61 # debuginfo = self.__dict__['debuginfo'] if 'debuginfo' in self.__dict__ else '(not-inited)' 62 if c_api is not None: # there is some unknown interaction between the native Framsticks library and other native Python libraries (like numpy) which affects the order of Python interpreter's garbage collector and leads to occasional calls of this destructor after c_api becomes None (when the Python interpreter exits). Hence this protection to avoid calling extFree() on None. An alternative would be to use self._finalizer = weakref.finalize(self, c_api.extFree, self.__ptr) instead of __del__. 63 #print("\tDeleter of the object with debuginfo='%s'" % debuginfo) 64 c_api.extFree(self.__ptr) 65 #else: 66 # print("\t*** The deleter of the object with debuginfo='%s' has c_api==None, so unable to extFree() !" % debuginfo) 58 67 59 68
Note: See TracChangeset
for help on using the changeset viewer.