From jython-checkins at python.org Thu Sep 4 06:35:34 2014
From: jython-checkins at python.org (jim.baker)
Date: Thu, 4 Sep 2014 06:35:34 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython=3A_Fixed_issue_1057=2E_In_this?=
=?utf-8?q?_patch_I_propose_to_forbid_Java-style_finalizers_for?=
Message-ID: <3hpTj26LW3z7Ljn@mail.python.org>
http://hg.python.org/jython/rev/288366399aed
changeset: 7360:288366399aed
parent: 7348:2c45f75a5406
user: Stefan Richthofer
date: Mon Aug 18 12:23:58 2014 +0200
summary:
Fixed issue 1057. In this patch I propose to forbid Java-style finalizers for PyObject subclasses. However there is an easy fix available for usecases where it is needed. If the impact of this decision for third party custom types should be too high, one could make it a compiler warning instead and undetake the obligatory change for Jython 3 or so.
files:
Lib/test/test_finalizers.py | 403 ++++++++++
src/org/python/antlr/ast/AssertDerived.java | 26 +-
src/org/python/antlr/ast/AssignDerived.java | 26 +-
src/org/python/antlr/ast/AttributeDerived.java | 26 +-
src/org/python/antlr/ast/AugAssignDerived.java | 26 +-
src/org/python/antlr/ast/BinOpDerived.java | 26 +-
src/org/python/antlr/ast/BoolOpDerived.java | 26 +-
src/org/python/antlr/ast/BreakDerived.java | 26 +-
src/org/python/antlr/ast/CallDerived.java | 26 +-
src/org/python/antlr/ast/ClassDefDerived.java | 26 +-
src/org/python/antlr/ast/CompareDerived.java | 26 +-
src/org/python/antlr/ast/ContinueDerived.java | 26 +-
src/org/python/antlr/ast/DeleteDerived.java | 26 +-
src/org/python/antlr/ast/DictDerived.java | 26 +-
src/org/python/antlr/ast/EllipsisDerived.java | 26 +-
src/org/python/antlr/ast/ExceptHandlerDerived.java | 26 +-
src/org/python/antlr/ast/ExecDerived.java | 26 +-
src/org/python/antlr/ast/ExprDerived.java | 26 +-
src/org/python/antlr/ast/ExpressionDerived.java | 26 +-
src/org/python/antlr/ast/ExtSliceDerived.java | 26 +-
src/org/python/antlr/ast/ForDerived.java | 26 +-
src/org/python/antlr/ast/FunctionDefDerived.java | 26 +-
src/org/python/antlr/ast/GeneratorExpDerived.java | 26 +-
src/org/python/antlr/ast/GlobalDerived.java | 26 +-
src/org/python/antlr/ast/IfDerived.java | 26 +-
src/org/python/antlr/ast/IfExpDerived.java | 26 +-
src/org/python/antlr/ast/ImportDerived.java | 26 +-
src/org/python/antlr/ast/ImportFromDerived.java | 26 +-
src/org/python/antlr/ast/IndexDerived.java | 26 +-
src/org/python/antlr/ast/InteractiveDerived.java | 26 +-
src/org/python/antlr/ast/LambdaDerived.java | 26 +-
src/org/python/antlr/ast/ListCompDerived.java | 26 +-
src/org/python/antlr/ast/ListDerived.java | 26 +-
src/org/python/antlr/ast/ModuleDerived.java | 26 +-
src/org/python/antlr/ast/NameDerived.java | 26 +-
src/org/python/antlr/ast/NumDerived.java | 26 +-
src/org/python/antlr/ast/PassDerived.java | 26 +-
src/org/python/antlr/ast/PrintDerived.java | 26 +-
src/org/python/antlr/ast/RaiseDerived.java | 26 +-
src/org/python/antlr/ast/ReprDerived.java | 26 +-
src/org/python/antlr/ast/ReturnDerived.java | 26 +-
src/org/python/antlr/ast/SliceDerived.java | 26 +-
src/org/python/antlr/ast/StrDerived.java | 26 +-
src/org/python/antlr/ast/SubscriptDerived.java | 26 +-
src/org/python/antlr/ast/SuiteDerived.java | 26 +-
src/org/python/antlr/ast/TryExceptDerived.java | 26 +-
src/org/python/antlr/ast/TryFinallyDerived.java | 26 +-
src/org/python/antlr/ast/TupleDerived.java | 26 +-
src/org/python/antlr/ast/UnaryOpDerived.java | 26 +-
src/org/python/antlr/ast/WhileDerived.java | 26 +-
src/org/python/antlr/ast/WithDerived.java | 26 +-
src/org/python/antlr/ast/YieldDerived.java | 26 +-
src/org/python/antlr/ast/aliasDerived.java | 26 +-
src/org/python/antlr/ast/argumentsDerived.java | 26 +-
src/org/python/antlr/ast/comprehensionDerived.java | 26 +-
src/org/python/antlr/ast/keywordDerived.java | 26 +-
src/org/python/antlr/op/AddDerived.java | 26 +-
src/org/python/antlr/op/AndDerived.java | 26 +-
src/org/python/antlr/op/AugLoadDerived.java | 26 +-
src/org/python/antlr/op/AugStoreDerived.java | 26 +-
src/org/python/antlr/op/BitAndDerived.java | 26 +-
src/org/python/antlr/op/BitOrDerived.java | 26 +-
src/org/python/antlr/op/BitXorDerived.java | 26 +-
src/org/python/antlr/op/DelDerived.java | 26 +-
src/org/python/antlr/op/DivDerived.java | 26 +-
src/org/python/antlr/op/EqDerived.java | 26 +-
src/org/python/antlr/op/FloorDivDerived.java | 26 +-
src/org/python/antlr/op/GtDerived.java | 26 +-
src/org/python/antlr/op/GtEDerived.java | 26 +-
src/org/python/antlr/op/InDerived.java | 26 +-
src/org/python/antlr/op/InvertDerived.java | 26 +-
src/org/python/antlr/op/IsDerived.java | 26 +-
src/org/python/antlr/op/IsNotDerived.java | 26 +-
src/org/python/antlr/op/LShiftDerived.java | 26 +-
src/org/python/antlr/op/LoadDerived.java | 26 +-
src/org/python/antlr/op/LtDerived.java | 26 +-
src/org/python/antlr/op/LtEDerived.java | 26 +-
src/org/python/antlr/op/ModDerived.java | 26 +-
src/org/python/antlr/op/MultDerived.java | 26 +-
src/org/python/antlr/op/NotDerived.java | 26 +-
src/org/python/antlr/op/NotEqDerived.java | 26 +-
src/org/python/antlr/op/NotInDerived.java | 26 +-
src/org/python/antlr/op/OrDerived.java | 26 +-
src/org/python/antlr/op/ParamDerived.java | 26 +-
src/org/python/antlr/op/PowDerived.java | 26 +-
src/org/python/antlr/op/RShiftDerived.java | 26 +-
src/org/python/antlr/op/StoreDerived.java | 26 +-
src/org/python/antlr/op/SubDerived.java | 26 +-
src/org/python/antlr/op/UAddDerived.java | 26 +-
src/org/python/antlr/op/USubDerived.java | 26 +-
src/org/python/core/ClasspathPyImporterDerived.java | 23 +-
src/org/python/core/PyArrayDerived.java | 26 +-
src/org/python/core/PyBaseExceptionDerived.java | 23 +-
src/org/python/core/PyByteArrayDerived.java | 26 +-
src/org/python/core/PyClass.java | 15 +-
src/org/python/core/PyClassMethodDerived.java | 26 +-
src/org/python/core/PyComplexDerived.java | 26 +-
src/org/python/core/PyDictionaryDerived.java | 26 +-
src/org/python/core/PyEnumerateDerived.java | 26 +-
src/org/python/core/PyFile.java | 16 +-
src/org/python/core/PyFileDerived.java | 26 +-
src/org/python/core/PyFinalizableInstance.java | 37 -
src/org/python/core/PyFloatDerived.java | 26 +-
src/org/python/core/PyFrozenSetDerived.java | 26 +-
src/org/python/core/PyGenerator.java | 13 +-
src/org/python/core/PyInstance.java | 53 +-
src/org/python/core/PyIntegerDerived.java | 26 +-
src/org/python/core/PyListDerived.java | 26 +-
src/org/python/core/PyLongDerived.java | 26 +-
src/org/python/core/PyModuleDerived.java | 23 +-
src/org/python/core/PyObject.java | 15 +
src/org/python/core/PyObjectDerived.java | 26 +-
src/org/python/core/PyPropertyDerived.java | 26 +-
src/org/python/core/PySetDerived.java | 26 +-
src/org/python/core/PyStringDerived.java | 26 +-
src/org/python/core/PySuperDerived.java | 26 +-
src/org/python/core/PyTupleDerived.java | 26 +-
src/org/python/core/PyType.java | 22 +-
src/org/python/core/PyTypeDerived.java | 23 +-
src/org/python/core/PyUnicodeDerived.java | 26 +-
src/org/python/core/finalization/FinalizableBuiltin.java | 18 +
src/org/python/core/finalization/FinalizablePyObject.java | 90 ++
src/org/python/core/finalization/FinalizablePyObjectDerived.java | 23 +
src/org/python/core/finalization/FinalizeTrigger.java | 138 +++
src/org/python/core/finalization/FinalizeTriggerFactory.java | 6 +
src/org/python/core/finalization/HasFinalizeTrigger.java | 13 +
src/org/python/core/finalization/PyFinalizableObject.java | 17 +
src/org/python/modules/PyStructDerived.java | 26 +-
src/org/python/modules/_collections/PyDefaultDictDerived.java | 26 +-
src/org/python/modules/_collections/PyDequeDerived.java | 26 +-
src/org/python/modules/_csv/PyDialectDerived.java | 23 +-
src/org/python/modules/_functools/PyPartialDerived.java | 26 +-
src/org/python/modules/_io/PyFileIODerived.java | 23 +-
src/org/python/modules/_io/PyIOBase.java | 11 +-
src/org/python/modules/_io/PyIOBaseDerived.java | 23 +-
src/org/python/modules/_io/PyRawIOBaseDerived.java | 23 +-
src/org/python/modules/_weakref/ReferenceTypeDerived.java | 26 +-
src/org/python/modules/bz2/PyBZ2CompressorDerived.java | 26 +-
src/org/python/modules/bz2/PyBZ2DecompressorDerived.java | 26 +-
src/org/python/modules/bz2/PyBZ2File.java | 13 +-
src/org/python/modules/bz2/PyBZ2FileDerived.java | 26 +-
src/org/python/modules/itertools/PyTeeIteratorDerived.java | 26 +-
src/org/python/modules/itertools/chainDerived.java | 26 +-
src/org/python/modules/itertools/combinationsDerived.java | 26 +-
src/org/python/modules/itertools/combinationsWithReplacementDerived.java | 26 +-
src/org/python/modules/itertools/compressDerived.java | 26 +-
src/org/python/modules/itertools/countDerived.java | 26 +-
src/org/python/modules/itertools/cycleDerived.java | 26 +-
src/org/python/modules/itertools/dropwhileDerived.java | 26 +-
src/org/python/modules/itertools/groupbyDerived.java | 26 +-
src/org/python/modules/itertools/ifilterDerived.java | 26 +-
src/org/python/modules/itertools/ifilterfalseDerived.java | 26 +-
src/org/python/modules/itertools/isliceDerived.java | 26 +-
src/org/python/modules/itertools/izipDerived.java | 26 +-
src/org/python/modules/itertools/izipLongestDerived.java | 26 +-
src/org/python/modules/itertools/permutationsDerived.java | 26 +-
src/org/python/modules/itertools/productDerived.java | 26 +-
src/org/python/modules/itertools/repeatDerived.java | 26 +-
src/org/python/modules/itertools/starmapDerived.java | 26 +-
src/org/python/modules/itertools/takewhileDerived.java | 26 +-
src/org/python/modules/random/PyRandomDerived.java | 26 +-
src/org/python/modules/thread/PyLocalDerived.java | 23 +-
src/org/python/modules/zipimport/zipimporterDerived.java | 26 +-
src/templates/gderived-defs | 26 +-
src/templates/gderived.py | 125 +-
src/templates/object.derived | 2 +
166 files changed, 4556 insertions(+), 269 deletions(-)
diff --git a/Lib/test/test_finalizers.py b/Lib/test/test_finalizers.py
new file mode 100644
--- /dev/null
+++ b/Lib/test/test_finalizers.py
@@ -0,0 +1,403 @@
+'''
+Created on 06.08.2014
+'''
+
+import platform
+import unittest
+import types
+import time
+if platform.system() == "Java":
+ from java.lang import System
+ from org.python.core.finalization import FinalizeTrigger
+
+class GCDetector():
+ gcIndex = 0
+
+ def __del__(self):
+ GCDetector.gcIndex += 1
+
+maxGCRun = 10
+
+def runGCIfJython():
+ if platform.system() == "Java":
+ currentIndex = GCDetector.gcIndex
+ gcCount = 0
+ detector = GCDetector()
+ detector = None
+ while currentIndex == GCDetector.gcIndex and gcCount < maxGCRun:
+ System.gc()
+ gcCount += 1
+ time.sleep(0.1)
+
+finalizeMsgList = []
+verbose = False
+resurrectedObject_I = None
+resurrectedObject_J = None
+resurrectedObject_K = None
+resurrectedObject_L = None
+resurrectedObject_M = None
+resurrectedObject_N = None
+
+class ResurrectableDummyClass():
+
+ def __init__(self, name):
+ self.name = name
+ self.doResurrection = True
+
+ def __str__(self):
+ return self.name
+
+
+class ResurrectableDummyClassNew(object):
+
+ def __init__(self, name):
+ self.name = name
+ self.doResurrection = True
+
+ def __str__(self):
+ return self.name
+
+
+def __del__I(self):
+ global resurrectedObject_I
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_I = self
+
+def __del__J(self):
+ global resurrectedObject_J
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_J = self
+
+def __del__K(self):
+ global resurrectedObject_K
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_K = self
+
+def __del__L(self):
+ global resurrectedObject_L
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_L = self
+
+def __del__M(self):
+ global resurrectedObject_M
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_M = self
+
+def __del__N(self):
+ global resurrectedObject_N
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_N = self
+
+delI = __del__I
+delJ = __del__J
+delK = __del__K
+delL = __del__L
+delM = __del__M
+delN = __del__N
+
+
+class DummyClass():
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+
+class DummyClassDel():
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyClassDel)")
+ if verbose:
+ print str(self)+" finalized (DummyClassDel)"
+
+
+class DummyClassNew(object):
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+class DummyClassDelNew(object):
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyClassDelNew)")
+ if verbose:
+ print str(self)+" finalized (DummyClassDelNew)"
+
+class DummyFileClassNew(file):
+
+ def __init__(self, name):
+ self.name0 = name
+
+ def __str__(self):
+ return self.name0
+
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyFileClassNew)")
+ if verbose:
+ print str(self)+" finalized (DummyFileClassNew)"
+
+
+def __del__class(self):
+ finalizeMsgList.append(str(self)+" finalized (acquired by class)")
+ if verbose:
+ print str(self)+" finalized (acquired by class)"
+
+def __del__object(self):
+ finalizeMsgList.append(str(self)+" finalized (acquired by object)")
+ if verbose:
+ print str(self)+" finalized (acquired by object)"
+
+def __del__object0():
+ finalizeMsgList.append("_ finalized (acquired by object)")
+ if verbose:
+ print "_ finalized (acquired by object)"
+
+delClass = __del__class
+delObject = __del__object
+delObject0 = __del__object0
+
+class TestFinalizers(unittest.TestCase):
+ def test_finalizer_builtin_oldStyleClass(self):
+ A = DummyClassDel("A")
+ A = None
+ runGCIfJython()
+ assert("A finalized (DummyClassDel)" in finalizeMsgList)
+
+ def test_classAcquiresFinalizer_beforeInstanciation_oldStyleClass(self):
+ DummyClass.__del__ = delClass
+ B = DummyClass("B")
+ B = None
+ runGCIfJython()
+ assert("B finalized (acquired by class)" in finalizeMsgList)
+ del DummyClass.__del__
+
+ def test_classAcquiresFinalizer_afterInstanciation_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer call
+ C = DummyClass("C")
+ DummyClass.__del__ = delClass
+ if platform.system() == "Java":
+ FinalizeTrigger.ensureFinalizer(C)
+ C = None
+ runGCIfJython()
+ assert("C finalized (acquired by class)" in finalizeMsgList)
+ del DummyClass.__del__
+
+ def test_instanceAcquiresFinalizer_bound_oldStyleClass(self):
+ D = DummyClassDel("D")
+ dl = types.MethodType(delObject, D.name)
+ D.__del__ = dl
+ D = None
+ runGCIfJython()
+ assert("D finalized (DummyClassDel)" not in finalizeMsgList)
+ assert("D finalized (acquired by object)" in finalizeMsgList)
+
+ def test_finalizer_builtin_newStyleClass(self):
+ E = DummyClassDelNew("E")
+ E = None
+ runGCIfJython()
+ assert("E finalized (DummyClassDelNew)" in finalizeMsgList)
+
+ def test_classAcquiresFinalizer_beforeInstanciation_newStyleClass(self):
+ DummyClassNew.__del__ = delClass
+ F = DummyClassNew("F")
+ F = None
+ runGCIfJython()
+ assert("F finalized (acquired by class)" in finalizeMsgList)
+ del DummyClassNew.__del__
+
+ def test_classAcquiresFinalizer_afterInstanciation_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer call
+ G = DummyClassNew("G")
+ DummyClassNew.__del__ = delClass
+ if platform.system() == "Java":
+ FinalizeTrigger.ensureFinalizer(G)
+ G = None
+ runGCIfJython()
+ assert("G finalized (acquired by class)" in finalizeMsgList)
+ del DummyClassNew.__del__
+
+ def test_instanceAcquiresFinalizer_bound_newStyleClass(self):
+ """
+ It seems, CPython prohibits new style instances from acquiring a finalizer.
+ """
+ H = DummyClassDelNew("H")
+ H.__del__ = types.MethodType(delObject, H.name)
+ H = None
+ runGCIfJython()
+ assert("H finalized (DummyClassDelNew)" in finalizeMsgList)
+ assert("H finalized (acquired by object)" not in finalizeMsgList)
+
+ def test_instanceAcquiresFinalizer_bound_newStyleClass2(self):
+ """
+ It seems, CPython prohibits new style instances from acquiring a finalizer.
+ If one calls the instance-acquired __del__ manually, it works, but the gc
+ will still call the old one.
+ """
+ H = DummyClassDelNew("H2")
+ H.__del__ = types.MethodType(delObject, H.name)
+ H.__del__()
+ H = None
+ runGCIfJython()
+ assert("H2 finalized (DummyClassDelNew)" in finalizeMsgList)
+ assert("H2 finalized (acquired by object)" in finalizeMsgList)
+
+ def test_objectResurrection_oldStyleClass(self):
+ ResurrectableDummyClass.__del__ = delI
+ I = ResurrectableDummyClass("I")
+ I = None
+ runGCIfJython()
+ assert("I finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_I) == "I")
+
+ def test_objectDoubleResurrection_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClass.__del__ = delJ
+ J = ResurrectableDummyClass("J")
+ J = None
+
+ runGCIfJython()
+ assert("J finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ global resurrectedObject_J
+ assert(str(resurrectedObject_J) == "J")
+ J = resurrectedObject_J
+ resurrectedObject_J = None
+ assert(resurrectedObject_J is None)
+ if platform.system() == "Java":
+ #For Jython one can restore the finalizer manually.
+ #This is offered as an easy fix if the CPython behavior
+ #in this test should be needed for some reason.
+ FinalizeTrigger.ensureFinalizer(J)
+ J = None
+
+ runGCIfJython()
+ assert(str(resurrectedObject_J) == "J")
+ resurrectedObject_J.doResurrection = False
+ if platform.system() == "Java":
+ #again...
+ FinalizeTrigger.ensureFinalizer(resurrectedObject_J)
+ resurrectedObject_J = None
+
+ runGCIfJython()
+ assert(resurrectedObject_J is None)
+
+
+ def test_objectDoubleResurrectionAndFinalize_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClass.__del__ = delK
+ K = ResurrectableDummyClass("K")
+ K = None
+
+ runGCIfJython()
+ assert("K finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ finalizeMsgList.remove("K finalized (ResurrectableDummyClass)")
+ assert("K finalized (ResurrectableDummyClass)" not in finalizeMsgList)
+ global resurrectedObject_K
+ assert(str(resurrectedObject_K) == "K")
+ K = resurrectedObject_K
+ resurrectedObject_K = None
+ assert(resurrectedObject_K is None)
+ if platform.system() == "Java":
+ FinalizeTrigger.ensureFinalizer(K)
+ K = None
+
+ runGCIfJython()
+ assert("K finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_K) == "K")
+
+ def test_objectResurrection_newStyleClass(self):
+ ResurrectableDummyClassNew.__del__ = delL
+ L = ResurrectableDummyClassNew("L")
+ L = None
+ runGCIfJython()
+ assert("L finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_L) == "L")
+
+ def test_objectDoubleResurrection_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClassNew.__del__ = delM
+ M = ResurrectableDummyClassNew("M")
+ M = None
+
+ runGCIfJython()
+ assert("M finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ global resurrectedObject_M
+ assert(str(resurrectedObject_M) == "M")
+ M = resurrectedObject_M
+ resurrectedObject_M = None
+ assert(resurrectedObject_M is None)
+ if platform.system() == "Java":
+ FinalizeTrigger.ensureFinalizer(M)
+ M = None
+
+ runGCIfJython()
+ assert(str(resurrectedObject_M) == "M")
+
+ def test_objectDoubleResurrectionAndFinalize_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClassNew.__del__ = delN
+ N = ResurrectableDummyClassNew("N")
+ N = None
+
+ runGCIfJython()
+ assert("N finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ finalizeMsgList.remove("N finalized (ResurrectableDummyClass)")
+ assert("N finalized (ResurrectableDummyClass)" not in finalizeMsgList)
+ global resurrectedObject_N
+ assert(str(resurrectedObject_N) == "N")
+ N = resurrectedObject_N
+ resurrectedObject_N = None
+ assert(resurrectedObject_N is None)
+ if platform.system() == "Java":
+ FinalizeTrigger.ensureFinalizer(N)
+ N = None
+
+ runGCIfJython()
+ assert("N finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_N) == "N")
+
+ def test_file_overwrite_del(self):
+ O = DummyFileClassNew("O")
+ O = None
+
+ runGCIfJython()
+ assert("O finalized (DummyFileClassNew)" in finalizeMsgList)
+
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/src/org/python/antlr/ast/AssertDerived.java b/src/org/python/antlr/ast/AssertDerived.java
--- a/src/org/python/antlr/ast/AssertDerived.java
+++ b/src/org/python/antlr/ast/AssertDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AssertDerived extends Assert implements Slotted {
+public class AssertDerived extends Assert implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/AssignDerived.java b/src/org/python/antlr/ast/AssignDerived.java
--- a/src/org/python/antlr/ast/AssignDerived.java
+++ b/src/org/python/antlr/ast/AssignDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AssignDerived extends Assign implements Slotted {
+public class AssignDerived extends Assign implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/AttributeDerived.java b/src/org/python/antlr/ast/AttributeDerived.java
--- a/src/org/python/antlr/ast/AttributeDerived.java
+++ b/src/org/python/antlr/ast/AttributeDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AttributeDerived extends Attribute implements Slotted {
+public class AttributeDerived extends Attribute implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/AugAssignDerived.java b/src/org/python/antlr/ast/AugAssignDerived.java
--- a/src/org/python/antlr/ast/AugAssignDerived.java
+++ b/src/org/python/antlr/ast/AugAssignDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AugAssignDerived extends AugAssign implements Slotted {
+public class AugAssignDerived extends AugAssign implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/BinOpDerived.java b/src/org/python/antlr/ast/BinOpDerived.java
--- a/src/org/python/antlr/ast/BinOpDerived.java
+++ b/src/org/python/antlr/ast/BinOpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BinOpDerived extends BinOp implements Slotted {
+public class BinOpDerived extends BinOp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/BoolOpDerived.java b/src/org/python/antlr/ast/BoolOpDerived.java
--- a/src/org/python/antlr/ast/BoolOpDerived.java
+++ b/src/org/python/antlr/ast/BoolOpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BoolOpDerived extends BoolOp implements Slotted {
+public class BoolOpDerived extends BoolOp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/BreakDerived.java b/src/org/python/antlr/ast/BreakDerived.java
--- a/src/org/python/antlr/ast/BreakDerived.java
+++ b/src/org/python/antlr/ast/BreakDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BreakDerived extends Break implements Slotted {
+public class BreakDerived extends Break implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/CallDerived.java b/src/org/python/antlr/ast/CallDerived.java
--- a/src/org/python/antlr/ast/CallDerived.java
+++ b/src/org/python/antlr/ast/CallDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class CallDerived extends Call implements Slotted {
+public class CallDerived extends Call implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ClassDefDerived.java b/src/org/python/antlr/ast/ClassDefDerived.java
--- a/src/org/python/antlr/ast/ClassDefDerived.java
+++ b/src/org/python/antlr/ast/ClassDefDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ClassDefDerived extends ClassDef implements Slotted {
+public class ClassDefDerived extends ClassDef implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/CompareDerived.java b/src/org/python/antlr/ast/CompareDerived.java
--- a/src/org/python/antlr/ast/CompareDerived.java
+++ b/src/org/python/antlr/ast/CompareDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class CompareDerived extends Compare implements Slotted {
+public class CompareDerived extends Compare implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ContinueDerived.java b/src/org/python/antlr/ast/ContinueDerived.java
--- a/src/org/python/antlr/ast/ContinueDerived.java
+++ b/src/org/python/antlr/ast/ContinueDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ContinueDerived extends Continue implements Slotted {
+public class ContinueDerived extends Continue implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/DeleteDerived.java b/src/org/python/antlr/ast/DeleteDerived.java
--- a/src/org/python/antlr/ast/DeleteDerived.java
+++ b/src/org/python/antlr/ast/DeleteDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class DeleteDerived extends Delete implements Slotted {
+public class DeleteDerived extends Delete implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/DictDerived.java b/src/org/python/antlr/ast/DictDerived.java
--- a/src/org/python/antlr/ast/DictDerived.java
+++ b/src/org/python/antlr/ast/DictDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class DictDerived extends Dict implements Slotted {
+public class DictDerived extends Dict implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/EllipsisDerived.java b/src/org/python/antlr/ast/EllipsisDerived.java
--- a/src/org/python/antlr/ast/EllipsisDerived.java
+++ b/src/org/python/antlr/ast/EllipsisDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class EllipsisDerived extends Ellipsis implements Slotted {
+public class EllipsisDerived extends Ellipsis implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExceptHandlerDerived.java b/src/org/python/antlr/ast/ExceptHandlerDerived.java
--- a/src/org/python/antlr/ast/ExceptHandlerDerived.java
+++ b/src/org/python/antlr/ast/ExceptHandlerDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExceptHandlerDerived extends ExceptHandler implements Slotted {
+public class ExceptHandlerDerived extends ExceptHandler implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExecDerived.java b/src/org/python/antlr/ast/ExecDerived.java
--- a/src/org/python/antlr/ast/ExecDerived.java
+++ b/src/org/python/antlr/ast/ExecDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExecDerived extends Exec implements Slotted {
+public class ExecDerived extends Exec implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExprDerived.java b/src/org/python/antlr/ast/ExprDerived.java
--- a/src/org/python/antlr/ast/ExprDerived.java
+++ b/src/org/python/antlr/ast/ExprDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExprDerived extends Expr implements Slotted {
+public class ExprDerived extends Expr implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExpressionDerived.java b/src/org/python/antlr/ast/ExpressionDerived.java
--- a/src/org/python/antlr/ast/ExpressionDerived.java
+++ b/src/org/python/antlr/ast/ExpressionDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExpressionDerived extends Expression implements Slotted {
+public class ExpressionDerived extends Expression implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExtSliceDerived.java b/src/org/python/antlr/ast/ExtSliceDerived.java
--- a/src/org/python/antlr/ast/ExtSliceDerived.java
+++ b/src/org/python/antlr/ast/ExtSliceDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExtSliceDerived extends ExtSlice implements Slotted {
+public class ExtSliceDerived extends ExtSlice implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ForDerived.java b/src/org/python/antlr/ast/ForDerived.java
--- a/src/org/python/antlr/ast/ForDerived.java
+++ b/src/org/python/antlr/ast/ForDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ForDerived extends For implements Slotted {
+public class ForDerived extends For implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/FunctionDefDerived.java b/src/org/python/antlr/ast/FunctionDefDerived.java
--- a/src/org/python/antlr/ast/FunctionDefDerived.java
+++ b/src/org/python/antlr/ast/FunctionDefDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class FunctionDefDerived extends FunctionDef implements Slotted {
+public class FunctionDefDerived extends FunctionDef implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/GeneratorExpDerived.java b/src/org/python/antlr/ast/GeneratorExpDerived.java
--- a/src/org/python/antlr/ast/GeneratorExpDerived.java
+++ b/src/org/python/antlr/ast/GeneratorExpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class GeneratorExpDerived extends GeneratorExp implements Slotted {
+public class GeneratorExpDerived extends GeneratorExp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/GlobalDerived.java b/src/org/python/antlr/ast/GlobalDerived.java
--- a/src/org/python/antlr/ast/GlobalDerived.java
+++ b/src/org/python/antlr/ast/GlobalDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class GlobalDerived extends Global implements Slotted {
+public class GlobalDerived extends Global implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/IfDerived.java b/src/org/python/antlr/ast/IfDerived.java
--- a/src/org/python/antlr/ast/IfDerived.java
+++ b/src/org/python/antlr/ast/IfDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IfDerived extends If implements Slotted {
+public class IfDerived extends If implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/IfExpDerived.java b/src/org/python/antlr/ast/IfExpDerived.java
--- a/src/org/python/antlr/ast/IfExpDerived.java
+++ b/src/org/python/antlr/ast/IfExpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IfExpDerived extends IfExp implements Slotted {
+public class IfExpDerived extends IfExp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ImportDerived.java b/src/org/python/antlr/ast/ImportDerived.java
--- a/src/org/python/antlr/ast/ImportDerived.java
+++ b/src/org/python/antlr/ast/ImportDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ImportDerived extends Import implements Slotted {
+public class ImportDerived extends Import implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ImportFromDerived.java b/src/org/python/antlr/ast/ImportFromDerived.java
--- a/src/org/python/antlr/ast/ImportFromDerived.java
+++ b/src/org/python/antlr/ast/ImportFromDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ImportFromDerived extends ImportFrom implements Slotted {
+public class ImportFromDerived extends ImportFrom implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/IndexDerived.java b/src/org/python/antlr/ast/IndexDerived.java
--- a/src/org/python/antlr/ast/IndexDerived.java
+++ b/src/org/python/antlr/ast/IndexDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IndexDerived extends Index implements Slotted {
+public class IndexDerived extends Index implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/InteractiveDerived.java b/src/org/python/antlr/ast/InteractiveDerived.java
--- a/src/org/python/antlr/ast/InteractiveDerived.java
+++ b/src/org/python/antlr/ast/InteractiveDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class InteractiveDerived extends Interactive implements Slotted {
+public class InteractiveDerived extends Interactive implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/LambdaDerived.java b/src/org/python/antlr/ast/LambdaDerived.java
--- a/src/org/python/antlr/ast/LambdaDerived.java
+++ b/src/org/python/antlr/ast/LambdaDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LambdaDerived extends Lambda implements Slotted {
+public class LambdaDerived extends Lambda implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ListCompDerived.java b/src/org/python/antlr/ast/ListCompDerived.java
--- a/src/org/python/antlr/ast/ListCompDerived.java
+++ b/src/org/python/antlr/ast/ListCompDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ListCompDerived extends ListComp implements Slotted {
+public class ListCompDerived extends ListComp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ListDerived.java b/src/org/python/antlr/ast/ListDerived.java
--- a/src/org/python/antlr/ast/ListDerived.java
+++ b/src/org/python/antlr/ast/ListDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ListDerived extends List implements Slotted {
+public class ListDerived extends List implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ModuleDerived.java b/src/org/python/antlr/ast/ModuleDerived.java
--- a/src/org/python/antlr/ast/ModuleDerived.java
+++ b/src/org/python/antlr/ast/ModuleDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ModuleDerived extends Module implements Slotted {
+public class ModuleDerived extends Module implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/NameDerived.java b/src/org/python/antlr/ast/NameDerived.java
--- a/src/org/python/antlr/ast/NameDerived.java
+++ b/src/org/python/antlr/ast/NameDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NameDerived extends Name implements Slotted {
+public class NameDerived extends Name implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/NumDerived.java b/src/org/python/antlr/ast/NumDerived.java
--- a/src/org/python/antlr/ast/NumDerived.java
+++ b/src/org/python/antlr/ast/NumDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NumDerived extends Num implements Slotted {
+public class NumDerived extends Num implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/PassDerived.java b/src/org/python/antlr/ast/PassDerived.java
--- a/src/org/python/antlr/ast/PassDerived.java
+++ b/src/org/python/antlr/ast/PassDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PassDerived extends Pass implements Slotted {
+public class PassDerived extends Pass implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/PrintDerived.java b/src/org/python/antlr/ast/PrintDerived.java
--- a/src/org/python/antlr/ast/PrintDerived.java
+++ b/src/org/python/antlr/ast/PrintDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PrintDerived extends Print implements Slotted {
+public class PrintDerived extends Print implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/RaiseDerived.java b/src/org/python/antlr/ast/RaiseDerived.java
--- a/src/org/python/antlr/ast/RaiseDerived.java
+++ b/src/org/python/antlr/ast/RaiseDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class RaiseDerived extends Raise implements Slotted {
+public class RaiseDerived extends Raise implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ReprDerived.java b/src/org/python/antlr/ast/ReprDerived.java
--- a/src/org/python/antlr/ast/ReprDerived.java
+++ b/src/org/python/antlr/ast/ReprDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ReprDerived extends Repr implements Slotted {
+public class ReprDerived extends Repr implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ReturnDerived.java b/src/org/python/antlr/ast/ReturnDerived.java
--- a/src/org/python/antlr/ast/ReturnDerived.java
+++ b/src/org/python/antlr/ast/ReturnDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ReturnDerived extends Return implements Slotted {
+public class ReturnDerived extends Return implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/SliceDerived.java b/src/org/python/antlr/ast/SliceDerived.java
--- a/src/org/python/antlr/ast/SliceDerived.java
+++ b/src/org/python/antlr/ast/SliceDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class SliceDerived extends Slice implements Slotted {
+public class SliceDerived extends Slice implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/StrDerived.java b/src/org/python/antlr/ast/StrDerived.java
--- a/src/org/python/antlr/ast/StrDerived.java
+++ b/src/org/python/antlr/ast/StrDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class StrDerived extends Str implements Slotted {
+public class StrDerived extends Str implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/SubscriptDerived.java b/src/org/python/antlr/ast/SubscriptDerived.java
--- a/src/org/python/antlr/ast/SubscriptDerived.java
+++ b/src/org/python/antlr/ast/SubscriptDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class SubscriptDerived extends Subscript implements Slotted {
+public class SubscriptDerived extends Subscript implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/SuiteDerived.java b/src/org/python/antlr/ast/SuiteDerived.java
--- a/src/org/python/antlr/ast/SuiteDerived.java
+++ b/src/org/python/antlr/ast/SuiteDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class SuiteDerived extends Suite implements Slotted {
+public class SuiteDerived extends Suite implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/TryExceptDerived.java b/src/org/python/antlr/ast/TryExceptDerived.java
--- a/src/org/python/antlr/ast/TryExceptDerived.java
+++ b/src/org/python/antlr/ast/TryExceptDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class TryExceptDerived extends TryExcept implements Slotted {
+public class TryExceptDerived extends TryExcept implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/TryFinallyDerived.java b/src/org/python/antlr/ast/TryFinallyDerived.java
--- a/src/org/python/antlr/ast/TryFinallyDerived.java
+++ b/src/org/python/antlr/ast/TryFinallyDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class TryFinallyDerived extends TryFinally implements Slotted {
+public class TryFinallyDerived extends TryFinally implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/TupleDerived.java b/src/org/python/antlr/ast/TupleDerived.java
--- a/src/org/python/antlr/ast/TupleDerived.java
+++ b/src/org/python/antlr/ast/TupleDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class TupleDerived extends Tuple implements Slotted {
+public class TupleDerived extends Tuple implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/UnaryOpDerived.java b/src/org/python/antlr/ast/UnaryOpDerived.java
--- a/src/org/python/antlr/ast/UnaryOpDerived.java
+++ b/src/org/python/antlr/ast/UnaryOpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class UnaryOpDerived extends UnaryOp implements Slotted {
+public class UnaryOpDerived extends UnaryOp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/WhileDerived.java b/src/org/python/antlr/ast/WhileDerived.java
--- a/src/org/python/antlr/ast/WhileDerived.java
+++ b/src/org/python/antlr/ast/WhileDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class WhileDerived extends While implements Slotted {
+public class WhileDerived extends While implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/WithDerived.java b/src/org/python/antlr/ast/WithDerived.java
--- a/src/org/python/antlr/ast/WithDerived.java
+++ b/src/org/python/antlr/ast/WithDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class WithDerived extends With implements Slotted {
+public class WithDerived extends With implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/YieldDerived.java b/src/org/python/antlr/ast/YieldDerived.java
--- a/src/org/python/antlr/ast/YieldDerived.java
+++ b/src/org/python/antlr/ast/YieldDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class YieldDerived extends Yield implements Slotted {
+public class YieldDerived extends Yield implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/aliasDerived.java b/src/org/python/antlr/ast/aliasDerived.java
--- a/src/org/python/antlr/ast/aliasDerived.java
+++ b/src/org/python/antlr/ast/aliasDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class aliasDerived extends alias implements Slotted {
+public class aliasDerived extends alias implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/argumentsDerived.java b/src/org/python/antlr/ast/argumentsDerived.java
--- a/src/org/python/antlr/ast/argumentsDerived.java
+++ b/src/org/python/antlr/ast/argumentsDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class argumentsDerived extends arguments implements Slotted {
+public class argumentsDerived extends arguments implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/comprehensionDerived.java b/src/org/python/antlr/ast/comprehensionDerived.java
--- a/src/org/python/antlr/ast/comprehensionDerived.java
+++ b/src/org/python/antlr/ast/comprehensionDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class comprehensionDerived extends comprehension implements Slotted {
+public class comprehensionDerived extends comprehension implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/keywordDerived.java b/src/org/python/antlr/ast/keywordDerived.java
--- a/src/org/python/antlr/ast/keywordDerived.java
+++ b/src/org/python/antlr/ast/keywordDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class keywordDerived extends keyword implements Slotted {
+public class keywordDerived extends keyword implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/AddDerived.java b/src/org/python/antlr/op/AddDerived.java
--- a/src/org/python/antlr/op/AddDerived.java
+++ b/src/org/python/antlr/op/AddDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AddDerived extends Add implements Slotted {
+public class AddDerived extends Add implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/AndDerived.java b/src/org/python/antlr/op/AndDerived.java
--- a/src/org/python/antlr/op/AndDerived.java
+++ b/src/org/python/antlr/op/AndDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AndDerived extends And implements Slotted {
+public class AndDerived extends And implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/AugLoadDerived.java b/src/org/python/antlr/op/AugLoadDerived.java
--- a/src/org/python/antlr/op/AugLoadDerived.java
+++ b/src/org/python/antlr/op/AugLoadDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AugLoadDerived extends AugLoad implements Slotted {
+public class AugLoadDerived extends AugLoad implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/AugStoreDerived.java b/src/org/python/antlr/op/AugStoreDerived.java
--- a/src/org/python/antlr/op/AugStoreDerived.java
+++ b/src/org/python/antlr/op/AugStoreDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AugStoreDerived extends AugStore implements Slotted {
+public class AugStoreDerived extends AugStore implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/BitAndDerived.java b/src/org/python/antlr/op/BitAndDerived.java
--- a/src/org/python/antlr/op/BitAndDerived.java
+++ b/src/org/python/antlr/op/BitAndDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BitAndDerived extends BitAnd implements Slotted {
+public class BitAndDerived extends BitAnd implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/BitOrDerived.java b/src/org/python/antlr/op/BitOrDerived.java
--- a/src/org/python/antlr/op/BitOrDerived.java
+++ b/src/org/python/antlr/op/BitOrDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BitOrDerived extends BitOr implements Slotted {
+public class BitOrDerived extends BitOr implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/BitXorDerived.java b/src/org/python/antlr/op/BitXorDerived.java
--- a/src/org/python/antlr/op/BitXorDerived.java
+++ b/src/org/python/antlr/op/BitXorDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BitXorDerived extends BitXor implements Slotted {
+public class BitXorDerived extends BitXor implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/DelDerived.java b/src/org/python/antlr/op/DelDerived.java
--- a/src/org/python/antlr/op/DelDerived.java
+++ b/src/org/python/antlr/op/DelDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class DelDerived extends Del implements Slotted {
+public class DelDerived extends Del implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/DivDerived.java b/src/org/python/antlr/op/DivDerived.java
--- a/src/org/python/antlr/op/DivDerived.java
+++ b/src/org/python/antlr/op/DivDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class DivDerived extends Div implements Slotted {
+public class DivDerived extends Div implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/EqDerived.java b/src/org/python/antlr/op/EqDerived.java
--- a/src/org/python/antlr/op/EqDerived.java
+++ b/src/org/python/antlr/op/EqDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class EqDerived extends Eq implements Slotted {
+public class EqDerived extends Eq implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/FloorDivDerived.java b/src/org/python/antlr/op/FloorDivDerived.java
--- a/src/org/python/antlr/op/FloorDivDerived.java
+++ b/src/org/python/antlr/op/FloorDivDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class FloorDivDerived extends FloorDiv implements Slotted {
+public class FloorDivDerived extends FloorDiv implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/GtDerived.java b/src/org/python/antlr/op/GtDerived.java
--- a/src/org/python/antlr/op/GtDerived.java
+++ b/src/org/python/antlr/op/GtDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class GtDerived extends Gt implements Slotted {
+public class GtDerived extends Gt implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/GtEDerived.java b/src/org/python/antlr/op/GtEDerived.java
--- a/src/org/python/antlr/op/GtEDerived.java
+++ b/src/org/python/antlr/op/GtEDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class GtEDerived extends GtE implements Slotted {
+public class GtEDerived extends GtE implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/InDerived.java b/src/org/python/antlr/op/InDerived.java
--- a/src/org/python/antlr/op/InDerived.java
+++ b/src/org/python/antlr/op/InDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class InDerived extends In implements Slotted {
+public class InDerived extends In implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/InvertDerived.java b/src/org/python/antlr/op/InvertDerived.java
--- a/src/org/python/antlr/op/InvertDerived.java
+++ b/src/org/python/antlr/op/InvertDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class InvertDerived extends Invert implements Slotted {
+public class InvertDerived extends Invert implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/IsDerived.java b/src/org/python/antlr/op/IsDerived.java
--- a/src/org/python/antlr/op/IsDerived.java
+++ b/src/org/python/antlr/op/IsDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IsDerived extends Is implements Slotted {
+public class IsDerived extends Is implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/IsNotDerived.java b/src/org/python/antlr/op/IsNotDerived.java
--- a/src/org/python/antlr/op/IsNotDerived.java
+++ b/src/org/python/antlr/op/IsNotDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IsNotDerived extends IsNot implements Slotted {
+public class IsNotDerived extends IsNot implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/LShiftDerived.java b/src/org/python/antlr/op/LShiftDerived.java
--- a/src/org/python/antlr/op/LShiftDerived.java
+++ b/src/org/python/antlr/op/LShiftDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LShiftDerived extends LShift implements Slotted {
+public class LShiftDerived extends LShift implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/LoadDerived.java b/src/org/python/antlr/op/LoadDerived.java
--- a/src/org/python/antlr/op/LoadDerived.java
+++ b/src/org/python/antlr/op/LoadDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LoadDerived extends Load implements Slotted {
+public class LoadDerived extends Load implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/LtDerived.java b/src/org/python/antlr/op/LtDerived.java
--- a/src/org/python/antlr/op/LtDerived.java
+++ b/src/org/python/antlr/op/LtDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LtDerived extends Lt implements Slotted {
+public class LtDerived extends Lt implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/LtEDerived.java b/src/org/python/antlr/op/LtEDerived.java
--- a/src/org/python/antlr/op/LtEDerived.java
+++ b/src/org/python/antlr/op/LtEDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LtEDerived extends LtE implements Slotted {
+public class LtEDerived extends LtE implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/ModDerived.java b/src/org/python/antlr/op/ModDerived.java
--- a/src/org/python/antlr/op/ModDerived.java
+++ b/src/org/python/antlr/op/ModDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ModDerived extends Mod implements Slotted {
+public class ModDerived extends Mod implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/MultDerived.java b/src/org/python/antlr/op/MultDerived.java
--- a/src/org/python/antlr/op/MultDerived.java
+++ b/src/org/python/antlr/op/MultDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class MultDerived extends Mult implements Slotted {
+public class MultDerived extends Mult implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/NotDerived.java b/src/org/python/antlr/op/NotDerived.java
--- a/src/org/python/antlr/op/NotDerived.java
+++ b/src/org/python/antlr/op/NotDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NotDerived extends Not implements Slotted {
+public class NotDerived extends Not implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/NotEqDerived.java b/src/org/python/antlr/op/NotEqDerived.java
--- a/src/org/python/antlr/op/NotEqDerived.java
+++ b/src/org/python/antlr/op/NotEqDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NotEqDerived extends NotEq implements Slotted {
+public class NotEqDerived extends NotEq implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/NotInDerived.java b/src/org/python/antlr/op/NotInDerived.java
--- a/src/org/python/antlr/op/NotInDerived.java
+++ b/src/org/python/antlr/op/NotInDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NotInDerived extends NotIn implements Slotted {
+public class NotInDerived extends NotIn implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/OrDerived.java b/src/org/python/antlr/op/OrDerived.java
--- a/src/org/python/antlr/op/OrDerived.java
+++ b/src/org/python/antlr/op/OrDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class OrDerived extends Or implements Slotted {
+public class OrDerived extends Or implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/ParamDerived.java b/src/org/python/antlr/op/ParamDerived.java
--- a/src/org/python/antlr/op/ParamDerived.java
+++ b/src/org/python/antlr/op/ParamDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ParamDerived extends Param implements Slotted {
+public class ParamDerived extends Param implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/PowDerived.java b/src/org/python/antlr/op/PowDerived.java
--- a/src/org/python/antlr/op/PowDerived.java
+++ b/src/org/python/antlr/op/PowDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PowDerived extends Pow implements Slotted {
+public class PowDerived extends Pow implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/RShiftDerived.java b/src/org/python/antlr/op/RShiftDerived.java
--- a/src/org/python/antlr/op/RShiftDerived.java
+++ b/src/org/python/antlr/op/RShiftDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class RShiftDerived extends RShift implements Slotted {
+public class RShiftDerived extends RShift implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/StoreDerived.java b/src/org/python/antlr/op/StoreDerived.java
--- a/src/org/python/antlr/op/StoreDerived.java
+++ b/src/org/python/antlr/op/StoreDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class StoreDerived extends Store implements Slotted {
+public class StoreDerived extends Store implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/SubDerived.java b/src/org/python/antlr/op/SubDerived.java
--- a/src/org/python/antlr/op/SubDerived.java
+++ b/src/org/python/antlr/op/SubDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class SubDerived extends Sub implements Slotted {
+public class SubDerived extends Sub implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/UAddDerived.java b/src/org/python/antlr/op/UAddDerived.java
--- a/src/org/python/antlr/op/UAddDerived.java
+++ b/src/org/python/antlr/op/UAddDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class UAddDerived extends UAdd implements Slotted {
+public class UAddDerived extends UAdd implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/USubDerived.java b/src/org/python/antlr/op/USubDerived.java
--- a/src/org/python/antlr/op/USubDerived.java
+++ b/src/org/python/antlr/op/USubDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class USubDerived extends USub implements Slotted {
+public class USubDerived extends USub implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/ClasspathPyImporterDerived.java b/src/org/python/core/ClasspathPyImporterDerived.java
--- a/src/org/python/core/ClasspathPyImporterDerived.java
+++ b/src/org/python/core/ClasspathPyImporterDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ClasspathPyImporterDerived extends ClasspathPyImporter implements Slotted {
+public class ClasspathPyImporterDerived extends ClasspathPyImporter implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,9 +19,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public ClasspathPyImporterDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -978,6 +997,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyArrayDerived.java b/src/org/python/core/PyArrayDerived.java
--- a/src/org/python/core/PyArrayDerived.java
+++ b/src/org/python/core/PyArrayDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyArrayDerived extends PyArray implements Slotted {
+public class PyArrayDerived extends PyArray implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyBaseExceptionDerived.java b/src/org/python/core/PyBaseExceptionDerived.java
--- a/src/org/python/core/PyBaseExceptionDerived.java
+++ b/src/org/python/core/PyBaseExceptionDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyBaseExceptionDerived extends PyBaseException implements Slotted {
+public class PyBaseExceptionDerived extends PyBaseException implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,9 +19,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyBaseExceptionDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -978,6 +997,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyByteArrayDerived.java b/src/org/python/core/PyByteArrayDerived.java
--- a/src/org/python/core/PyByteArrayDerived.java
+++ b/src/org/python/core/PyByteArrayDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyByteArrayDerived extends PyByteArray implements Slotted {
+public class PyByteArrayDerived extends PyByteArray implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyClass.java b/src/org/python/core/PyClass.java
--- a/src/org/python/core/PyClass.java
+++ b/src/org/python/core/PyClass.java
@@ -3,6 +3,7 @@
import org.python.expose.ExposedNew;
import org.python.expose.ExposedType;
+import org.python.core.finalization.FinalizeTrigger;
/**
* The classic Python class.
@@ -185,12 +186,16 @@
@Override
public PyObject __call__(PyObject[] args, String[] keywords) {
PyInstance inst;
- if (__del__ == null) {
- inst = new PyInstance(this);
- } else {
- // the class defined a __del__ method
- inst = new PyFinalizableInstance(this);
+ inst = new PyInstance(this);
+ if (__del__ != null) {
+ inst.finalizeTrigger = FinalizeTrigger.makeTrigger(inst);
}
+// if (__del__ == null) {
+// inst = new PyInstance(this);
+// } else {
+// // the class defined a __del__ method
+// inst = new PyFinalizableInstance(this);
+// }
inst.__init__(args, keywords);
return inst;
}
diff --git a/src/org/python/core/PyClassMethodDerived.java b/src/org/python/core/PyClassMethodDerived.java
--- a/src/org/python/core/PyClassMethodDerived.java
+++ b/src/org/python/core/PyClassMethodDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyClassMethodDerived extends PyClassMethod implements Slotted {
+public class PyClassMethodDerived extends PyClassMethod implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyComplexDerived.java b/src/org/python/core/PyComplexDerived.java
--- a/src/org/python/core/PyComplexDerived.java
+++ b/src/org/python/core/PyComplexDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyComplexDerived extends PyComplex implements Slotted {
+public class PyComplexDerived extends PyComplex implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,real,imaginary);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyDictionaryDerived.java b/src/org/python/core/PyDictionaryDerived.java
--- a/src/org/python/core/PyDictionaryDerived.java
+++ b/src/org/python/core/PyDictionaryDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyDictionaryDerived extends PyDictionary implements Slotted {
+public class PyDictionaryDerived extends PyDictionary implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyEnumerateDerived.java b/src/org/python/core/PyEnumerateDerived.java
--- a/src/org/python/core/PyEnumerateDerived.java
+++ b/src/org/python/core/PyEnumerateDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyEnumerateDerived extends PyEnumerate implements Slotted {
+public class PyEnumerateDerived extends PyEnumerate implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,seq,start);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyFile.java b/src/org/python/core/PyFile.java
--- a/src/org/python/core/PyFile.java
+++ b/src/org/python/core/PyFile.java
@@ -8,6 +8,8 @@
import java.io.OutputStream;
import java.util.concurrent.Callable;
+import org.python.core.finalization.FinalizableBuiltin;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.core.io.BinaryIOWrapper;
import org.python.core.io.BufferedIOBase;
import org.python.core.io.BufferedRandom;
@@ -33,7 +35,7 @@
* The Python file type. Wraps an {@link TextIOBase} object.
*/
@ExposedType(name = "file", doc = BuiltinDocs.file_doc)
-public class PyFile extends PyObject {
+public class PyFile extends PyObject implements FinalizableBuiltin {
public static final PyType TYPE = PyType.fromClass(PyFile.class);
@@ -80,21 +82,26 @@
/** The file's closer object; ensures the file is closed at
* shutdown */
private Closer closer;
+
+ public FinalizeTrigger finalizeTrigger;
- public PyFile() {}
+ public PyFile() {finalizeTrigger = FinalizeTrigger.makeTrigger(this);}
public PyFile(PyType subType) {
super(subType);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
public PyFile(RawIOBase raw, String name, String mode, int bufsize) {
parseMode(mode);
file___init__(raw, name, mode, bufsize);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
public PyFile(InputStream istream, String name, String mode, int bufsize, boolean closefd) {
parseMode(mode);
file___init__(new StreamIO(istream, closefd), name, mode, bufsize);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
/**
@@ -126,6 +133,7 @@
public PyFile(OutputStream ostream, String name, String mode, int bufsize, boolean closefd) {
parseMode(mode);
file___init__(new StreamIO(ostream, closefd), name, mode, bufsize);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
/**
@@ -153,6 +161,7 @@
public PyFile(String name, String mode, int bufsize) {
file___init__(new FileIO(name, parseMode(mode)), name, mode, bufsize);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
@ExposedNew
@@ -674,8 +683,7 @@
}
@Override
- protected void finalize() throws Throwable {
- super.finalize();
+ public void __del__Builtin() {
if (closer != null) {
closer.close();
}
diff --git a/src/org/python/core/PyFileDerived.java b/src/org/python/core/PyFileDerived.java
--- a/src/org/python/core/PyFileDerived.java
+++ b/src/org/python/core/PyFileDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyFileDerived extends PyFile implements Slotted {
+public class PyFileDerived extends PyFile implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyFinalizableInstance.java b/src/org/python/core/PyFinalizableInstance.java
deleted file mode 100644
--- a/src/org/python/core/PyFinalizableInstance.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) Corporation for National Research Initiatives
-// These are just like normal instances, except that their classes included
-// a definition for __del__(), i.e. Python's finalizer. These two instance
-// types have to be separated due to Java performance issues.
-
-package org.python.core;
-
-
-/**
- * A python class instance with __del__ defined.
- *
- * This is a special class due to performance. Defining
- * finalize() on a class, makes the class a lot slower.
- */
-public class PyFinalizableInstance extends PyInstance {
-
- public PyFinalizableInstance(PyClass iclass) {
- super(iclass);
- }
-
- // __del__ method is invoked upon object finalization.
- @Override
- protected void finalize() {
- try {
- instclass.__del__.__call__(this);
- } catch (PyException exc) {
- // Try to get the right method description.
- PyObject method = instclass.__del__;
- try {
- method = __findattr__("__del__");
- } catch (PyException e) {
- // nothing we can do
- }
- Py.writeUnraisable(exc, method);
- }
- }
-}
diff --git a/src/org/python/core/PyFloatDerived.java b/src/org/python/core/PyFloatDerived.java
--- a/src/org/python/core/PyFloatDerived.java
+++ b/src/org/python/core/PyFloatDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyFloatDerived extends PyFloat implements Slotted {
+public class PyFloatDerived extends PyFloat implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,v);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyFrozenSetDerived.java b/src/org/python/core/PyFrozenSetDerived.java
--- a/src/org/python/core/PyFrozenSetDerived.java
+++ b/src/org/python/core/PyFrozenSetDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyFrozenSetDerived extends PyFrozenSet implements Slotted {
+public class PyFrozenSetDerived extends PyFrozenSet implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,data);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyGenerator.java b/src/org/python/core/PyGenerator.java
--- a/src/org/python/core/PyGenerator.java
+++ b/src/org/python/core/PyGenerator.java
@@ -1,12 +1,14 @@
/* Copyright (c) Jython Developers */
package org.python.core;
+import org.python.core.finalization.FinalizableBuiltin;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.expose.ExposedGet;
import org.python.expose.ExposedMethod;
import org.python.expose.ExposedType;
@ExposedType(name = "generator", base = PyObject.class, isBaseType = false)
-public class PyGenerator extends PyIterator {
+public class PyGenerator extends PyIterator implements FinalizableBuiltin {
public static final PyType TYPE = PyType.fromClass(PyGenerator.class);
@@ -20,6 +22,8 @@
protected boolean gi_running;
private PyObject closure;
+
+ public FinalizeTrigger finalizeTrigger;
public PyGenerator(PyFrame frame, PyObject closure) {
super(TYPE);
@@ -28,6 +32,7 @@
gi_code = gi_frame.f_code;
}
this.closure = closure;
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
public PyObject send(PyObject value) {
@@ -105,9 +110,9 @@
gi_frame.setGeneratorInput(ex);
return next();
}
-
+
@Override
- protected void finalize() throws Throwable {
+ public void __del__Builtin() {
if (gi_frame == null || gi_frame.f_lasti == -1) {
return;
}
@@ -127,8 +132,6 @@
} catch (Throwable t) {
// but we currently ignore any Java exception completely. perhaps we
// can also output something meaningful too?
- } finally {
- super.finalize();
}
}
diff --git a/src/org/python/core/PyInstance.java b/src/org/python/core/PyInstance.java
--- a/src/org/python/core/PyInstance.java
+++ b/src/org/python/core/PyInstance.java
@@ -6,14 +6,19 @@
import org.python.expose.ExposedType;
import org.python.expose.MethodType;
+import org.python.core.finalization.FinalizablePyObject;
+import org.python.core.finalization.FinalizeTrigger;
+
/**
* An instance of a classic Python class.
*/
@ExposedType(name = "instance", isBaseType = false)
-public class PyInstance extends PyObject {
+public class PyInstance extends PyObject implements FinalizablePyObject {
public static final PyType TYPE = PyType.fromClass(PyInstance.class);
+ public FinalizeTrigger finalizeTrigger;
+
// xxx doc, final name
public transient PyClass instclass;
@@ -24,6 +29,9 @@
public PyInstance() {
super(TYPE);
+// if (TYPE.needsFinalizer()) {
+// finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+// }
}
public PyInstance(PyClass iclass, PyObject dict) {
@@ -33,10 +41,16 @@
dict = new PyStringMap();
}
__dict__ = dict;
+// if (TYPE.needsFinalizer()) {
+// finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+// }
}
public PyInstance(PyClass iclass) {
this(iclass, null);
+// if (TYPE.needsFinalizer()) {
+// finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+// }
}
@ExposedNew
@@ -263,6 +277,9 @@
if (name == "__class__") {
if (value instanceof PyClass) {
instclass = (PyClass) value;
+ if (instclass.__del__ != null && finalizeTrigger == null) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__class__ must be set to a class");
}
@@ -278,6 +295,9 @@
} else {
__dict__.__setitem__(name, value);
}
+ if (name == "__del__" && finalizeTrigger == null) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
}
protected void noField(String name, PyObject value) {
@@ -1909,4 +1929,35 @@
return super.__ixor__(o);
}
+ /*
+ public void ensureFinalizer()
+ {
+ instance_ensureFinalizer();
+ }
+
+ public void instance_ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+ */
+
+ @Override
+ public void __del__() {
+ try {
+ PyObject method = __findattr__("__del__");
+ if (method != null) {
+ method.__call__();
+ } else if (instclass.__del__ != null) {
+ instclass.__del__.__call__(this);
+ }
+ } catch (PyException exc) {
+ // Try to get the right method description.
+ PyObject method = instclass.__del__;
+ try {
+ method = __findattr__("__del__");
+ } catch (PyException e) {
+ // nothing we can do
+ }
+ Py.writeUnraisable(exc, method);
+ }
+ }
}
diff --git a/src/org/python/core/PyIntegerDerived.java b/src/org/python/core/PyIntegerDerived.java
--- a/src/org/python/core/PyIntegerDerived.java
+++ b/src/org/python/core/PyIntegerDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyIntegerDerived extends PyInteger implements Slotted {
+public class PyIntegerDerived extends PyInteger implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,v);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyListDerived.java b/src/org/python/core/PyListDerived.java
--- a/src/org/python/core/PyListDerived.java
+++ b/src/org/python/core/PyListDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyListDerived extends PyList implements Slotted {
+public class PyListDerived extends PyList implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyLongDerived.java b/src/org/python/core/PyLongDerived.java
--- a/src/org/python/core/PyLongDerived.java
+++ b/src/org/python/core/PyLongDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyLongDerived extends PyLong implements Slotted {
+public class PyLongDerived extends PyLong implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,v);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyModuleDerived.java b/src/org/python/core/PyModuleDerived.java
--- a/src/org/python/core/PyModuleDerived.java
+++ b/src/org/python/core/PyModuleDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyModuleDerived extends PyModule implements Slotted {
+public class PyModuleDerived extends PyModule implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,9 +19,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyModuleDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -978,6 +997,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyObject.java b/src/org/python/core/PyObject.java
--- a/src/org/python/core/PyObject.java
+++ b/src/org/python/core/PyObject.java
@@ -99,6 +99,21 @@
return new_.for_type == subtype ? new PyObject() : new PyObjectDerived(subtype);
}
+ /**
+ *
+ * From Jython 2.7 on, {@code PyObject}s must not have finalizers directly.
+ * If a finalizer, a.k.a. {@code __del__} is needed, follow the instructions in the
+ * documentation of {@link org.python.core.finalization.FinalizablePyObject}.
+ *
+ *
+ * Note that this empty finalizer implementation is optimized away by the JVM
+ * (See {@link http://www.javaspecialists.eu/archive/Issue170.html}).
+ * So {@code PyObject}s are not expensively treaded as finalizable objects by the
+ * GC. Its only intention is to prevent subclasses from having Java-style finalizers.
+ *
+ */
+ protected final void finalize() throws Throwable {}
+
@ExposedMethod(doc = BuiltinDocs.object___init___doc)
final void object___init__(PyObject[] args, String[] keywords) {
}
diff --git a/src/org/python/core/PyObjectDerived.java b/src/org/python/core/PyObjectDerived.java
--- a/src/org/python/core/PyObjectDerived.java
+++ b/src/org/python/core/PyObjectDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyObjectDerived extends PyObject implements Slotted {
+public class PyObjectDerived extends PyObject implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyPropertyDerived.java b/src/org/python/core/PyPropertyDerived.java
--- a/src/org/python/core/PyPropertyDerived.java
+++ b/src/org/python/core/PyPropertyDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyPropertyDerived extends PyProperty implements Slotted {
+public class PyPropertyDerived extends PyProperty implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PySetDerived.java b/src/org/python/core/PySetDerived.java
--- a/src/org/python/core/PySetDerived.java
+++ b/src/org/python/core/PySetDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PySetDerived extends PySet implements Slotted {
+public class PySetDerived extends PySet implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyStringDerived.java b/src/org/python/core/PyStringDerived.java
--- a/src/org/python/core/PyStringDerived.java
+++ b/src/org/python/core/PyStringDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyStringDerived extends PyString implements Slotted {
+public class PyStringDerived extends PyString implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,v);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PySuperDerived.java b/src/org/python/core/PySuperDerived.java
--- a/src/org/python/core/PySuperDerived.java
+++ b/src/org/python/core/PySuperDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PySuperDerived extends PySuper implements Slotted {
+public class PySuperDerived extends PySuper implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyTupleDerived.java b/src/org/python/core/PyTupleDerived.java
--- a/src/org/python/core/PyTupleDerived.java
+++ b/src/org/python/core/PyTupleDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyTupleDerived extends PyTuple implements Slotted {
+public class PyTupleDerived extends PyTuple implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,elements);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyType.java b/src/org/python/core/PyType.java
--- a/src/org/python/core/PyType.java
+++ b/src/org/python/core/PyType.java
@@ -82,7 +82,7 @@
protected boolean needs_weakref;
/** Whether finalization is required for this type's instances (implements __del__). */
- private boolean needs_finalizer;
+ protected boolean needs_finalizer;
/** Whether this type's __getattribute__ is object.__getattribute__. */
private volatile boolean usesObjectGetattribute;
@@ -310,7 +310,7 @@
if (wantWeak) {
createWeakrefSlot();
}
- needs_finalizer = lookup_mro("__del__") != null;
+ needs_finalizer = needsFinalizer();
}
/**
@@ -568,6 +568,24 @@
}
/**
+ * Offers public read-only access to the protected field needs_finalizer.
+ *
+ * @return a boolean indicating whether the type implements __del__
+ */
+ public final boolean needsFinalizer() {
+ //It might be sluggish to assume that if a finalizer was needed
+ //once, this would never change. However since an expensive
+ //FinalizeTrigger was created anyway, it won't hurt to keep it.
+ //Whether there actually is a __del__ in the dict will be checked
+ //again when the finalizer runs.
+ if (needs_finalizer) return true;
+ else {
+ needs_finalizer = lookup_mro("__del__") != null;
+ return needs_finalizer;
+ }
+ }
+
+ /**
* Ensures that the physical layout between this type and other are compatible.
* Raises a TypeError if not.
*/
diff --git a/src/org/python/core/PyTypeDerived.java b/src/org/python/core/PyTypeDerived.java
--- a/src/org/python/core/PyTypeDerived.java
+++ b/src/org/python/core/PyTypeDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyTypeDerived extends PyType implements Slotted {
+public class PyTypeDerived extends PyType implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,9 +19,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyTypeDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -978,6 +997,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyUnicodeDerived.java b/src/org/python/core/PyUnicodeDerived.java
--- a/src/org/python/core/PyUnicodeDerived.java
+++ b/src/org/python/core/PyUnicodeDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyUnicodeDerived extends PyUnicode implements Slotted {
+public class PyUnicodeDerived extends PyUnicode implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,string);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/finalization/FinalizableBuiltin.java b/src/org/python/core/finalization/FinalizableBuiltin.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizableBuiltin.java
@@ -0,0 +1,18 @@
+package org.python.core.finalization;
+
+/**
+ * See documentation of {@link FinalizablePyObject}.
+ */
+
+public interface FinalizableBuiltin extends HasFinalizeTrigger {
+ /**
+ * {@code __del__Builtin} is the built-in's own finalizer, while
+ * {@code __del__Derived} refers to an instance's in-dict {@code __del__}.
+ * A FinalizeTrigger calls {@code __del__Derived} first and
+ * - if existent - {@code __del__Builtin} after that. A plain {@code __del__}
+ * would behave as overwritten by {@code __del__Derived}, i.e. won't be called
+ * if the type implements {@code FinalizablePyObjectDerived} while
+ * {@code __del__Builtin} is called in any case.
+ */
+ public void __del__Builtin();
+}
diff --git a/src/org/python/core/finalization/FinalizablePyObject.java b/src/org/python/core/finalization/FinalizablePyObject.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizablePyObject.java
@@ -0,0 +1,90 @@
+package org.python.core.finalization;
+
+/**
+ *
+ * This interface allows {@code PyObject}s to have finalizers.
+ * Alternatively one can use
+ * {@link org.python.core.finalization.FinalizableBuiltin}.
+ *
+ *
+ * The difference is that {@code __del__} can be overwritten by a
+ * new-style subclass's {@code __del__}-method on Python-side, while
+ * {@code __del__Builtin} is always called. If a Python-side
+ * finalizer exists, {@code __del__Builtin} will be called after the
+ * Python-side finalizer has been processed.
+ *
+ *
+ * One can even implement both interfaces.
+ * If both interfaces are implemented, the {@code FinalizeTrigger} will
+ * call {@code __del__} first and then {@code __del__Builtin}. If a
+ * new-style subclass has an own, Python-side {@code __del__}-method, this
+ * overwrites the Java-implemented {@code __del__}, but not
+ * {@code __del__Builtin}, which will be called after the Python-side
+ * finalizer.
+ *
+ *
+ * If you are writing a custom built-in that shall directly
+ * extend {@link org.python.core.PyObject} and have a finalizer, you can simply
+ * extend {@link org.python.core.finalization.PyFinalizableObject}
+ * and overwrite its {@code __del__}-method.
+ * Follow the instructions below, starting at 4).
+ *
+ *
+ * If you want to extend some subclass of PyObject that does not yet implement
+ * this interface, you have to take care of the following steps:
+ *
+ *
+ * Let your subclass implement {@code FinalizablePyObject}
+ * (or {@link org.python.core.finalization.FinalizableBuiltin}).
+ *
+ *
+ * Let it have a member
+ * {@code public FinalizeTrigger finalizeTrigger;}
+ * Other scopes also work, but might fail with security managers.
+ *
+ *
+ * In every constructor initialize this member via
+ * {@code finalizeTrigger = FinalizeTrigger.makeTrigger(this);}
+ * or
+ * {@code FinalizeTrigger.ensureFinalizer(this);}
+ * The latter is a better abstraction, but slightly less performant,
+ * since it uses reflection.
+ *
+ *
+ * Write your {@code __del__}-method however you intend it.
+ * (or {@code __del__Builtin} if
+ * {@link org.python.core.finalization.FinalizableBuiltin} was used)
+ *
+ *
+ * (optional)
+ * If your finalizer resurrects the object (Python allows this) and you wish the
+ * finalizer to run again on next collection of the object:
+ * In the block where the resurrection occurs, let your {@code __del__}- or
+ * {@code __del__Builtin}-method call
+ * {@code FinalizeTrigger.ensureFinalizer(this);}.
+ *
+ *
+ *
+ *
+ * Note: Regarding to object resurrection, Jython currently behaves like CPython >= 3.4.
+ * That means the finalizer {@code __del__} or {@code __del__Builtin} is called only the
+ * first time an object gets gc'ed. If pre 3.4. behavior is required for some reason (i.e.
+ * have the finalizer called repeatedly on every collection after a resurrection), one can
+ * achieve this manually via step 5).
+ *
+ *
+ * It is possible to switch finalization on and off at any desired time for a certain object.
+ * This can be helpful if it is only necessary to have {@code __del__} or
+ * {@code __del__Builtin} called for certain configurations of an object.
+ *
+ *
+ * To turn off the finalizer, call
+ * {@code finalizeTrigger.clear();}
+ * To turn it on again, call
+ * {@code finalizeTrigger.trigger(this);}
+ *
+ */
+
+public interface FinalizablePyObject extends HasFinalizeTrigger {
+ public void __del__();
+}
diff --git a/src/org/python/core/finalization/FinalizablePyObjectDerived.java b/src/org/python/core/finalization/FinalizablePyObjectDerived.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizablePyObjectDerived.java
@@ -0,0 +1,23 @@
+package org.python.core.finalization;
+
+/**
+ * This interface should never be used directly in any hand-written code.
+ * It should only appear in automatically generated {@code fooDerived}-classes.
+ *
+ * To use finalizers in hand-written classes read the instructions at
+ * {@link org.python.core.finalization.FinalizablePyObject}.
+ *
+ */
+public interface FinalizablePyObjectDerived extends HasFinalizeTrigger {
+
+ /**
+ * {@code __del__Builtin} is the built-in's own finalizer, while
+ * {@code __del__Derived} refers to an instance's in-dict {@code __del__}.
+ * A FinalizeTrigger calls {@code __del__Derived} first and
+ * - if existent - {@code __del__Builtin} after that. A plain {@code __del__}
+ * would behave as overwritten by {@code __del__Derived}, i.e. won't be called
+ * if the type implements {@code FinalizablePyObjectDerived} while
+ * {@code __del__Builtin} is called in any case.
+ */
+ public void __del__Derived();
+}
diff --git a/src/org/python/core/finalization/FinalizeTrigger.java b/src/org/python/core/finalization/FinalizeTrigger.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizeTrigger.java
@@ -0,0 +1,138 @@
+package org.python.core.finalization;
+
+import java.lang.reflect.Field;
+import java.lang.ref.WeakReference;
+import java.lang.ref.SoftReference;
+import java.lang.ref.Reference;
+import org.python.core.PyObject;
+
+/**
+ * To use finalizers on {@code PyObject}s, read the documentation of
+ * {@link org.python.core.finalization.FinalizablePyObject}.
+ */
+public class FinalizeTrigger {
+
+ /**
+ * This optional factory hook allows to replace the
+ * default {@code FinalizeTrigger}. It is f.i. needed by JyNI.
+ */
+ public static FinalizeTriggerFactory factory;
+
+ public static FinalizeTrigger makeTrigger(HasFinalizeTrigger toFinalize) {
+ if (factory != null) {
+ return factory.makeTrigger(toFinalize);
+ } else {
+ return new FinalizeTrigger(toFinalize);
+ }
+ }
+
+ /*
+ public static FinalizeTrigger makeTriggerDerived(FinalizablePyObjectDerived toFinalize) {
+ if (factory != null) {
+ return factory.makeTriggerDerived(toFinalize);
+ } else {
+ return new FinalizeTriggerDerived(toFinalize);
+ }
+ }
+ */
+
+ /**
+ * Recreates the {@code FinalizeTrigger} of the given object. This makes sure that
+ * once the resurrected object is gc'ed again, its {@code __del__}-method will be
+ * called again.
+ */
+ public static void ensureFinalizer(HasFinalizeTrigger resurrect) {
+ FinalizeTrigger trigger = makeTrigger(resurrect);
+ setFinalizeTrigger(resurrect, trigger);
+ }
+
+ /*
+ public static void ensureFinalizerDerived(FinalizablePyObjectDerived resurrect) {
+ setFinalizeTrigger(resurrect, makeTriggerDerived(resurrect));
+ }
+ */
+
+ public static void setFinalizeTrigger(HasFinalizeTrigger toFinalize, FinalizeTrigger trigger) {
+ Field triggerField;
+ try {
+ triggerField = toFinalize.getClass().getDeclaredField("finalizeTrigger");
+ } catch (NoSuchFieldException nfe) {
+ throw new IllegalArgumentException(toFinalize.getClass()+" must have a field finalizeTrigger.");
+ }
+ try {
+ triggerField.set(toFinalize, trigger);
+ } catch (IllegalAccessException iae) {
+ try {
+ triggerField.setAccessible(true);
+ triggerField.set(toFinalize, trigger);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("finalizeTrigger in "+toFinalize.getClass()+" must be accessible.");
+ }
+ }
+ }
+
+ public static FinalizeTrigger getFinalizeTrigger(HasFinalizeTrigger toFinalize) {
+ Field triggerField;
+ try {
+ triggerField = toFinalize.getClass().getDeclaredField("finalizeTrigger");
+ } catch (NoSuchFieldException nfe) {
+ throw new IllegalArgumentException(toFinalize.getClass()+" must have a field finalizeTrigger.");
+ }
+ try {
+ return (FinalizeTrigger) triggerField.get(toFinalize);
+ } catch (IllegalAccessException iae) {
+ try {
+ triggerField.setAccessible(true);
+ return (FinalizeTrigger) triggerField.get(toFinalize);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("finalizeTrigger in "+toFinalize.getClass()+" must be accessible.");
+ }
+ }
+ }
+
+
+ protected HasFinalizeTrigger toFinalize;
+ public void clear() {
+ toFinalize = null;
+ }
+
+ public void trigger(HasFinalizeTrigger toFinalize)
+ {
+ this.toFinalize = toFinalize;
+ }
+
+ protected FinalizeTrigger(HasFinalizeTrigger toFinalize) {
+ this.toFinalize = toFinalize;
+ }
+
+ protected void finalize() throws Throwable {
+ if (toFinalize != null) {
+ if (toFinalize instanceof FinalizablePyObjectDerived) {
+ ((FinalizablePyObjectDerived) toFinalize).__del__Derived();
+ } else if (toFinalize instanceof FinalizablePyObject) {
+ ((FinalizablePyObject) toFinalize).__del__();
+ }
+ if (toFinalize instanceof FinalizableBuiltin) {
+ ((FinalizableBuiltin) toFinalize).__del__Builtin();
+ }
+ }
+ }
+
+
+ /*
+ * A FinalizeTrigger variant that only calls __del__Derived, but not the
+ * built-in's finalizer __del__. It can be used to control finalization
+ * behavior of resurrected objects in more detail.
+ */
+ /*protected static class FinalizeTriggerDerived extends FinalizeTrigger {
+ protected FinalizeTriggerDerived(FinalizablePyObjectDerived toFinalize) {
+ super(toFinalize);
+ }
+
+ protected void finalize() throws Throwable {
+ if (toFinalize != null) {
+ ((FinalizablePyObjectDerived) toFinalize).__del__Derived();
+ }
+ }
+ }*/
+}
diff --git a/src/org/python/core/finalization/FinalizeTriggerFactory.java b/src/org/python/core/finalization/FinalizeTriggerFactory.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizeTriggerFactory.java
@@ -0,0 +1,6 @@
+package org.python.core.finalization;
+
+public interface FinalizeTriggerFactory {
+
+ public FinalizeTrigger makeTrigger(HasFinalizeTrigger toFinalize);
+}
diff --git a/src/org/python/core/finalization/HasFinalizeTrigger.java b/src/org/python/core/finalization/HasFinalizeTrigger.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/HasFinalizeTrigger.java
@@ -0,0 +1,13 @@
+package org.python.core.finalization;
+
+/**
+ * This is a pure marker-interface to indicate that a
+ * {@link org.python.core.PyObject} has a field declaration
+ * {@code FinalizeTrigger finalizeTrigger;}
+ * and thus can be treated by Jython's finalization API.
+ *
+ * For detailed instructions how to use finalizers in Jython, see
+ * {@link org.python.core.finalization.FinalizablePyObject}.
+ */
+public interface HasFinalizeTrigger {
+}
diff --git a/src/org/python/core/finalization/PyFinalizableObject.java b/src/org/python/core/finalization/PyFinalizableObject.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/PyFinalizableObject.java
@@ -0,0 +1,17 @@
+package org.python.core.finalization;
+
+import org.python.core.PyObject;;
+
+/**
+ * For detailed intructions how to use finalizers on PyObjects,
+ * read the documentation of {@link org.python.core.finalization.FinalizablePyObject}.
+ */
+public abstract class PyFinalizableObject extends PyObject implements FinalizablePyObject {
+
+ public FinalizeTrigger finalizeTrigger;
+
+ public PyFinalizableObject() {
+ super();
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
+}
diff --git a/src/org/python/modules/PyStructDerived.java b/src/org/python/modules/PyStructDerived.java
--- a/src/org/python/modules/PyStructDerived.java
+++ b/src/org/python/modules/PyStructDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyStructDerived extends PyStruct implements Slotted {
+public class PyStructDerived extends PyStruct implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype,format);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_collections/PyDefaultDictDerived.java b/src/org/python/modules/_collections/PyDefaultDictDerived.java
--- a/src/org/python/modules/_collections/PyDefaultDictDerived.java
+++ b/src/org/python/modules/_collections/PyDefaultDictDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyDefaultDictDerived extends PyDefaultDict implements Slotted {
+public class PyDefaultDictDerived extends PyDefaultDict implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_collections/PyDequeDerived.java b/src/org/python/modules/_collections/PyDequeDerived.java
--- a/src/org/python/modules/_collections/PyDequeDerived.java
+++ b/src/org/python/modules/_collections/PyDequeDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyDequeDerived extends PyDeque implements Slotted {
+public class PyDequeDerived extends PyDeque implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_csv/PyDialectDerived.java b/src/org/python/modules/_csv/PyDialectDerived.java
--- a/src/org/python/modules/_csv/PyDialectDerived.java
+++ b/src/org/python/modules/_csv/PyDialectDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyDialectDerived extends PyDialect implements Slotted {
+public class PyDialectDerived extends PyDialect implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyDialectDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_functools/PyPartialDerived.java b/src/org/python/modules/_functools/PyPartialDerived.java
--- a/src/org/python/modules/_functools/PyPartialDerived.java
+++ b/src/org/python/modules/_functools/PyPartialDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyPartialDerived extends PyPartial implements Slotted {
+public class PyPartialDerived extends PyPartial implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_io/PyFileIODerived.java b/src/org/python/modules/_io/PyFileIODerived.java
--- a/src/org/python/modules/_io/PyFileIODerived.java
+++ b/src/org/python/modules/_io/PyFileIODerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyFileIODerived extends PyFileIO implements Slotted {
+public class PyFileIODerived extends PyFileIO implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyFileIODerived(PyType subtype,PyObject file,OpenMode mode,boolean closefd) {
super(subtype,file,mode,closefd);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_io/PyIOBase.java b/src/org/python/modules/_io/PyIOBase.java
--- a/src/org/python/modules/_io/PyIOBase.java
+++ b/src/org/python/modules/_io/PyIOBase.java
@@ -16,6 +16,8 @@
import org.python.core.PyType;
import org.python.core.PyUnicode;
import org.python.core.buffer.SimpleStringBuffer;
+import org.python.core.finalization.FinalizableBuiltin;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.core.io.FileIO;
import org.python.expose.ExposedGet;
import org.python.expose.ExposedMethod;
@@ -38,20 +40,24 @@
* in Python.
*/
@ExposedType(name = "_io._IOBase", doc = PyIOBase.doc)
-public class PyIOBase extends PyObject {
+public class PyIOBase extends PyObject implements FinalizableBuiltin {
public static final PyType TYPE = PyType.fromClass(PyIOBase.class);
/** The ioDelegate's closer object; ensures the stream is closed at shutdown */
private Closer closer;
+
+ public FinalizeTrigger finalizeTrigger;
protected PyIOBase() {
this(TYPE);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
protected PyIOBase(PyType subtype) {
super(subtype);
closer = new Closer(this, Py.getSystemState());
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
/**
@@ -726,10 +732,9 @@
}
@Override
- protected void finalize() throws Throwable {
+ public void __del__Builtin() {
closer.dismiss();
invoke("close");
- super.finalize();
}
/** Convenience method providing the exception in the _checkWhatever() methods. */
diff --git a/src/org/python/modules/_io/PyIOBaseDerived.java b/src/org/python/modules/_io/PyIOBaseDerived.java
--- a/src/org/python/modules/_io/PyIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyIOBaseDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyIOBaseDerived extends PyIOBase implements Slotted {
+public class PyIOBaseDerived extends PyIOBase implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyIOBaseDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_io/PyRawIOBaseDerived.java b/src/org/python/modules/_io/PyRawIOBaseDerived.java
--- a/src/org/python/modules/_io/PyRawIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyRawIOBaseDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyRawIOBaseDerived extends PyRawIOBase implements Slotted {
+public class PyRawIOBaseDerived extends PyRawIOBase implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyRawIOBaseDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_weakref/ReferenceTypeDerived.java b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
--- a/src/org/python/modules/_weakref/ReferenceTypeDerived.java
+++ b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ReferenceTypeDerived extends ReferenceType implements Slotted {
+public class ReferenceTypeDerived extends ReferenceType implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype,gref,callback);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyBZ2CompressorDerived extends PyBZ2Compressor implements Slotted {
+public class PyBZ2CompressorDerived extends PyBZ2Compressor implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyBZ2DecompressorDerived extends PyBZ2Decompressor implements Slotted {
+public class PyBZ2DecompressorDerived extends PyBZ2Decompressor implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/bz2/PyBZ2File.java b/src/org/python/modules/bz2/PyBZ2File.java
--- a/src/org/python/modules/bz2/PyBZ2File.java
+++ b/src/org/python/modules/bz2/PyBZ2File.java
@@ -24,6 +24,9 @@
import org.python.core.PySequence;
import org.python.core.PyString;
import org.python.core.PyType;
+import org.python.core.finalization.FinalizablePyObject;
+import org.python.core.finalization.FinalizableBuiltin;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.core.io.BinaryIOWrapper;
import org.python.core.io.BufferedReader;
import org.python.core.io.BufferedWriter;
@@ -37,7 +40,7 @@
import org.python.expose.ExposedType;
@ExposedType(name = "bz2.BZ2File")
-public class PyBZ2File extends PyObject {
+public class PyBZ2File extends PyObject implements FinalizablePyObject, FinalizableBuiltin {
public static final PyType TYPE = PyType.fromClass(PyBZ2File.class);
private int buffering;
@@ -58,20 +61,23 @@
private boolean needReadBufferInit = false;
private boolean inReadMode = false;
private boolean inWriteMode = false;
+
+ public FinalizeTrigger finalizeTrigger;
public PyBZ2File() {
super(TYPE);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
public PyBZ2File(PyType subType) {
super(subType);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
@Override
- protected void finalize() throws Throwable {
+ public void __del__Builtin() {
BZ2File_close();
- super.finalize();
}
@ExposedNew
@@ -151,6 +157,7 @@
}
}
+ @Override
@ExposedMethod
public void __del__() {
BZ2File_close();
diff --git a/src/org/python/modules/bz2/PyBZ2FileDerived.java b/src/org/python/modules/bz2/PyBZ2FileDerived.java
--- a/src/org/python/modules/bz2/PyBZ2FileDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2FileDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyBZ2FileDerived extends PyBZ2File implements Slotted {
+public class PyBZ2FileDerived extends PyBZ2File implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/PyTeeIteratorDerived.java b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
--- a/src/org/python/modules/itertools/PyTeeIteratorDerived.java
+++ b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyTeeIteratorDerived extends PyTeeIterator implements Slotted {
+public class PyTeeIteratorDerived extends PyTeeIterator implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/chainDerived.java b/src/org/python/modules/itertools/chainDerived.java
--- a/src/org/python/modules/itertools/chainDerived.java
+++ b/src/org/python/modules/itertools/chainDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class chainDerived extends chain implements Slotted {
+public class chainDerived extends chain implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/combinationsDerived.java b/src/org/python/modules/itertools/combinationsDerived.java
--- a/src/org/python/modules/itertools/combinationsDerived.java
+++ b/src/org/python/modules/itertools/combinationsDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class combinationsDerived extends combinations implements Slotted {
+public class combinationsDerived extends combinations implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
--- a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
+++ b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class combinationsWithReplacementDerived extends combinationsWithReplacement implements Slotted {
+public class combinationsWithReplacementDerived extends combinationsWithReplacement implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/compressDerived.java b/src/org/python/modules/itertools/compressDerived.java
--- a/src/org/python/modules/itertools/compressDerived.java
+++ b/src/org/python/modules/itertools/compressDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class compressDerived extends compress implements Slotted {
+public class compressDerived extends compress implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/countDerived.java b/src/org/python/modules/itertools/countDerived.java
--- a/src/org/python/modules/itertools/countDerived.java
+++ b/src/org/python/modules/itertools/countDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class countDerived extends count implements Slotted {
+public class countDerived extends count implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/cycleDerived.java b/src/org/python/modules/itertools/cycleDerived.java
--- a/src/org/python/modules/itertools/cycleDerived.java
+++ b/src/org/python/modules/itertools/cycleDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class cycleDerived extends cycle implements Slotted {
+public class cycleDerived extends cycle implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/dropwhileDerived.java b/src/org/python/modules/itertools/dropwhileDerived.java
--- a/src/org/python/modules/itertools/dropwhileDerived.java
+++ b/src/org/python/modules/itertools/dropwhileDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class dropwhileDerived extends dropwhile implements Slotted {
+public class dropwhileDerived extends dropwhile implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/groupbyDerived.java b/src/org/python/modules/itertools/groupbyDerived.java
--- a/src/org/python/modules/itertools/groupbyDerived.java
+++ b/src/org/python/modules/itertools/groupbyDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class groupbyDerived extends groupby implements Slotted {
+public class groupbyDerived extends groupby implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/ifilterDerived.java b/src/org/python/modules/itertools/ifilterDerived.java
--- a/src/org/python/modules/itertools/ifilterDerived.java
+++ b/src/org/python/modules/itertools/ifilterDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ifilterDerived extends ifilter implements Slotted {
+public class ifilterDerived extends ifilter implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/ifilterfalseDerived.java b/src/org/python/modules/itertools/ifilterfalseDerived.java
--- a/src/org/python/modules/itertools/ifilterfalseDerived.java
+++ b/src/org/python/modules/itertools/ifilterfalseDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ifilterfalseDerived extends ifilterfalse implements Slotted {
+public class ifilterfalseDerived extends ifilterfalse implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/isliceDerived.java b/src/org/python/modules/itertools/isliceDerived.java
--- a/src/org/python/modules/itertools/isliceDerived.java
+++ b/src/org/python/modules/itertools/isliceDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class isliceDerived extends islice implements Slotted {
+public class isliceDerived extends islice implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/izipDerived.java b/src/org/python/modules/itertools/izipDerived.java
--- a/src/org/python/modules/itertools/izipDerived.java
+++ b/src/org/python/modules/itertools/izipDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class izipDerived extends izip implements Slotted {
+public class izipDerived extends izip implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/izipLongestDerived.java b/src/org/python/modules/itertools/izipLongestDerived.java
--- a/src/org/python/modules/itertools/izipLongestDerived.java
+++ b/src/org/python/modules/itertools/izipLongestDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class izipLongestDerived extends izipLongest implements Slotted {
+public class izipLongestDerived extends izipLongest implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/permutationsDerived.java b/src/org/python/modules/itertools/permutationsDerived.java
--- a/src/org/python/modules/itertools/permutationsDerived.java
+++ b/src/org/python/modules/itertools/permutationsDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class permutationsDerived extends permutations implements Slotted {
+public class permutationsDerived extends permutations implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/productDerived.java b/src/org/python/modules/itertools/productDerived.java
--- a/src/org/python/modules/itertools/productDerived.java
+++ b/src/org/python/modules/itertools/productDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class productDerived extends product implements Slotted {
+public class productDerived extends product implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/repeatDerived.java b/src/org/python/modules/itertools/repeatDerived.java
--- a/src/org/python/modules/itertools/repeatDerived.java
+++ b/src/org/python/modules/itertools/repeatDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class repeatDerived extends repeat implements Slotted {
+public class repeatDerived extends repeat implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/starmapDerived.java b/src/org/python/modules/itertools/starmapDerived.java
--- a/src/org/python/modules/itertools/starmapDerived.java
+++ b/src/org/python/modules/itertools/starmapDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class starmapDerived extends starmap implements Slotted {
+public class starmapDerived extends starmap implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/takewhileDerived.java b/src/org/python/modules/itertools/takewhileDerived.java
--- a/src/org/python/modules/itertools/takewhileDerived.java
+++ b/src/org/python/modules/itertools/takewhileDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class takewhileDerived extends takewhile implements Slotted {
+public class takewhileDerived extends takewhile implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/random/PyRandomDerived.java b/src/org/python/modules/random/PyRandomDerived.java
--- a/src/org/python/modules/random/PyRandomDerived.java
+++ b/src/org/python/modules/random/PyRandomDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyRandomDerived extends PyRandom implements Slotted {
+public class PyRandomDerived extends PyRandom implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/thread/PyLocalDerived.java b/src/org/python/modules/thread/PyLocalDerived.java
--- a/src/org/python/modules/thread/PyLocalDerived.java
+++ b/src/org/python/modules/thread/PyLocalDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyLocalDerived extends PyLocal implements Slotted {
+public class PyLocalDerived extends PyLocal implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyLocalDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/zipimport/zipimporterDerived.java b/src/org/python/modules/zipimport/zipimporterDerived.java
--- a/src/org/python/modules/zipimport/zipimporterDerived.java
+++ b/src/org/python/modules/zipimport/zipimporterDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class zipimporterDerived extends zipimporter implements Slotted {
+public class zipimporterDerived extends zipimporter implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del__Derived() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/templates/gderived-defs b/src/templates/gderived-defs
--- a/src/templates/gderived-defs
+++ b/src/templates/gderived-defs
@@ -4,8 +4,11 @@
package org.python.core;
import java.io.Serializable;
+ import org.python.core.finalization.FinalizeTrigger;
+ import org.python.core.finalization.FinalizablePyObjectDerived;
- public class `concat`(`base,Derived) extends `base implements Slotted {
+ public class `concat`(`base,Derived) extends `base implements Slotted, FinalizablePyObjectDerived {
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +19,18 @@
}
private PyObject[] slots;
+
+ public void __del__Derived() {
+ PyType self_type = getType();
+ PyObject impl = self_type.lookup("__del__");
+ if (impl != null) {
+ impl.__get__(this, self_type).__call__();
+ }
+ }
+
+ public void ensureFinalizer() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
`decls;
}
@@ -81,6 +96,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap || newDict instanceof PyDictionary ) {
dict = newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__")) != null && finalizeTrigger == null) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
}
else {
throw Py.TypeError("__dict__ must be set to a Dictionary " + newDict.getClass().getName());
@@ -96,6 +114,9 @@
public `concat`(`base,Derived)(PyType subtype,`extraargs) {
super(subtype,`extra);
slots = new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
}
define: (ClassBodyDeclarations)ctr_userdict
@@ -103,6 +124,9 @@
super(subtype,`extra);
slots = new PyObject[subtype.getNumSlots()];
dict = subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
}
define: (ClassBodyDeclarations)toString
diff --git a/src/templates/gderived.py b/src/templates/gderived.py
--- a/src/templates/gderived.py
+++ b/src/templates/gderived.py
@@ -8,7 +8,7 @@
import directives
import java_parser
import java_templating
-from java_templating import JavaTemplate,jast_make,jast
+from java_templating import JavaTemplate, jast_make, jast
org_python_dir = os.path.join(os.path.dirname(os.path.abspath(scriptdir)),
'org', 'python')
@@ -19,22 +19,24 @@
package org.python.%s;
import java.io.Serializable;
-import org.python.core.*;"""
+import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;"""
modif_re = re.compile(r"(?:\((\w+)\))?(\w+)")
# os.path.samefile unavailable on Windows before Python v3.2
-if hasattr(os.path,"samefile"):
+if hasattr(os.path, "samefile"):
# Good: available on this platform
os_path_samefile = os.path.samefile
else:
- def os_path_samefile(a,b):
+ def os_path_samefile(a, b):
'Files are considered the same if their absolute paths are equal'
return os.path.abspath(a)==os.path.abspath(b)
class Gen:
- priority_order = ['require','define','base_class',
+ priority_order = ['require', 'define', 'base_class',
'want_dict',
'ctr',
'incl',
@@ -44,7 +46,7 @@
'no_toString'
]
- def __init__(self,bindings=None,priority_order=None):
+ def __init__(self, bindings=None, priority_order=None):
if bindings is None:
self.global_bindings = { 'csub': java_templating.csub,
'concat': java_templating.concat,
@@ -64,35 +66,35 @@
self.no_toString = False
self.ctr_done = 0
- def debug(self,bindings):
- for name,val in bindings.items():
- if isinstance(val,JavaTemplate):
+ def debug(self, bindings):
+ for name, val in bindings.items():
+ if isinstance(val, JavaTemplate):
print "%s:" % name
print val.texpand({})
- def invalid(self,dire,value):
- raise Exception,"invalid '%s': %s" % (dire,value)
+ def invalid(self, dire, value):
+ raise Exception,"invalid '%s': %s" % (dire, value)
- def get_aux(self,name):
+ def get_aux(self, name):
if self.auxiliary is None:
- aux_gen = Gen(priority_order=['require','define'])
- directives.execute(directives.load(os.path.join(scriptdir,'gderived-defs')),aux_gen)
+ aux_gen = Gen(priority_order=['require', 'define'])
+ directives.execute(directives.load(os.path.join(scriptdir, 'gderived-defs')), aux_gen)
self.auxiliary = aux_gen.global_bindings
return self.auxiliary[name]
- def dire_require(self,name,parm,body):
+ def dire_require(self, name, parm, body):
if body is not None:
- self.invalid('require','non-empty body')
- sub_gen = Gen(bindings=self.global_bindings, priority__order=['require','define'])
- directives.execute(directives.load(parm.strip()),sub_gen)
+ self.invalid('require', 'non-empty body')
+ sub_gen = Gen(bindings=self.global_bindings, priority__order=['require', 'define'])
+ directives.execute(directives.load(parm.strip()), sub_gen)
- def dire_define(self,name,parm,body):
+ def dire_define(self, name, parm, body):
parms = parm.split()
if not parms:
- self.invalid('define',parm)
+ self.invalid('define', parm)
parsed_name = modif_re.match(parms[0])
if not parsed_name:
- self.invalid('define',parm)
+ self.invalid('define', parm)
templ_kind = parsed_name.group(1)
templ_name = parsed_name.group(2)
if templ_kind is None:
@@ -104,40 +106,40 @@
start = templ_kind)
self.global_bindings[templ_name] = templ
- def dire_base_class(self,name,parm,body):
+ def dire_base_class(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
if self.base_class is None:
self.base_class = JavaTemplate(parm.strip())
self.global_bindings['base'] = self.base_class
- def dire_want_dict(self,name,parm,body):
+ def dire_want_dict(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
if self.want_dict is None:
self.want_dict = {"true": 1, "false": 0}[parm.strip()]
- def dire_no_toString(self,name,parm,body):
+ def dire_no_toString(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
self.no_toString = True
- def dire_incl(self,name,parm,body):
+ def dire_incl(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
directives.execute(directives.load(parm.strip()+'.derived'),self)
- def dire_ctr(self,name,parm,body):
+ def dire_ctr(self, name, parm, body):
if self.ctr_done:
return
if body is not None:
- self.invalid(name,"non-empty body")
+ self.invalid(name, "non-empty body")
if self.want_dict:
self.add_decl(self.get_aux('userdict'))
ctr = self.get_aux('ctr_userdict')
else:
ctr = self.get_aux('ctr')
- extraargs = JavaTemplate(parm.strip(),start="FormalParameterListOpt")
+ extraargs = JavaTemplate(parm.strip(), start="FormalParameterListOpt")
def visit(node):
if isinstance(node, jast.VariableDeclaratorId):
yield node.Identifier
@@ -145,20 +147,20 @@
for child in node.children:
for x in visit(child):
yield x
- extra = jast_make(jast.Expressions, [jast_make(jast.Primary,Identifier=x,ArgumentsOpt=None) for x in visit(extraargs.fragment)])
+ extra = jast_make(jast.Expressions, [jast_make(jast.Primary, Identifier=x, ArgumentsOpt=None) for x in visit(extraargs.fragment)])
extra = JavaTemplate(extra)
self.add_decl(ctr.tbind({'base': self.base_class, 'extraargs': extraargs, 'extra': extra}))
self.ctr_done = 1
- def add_decl(self,templ):
+ def add_decl(self, templ):
pair = self.get_aux('pair')
self.decls = pair.tbind({'trailer': self.decls, 'last': templ})
- def dire_unary1(self,name,parm,body):
+ def dire_unary1(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
parms = parm.split()
- if len(parms) not in (1,2,3):
- self.invalid(name,parm)
+ if len(parms) not in (1, 2, 3):
+ self.invalid(name, parm)
meth_name = parms[0]
if len(parms) == 1:
unary_body = self.get_aux('unary')
@@ -176,28 +178,28 @@
'rettype': JavaTemplate(rettype_class)}))
- def dire_binary(self,name,parm,body):
+ def dire_binary(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
meth_names = parm.split()
binary_body = self.get_aux('binary')
for meth_name in meth_names:
self.add_decl(binary_body.tbind({'binary': JavaTemplate(meth_name)}))
- def dire_ibinary(self,name,parm,body):
+ def dire_ibinary(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
meth_names = parm.split()
binary_body = self.get_aux('ibinary')
for meth_name in meth_names:
self.add_decl(binary_body.tbind({'binary': JavaTemplate(meth_name)}))
- def dire_rest(self,name,parm,body):
+ def dire_rest(self, name, parm, body):
if parm:
- self.invalid(name,'non-empty parm')
+ self.invalid(name, 'non-empty parm')
if body is None:
return
- self.add_decl(JavaTemplate(body,start='ClassBodyDeclarations'))
+ self.add_decl(JavaTemplate(body, start='ClassBodyDeclarations'))
def generate(self):
if not self.no_toString:
@@ -209,10 +211,10 @@
if (lazy and
os.path.exists(outfile) and
os.stat(fn).st_mtime < os.stat(outfile).st_mtime):
- return
+ return
print 'Processing %s into %s' % (fn, outfile)
gen = Gen()
- directives.execute(directives.load(fn),gen)
+ directives.execute(directives.load(fn), gen)
result = gen.generate()
result = hack_derived_header(outfile, result)
print >> open(outfile, 'w'), result
@@ -240,30 +242,29 @@
header = DERIVED_HEADER % '.'.join(dirs)
result[0:num - 1] = header.splitlines()
break
+
+ return '\n'.join(result)
- return '\n'.join(result)
-
+
if __name__ == '__main__':
from gexpose import load_mappings, usage
lazy = False
if len(sys.argv) > 4:
usage()
- sys.exit(1)
+ sys.exit(1)
if len(sys.argv) >= 2:
- if '--help' in sys.argv:
- usage()
- sys.exit(0)
- elif '--lazy' in sys.argv:
- lazy = True
- sys.argv.remove('--lazy')
+ if '--help' in sys.argv:
+ usage()
+ sys.exit(0)
+ elif '--lazy' in sys.argv:
+ lazy = True
+ sys.argv.remove('--lazy')
if len(sys.argv) == 1:
- for template, mapping in load_mappings().items():
- if template.endswith('derived'):
- process(mapping[0], mapping[1], lazy)
+ for template, mapping in load_mappings().items():
+ if template.endswith('derived'):
+ process(mapping[0], mapping[1], lazy)
elif len(sys.argv) == 2:
- mapping = load_mappings()[sys.argv[1]]
+ mapping = load_mappings()[sys.argv[1]]
process(mapping[0], mapping[1], lazy)
else:
process(sys.argv[1], sys.argv[2], lazy)
-
-
diff --git a/src/templates/object.derived b/src/templates/object.derived
--- a/src/templates/object.derived
+++ b/src/templates/object.derived
@@ -318,6 +318,8 @@
PyObject impl = self_type.lookup("__setattr__");
if (impl != null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
--
Repository URL: http://hg.python.org/jython
From jython-checkins at python.org Thu Sep 4 06:35:37 2014
From: jython-checkins at python.org (jim.baker)
Date: Thu, 4 Sep 2014 06:35:37 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython=3A_Now_one_can_manually_restor?=
=?utf-8?q?e_an_object=27s_finalizer_via?=
Message-ID: <3hpTj53bMCz7Lk8@mail.python.org>
http://hg.python.org/jython/rev/4a04ad5e201b
changeset: 7361:4a04ad5e201b
user: Stefan Richthofer
date: Tue Aug 26 14:21:45 2014 +0200
summary:
Now one can manually restore an object's finalizer via someObject.__ensure_finalizer__. Additionally I cleaned up out-commented and dead code and changed the indentation style in test_finalizers.py to comply with Jython's coding guideline. I also refectored the method names __del__Builtin and __del__Derived to __del_builtin__ and __del_derived__.
files:
Lib/test/test_finalizers.py | 615 +++++----
src/org/python/antlr/ast/AssertDerived.java | 4 +-
src/org/python/antlr/ast/AssignDerived.java | 4 +-
src/org/python/antlr/ast/AttributeDerived.java | 4 +-
src/org/python/antlr/ast/AugAssignDerived.java | 4 +-
src/org/python/antlr/ast/BinOpDerived.java | 4 +-
src/org/python/antlr/ast/BoolOpDerived.java | 4 +-
src/org/python/antlr/ast/BreakDerived.java | 4 +-
src/org/python/antlr/ast/CallDerived.java | 4 +-
src/org/python/antlr/ast/ClassDefDerived.java | 4 +-
src/org/python/antlr/ast/CompareDerived.java | 4 +-
src/org/python/antlr/ast/ContinueDerived.java | 4 +-
src/org/python/antlr/ast/DeleteDerived.java | 4 +-
src/org/python/antlr/ast/DictDerived.java | 4 +-
src/org/python/antlr/ast/EllipsisDerived.java | 4 +-
src/org/python/antlr/ast/ExceptHandlerDerived.java | 4 +-
src/org/python/antlr/ast/ExecDerived.java | 4 +-
src/org/python/antlr/ast/ExprDerived.java | 4 +-
src/org/python/antlr/ast/ExpressionDerived.java | 4 +-
src/org/python/antlr/ast/ExtSliceDerived.java | 4 +-
src/org/python/antlr/ast/ForDerived.java | 4 +-
src/org/python/antlr/ast/FunctionDefDerived.java | 4 +-
src/org/python/antlr/ast/GeneratorExpDerived.java | 4 +-
src/org/python/antlr/ast/GlobalDerived.java | 4 +-
src/org/python/antlr/ast/IfDerived.java | 4 +-
src/org/python/antlr/ast/IfExpDerived.java | 4 +-
src/org/python/antlr/ast/ImportDerived.java | 4 +-
src/org/python/antlr/ast/ImportFromDerived.java | 4 +-
src/org/python/antlr/ast/IndexDerived.java | 4 +-
src/org/python/antlr/ast/InteractiveDerived.java | 4 +-
src/org/python/antlr/ast/LambdaDerived.java | 4 +-
src/org/python/antlr/ast/ListCompDerived.java | 4 +-
src/org/python/antlr/ast/ListDerived.java | 4 +-
src/org/python/antlr/ast/ModuleDerived.java | 4 +-
src/org/python/antlr/ast/NameDerived.java | 4 +-
src/org/python/antlr/ast/NumDerived.java | 4 +-
src/org/python/antlr/ast/PassDerived.java | 4 +-
src/org/python/antlr/ast/PrintDerived.java | 4 +-
src/org/python/antlr/ast/RaiseDerived.java | 4 +-
src/org/python/antlr/ast/ReprDerived.java | 4 +-
src/org/python/antlr/ast/ReturnDerived.java | 4 +-
src/org/python/antlr/ast/SliceDerived.java | 4 +-
src/org/python/antlr/ast/StrDerived.java | 4 +-
src/org/python/antlr/ast/SubscriptDerived.java | 4 +-
src/org/python/antlr/ast/SuiteDerived.java | 4 +-
src/org/python/antlr/ast/TryExceptDerived.java | 4 +-
src/org/python/antlr/ast/TryFinallyDerived.java | 4 +-
src/org/python/antlr/ast/TupleDerived.java | 4 +-
src/org/python/antlr/ast/UnaryOpDerived.java | 4 +-
src/org/python/antlr/ast/WhileDerived.java | 4 +-
src/org/python/antlr/ast/WithDerived.java | 4 +-
src/org/python/antlr/ast/YieldDerived.java | 4 +-
src/org/python/antlr/ast/aliasDerived.java | 4 +-
src/org/python/antlr/ast/argumentsDerived.java | 4 +-
src/org/python/antlr/ast/comprehensionDerived.java | 4 +-
src/org/python/antlr/ast/keywordDerived.java | 4 +-
src/org/python/antlr/op/AddDerived.java | 4 +-
src/org/python/antlr/op/AndDerived.java | 4 +-
src/org/python/antlr/op/AugLoadDerived.java | 4 +-
src/org/python/antlr/op/AugStoreDerived.java | 4 +-
src/org/python/antlr/op/BitAndDerived.java | 4 +-
src/org/python/antlr/op/BitOrDerived.java | 4 +-
src/org/python/antlr/op/BitXorDerived.java | 4 +-
src/org/python/antlr/op/DelDerived.java | 4 +-
src/org/python/antlr/op/DivDerived.java | 4 +-
src/org/python/antlr/op/EqDerived.java | 4 +-
src/org/python/antlr/op/FloorDivDerived.java | 4 +-
src/org/python/antlr/op/GtDerived.java | 4 +-
src/org/python/antlr/op/GtEDerived.java | 4 +-
src/org/python/antlr/op/InDerived.java | 4 +-
src/org/python/antlr/op/InvertDerived.java | 4 +-
src/org/python/antlr/op/IsDerived.java | 4 +-
src/org/python/antlr/op/IsNotDerived.java | 4 +-
src/org/python/antlr/op/LShiftDerived.java | 4 +-
src/org/python/antlr/op/LoadDerived.java | 4 +-
src/org/python/antlr/op/LtDerived.java | 4 +-
src/org/python/antlr/op/LtEDerived.java | 4 +-
src/org/python/antlr/op/ModDerived.java | 4 +-
src/org/python/antlr/op/MultDerived.java | 4 +-
src/org/python/antlr/op/NotDerived.java | 4 +-
src/org/python/antlr/op/NotEqDerived.java | 4 +-
src/org/python/antlr/op/NotInDerived.java | 4 +-
src/org/python/antlr/op/OrDerived.java | 4 +-
src/org/python/antlr/op/ParamDerived.java | 4 +-
src/org/python/antlr/op/PowDerived.java | 4 +-
src/org/python/antlr/op/RShiftDerived.java | 4 +-
src/org/python/antlr/op/StoreDerived.java | 4 +-
src/org/python/antlr/op/SubDerived.java | 4 +-
src/org/python/antlr/op/UAddDerived.java | 4 +-
src/org/python/antlr/op/USubDerived.java | 4 +-
src/org/python/core/ClasspathPyImporterDerived.java | 4 +-
src/org/python/core/Py.java | 3 +-
src/org/python/core/PyArrayDerived.java | 4 +-
src/org/python/core/PyBaseExceptionDerived.java | 4 +-
src/org/python/core/PyByteArrayDerived.java | 4 +-
src/org/python/core/PyClass.java | 6 -
src/org/python/core/PyClassMethodDerived.java | 4 +-
src/org/python/core/PyComplexDerived.java | 4 +-
src/org/python/core/PyDictionaryDerived.java | 4 +-
src/org/python/core/PyEnumerateDerived.java | 4 +-
src/org/python/core/PyFile.java | 2 +-
src/org/python/core/PyFileDerived.java | 4 +-
src/org/python/core/PyFloatDerived.java | 4 +-
src/org/python/core/PyFrozenSetDerived.java | 4 +-
src/org/python/core/PyGenerator.java | 2 +-
src/org/python/core/PyInstance.java | 39 +-
src/org/python/core/PyIntegerDerived.java | 4 +-
src/org/python/core/PyListDerived.java | 4 +-
src/org/python/core/PyLongDerived.java | 4 +-
src/org/python/core/PyModuleDerived.java | 4 +-
src/org/python/core/PyObject.java | 7 +
src/org/python/core/PyObjectDerived.java | 4 +-
src/org/python/core/PyPropertyDerived.java | 4 +-
src/org/python/core/PySetDerived.java | 4 +-
src/org/python/core/PyStringDerived.java | 4 +-
src/org/python/core/PySuperDerived.java | 4 +-
src/org/python/core/PyTupleDerived.java | 4 +-
src/org/python/core/PyTypeDerived.java | 4 +-
src/org/python/core/PyUnicodeDerived.java | 4 +-
src/org/python/core/finalization/FinalizableBuiltin.java | 12 +-
src/org/python/core/finalization/FinalizablePyObject.java | 14 +-
src/org/python/core/finalization/FinalizablePyObjectDerived.java | 14 +-
src/org/python/core/finalization/FinalizeTrigger.java | 43 +-
src/org/python/modules/PyStructDerived.java | 4 +-
src/org/python/modules/_collections/PyDefaultDictDerived.java | 4 +-
src/org/python/modules/_collections/PyDequeDerived.java | 4 +-
src/org/python/modules/_csv/PyDialectDerived.java | 4 +-
src/org/python/modules/_functools/PyPartialDerived.java | 4 +-
src/org/python/modules/_io/PyFileIODerived.java | 4 +-
src/org/python/modules/_io/PyIOBase.java | 2 +-
src/org/python/modules/_io/PyIOBaseDerived.java | 4 +-
src/org/python/modules/_io/PyRawIOBaseDerived.java | 4 +-
src/org/python/modules/_weakref/ReferenceTypeDerived.java | 4 +-
src/org/python/modules/bz2/PyBZ2CompressorDerived.java | 4 +-
src/org/python/modules/bz2/PyBZ2DecompressorDerived.java | 4 +-
src/org/python/modules/bz2/PyBZ2File.java | 2 +-
src/org/python/modules/bz2/PyBZ2FileDerived.java | 4 +-
src/org/python/modules/itertools/PyTeeIteratorDerived.java | 4 +-
src/org/python/modules/itertools/chainDerived.java | 4 +-
src/org/python/modules/itertools/combinationsDerived.java | 4 +-
src/org/python/modules/itertools/combinationsWithReplacementDerived.java | 4 +-
src/org/python/modules/itertools/compressDerived.java | 4 +-
src/org/python/modules/itertools/countDerived.java | 4 +-
src/org/python/modules/itertools/cycleDerived.java | 4 +-
src/org/python/modules/itertools/dropwhileDerived.java | 4 +-
src/org/python/modules/itertools/groupbyDerived.java | 4 +-
src/org/python/modules/itertools/ifilterDerived.java | 4 +-
src/org/python/modules/itertools/ifilterfalseDerived.java | 4 +-
src/org/python/modules/itertools/isliceDerived.java | 4 +-
src/org/python/modules/itertools/izipDerived.java | 4 +-
src/org/python/modules/itertools/izipLongestDerived.java | 4 +-
src/org/python/modules/itertools/permutationsDerived.java | 4 +-
src/org/python/modules/itertools/productDerived.java | 4 +-
src/org/python/modules/itertools/repeatDerived.java | 4 +-
src/org/python/modules/itertools/starmapDerived.java | 4 +-
src/org/python/modules/itertools/takewhileDerived.java | 4 +-
src/org/python/modules/random/PyRandomDerived.java | 4 +-
src/org/python/modules/thread/PyLocalDerived.java | 4 +-
src/org/python/modules/zipimport/zipimporterDerived.java | 4 +-
src/templates/gderived-defs | 6 +-
src/templates/object.derived | 1 -
161 files changed, 665 insertions(+), 687 deletions(-)
diff --git a/Lib/test/test_finalizers.py b/Lib/test/test_finalizers.py
--- a/Lib/test/test_finalizers.py
+++ b/Lib/test/test_finalizers.py
@@ -2,32 +2,34 @@
Created on 06.08.2014
'''
-import platform
import unittest
import types
import time
-if platform.system() == "Java":
- from java.lang import System
- from org.python.core.finalization import FinalizeTrigger
+try:
+ from java.lang import System
+except:
+ pass
class GCDetector():
- gcIndex = 0
-
- def __del__(self):
- GCDetector.gcIndex += 1
+ gcIndex = 0
+
+ def __del__(self):
+ GCDetector.gcIndex += 1
maxGCRun = 10
def runGCIfJython():
- if platform.system() == "Java":
- currentIndex = GCDetector.gcIndex
- gcCount = 0
- detector = GCDetector()
- detector = None
- while currentIndex == GCDetector.gcIndex and gcCount < maxGCRun:
- System.gc()
- gcCount += 1
- time.sleep(0.1)
+ try:
+ currentIndex = GCDetector.gcIndex
+ gcCount = 0
+ detector = GCDetector()
+ detector = None
+ while currentIndex == GCDetector.gcIndex and gcCount < maxGCRun:
+ System.gc()
+ gcCount += 1
+ time.sleep(0.1)
+ except:
+ pass
finalizeMsgList = []
verbose = False
@@ -40,71 +42,71 @@
class ResurrectableDummyClass():
- def __init__(self, name):
- self.name = name
- self.doResurrection = True
+ def __init__(self, name):
+ self.name = name
+ self.doResurrection = True
- def __str__(self):
- return self.name
+ def __str__(self):
+ return self.name
class ResurrectableDummyClassNew(object):
- def __init__(self, name):
- self.name = name
- self.doResurrection = True
+ def __init__(self, name):
+ self.name = name
+ self.doResurrection = True
- def __str__(self):
- return self.name
+ def __str__(self):
+ return self.name
def __del__I(self):
- global resurrectedObject_I
- finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
- if verbose:
- print str(self)+" finalized (ResurrectableDummyClass)"
- if self.doResurrection:
- resurrectedObject_I = self
+ global resurrectedObject_I
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_I = self
def __del__J(self):
- global resurrectedObject_J
- finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
- if verbose:
- print str(self)+" finalized (ResurrectableDummyClass)"
- if self.doResurrection:
- resurrectedObject_J = self
+ global resurrectedObject_J
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_J = self
def __del__K(self):
- global resurrectedObject_K
- finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
- if verbose:
- print str(self)+" finalized (ResurrectableDummyClass)"
- if self.doResurrection:
- resurrectedObject_K = self
+ global resurrectedObject_K
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_K = self
def __del__L(self):
- global resurrectedObject_L
- finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
- if verbose:
- print str(self)+" finalized (ResurrectableDummyClass)"
- if self.doResurrection:
- resurrectedObject_L = self
+ global resurrectedObject_L
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_L = self
def __del__M(self):
- global resurrectedObject_M
- finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
- if verbose:
- print str(self)+" finalized (ResurrectableDummyClass)"
- if self.doResurrection:
- resurrectedObject_M = self
+ global resurrectedObject_M
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_M = self
def __del__N(self):
- global resurrectedObject_N
- finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
- if verbose:
- print str(self)+" finalized (ResurrectableDummyClass)"
- if self.doResurrection:
- resurrectedObject_N = self
+ global resurrectedObject_N
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_N = self
delI = __del__I
delJ = __del__J
@@ -115,289 +117,302 @@
class DummyClass():
-
- def __init__(self, name):
- self.name = name
-
- def __str__(self):
- return self.name
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
class DummyClassDel():
-
- def __init__(self, name):
- self.name = name
-
- def __str__(self):
- return self.name
-
- def __del__(self):
- finalizeMsgList.append(str(self)+" finalized (DummyClassDel)")
- if verbose:
- print str(self)+" finalized (DummyClassDel)"
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyClassDel)")
+ if verbose:
+ print str(self)+" finalized (DummyClassDel)"
class DummyClassNew(object):
-
- def __init__(self, name):
- self.name = name
-
- def __str__(self):
- return self.name
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
class DummyClassDelNew(object):
-
- def __init__(self, name):
- self.name = name
-
- def __str__(self):
- return self.name
-
- def __del__(self):
- finalizeMsgList.append(str(self)+" finalized (DummyClassDelNew)")
- if verbose:
- print str(self)+" finalized (DummyClassDelNew)"
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyClassDelNew)")
+ if verbose:
+ print str(self)+" finalized (DummyClassDelNew)"
class DummyFileClassNew(file):
-
- def __init__(self, name):
- self.name0 = name
-
- def __str__(self):
- return self.name0
+
+ def __init__(self, name):
+ self.name0 = name
+
+ def __str__(self):
+ return self.name0
- def __del__(self):
- finalizeMsgList.append(str(self)+" finalized (DummyFileClassNew)")
- if verbose:
- print str(self)+" finalized (DummyFileClassNew)"
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyFileClassNew)")
+ if verbose:
+ print str(self)+" finalized (DummyFileClassNew)"
def __del__class(self):
- finalizeMsgList.append(str(self)+" finalized (acquired by class)")
- if verbose:
- print str(self)+" finalized (acquired by class)"
+ finalizeMsgList.append(str(self)+" finalized (acquired by class)")
+ if verbose:
+ print str(self)+" finalized (acquired by class)"
def __del__object(self):
- finalizeMsgList.append(str(self)+" finalized (acquired by object)")
- if verbose:
- print str(self)+" finalized (acquired by object)"
+ finalizeMsgList.append(str(self)+" finalized (acquired by object)")
+ if verbose:
+ print str(self)+" finalized (acquired by object)"
def __del__object0():
- finalizeMsgList.append("_ finalized (acquired by object)")
- if verbose:
- print "_ finalized (acquired by object)"
+ finalizeMsgList.append("_ finalized (acquired by object)")
+ if verbose:
+ print "_ finalized (acquired by object)"
delClass = __del__class
delObject = __del__object
delObject0 = __del__object0
class TestFinalizers(unittest.TestCase):
- def test_finalizer_builtin_oldStyleClass(self):
- A = DummyClassDel("A")
- A = None
- runGCIfJython()
- assert("A finalized (DummyClassDel)" in finalizeMsgList)
+ def test_finalizer_builtin_oldStyleClass(self):
+ A = DummyClassDel("A")
+ A = None
+ runGCIfJython()
+ assert("A finalized (DummyClassDel)" in finalizeMsgList)
- def test_classAcquiresFinalizer_beforeInstanciation_oldStyleClass(self):
- DummyClass.__del__ = delClass
- B = DummyClass("B")
- B = None
- runGCIfJython()
- assert("B finalized (acquired by class)" in finalizeMsgList)
- del DummyClass.__del__
+ def test_classAcquiresFinalizer_beforeInstanciation_oldStyleClass(self):
+ DummyClass.__del__ = delClass
+ B = DummyClass("B")
+ B = None
+ runGCIfJython()
+ assert("B finalized (acquired by class)" in finalizeMsgList)
+ del DummyClass.__del__
- def test_classAcquiresFinalizer_afterInstanciation_oldStyleClass(self):
- #okay to fail in Jython without the manual ensureFinalizer call
- C = DummyClass("C")
- DummyClass.__del__ = delClass
- if platform.system() == "Java":
- FinalizeTrigger.ensureFinalizer(C)
- C = None
- runGCIfJython()
- assert("C finalized (acquired by class)" in finalizeMsgList)
- del DummyClass.__del__
+ def test_classAcquiresFinalizer_afterInstanciation_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer call
+ C = DummyClass("C")
+ DummyClass.__del__ = delClass
+ try:
+ C.__ensure_finalizer__()
+ except:
+ pass
+ C = None
+ runGCIfJython()
+ assert("C finalized (acquired by class)" in finalizeMsgList)
+ del DummyClass.__del__
- def test_instanceAcquiresFinalizer_bound_oldStyleClass(self):
- D = DummyClassDel("D")
- dl = types.MethodType(delObject, D.name)
- D.__del__ = dl
- D = None
- runGCIfJython()
- assert("D finalized (DummyClassDel)" not in finalizeMsgList)
- assert("D finalized (acquired by object)" in finalizeMsgList)
+ def test_instanceAcquiresFinalizer_bound_oldStyleClass(self):
+ D = DummyClassDel("D")
+ dl = types.MethodType(delObject, D.name)
+ D.__del__ = dl
+ D = None
+ runGCIfJython()
+ assert("D finalized (DummyClassDel)" not in finalizeMsgList)
+ assert("D finalized (acquired by object)" in finalizeMsgList)
- def test_finalizer_builtin_newStyleClass(self):
- E = DummyClassDelNew("E")
- E = None
- runGCIfJython()
- assert("E finalized (DummyClassDelNew)" in finalizeMsgList)
+ def test_finalizer_builtin_newStyleClass(self):
+ E = DummyClassDelNew("E")
+ E = None
+ runGCIfJython()
+ assert("E finalized (DummyClassDelNew)" in finalizeMsgList)
- def test_classAcquiresFinalizer_beforeInstanciation_newStyleClass(self):
- DummyClassNew.__del__ = delClass
- F = DummyClassNew("F")
- F = None
- runGCIfJython()
- assert("F finalized (acquired by class)" in finalizeMsgList)
- del DummyClassNew.__del__
+ def test_classAcquiresFinalizer_beforeInstanciation_newStyleClass(self):
+ DummyClassNew.__del__ = delClass
+ F = DummyClassNew("F")
+ F = None
+ runGCIfJython()
+ assert("F finalized (acquired by class)" in finalizeMsgList)
+ del DummyClassNew.__del__
- def test_classAcquiresFinalizer_afterInstanciation_newStyleClass(self):
- #okay to fail in Jython without the manual ensureFinalizer call
- G = DummyClassNew("G")
- DummyClassNew.__del__ = delClass
- if platform.system() == "Java":
- FinalizeTrigger.ensureFinalizer(G)
- G = None
- runGCIfJython()
- assert("G finalized (acquired by class)" in finalizeMsgList)
- del DummyClassNew.__del__
+ def test_classAcquiresFinalizer_afterInstanciation_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer call
+ G = DummyClassNew("G")
+ DummyClassNew.__del__ = delClass
+ try:
+ G.__ensure_finalizer__()
+ except:
+ pass
+ G = None
+ runGCIfJython()
+ assert("G finalized (acquired by class)" in finalizeMsgList)
+ del DummyClassNew.__del__
- def test_instanceAcquiresFinalizer_bound_newStyleClass(self):
- """
- It seems, CPython prohibits new style instances from acquiring a finalizer.
- """
- H = DummyClassDelNew("H")
- H.__del__ = types.MethodType(delObject, H.name)
- H = None
- runGCIfJython()
- assert("H finalized (DummyClassDelNew)" in finalizeMsgList)
- assert("H finalized (acquired by object)" not in finalizeMsgList)
+ def test_instanceAcquiresFinalizer_bound_newStyleClass(self):
+ """
+ It seems, CPython prohibits new style instances from acquiring a finalizer.
+ """
+ H = DummyClassDelNew("H")
+ H.__del__ = types.MethodType(delObject, H.name)
+ H = None
+ runGCIfJython()
+ assert("H finalized (DummyClassDelNew)" in finalizeMsgList)
+ assert("H finalized (acquired by object)" not in finalizeMsgList)
- def test_instanceAcquiresFinalizer_bound_newStyleClass2(self):
- """
- It seems, CPython prohibits new style instances from acquiring a finalizer.
- If one calls the instance-acquired __del__ manually, it works, but the gc
- will still call the old one.
- """
- H = DummyClassDelNew("H2")
- H.__del__ = types.MethodType(delObject, H.name)
- H.__del__()
- H = None
- runGCIfJython()
- assert("H2 finalized (DummyClassDelNew)" in finalizeMsgList)
- assert("H2 finalized (acquired by object)" in finalizeMsgList)
+ def test_instanceAcquiresFinalizer_bound_newStyleClass2(self):
+ """
+ It seems, CPython prohibits new style instances from acquiring a finalizer.
+ If one calls the instance-acquired __del__ manually, it works, but the gc
+ will still call the old one.
+ """
+ H = DummyClassDelNew("H2")
+ H.__del__ = types.MethodType(delObject, H.name)
+ H.__del__()
+ H = None
+ runGCIfJython()
+ assert("H2 finalized (DummyClassDelNew)" in finalizeMsgList)
+ assert("H2 finalized (acquired by object)" in finalizeMsgList)
- def test_objectResurrection_oldStyleClass(self):
- ResurrectableDummyClass.__del__ = delI
- I = ResurrectableDummyClass("I")
- I = None
- runGCIfJython()
- assert("I finalized (ResurrectableDummyClass)" in finalizeMsgList)
- assert(str(resurrectedObject_I) == "I")
+ def test_objectResurrection_oldStyleClass(self):
+ ResurrectableDummyClass.__del__ = delI
+ I = ResurrectableDummyClass("I")
+ I = None
+ runGCIfJython()
+ assert("I finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_I) == "I")
- def test_objectDoubleResurrection_oldStyleClass(self):
- #okay to fail in Jython without the manual ensureFinalizer calls
- ResurrectableDummyClass.__del__ = delJ
- J = ResurrectableDummyClass("J")
- J = None
-
- runGCIfJython()
- assert("J finalized (ResurrectableDummyClass)" in finalizeMsgList)
- global resurrectedObject_J
- assert(str(resurrectedObject_J) == "J")
- J = resurrectedObject_J
- resurrectedObject_J = None
- assert(resurrectedObject_J is None)
- if platform.system() == "Java":
- #For Jython one can restore the finalizer manually.
- #This is offered as an easy fix if the CPython behavior
- #in this test should be needed for some reason.
- FinalizeTrigger.ensureFinalizer(J)
- J = None
+ def test_objectDoubleResurrection_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClass.__del__ = delJ
+ J = ResurrectableDummyClass("J")
+ J = None
+
+ runGCIfJython()
+ assert("J finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ global resurrectedObject_J
+ assert(str(resurrectedObject_J) == "J")
+ J = resurrectedObject_J
+ resurrectedObject_J = None
+ assert(resurrectedObject_J is None)
+ try:
+ #For Jython one can restore the finalizer manually.
+ #This is offered as an easy fix if the CPython behavior
+ #in this test should be needed for some reason.
+ J.__ensure_finalizer__()
+ except:
+ pass
+ J = None
- runGCIfJython()
- assert(str(resurrectedObject_J) == "J")
- resurrectedObject_J.doResurrection = False
- if platform.system() == "Java":
- #again...
- FinalizeTrigger.ensureFinalizer(resurrectedObject_J)
- resurrectedObject_J = None
-
- runGCIfJython()
- assert(resurrectedObject_J is None)
-
+ runGCIfJython()
+ assert(str(resurrectedObject_J) == "J")
+ resurrectedObject_J.doResurrection = False
+ try:
+ #again...
+ resurrectedObject_J.__ensure_finalizer__()
+ except:
+ pass
+ resurrectedObject_J = None
+
+ runGCIfJython()
+ assert(resurrectedObject_J is None)
+
- def test_objectDoubleResurrectionAndFinalize_oldStyleClass(self):
- #okay to fail in Jython without the manual ensureFinalizer calls
- ResurrectableDummyClass.__del__ = delK
- K = ResurrectableDummyClass("K")
- K = None
-
- runGCIfJython()
- assert("K finalized (ResurrectableDummyClass)" in finalizeMsgList)
- finalizeMsgList.remove("K finalized (ResurrectableDummyClass)")
- assert("K finalized (ResurrectableDummyClass)" not in finalizeMsgList)
- global resurrectedObject_K
- assert(str(resurrectedObject_K) == "K")
- K = resurrectedObject_K
- resurrectedObject_K = None
- assert(resurrectedObject_K is None)
- if platform.system() == "Java":
- FinalizeTrigger.ensureFinalizer(K)
- K = None
-
- runGCIfJython()
- assert("K finalized (ResurrectableDummyClass)" in finalizeMsgList)
- assert(str(resurrectedObject_K) == "K")
+ def test_objectDoubleResurrectionAndFinalize_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClass.__del__ = delK
+ K = ResurrectableDummyClass("K")
+ K = None
- def test_objectResurrection_newStyleClass(self):
- ResurrectableDummyClassNew.__del__ = delL
- L = ResurrectableDummyClassNew("L")
- L = None
- runGCIfJython()
- assert("L finalized (ResurrectableDummyClass)" in finalizeMsgList)
- assert(str(resurrectedObject_L) == "L")
+ runGCIfJython()
+ assert("K finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ finalizeMsgList.remove("K finalized (ResurrectableDummyClass)")
+ assert("K finalized (ResurrectableDummyClass)" not in finalizeMsgList)
+ global resurrectedObject_K
+ assert(str(resurrectedObject_K) == "K")
+ K = resurrectedObject_K
+ resurrectedObject_K = None
+ assert(resurrectedObject_K is None)
+ try:
+ K.__ensure_finalizer__()
+ except:
+ pass
+ K = None
- def test_objectDoubleResurrection_newStyleClass(self):
- #okay to fail in Jython without the manual ensureFinalizer calls
- ResurrectableDummyClassNew.__del__ = delM
- M = ResurrectableDummyClassNew("M")
- M = None
+ runGCIfJython()
+ assert("K finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_K) == "K")
- runGCIfJython()
- assert("M finalized (ResurrectableDummyClass)" in finalizeMsgList)
- global resurrectedObject_M
- assert(str(resurrectedObject_M) == "M")
- M = resurrectedObject_M
- resurrectedObject_M = None
- assert(resurrectedObject_M is None)
- if platform.system() == "Java":
- FinalizeTrigger.ensureFinalizer(M)
- M = None
+ def test_objectResurrection_newStyleClass(self):
+ ResurrectableDummyClassNew.__del__ = delL
+ L = ResurrectableDummyClassNew("L")
+ L = None
+ runGCIfJython()
+ assert("L finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_L) == "L")
- runGCIfJython()
- assert(str(resurrectedObject_M) == "M")
+ def test_objectDoubleResurrection_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClassNew.__del__ = delM
+ M = ResurrectableDummyClassNew("M")
+ M = None
- def test_objectDoubleResurrectionAndFinalize_newStyleClass(self):
- #okay to fail in Jython without the manual ensureFinalizer calls
- ResurrectableDummyClassNew.__del__ = delN
- N = ResurrectableDummyClassNew("N")
- N = None
+ runGCIfJython()
+ assert("M finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ global resurrectedObject_M
+ assert(str(resurrectedObject_M) == "M")
+ M = resurrectedObject_M
+ resurrectedObject_M = None
+ assert(resurrectedObject_M is None)
+ try:
+ M.__ensure_finalizer__()
+ except:
+ pass
+ M = None
- runGCIfJython()
- assert("N finalized (ResurrectableDummyClass)" in finalizeMsgList)
- finalizeMsgList.remove("N finalized (ResurrectableDummyClass)")
- assert("N finalized (ResurrectableDummyClass)" not in finalizeMsgList)
- global resurrectedObject_N
- assert(str(resurrectedObject_N) == "N")
- N = resurrectedObject_N
- resurrectedObject_N = None
- assert(resurrectedObject_N is None)
- if platform.system() == "Java":
- FinalizeTrigger.ensureFinalizer(N)
- N = None
+ runGCIfJython()
+ assert(str(resurrectedObject_M) == "M")
- runGCIfJython()
- assert("N finalized (ResurrectableDummyClass)" in finalizeMsgList)
- assert(str(resurrectedObject_N) == "N")
+ def test_objectDoubleResurrectionAndFinalize_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClassNew.__del__ = delN
+ N = ResurrectableDummyClassNew("N")
+ N = None
- def test_file_overwrite_del(self):
- O = DummyFileClassNew("O")
- O = None
+ runGCIfJython()
+ assert("N finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ finalizeMsgList.remove("N finalized (ResurrectableDummyClass)")
+ assert("N finalized (ResurrectableDummyClass)" not in finalizeMsgList)
+ global resurrectedObject_N
+ assert(str(resurrectedObject_N) == "N")
+ N = resurrectedObject_N
+ resurrectedObject_N = None
+ assert(resurrectedObject_N is None)
+ try:
+ N.__ensure_finalizer__()
+ except:
+ pass
+ N = None
- runGCIfJython()
- assert("O finalized (DummyFileClassNew)" in finalizeMsgList)
+ runGCIfJython()
+ assert("N finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_N) == "N")
+ def test_file_overwrite_del(self):
+ O = DummyFileClassNew("O")
+ O = None
+
+ runGCIfJython()
+ assert("O finalized (DummyFileClassNew)" in finalizeMsgList)
if __name__ == '__main__':
- unittest.main()
+ unittest.main()
diff --git a/src/org/python/antlr/ast/AssertDerived.java b/src/org/python/antlr/ast/AssertDerived.java
--- a/src/org/python/antlr/ast/AssertDerived.java
+++ b/src/org/python/antlr/ast/AssertDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/AssignDerived.java b/src/org/python/antlr/ast/AssignDerived.java
--- a/src/org/python/antlr/ast/AssignDerived.java
+++ b/src/org/python/antlr/ast/AssignDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/AttributeDerived.java b/src/org/python/antlr/ast/AttributeDerived.java
--- a/src/org/python/antlr/ast/AttributeDerived.java
+++ b/src/org/python/antlr/ast/AttributeDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/AugAssignDerived.java b/src/org/python/antlr/ast/AugAssignDerived.java
--- a/src/org/python/antlr/ast/AugAssignDerived.java
+++ b/src/org/python/antlr/ast/AugAssignDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/BinOpDerived.java b/src/org/python/antlr/ast/BinOpDerived.java
--- a/src/org/python/antlr/ast/BinOpDerived.java
+++ b/src/org/python/antlr/ast/BinOpDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/BoolOpDerived.java b/src/org/python/antlr/ast/BoolOpDerived.java
--- a/src/org/python/antlr/ast/BoolOpDerived.java
+++ b/src/org/python/antlr/ast/BoolOpDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/BreakDerived.java b/src/org/python/antlr/ast/BreakDerived.java
--- a/src/org/python/antlr/ast/BreakDerived.java
+++ b/src/org/python/antlr/ast/BreakDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/CallDerived.java b/src/org/python/antlr/ast/CallDerived.java
--- a/src/org/python/antlr/ast/CallDerived.java
+++ b/src/org/python/antlr/ast/CallDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ClassDefDerived.java b/src/org/python/antlr/ast/ClassDefDerived.java
--- a/src/org/python/antlr/ast/ClassDefDerived.java
+++ b/src/org/python/antlr/ast/ClassDefDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/CompareDerived.java b/src/org/python/antlr/ast/CompareDerived.java
--- a/src/org/python/antlr/ast/CompareDerived.java
+++ b/src/org/python/antlr/ast/CompareDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ContinueDerived.java b/src/org/python/antlr/ast/ContinueDerived.java
--- a/src/org/python/antlr/ast/ContinueDerived.java
+++ b/src/org/python/antlr/ast/ContinueDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/DeleteDerived.java b/src/org/python/antlr/ast/DeleteDerived.java
--- a/src/org/python/antlr/ast/DeleteDerived.java
+++ b/src/org/python/antlr/ast/DeleteDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/DictDerived.java b/src/org/python/antlr/ast/DictDerived.java
--- a/src/org/python/antlr/ast/DictDerived.java
+++ b/src/org/python/antlr/ast/DictDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/EllipsisDerived.java b/src/org/python/antlr/ast/EllipsisDerived.java
--- a/src/org/python/antlr/ast/EllipsisDerived.java
+++ b/src/org/python/antlr/ast/EllipsisDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ExceptHandlerDerived.java b/src/org/python/antlr/ast/ExceptHandlerDerived.java
--- a/src/org/python/antlr/ast/ExceptHandlerDerived.java
+++ b/src/org/python/antlr/ast/ExceptHandlerDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ExecDerived.java b/src/org/python/antlr/ast/ExecDerived.java
--- a/src/org/python/antlr/ast/ExecDerived.java
+++ b/src/org/python/antlr/ast/ExecDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ExprDerived.java b/src/org/python/antlr/ast/ExprDerived.java
--- a/src/org/python/antlr/ast/ExprDerived.java
+++ b/src/org/python/antlr/ast/ExprDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ExpressionDerived.java b/src/org/python/antlr/ast/ExpressionDerived.java
--- a/src/org/python/antlr/ast/ExpressionDerived.java
+++ b/src/org/python/antlr/ast/ExpressionDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ExtSliceDerived.java b/src/org/python/antlr/ast/ExtSliceDerived.java
--- a/src/org/python/antlr/ast/ExtSliceDerived.java
+++ b/src/org/python/antlr/ast/ExtSliceDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ForDerived.java b/src/org/python/antlr/ast/ForDerived.java
--- a/src/org/python/antlr/ast/ForDerived.java
+++ b/src/org/python/antlr/ast/ForDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/FunctionDefDerived.java b/src/org/python/antlr/ast/FunctionDefDerived.java
--- a/src/org/python/antlr/ast/FunctionDefDerived.java
+++ b/src/org/python/antlr/ast/FunctionDefDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/GeneratorExpDerived.java b/src/org/python/antlr/ast/GeneratorExpDerived.java
--- a/src/org/python/antlr/ast/GeneratorExpDerived.java
+++ b/src/org/python/antlr/ast/GeneratorExpDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/GlobalDerived.java b/src/org/python/antlr/ast/GlobalDerived.java
--- a/src/org/python/antlr/ast/GlobalDerived.java
+++ b/src/org/python/antlr/ast/GlobalDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/IfDerived.java b/src/org/python/antlr/ast/IfDerived.java
--- a/src/org/python/antlr/ast/IfDerived.java
+++ b/src/org/python/antlr/ast/IfDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/IfExpDerived.java b/src/org/python/antlr/ast/IfExpDerived.java
--- a/src/org/python/antlr/ast/IfExpDerived.java
+++ b/src/org/python/antlr/ast/IfExpDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ImportDerived.java b/src/org/python/antlr/ast/ImportDerived.java
--- a/src/org/python/antlr/ast/ImportDerived.java
+++ b/src/org/python/antlr/ast/ImportDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ImportFromDerived.java b/src/org/python/antlr/ast/ImportFromDerived.java
--- a/src/org/python/antlr/ast/ImportFromDerived.java
+++ b/src/org/python/antlr/ast/ImportFromDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/IndexDerived.java b/src/org/python/antlr/ast/IndexDerived.java
--- a/src/org/python/antlr/ast/IndexDerived.java
+++ b/src/org/python/antlr/ast/IndexDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/InteractiveDerived.java b/src/org/python/antlr/ast/InteractiveDerived.java
--- a/src/org/python/antlr/ast/InteractiveDerived.java
+++ b/src/org/python/antlr/ast/InteractiveDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/LambdaDerived.java b/src/org/python/antlr/ast/LambdaDerived.java
--- a/src/org/python/antlr/ast/LambdaDerived.java
+++ b/src/org/python/antlr/ast/LambdaDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ListCompDerived.java b/src/org/python/antlr/ast/ListCompDerived.java
--- a/src/org/python/antlr/ast/ListCompDerived.java
+++ b/src/org/python/antlr/ast/ListCompDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ListDerived.java b/src/org/python/antlr/ast/ListDerived.java
--- a/src/org/python/antlr/ast/ListDerived.java
+++ b/src/org/python/antlr/ast/ListDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ModuleDerived.java b/src/org/python/antlr/ast/ModuleDerived.java
--- a/src/org/python/antlr/ast/ModuleDerived.java
+++ b/src/org/python/antlr/ast/ModuleDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/NameDerived.java b/src/org/python/antlr/ast/NameDerived.java
--- a/src/org/python/antlr/ast/NameDerived.java
+++ b/src/org/python/antlr/ast/NameDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/NumDerived.java b/src/org/python/antlr/ast/NumDerived.java
--- a/src/org/python/antlr/ast/NumDerived.java
+++ b/src/org/python/antlr/ast/NumDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/PassDerived.java b/src/org/python/antlr/ast/PassDerived.java
--- a/src/org/python/antlr/ast/PassDerived.java
+++ b/src/org/python/antlr/ast/PassDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/PrintDerived.java b/src/org/python/antlr/ast/PrintDerived.java
--- a/src/org/python/antlr/ast/PrintDerived.java
+++ b/src/org/python/antlr/ast/PrintDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/RaiseDerived.java b/src/org/python/antlr/ast/RaiseDerived.java
--- a/src/org/python/antlr/ast/RaiseDerived.java
+++ b/src/org/python/antlr/ast/RaiseDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ReprDerived.java b/src/org/python/antlr/ast/ReprDerived.java
--- a/src/org/python/antlr/ast/ReprDerived.java
+++ b/src/org/python/antlr/ast/ReprDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/ReturnDerived.java b/src/org/python/antlr/ast/ReturnDerived.java
--- a/src/org/python/antlr/ast/ReturnDerived.java
+++ b/src/org/python/antlr/ast/ReturnDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/SliceDerived.java b/src/org/python/antlr/ast/SliceDerived.java
--- a/src/org/python/antlr/ast/SliceDerived.java
+++ b/src/org/python/antlr/ast/SliceDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/StrDerived.java b/src/org/python/antlr/ast/StrDerived.java
--- a/src/org/python/antlr/ast/StrDerived.java
+++ b/src/org/python/antlr/ast/StrDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/SubscriptDerived.java b/src/org/python/antlr/ast/SubscriptDerived.java
--- a/src/org/python/antlr/ast/SubscriptDerived.java
+++ b/src/org/python/antlr/ast/SubscriptDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/SuiteDerived.java b/src/org/python/antlr/ast/SuiteDerived.java
--- a/src/org/python/antlr/ast/SuiteDerived.java
+++ b/src/org/python/antlr/ast/SuiteDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/TryExceptDerived.java b/src/org/python/antlr/ast/TryExceptDerived.java
--- a/src/org/python/antlr/ast/TryExceptDerived.java
+++ b/src/org/python/antlr/ast/TryExceptDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/TryFinallyDerived.java b/src/org/python/antlr/ast/TryFinallyDerived.java
--- a/src/org/python/antlr/ast/TryFinallyDerived.java
+++ b/src/org/python/antlr/ast/TryFinallyDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/TupleDerived.java b/src/org/python/antlr/ast/TupleDerived.java
--- a/src/org/python/antlr/ast/TupleDerived.java
+++ b/src/org/python/antlr/ast/TupleDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/UnaryOpDerived.java b/src/org/python/antlr/ast/UnaryOpDerived.java
--- a/src/org/python/antlr/ast/UnaryOpDerived.java
+++ b/src/org/python/antlr/ast/UnaryOpDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/WhileDerived.java b/src/org/python/antlr/ast/WhileDerived.java
--- a/src/org/python/antlr/ast/WhileDerived.java
+++ b/src/org/python/antlr/ast/WhileDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/WithDerived.java b/src/org/python/antlr/ast/WithDerived.java
--- a/src/org/python/antlr/ast/WithDerived.java
+++ b/src/org/python/antlr/ast/WithDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/YieldDerived.java b/src/org/python/antlr/ast/YieldDerived.java
--- a/src/org/python/antlr/ast/YieldDerived.java
+++ b/src/org/python/antlr/ast/YieldDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/aliasDerived.java b/src/org/python/antlr/ast/aliasDerived.java
--- a/src/org/python/antlr/ast/aliasDerived.java
+++ b/src/org/python/antlr/ast/aliasDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/argumentsDerived.java b/src/org/python/antlr/ast/argumentsDerived.java
--- a/src/org/python/antlr/ast/argumentsDerived.java
+++ b/src/org/python/antlr/ast/argumentsDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/comprehensionDerived.java b/src/org/python/antlr/ast/comprehensionDerived.java
--- a/src/org/python/antlr/ast/comprehensionDerived.java
+++ b/src/org/python/antlr/ast/comprehensionDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/ast/keywordDerived.java b/src/org/python/antlr/ast/keywordDerived.java
--- a/src/org/python/antlr/ast/keywordDerived.java
+++ b/src/org/python/antlr/ast/keywordDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/AddDerived.java b/src/org/python/antlr/op/AddDerived.java
--- a/src/org/python/antlr/op/AddDerived.java
+++ b/src/org/python/antlr/op/AddDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/AndDerived.java b/src/org/python/antlr/op/AndDerived.java
--- a/src/org/python/antlr/op/AndDerived.java
+++ b/src/org/python/antlr/op/AndDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/AugLoadDerived.java b/src/org/python/antlr/op/AugLoadDerived.java
--- a/src/org/python/antlr/op/AugLoadDerived.java
+++ b/src/org/python/antlr/op/AugLoadDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/AugStoreDerived.java b/src/org/python/antlr/op/AugStoreDerived.java
--- a/src/org/python/antlr/op/AugStoreDerived.java
+++ b/src/org/python/antlr/op/AugStoreDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/BitAndDerived.java b/src/org/python/antlr/op/BitAndDerived.java
--- a/src/org/python/antlr/op/BitAndDerived.java
+++ b/src/org/python/antlr/op/BitAndDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/BitOrDerived.java b/src/org/python/antlr/op/BitOrDerived.java
--- a/src/org/python/antlr/op/BitOrDerived.java
+++ b/src/org/python/antlr/op/BitOrDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/BitXorDerived.java b/src/org/python/antlr/op/BitXorDerived.java
--- a/src/org/python/antlr/op/BitXorDerived.java
+++ b/src/org/python/antlr/op/BitXorDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/DelDerived.java b/src/org/python/antlr/op/DelDerived.java
--- a/src/org/python/antlr/op/DelDerived.java
+++ b/src/org/python/antlr/op/DelDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/DivDerived.java b/src/org/python/antlr/op/DivDerived.java
--- a/src/org/python/antlr/op/DivDerived.java
+++ b/src/org/python/antlr/op/DivDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/EqDerived.java b/src/org/python/antlr/op/EqDerived.java
--- a/src/org/python/antlr/op/EqDerived.java
+++ b/src/org/python/antlr/op/EqDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/FloorDivDerived.java b/src/org/python/antlr/op/FloorDivDerived.java
--- a/src/org/python/antlr/op/FloorDivDerived.java
+++ b/src/org/python/antlr/op/FloorDivDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/GtDerived.java b/src/org/python/antlr/op/GtDerived.java
--- a/src/org/python/antlr/op/GtDerived.java
+++ b/src/org/python/antlr/op/GtDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/GtEDerived.java b/src/org/python/antlr/op/GtEDerived.java
--- a/src/org/python/antlr/op/GtEDerived.java
+++ b/src/org/python/antlr/op/GtEDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/InDerived.java b/src/org/python/antlr/op/InDerived.java
--- a/src/org/python/antlr/op/InDerived.java
+++ b/src/org/python/antlr/op/InDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/InvertDerived.java b/src/org/python/antlr/op/InvertDerived.java
--- a/src/org/python/antlr/op/InvertDerived.java
+++ b/src/org/python/antlr/op/InvertDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/IsDerived.java b/src/org/python/antlr/op/IsDerived.java
--- a/src/org/python/antlr/op/IsDerived.java
+++ b/src/org/python/antlr/op/IsDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/IsNotDerived.java b/src/org/python/antlr/op/IsNotDerived.java
--- a/src/org/python/antlr/op/IsNotDerived.java
+++ b/src/org/python/antlr/op/IsNotDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/LShiftDerived.java b/src/org/python/antlr/op/LShiftDerived.java
--- a/src/org/python/antlr/op/LShiftDerived.java
+++ b/src/org/python/antlr/op/LShiftDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/LoadDerived.java b/src/org/python/antlr/op/LoadDerived.java
--- a/src/org/python/antlr/op/LoadDerived.java
+++ b/src/org/python/antlr/op/LoadDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/LtDerived.java b/src/org/python/antlr/op/LtDerived.java
--- a/src/org/python/antlr/op/LtDerived.java
+++ b/src/org/python/antlr/op/LtDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/LtEDerived.java b/src/org/python/antlr/op/LtEDerived.java
--- a/src/org/python/antlr/op/LtEDerived.java
+++ b/src/org/python/antlr/op/LtEDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/ModDerived.java b/src/org/python/antlr/op/ModDerived.java
--- a/src/org/python/antlr/op/ModDerived.java
+++ b/src/org/python/antlr/op/ModDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/MultDerived.java b/src/org/python/antlr/op/MultDerived.java
--- a/src/org/python/antlr/op/MultDerived.java
+++ b/src/org/python/antlr/op/MultDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/NotDerived.java b/src/org/python/antlr/op/NotDerived.java
--- a/src/org/python/antlr/op/NotDerived.java
+++ b/src/org/python/antlr/op/NotDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/NotEqDerived.java b/src/org/python/antlr/op/NotEqDerived.java
--- a/src/org/python/antlr/op/NotEqDerived.java
+++ b/src/org/python/antlr/op/NotEqDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/NotInDerived.java b/src/org/python/antlr/op/NotInDerived.java
--- a/src/org/python/antlr/op/NotInDerived.java
+++ b/src/org/python/antlr/op/NotInDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/OrDerived.java b/src/org/python/antlr/op/OrDerived.java
--- a/src/org/python/antlr/op/OrDerived.java
+++ b/src/org/python/antlr/op/OrDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/ParamDerived.java b/src/org/python/antlr/op/ParamDerived.java
--- a/src/org/python/antlr/op/ParamDerived.java
+++ b/src/org/python/antlr/op/ParamDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/PowDerived.java b/src/org/python/antlr/op/PowDerived.java
--- a/src/org/python/antlr/op/PowDerived.java
+++ b/src/org/python/antlr/op/PowDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/RShiftDerived.java b/src/org/python/antlr/op/RShiftDerived.java
--- a/src/org/python/antlr/op/RShiftDerived.java
+++ b/src/org/python/antlr/op/RShiftDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/StoreDerived.java b/src/org/python/antlr/op/StoreDerived.java
--- a/src/org/python/antlr/op/StoreDerived.java
+++ b/src/org/python/antlr/op/StoreDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/SubDerived.java b/src/org/python/antlr/op/SubDerived.java
--- a/src/org/python/antlr/op/SubDerived.java
+++ b/src/org/python/antlr/op/SubDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/UAddDerived.java b/src/org/python/antlr/op/UAddDerived.java
--- a/src/org/python/antlr/op/UAddDerived.java
+++ b/src/org/python/antlr/op/UAddDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/antlr/op/USubDerived.java b/src/org/python/antlr/op/USubDerived.java
--- a/src/org/python/antlr/op/USubDerived.java
+++ b/src/org/python/antlr/op/USubDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/ClasspathPyImporterDerived.java b/src/org/python/core/ClasspathPyImporterDerived.java
--- a/src/org/python/core/ClasspathPyImporterDerived.java
+++ b/src/org/python/core/ClasspathPyImporterDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java
--- a/src/org/python/core/Py.java
+++ b/src/org/python/core/Py.java
@@ -31,6 +31,7 @@
import org.python.antlr.base.mod;
import org.python.core.adapter.ClassicPyObjectAdapter;
import org.python.core.adapter.ExtensiblePyObjectAdapter;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.modules.posix.PosixModule;
import org.python.util.Generic;
@@ -2291,7 +2292,7 @@
public PyObject __call__(PyObject[] args, String[] kws) {
Object[] margs = new Object[]{args, kws};
try {
- return Py.java2py(method.invoke(null, margs));
+ return Py.java2py(method.invoke(null, margs));
} catch (Throwable t) {
throw Py.JavaError(t);
}
diff --git a/src/org/python/core/PyArrayDerived.java b/src/org/python/core/PyArrayDerived.java
--- a/src/org/python/core/PyArrayDerived.java
+++ b/src/org/python/core/PyArrayDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyBaseExceptionDerived.java b/src/org/python/core/PyBaseExceptionDerived.java
--- a/src/org/python/core/PyBaseExceptionDerived.java
+++ b/src/org/python/core/PyBaseExceptionDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyByteArrayDerived.java b/src/org/python/core/PyByteArrayDerived.java
--- a/src/org/python/core/PyByteArrayDerived.java
+++ b/src/org/python/core/PyByteArrayDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyClass.java b/src/org/python/core/PyClass.java
--- a/src/org/python/core/PyClass.java
+++ b/src/org/python/core/PyClass.java
@@ -190,12 +190,6 @@
if (__del__ != null) {
inst.finalizeTrigger = FinalizeTrigger.makeTrigger(inst);
}
-// if (__del__ == null) {
-// inst = new PyInstance(this);
-// } else {
-// // the class defined a __del__ method
-// inst = new PyFinalizableInstance(this);
-// }
inst.__init__(args, keywords);
return inst;
}
diff --git a/src/org/python/core/PyClassMethodDerived.java b/src/org/python/core/PyClassMethodDerived.java
--- a/src/org/python/core/PyClassMethodDerived.java
+++ b/src/org/python/core/PyClassMethodDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyComplexDerived.java b/src/org/python/core/PyComplexDerived.java
--- a/src/org/python/core/PyComplexDerived.java
+++ b/src/org/python/core/PyComplexDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyDictionaryDerived.java b/src/org/python/core/PyDictionaryDerived.java
--- a/src/org/python/core/PyDictionaryDerived.java
+++ b/src/org/python/core/PyDictionaryDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyEnumerateDerived.java b/src/org/python/core/PyEnumerateDerived.java
--- a/src/org/python/core/PyEnumerateDerived.java
+++ b/src/org/python/core/PyEnumerateDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyFile.java b/src/org/python/core/PyFile.java
--- a/src/org/python/core/PyFile.java
+++ b/src/org/python/core/PyFile.java
@@ -683,7 +683,7 @@
}
@Override
- public void __del__Builtin() {
+ public void __del_builtin__() {
if (closer != null) {
closer.close();
}
diff --git a/src/org/python/core/PyFileDerived.java b/src/org/python/core/PyFileDerived.java
--- a/src/org/python/core/PyFileDerived.java
+++ b/src/org/python/core/PyFileDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyFloatDerived.java b/src/org/python/core/PyFloatDerived.java
--- a/src/org/python/core/PyFloatDerived.java
+++ b/src/org/python/core/PyFloatDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyFrozenSetDerived.java b/src/org/python/core/PyFrozenSetDerived.java
--- a/src/org/python/core/PyFrozenSetDerived.java
+++ b/src/org/python/core/PyFrozenSetDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyGenerator.java b/src/org/python/core/PyGenerator.java
--- a/src/org/python/core/PyGenerator.java
+++ b/src/org/python/core/PyGenerator.java
@@ -112,7 +112,7 @@
}
@Override
- public void __del__Builtin() {
+ public void __del_builtin__() {
if (gi_frame == null || gi_frame.f_lasti == -1) {
return;
}
diff --git a/src/org/python/core/PyInstance.java b/src/org/python/core/PyInstance.java
--- a/src/org/python/core/PyInstance.java
+++ b/src/org/python/core/PyInstance.java
@@ -18,6 +18,7 @@
public static final PyType TYPE = PyType.fromClass(PyInstance.class);
public FinalizeTrigger finalizeTrigger;
+ private static JavaFunc __ensure_finalizer__Function;
// xxx doc, final name
public transient PyClass instclass;
@@ -29,9 +30,6 @@
public PyInstance() {
super(TYPE);
-// if (TYPE.needsFinalizer()) {
-// finalizeTrigger = FinalizeTrigger.makeTrigger(this);
-// }
}
public PyInstance(PyClass iclass, PyObject dict) {
@@ -41,16 +39,10 @@
dict = new PyStringMap();
}
__dict__ = dict;
-// if (TYPE.needsFinalizer()) {
-// finalizeTrigger = FinalizeTrigger.makeTrigger(this);
-// }
}
public PyInstance(PyClass iclass) {
this(iclass, null);
-// if (TYPE.needsFinalizer()) {
-// finalizeTrigger = FinalizeTrigger.makeTrigger(this);
-// }
}
@ExposedNew
@@ -161,9 +153,27 @@
return ifindfunction(name);
}
+ public static void ensureFinalizer(PyObject[] args, String[] kws) {
+ FinalizeTrigger.ensureFinalizer((PyInstance) args[0]);
+ }
+
+ private static JavaFunc makeFunction__ensure_finalizer__() {
+ try {
+ return new JavaFunc(
+ PyInstance.class.getMethod("ensureFinalizer",
+ PyObject[].class, String[].class));
+ } catch (Exception e) {return null;} //cannot happen
+ }
+
protected PyObject ifindlocal(String name) {
if (name == "__dict__") return __dict__;
if (name == "__class__") return instclass;
+ if (name == "__ensure_finalizer__") {
+ if (__ensure_finalizer__Function == null) {
+ __ensure_finalizer__Function = makeFunction__ensure_finalizer__();
+ }
+ return new PyMethod(__ensure_finalizer__Function, this, instclass);
+ }
if (__dict__ == null) return null;
return __dict__.__finditem__(name);
@@ -1929,17 +1939,6 @@
return super.__ixor__(o);
}
- /*
- public void ensureFinalizer()
- {
- instance_ensureFinalizer();
- }
-
- public void instance_ensureFinalizer() {
- FinalizeTrigger.ensureFinalizer(this);
- }
- */
-
@Override
public void __del__() {
try {
diff --git a/src/org/python/core/PyIntegerDerived.java b/src/org/python/core/PyIntegerDerived.java
--- a/src/org/python/core/PyIntegerDerived.java
+++ b/src/org/python/core/PyIntegerDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyListDerived.java b/src/org/python/core/PyListDerived.java
--- a/src/org/python/core/PyListDerived.java
+++ b/src/org/python/core/PyListDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyLongDerived.java b/src/org/python/core/PyLongDerived.java
--- a/src/org/python/core/PyLongDerived.java
+++ b/src/org/python/core/PyLongDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyModuleDerived.java b/src/org/python/core/PyModuleDerived.java
--- a/src/org/python/core/PyModuleDerived.java
+++ b/src/org/python/core/PyModuleDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyObject.java b/src/org/python/core/PyObject.java
--- a/src/org/python/core/PyObject.java
+++ b/src/org/python/core/PyObject.java
@@ -8,6 +8,7 @@
import java.util.List;
import java.util.Map;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.expose.ExposedClassMethod;
import org.python.expose.ExposedDelete;
import org.python.expose.ExposedGet;
@@ -238,6 +239,12 @@
return __repr__();
}
+ @ExposedMethod
+ public void __ensure_finalizer__() {
+ //PyObjects that implement HasFinalizeTrigger shall implement this method via:
+ //FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyUnicode __unicode__() {
return new PyUnicode(__str__());
}
diff --git a/src/org/python/core/PyObjectDerived.java b/src/org/python/core/PyObjectDerived.java
--- a/src/org/python/core/PyObjectDerived.java
+++ b/src/org/python/core/PyObjectDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyPropertyDerived.java b/src/org/python/core/PyPropertyDerived.java
--- a/src/org/python/core/PyPropertyDerived.java
+++ b/src/org/python/core/PyPropertyDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PySetDerived.java b/src/org/python/core/PySetDerived.java
--- a/src/org/python/core/PySetDerived.java
+++ b/src/org/python/core/PySetDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyStringDerived.java b/src/org/python/core/PyStringDerived.java
--- a/src/org/python/core/PyStringDerived.java
+++ b/src/org/python/core/PyStringDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PySuperDerived.java b/src/org/python/core/PySuperDerived.java
--- a/src/org/python/core/PySuperDerived.java
+++ b/src/org/python/core/PySuperDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyTupleDerived.java b/src/org/python/core/PyTupleDerived.java
--- a/src/org/python/core/PyTupleDerived.java
+++ b/src/org/python/core/PyTupleDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyTypeDerived.java b/src/org/python/core/PyTypeDerived.java
--- a/src/org/python/core/PyTypeDerived.java
+++ b/src/org/python/core/PyTypeDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/PyUnicodeDerived.java b/src/org/python/core/PyUnicodeDerived.java
--- a/src/org/python/core/PyUnicodeDerived.java
+++ b/src/org/python/core/PyUnicodeDerived.java
@@ -19,7 +19,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -27,7 +27,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/core/finalization/FinalizableBuiltin.java b/src/org/python/core/finalization/FinalizableBuiltin.java
--- a/src/org/python/core/finalization/FinalizableBuiltin.java
+++ b/src/org/python/core/finalization/FinalizableBuiltin.java
@@ -6,13 +6,13 @@
public interface FinalizableBuiltin extends HasFinalizeTrigger {
/**
- * {@code __del__Builtin} is the built-in's own finalizer, while
- * {@code __del__Derived} refers to an instance's in-dict {@code __del__}.
- * A FinalizeTrigger calls {@code __del__Derived} first and
- * - if existent - {@code __del__Builtin} after that. A plain {@code __del__}
+ * {@code __del_builtin__} is the built-in's own finalizer, while
+ * {@code __del_derived__} refers to an instance's in-dict {@code __del__}.
+ * A FinalizeTrigger calls {@code __del_derived__} first and
+ * - if existent - {@code __del_builtin__} after that. A plain {@code __del__}
* would behave as overwritten by {@code __del__Derived}, i.e. won't be called
* if the type implements {@code FinalizablePyObjectDerived} while
- * {@code __del__Builtin} is called in any case.
+ * {@code __del_builtin__} is called in any case.
*/
- public void __del__Builtin();
+ public void __del_builtin__();
}
diff --git a/src/org/python/core/finalization/FinalizablePyObject.java b/src/org/python/core/finalization/FinalizablePyObject.java
--- a/src/org/python/core/finalization/FinalizablePyObject.java
+++ b/src/org/python/core/finalization/FinalizablePyObject.java
@@ -9,17 +9,17 @@
*
* The difference is that {@code __del__} can be overwritten by a
* new-style subclass's {@code __del__}-method on Python-side, while
- * {@code __del__Builtin} is always called. If a Python-side
- * finalizer exists, {@code __del__Builtin} will be called after the
+ * {@code __del_builtin__} is always called. If a Python-side
+ * finalizer exists, {@code __del_builtin__} will be called after the
* Python-side finalizer has been processed.
*
*
* One can even implement both interfaces.
* If both interfaces are implemented, the {@code FinalizeTrigger} will
- * call {@code __del__} first and then {@code __del__Builtin}. If a
+ * call {@code __del__} first and then {@code __del_builtin__}. If a
* new-style subclass has an own, Python-side {@code __del__}-method, this
* overwrites the Java-implemented {@code __del__}, but not
- * {@code __del__Builtin}, which will be called after the Python-side
+ * {@code __del_builtin__}, which will be called after the Python-side
* finalizer.
*
*
@@ -60,14 +60,14 @@
* If your finalizer resurrects the object (Python allows this) and you wish the
* finalizer to run again on next collection of the object:
* In the block where the resurrection occurs, let your {@code __del__}- or
- * {@code __del__Builtin}-method call
+ * {@code __del_builtin__}-method call
* {@code FinalizeTrigger.ensureFinalizer(this);}.
*
*
*
*
* Note: Regarding to object resurrection, Jython currently behaves like CPython >= 3.4.
- * That means the finalizer {@code __del__} or {@code __del__Builtin} is called only the
+ * That means the finalizer {@code __del__} or {@code __del_builtin__} is called only the
* first time an object gets gc'ed. If pre 3.4. behavior is required for some reason (i.e.
* have the finalizer called repeatedly on every collection after a resurrection), one can
* achieve this manually via step 5).
@@ -75,7 +75,7 @@
*
* It is possible to switch finalization on and off at any desired time for a certain object.
* This can be helpful if it is only necessary to have {@code __del__} or
- * {@code __del__Builtin} called for certain configurations of an object.
+ * {@code __del_builtin__} called for certain configurations of an object.
*
*
* To turn off the finalizer, call
diff --git a/src/org/python/core/finalization/FinalizablePyObjectDerived.java b/src/org/python/core/finalization/FinalizablePyObjectDerived.java
--- a/src/org/python/core/finalization/FinalizablePyObjectDerived.java
+++ b/src/org/python/core/finalization/FinalizablePyObjectDerived.java
@@ -11,13 +11,13 @@
public interface FinalizablePyObjectDerived extends HasFinalizeTrigger {
/**
- * {@code __del__Builtin} is the built-in's own finalizer, while
- * {@code __del__Derived} refers to an instance's in-dict {@code __del__}.
- * A FinalizeTrigger calls {@code __del__Derived} first and
- * - if existent - {@code __del__Builtin} after that. A plain {@code __del__}
- * would behave as overwritten by {@code __del__Derived}, i.e. won't be called
+ * {@code __del_builtin__} is the built-in's own finalizer, while
+ * {@code __del_derived__} refers to an instance's in-dict {@code __del__}.
+ * A FinalizeTrigger calls {@code __del_derived__} first and
+ * - if existent - {@code __del_builtin__} after that. A plain {@code __del__}
+ * would behave as overwritten by {@code __del_derived__}, i.e. won't be called
* if the type implements {@code FinalizablePyObjectDerived} while
- * {@code __del__Builtin} is called in any case.
+ * {@code __del_builtin__} is called in any case.
*/
- public void __del__Derived();
+ public void __del_derived__();
}
diff --git a/src/org/python/core/finalization/FinalizeTrigger.java b/src/org/python/core/finalization/FinalizeTrigger.java
--- a/src/org/python/core/finalization/FinalizeTrigger.java
+++ b/src/org/python/core/finalization/FinalizeTrigger.java
@@ -1,10 +1,6 @@
package org.python.core.finalization;
import java.lang.reflect.Field;
-import java.lang.ref.WeakReference;
-import java.lang.ref.SoftReference;
-import java.lang.ref.Reference;
-import org.python.core.PyObject;
/**
* To use finalizers on {@code PyObject}s, read the documentation of
@@ -26,16 +22,6 @@
}
}
- /*
- public static FinalizeTrigger makeTriggerDerived(FinalizablePyObjectDerived toFinalize) {
- if (factory != null) {
- return factory.makeTriggerDerived(toFinalize);
- } else {
- return new FinalizeTriggerDerived(toFinalize);
- }
- }
- */
-
/**
* Recreates the {@code FinalizeTrigger} of the given object. This makes sure that
* once the resurrected object is gc'ed again, its {@code __del__}-method will be
@@ -46,12 +32,6 @@
setFinalizeTrigger(resurrect, trigger);
}
- /*
- public static void ensureFinalizerDerived(FinalizablePyObjectDerived resurrect) {
- setFinalizeTrigger(resurrect, makeTriggerDerived(resurrect));
- }
- */
-
public static void setFinalizeTrigger(HasFinalizeTrigger toFinalize, FinalizeTrigger trigger) {
Field triggerField;
try {
@@ -92,6 +72,7 @@
protected HasFinalizeTrigger toFinalize;
+
public void clear() {
toFinalize = null;
}
@@ -108,31 +89,13 @@
protected void finalize() throws Throwable {
if (toFinalize != null) {
if (toFinalize instanceof FinalizablePyObjectDerived) {
- ((FinalizablePyObjectDerived) toFinalize).__del__Derived();
+ ((FinalizablePyObjectDerived) toFinalize).__del_derived__();
} else if (toFinalize instanceof FinalizablePyObject) {
((FinalizablePyObject) toFinalize).__del__();
}
if (toFinalize instanceof FinalizableBuiltin) {
- ((FinalizableBuiltin) toFinalize).__del__Builtin();
+ ((FinalizableBuiltin) toFinalize).__del_builtin__();
}
}
}
-
-
- /*
- * A FinalizeTrigger variant that only calls __del__Derived, but not the
- * built-in's finalizer __del__. It can be used to control finalization
- * behavior of resurrected objects in more detail.
- */
- /*protected static class FinalizeTriggerDerived extends FinalizeTrigger {
- protected FinalizeTriggerDerived(FinalizablePyObjectDerived toFinalize) {
- super(toFinalize);
- }
-
- protected void finalize() throws Throwable {
- if (toFinalize != null) {
- ((FinalizablePyObjectDerived) toFinalize).__del__Derived();
- }
- }
- }*/
}
diff --git a/src/org/python/modules/PyStructDerived.java b/src/org/python/modules/PyStructDerived.java
--- a/src/org/python/modules/PyStructDerived.java
+++ b/src/org/python/modules/PyStructDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/_collections/PyDefaultDictDerived.java b/src/org/python/modules/_collections/PyDefaultDictDerived.java
--- a/src/org/python/modules/_collections/PyDefaultDictDerived.java
+++ b/src/org/python/modules/_collections/PyDefaultDictDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/_collections/PyDequeDerived.java b/src/org/python/modules/_collections/PyDequeDerived.java
--- a/src/org/python/modules/_collections/PyDequeDerived.java
+++ b/src/org/python/modules/_collections/PyDequeDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/_csv/PyDialectDerived.java b/src/org/python/modules/_csv/PyDialectDerived.java
--- a/src/org/python/modules/_csv/PyDialectDerived.java
+++ b/src/org/python/modules/_csv/PyDialectDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/_functools/PyPartialDerived.java b/src/org/python/modules/_functools/PyPartialDerived.java
--- a/src/org/python/modules/_functools/PyPartialDerived.java
+++ b/src/org/python/modules/_functools/PyPartialDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/_io/PyFileIODerived.java b/src/org/python/modules/_io/PyFileIODerived.java
--- a/src/org/python/modules/_io/PyFileIODerived.java
+++ b/src/org/python/modules/_io/PyFileIODerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/_io/PyIOBase.java b/src/org/python/modules/_io/PyIOBase.java
--- a/src/org/python/modules/_io/PyIOBase.java
+++ b/src/org/python/modules/_io/PyIOBase.java
@@ -732,7 +732,7 @@
}
@Override
- public void __del__Builtin() {
+ public void __del_builtin__() {
closer.dismiss();
invoke("close");
}
diff --git a/src/org/python/modules/_io/PyIOBaseDerived.java b/src/org/python/modules/_io/PyIOBaseDerived.java
--- a/src/org/python/modules/_io/PyIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyIOBaseDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/_io/PyRawIOBaseDerived.java b/src/org/python/modules/_io/PyRawIOBaseDerived.java
--- a/src/org/python/modules/_io/PyRawIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyRawIOBaseDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/_weakref/ReferenceTypeDerived.java b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
--- a/src/org/python/modules/_weakref/ReferenceTypeDerived.java
+++ b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/bz2/PyBZ2File.java b/src/org/python/modules/bz2/PyBZ2File.java
--- a/src/org/python/modules/bz2/PyBZ2File.java
+++ b/src/org/python/modules/bz2/PyBZ2File.java
@@ -76,7 +76,7 @@
}
@Override
- public void __del__Builtin() {
+ public void __del_builtin__() {
BZ2File_close();
}
diff --git a/src/org/python/modules/bz2/PyBZ2FileDerived.java b/src/org/python/modules/bz2/PyBZ2FileDerived.java
--- a/src/org/python/modules/bz2/PyBZ2FileDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2FileDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/PyTeeIteratorDerived.java b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
--- a/src/org/python/modules/itertools/PyTeeIteratorDerived.java
+++ b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/chainDerived.java b/src/org/python/modules/itertools/chainDerived.java
--- a/src/org/python/modules/itertools/chainDerived.java
+++ b/src/org/python/modules/itertools/chainDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/combinationsDerived.java b/src/org/python/modules/itertools/combinationsDerived.java
--- a/src/org/python/modules/itertools/combinationsDerived.java
+++ b/src/org/python/modules/itertools/combinationsDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
--- a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
+++ b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/compressDerived.java b/src/org/python/modules/itertools/compressDerived.java
--- a/src/org/python/modules/itertools/compressDerived.java
+++ b/src/org/python/modules/itertools/compressDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/countDerived.java b/src/org/python/modules/itertools/countDerived.java
--- a/src/org/python/modules/itertools/countDerived.java
+++ b/src/org/python/modules/itertools/countDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/cycleDerived.java b/src/org/python/modules/itertools/cycleDerived.java
--- a/src/org/python/modules/itertools/cycleDerived.java
+++ b/src/org/python/modules/itertools/cycleDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/dropwhileDerived.java b/src/org/python/modules/itertools/dropwhileDerived.java
--- a/src/org/python/modules/itertools/dropwhileDerived.java
+++ b/src/org/python/modules/itertools/dropwhileDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/groupbyDerived.java b/src/org/python/modules/itertools/groupbyDerived.java
--- a/src/org/python/modules/itertools/groupbyDerived.java
+++ b/src/org/python/modules/itertools/groupbyDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/ifilterDerived.java b/src/org/python/modules/itertools/ifilterDerived.java
--- a/src/org/python/modules/itertools/ifilterDerived.java
+++ b/src/org/python/modules/itertools/ifilterDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/ifilterfalseDerived.java b/src/org/python/modules/itertools/ifilterfalseDerived.java
--- a/src/org/python/modules/itertools/ifilterfalseDerived.java
+++ b/src/org/python/modules/itertools/ifilterfalseDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/isliceDerived.java b/src/org/python/modules/itertools/isliceDerived.java
--- a/src/org/python/modules/itertools/isliceDerived.java
+++ b/src/org/python/modules/itertools/isliceDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/izipDerived.java b/src/org/python/modules/itertools/izipDerived.java
--- a/src/org/python/modules/itertools/izipDerived.java
+++ b/src/org/python/modules/itertools/izipDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/izipLongestDerived.java b/src/org/python/modules/itertools/izipLongestDerived.java
--- a/src/org/python/modules/itertools/izipLongestDerived.java
+++ b/src/org/python/modules/itertools/izipLongestDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/permutationsDerived.java b/src/org/python/modules/itertools/permutationsDerived.java
--- a/src/org/python/modules/itertools/permutationsDerived.java
+++ b/src/org/python/modules/itertools/permutationsDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/productDerived.java b/src/org/python/modules/itertools/productDerived.java
--- a/src/org/python/modules/itertools/productDerived.java
+++ b/src/org/python/modules/itertools/productDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/repeatDerived.java b/src/org/python/modules/itertools/repeatDerived.java
--- a/src/org/python/modules/itertools/repeatDerived.java
+++ b/src/org/python/modules/itertools/repeatDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/starmapDerived.java b/src/org/python/modules/itertools/starmapDerived.java
--- a/src/org/python/modules/itertools/starmapDerived.java
+++ b/src/org/python/modules/itertools/starmapDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/itertools/takewhileDerived.java b/src/org/python/modules/itertools/takewhileDerived.java
--- a/src/org/python/modules/itertools/takewhileDerived.java
+++ b/src/org/python/modules/itertools/takewhileDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/random/PyRandomDerived.java b/src/org/python/modules/random/PyRandomDerived.java
--- a/src/org/python/modules/random/PyRandomDerived.java
+++ b/src/org/python/modules/random/PyRandomDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/thread/PyLocalDerived.java b/src/org/python/modules/thread/PyLocalDerived.java
--- a/src/org/python/modules/thread/PyLocalDerived.java
+++ b/src/org/python/modules/thread/PyLocalDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/org/python/modules/zipimport/zipimporterDerived.java b/src/org/python/modules/zipimport/zipimporterDerived.java
--- a/src/org/python/modules/zipimport/zipimporterDerived.java
+++ b/src/org/python/modules/zipimport/zipimporterDerived.java
@@ -20,7 +20,7 @@
private PyObject[]slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type=getType();
PyObject impl=self_type.lookup("__del__");
if (impl!=null) {
@@ -28,7 +28,7 @@
}
}
- public void ensureFinalizer() {
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/templates/gderived-defs b/src/templates/gderived-defs
--- a/src/templates/gderived-defs
+++ b/src/templates/gderived-defs
@@ -20,15 +20,15 @@
private PyObject[] slots;
- public void __del__Derived() {
+ public void __del_derived__() {
PyType self_type = getType();
PyObject impl = self_type.lookup("__del__");
if (impl != null) {
impl.__get__(this, self_type).__call__();
}
}
-
- public void ensureFinalizer() {
+
+ public void __ensure_finalizer__() {
FinalizeTrigger.ensureFinalizer(this);
}
diff --git a/src/templates/object.derived b/src/templates/object.derived
--- a/src/templates/object.derived
+++ b/src/templates/object.derived
@@ -431,4 +431,3 @@
}
return super.__coerce_ex__(o);
}
-
--
Repository URL: http://hg.python.org/jython
From jython-checkins at python.org Thu Sep 4 06:35:38 2014
From: jython-checkins at python.org (jim.baker)
Date: Thu, 4 Sep 2014 06:35:38 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython=3A_Removed_the_dead_import_in_?=
=?utf-8?q?Py=2Ejava_and_replaced_various_tab_indentations_by?=
Message-ID: <3hpTj66M83z7LkR@mail.python.org>
http://hg.python.org/jython/rev/5397c1f405c5
changeset: 7362:5397c1f405c5
user: Stefan Richthofer
date: Tue Aug 26 14:35:57 2014 +0200
summary:
Removed the dead import in Py.java and replaced various tab indentations by spaces. Beneath the one I accidentally caused when I had inserted some tmporarily debugging output, the search-and-replace fixed this for 21 other occurences too.
files:
src/org/python/core/Py.java | 41 ++++++++++++------------
1 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java
--- a/src/org/python/core/Py.java
+++ b/src/org/python/core/Py.java
@@ -31,7 +31,6 @@
import org.python.antlr.base.mod;
import org.python.core.adapter.ClassicPyObjectAdapter;
import org.python.core.adapter.ExtensiblePyObjectAdapter;
-import org.python.core.finalization.FinalizeTrigger;
import org.python.modules.posix.PosixModule;
import org.python.util.Generic;
@@ -838,27 +837,27 @@
* @throws ClassNotFoundException if the class wasn't found by the class loader
*/
private static Class> findClassInternal(String name, String reason) throws ClassNotFoundException {
- ClassLoader classLoader = Py.getSystemState().getClassLoader();
+ ClassLoader classLoader = Py.getSystemState().getClassLoader();
if (classLoader != null) {
- if (reason != null) {
- writeDebug("import", "trying " + name + " as " + reason +
- " in sys.classLoader");
- }
+ if (reason != null) {
+ writeDebug("import", "trying " + name + " as " + reason +
+ " in sys.classLoader");
+ }
return loadAndInitClass(name, classLoader);
}
if (!syspathJavaLoaderRestricted) {
try {
classLoader = imp.getSyspathJavaLoader();
if (classLoader != null && reason != null) {
- writeDebug("import", "trying " + name + " as " + reason +
- " in SysPathJavaLoader");
+ writeDebug("import", "trying " + name + " as " + reason +
+ " in SysPathJavaLoader");
}
} catch (SecurityException e) {
syspathJavaLoaderRestricted = true;
}
}
if (syspathJavaLoaderRestricted) {
- classLoader = imp.getParentClassLoader();
+ classLoader = imp.getParentClassLoader();
if (classLoader != null && reason != null) {
writeDebug("import", "trying " + name + " as " + reason +
" in Jython's parent class loader");
@@ -866,20 +865,20 @@
}
if (classLoader != null) {
try {
- return loadAndInitClass(name, classLoader);
+ return loadAndInitClass(name, classLoader);
} catch (ClassNotFoundException cnfe) {
// let the default classloader try
- // XXX: by trying another classloader that may not be on a
- // parent/child relationship with the Jython's parent
- // classsloader we are risking some nasty class loading
- // problems (such as having two incompatible copies for
- // the same class that is itself a dependency of two
- // classes loaded from these two different class loaders)
+ // XXX: by trying another classloader that may not be on a
+ // parent/child relationship with the Jython's parent
+ // classsloader we are risking some nasty class loading
+ // problems (such as having two incompatible copies for
+ // the same class that is itself a dependency of two
+ // classes loaded from these two different class loaders)
}
}
if (reason != null) {
- writeDebug("import", "trying " + name + " as " + reason +
- " in context class loader, for backwards compatibility");
+ writeDebug("import", "trying " + name + " as " + reason +
+ " in context class loader, for backwards compatibility");
}
return loadAndInitClass(name, Thread.currentThread().getContextClassLoader());
}
@@ -891,7 +890,7 @@
*/
public static Class> findClass(String name) {
try {
- return findClassInternal(name, null);
+ return findClassInternal(name, null);
} catch (ClassNotFoundException e) {
// e.printStackTrace();
return null;
@@ -931,7 +930,7 @@
// We *need* to initialize classes on findClass/findClassEx, so that import
// statements can trigger static initializers
private static Class> loadAndInitClass(String name, ClassLoader loader) throws ClassNotFoundException {
- return Class.forName(name, true, loader);
+ return Class.forName(name, true, loader);
}
@@ -2292,7 +2291,7 @@
public PyObject __call__(PyObject[] args, String[] kws) {
Object[] margs = new Object[]{args, kws};
try {
- return Py.java2py(method.invoke(null, margs));
+ return Py.java2py(method.invoke(null, margs));
} catch (Throwable t) {
throw Py.JavaError(t);
}
--
Repository URL: http://hg.python.org/jython
From jython-checkins at python.org Thu Sep 4 06:35:42 2014
From: jython-checkins at python.org (jim.baker)
Date: Thu, 4 Sep 2014 06:35:42 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython_=28merge_default_-=3E_default?=
=?utf-8?q?=29=3A_Merged_finalization_support_for_newstyle_classes?=
Message-ID: <3hpTjB1LqBz7Ljn@mail.python.org>
http://hg.python.org/jython/rev/61081b8859c1
changeset: 7363:61081b8859c1
parent: 7359:83cd10f1826d
parent: 7362:5397c1f405c5
user: Jim Baker
date: Tue Aug 26 22:51:33 2014 -0600
summary:
Merged finalization support for newstyle classes
files:
Lib/test/test_finalizers.py | 418 ++++++++++
src/org/python/antlr/ast/AssertDerived.java | 26 +-
src/org/python/antlr/ast/AssignDerived.java | 26 +-
src/org/python/antlr/ast/AttributeDerived.java | 26 +-
src/org/python/antlr/ast/AugAssignDerived.java | 26 +-
src/org/python/antlr/ast/BinOpDerived.java | 26 +-
src/org/python/antlr/ast/BoolOpDerived.java | 26 +-
src/org/python/antlr/ast/BreakDerived.java | 26 +-
src/org/python/antlr/ast/CallDerived.java | 26 +-
src/org/python/antlr/ast/ClassDefDerived.java | 26 +-
src/org/python/antlr/ast/CompareDerived.java | 26 +-
src/org/python/antlr/ast/ContinueDerived.java | 26 +-
src/org/python/antlr/ast/DeleteDerived.java | 26 +-
src/org/python/antlr/ast/DictDerived.java | 26 +-
src/org/python/antlr/ast/EllipsisDerived.java | 26 +-
src/org/python/antlr/ast/ExceptHandlerDerived.java | 26 +-
src/org/python/antlr/ast/ExecDerived.java | 26 +-
src/org/python/antlr/ast/ExprDerived.java | 26 +-
src/org/python/antlr/ast/ExpressionDerived.java | 26 +-
src/org/python/antlr/ast/ExtSliceDerived.java | 26 +-
src/org/python/antlr/ast/ForDerived.java | 26 +-
src/org/python/antlr/ast/FunctionDefDerived.java | 26 +-
src/org/python/antlr/ast/GeneratorExpDerived.java | 26 +-
src/org/python/antlr/ast/GlobalDerived.java | 26 +-
src/org/python/antlr/ast/IfDerived.java | 26 +-
src/org/python/antlr/ast/IfExpDerived.java | 26 +-
src/org/python/antlr/ast/ImportDerived.java | 26 +-
src/org/python/antlr/ast/ImportFromDerived.java | 26 +-
src/org/python/antlr/ast/IndexDerived.java | 26 +-
src/org/python/antlr/ast/InteractiveDerived.java | 26 +-
src/org/python/antlr/ast/LambdaDerived.java | 26 +-
src/org/python/antlr/ast/ListCompDerived.java | 26 +-
src/org/python/antlr/ast/ListDerived.java | 26 +-
src/org/python/antlr/ast/ModuleDerived.java | 26 +-
src/org/python/antlr/ast/NameDerived.java | 26 +-
src/org/python/antlr/ast/NumDerived.java | 26 +-
src/org/python/antlr/ast/PassDerived.java | 26 +-
src/org/python/antlr/ast/PrintDerived.java | 26 +-
src/org/python/antlr/ast/RaiseDerived.java | 26 +-
src/org/python/antlr/ast/ReprDerived.java | 26 +-
src/org/python/antlr/ast/ReturnDerived.java | 26 +-
src/org/python/antlr/ast/SliceDerived.java | 26 +-
src/org/python/antlr/ast/StrDerived.java | 26 +-
src/org/python/antlr/ast/SubscriptDerived.java | 26 +-
src/org/python/antlr/ast/SuiteDerived.java | 26 +-
src/org/python/antlr/ast/TryExceptDerived.java | 26 +-
src/org/python/antlr/ast/TryFinallyDerived.java | 26 +-
src/org/python/antlr/ast/TupleDerived.java | 26 +-
src/org/python/antlr/ast/UnaryOpDerived.java | 26 +-
src/org/python/antlr/ast/WhileDerived.java | 26 +-
src/org/python/antlr/ast/WithDerived.java | 26 +-
src/org/python/antlr/ast/YieldDerived.java | 26 +-
src/org/python/antlr/ast/aliasDerived.java | 26 +-
src/org/python/antlr/ast/argumentsDerived.java | 26 +-
src/org/python/antlr/ast/comprehensionDerived.java | 26 +-
src/org/python/antlr/ast/keywordDerived.java | 26 +-
src/org/python/antlr/op/AddDerived.java | 26 +-
src/org/python/antlr/op/AndDerived.java | 26 +-
src/org/python/antlr/op/AugLoadDerived.java | 26 +-
src/org/python/antlr/op/AugStoreDerived.java | 26 +-
src/org/python/antlr/op/BitAndDerived.java | 26 +-
src/org/python/antlr/op/BitOrDerived.java | 26 +-
src/org/python/antlr/op/BitXorDerived.java | 26 +-
src/org/python/antlr/op/DelDerived.java | 26 +-
src/org/python/antlr/op/DivDerived.java | 26 +-
src/org/python/antlr/op/EqDerived.java | 26 +-
src/org/python/antlr/op/FloorDivDerived.java | 26 +-
src/org/python/antlr/op/GtDerived.java | 26 +-
src/org/python/antlr/op/GtEDerived.java | 26 +-
src/org/python/antlr/op/InDerived.java | 26 +-
src/org/python/antlr/op/InvertDerived.java | 26 +-
src/org/python/antlr/op/IsDerived.java | 26 +-
src/org/python/antlr/op/IsNotDerived.java | 26 +-
src/org/python/antlr/op/LShiftDerived.java | 26 +-
src/org/python/antlr/op/LoadDerived.java | 26 +-
src/org/python/antlr/op/LtDerived.java | 26 +-
src/org/python/antlr/op/LtEDerived.java | 26 +-
src/org/python/antlr/op/ModDerived.java | 26 +-
src/org/python/antlr/op/MultDerived.java | 26 +-
src/org/python/antlr/op/NotDerived.java | 26 +-
src/org/python/antlr/op/NotEqDerived.java | 26 +-
src/org/python/antlr/op/NotInDerived.java | 26 +-
src/org/python/antlr/op/OrDerived.java | 26 +-
src/org/python/antlr/op/ParamDerived.java | 26 +-
src/org/python/antlr/op/PowDerived.java | 26 +-
src/org/python/antlr/op/RShiftDerived.java | 26 +-
src/org/python/antlr/op/StoreDerived.java | 26 +-
src/org/python/antlr/op/SubDerived.java | 26 +-
src/org/python/antlr/op/UAddDerived.java | 26 +-
src/org/python/antlr/op/USubDerived.java | 26 +-
src/org/python/core/ClasspathPyImporterDerived.java | 23 +-
src/org/python/core/Py.java | 38 +-
src/org/python/core/PyArrayDerived.java | 26 +-
src/org/python/core/PyBaseExceptionDerived.java | 23 +-
src/org/python/core/PyByteArrayDerived.java | 26 +-
src/org/python/core/PyClass.java | 9 +-
src/org/python/core/PyClassMethodDerived.java | 26 +-
src/org/python/core/PyComplexDerived.java | 26 +-
src/org/python/core/PyDictionaryDerived.java | 26 +-
src/org/python/core/PyEnumerateDerived.java | 26 +-
src/org/python/core/PyFile.java | 16 +-
src/org/python/core/PyFileDerived.java | 26 +-
src/org/python/core/PyFinalizableInstance.java | 37 -
src/org/python/core/PyFloatDerived.java | 26 +-
src/org/python/core/PyFrozenSetDerived.java | 26 +-
src/org/python/core/PyGenerator.java | 13 +-
src/org/python/core/PyInstance.java | 52 +-
src/org/python/core/PyIntegerDerived.java | 26 +-
src/org/python/core/PyListDerived.java | 26 +-
src/org/python/core/PyLongDerived.java | 26 +-
src/org/python/core/PyModuleDerived.java | 23 +-
src/org/python/core/PyObject.java | 22 +
src/org/python/core/PyObjectDerived.java | 26 +-
src/org/python/core/PyPropertyDerived.java | 26 +-
src/org/python/core/PySetDerived.java | 26 +-
src/org/python/core/PyStringDerived.java | 26 +-
src/org/python/core/PySuperDerived.java | 26 +-
src/org/python/core/PyTupleDerived.java | 26 +-
src/org/python/core/PyType.java | 22 +-
src/org/python/core/PyTypeDerived.java | 23 +-
src/org/python/core/PyUnicodeDerived.java | 26 +-
src/org/python/core/finalization/FinalizableBuiltin.java | 18 +
src/org/python/core/finalization/FinalizablePyObject.java | 90 ++
src/org/python/core/finalization/FinalizablePyObjectDerived.java | 23 +
src/org/python/core/finalization/FinalizeTrigger.java | 101 ++
src/org/python/core/finalization/FinalizeTriggerFactory.java | 6 +
src/org/python/core/finalization/HasFinalizeTrigger.java | 13 +
src/org/python/core/finalization/PyFinalizableObject.java | 17 +
src/org/python/modules/PyStructDerived.java | 26 +-
src/org/python/modules/_collections/PyDefaultDictDerived.java | 26 +-
src/org/python/modules/_collections/PyDequeDerived.java | 26 +-
src/org/python/modules/_csv/PyDialectDerived.java | 23 +-
src/org/python/modules/_functools/PyPartialDerived.java | 26 +-
src/org/python/modules/_io/PyFileIODerived.java | 23 +-
src/org/python/modules/_io/PyIOBase.java | 11 +-
src/org/python/modules/_io/PyIOBaseDerived.java | 23 +-
src/org/python/modules/_io/PyRawIOBaseDerived.java | 23 +-
src/org/python/modules/_weakref/ReferenceTypeDerived.java | 26 +-
src/org/python/modules/bz2/PyBZ2CompressorDerived.java | 26 +-
src/org/python/modules/bz2/PyBZ2DecompressorDerived.java | 26 +-
src/org/python/modules/bz2/PyBZ2File.java | 13 +-
src/org/python/modules/bz2/PyBZ2FileDerived.java | 26 +-
src/org/python/modules/itertools/PyTeeIteratorDerived.java | 26 +-
src/org/python/modules/itertools/chainDerived.java | 26 +-
src/org/python/modules/itertools/combinationsDerived.java | 26 +-
src/org/python/modules/itertools/combinationsWithReplacementDerived.java | 26 +-
src/org/python/modules/itertools/compressDerived.java | 26 +-
src/org/python/modules/itertools/countDerived.java | 26 +-
src/org/python/modules/itertools/cycleDerived.java | 26 +-
src/org/python/modules/itertools/dropwhileDerived.java | 26 +-
src/org/python/modules/itertools/groupbyDerived.java | 26 +-
src/org/python/modules/itertools/ifilterDerived.java | 26 +-
src/org/python/modules/itertools/ifilterfalseDerived.java | 26 +-
src/org/python/modules/itertools/isliceDerived.java | 26 +-
src/org/python/modules/itertools/izipDerived.java | 26 +-
src/org/python/modules/itertools/izipLongestDerived.java | 26 +-
src/org/python/modules/itertools/permutationsDerived.java | 26 +-
src/org/python/modules/itertools/productDerived.java | 26 +-
src/org/python/modules/itertools/repeatDerived.java | 26 +-
src/org/python/modules/itertools/starmapDerived.java | 26 +-
src/org/python/modules/itertools/takewhileDerived.java | 26 +-
src/org/python/modules/random/PyRandomDerived.java | 26 +-
src/org/python/modules/thread/PyLocalDerived.java | 23 +-
src/org/python/modules/zipimport/zipimporterDerived.java | 26 +-
src/templates/gderived-defs | 26 +-
src/templates/gderived.py | 125 +-
src/templates/object.derived | 3 +-
167 files changed, 4553 insertions(+), 289 deletions(-)
diff --git a/Lib/test/test_finalizers.py b/Lib/test/test_finalizers.py
new file mode 100644
--- /dev/null
+++ b/Lib/test/test_finalizers.py
@@ -0,0 +1,418 @@
+'''
+Created on 06.08.2014
+'''
+
+import unittest
+import types
+import time
+try:
+ from java.lang import System
+except:
+ pass
+
+class GCDetector():
+ gcIndex = 0
+
+ def __del__(self):
+ GCDetector.gcIndex += 1
+
+maxGCRun = 10
+
+def runGCIfJython():
+ try:
+ currentIndex = GCDetector.gcIndex
+ gcCount = 0
+ detector = GCDetector()
+ detector = None
+ while currentIndex == GCDetector.gcIndex and gcCount < maxGCRun:
+ System.gc()
+ gcCount += 1
+ time.sleep(0.1)
+ except:
+ pass
+
+finalizeMsgList = []
+verbose = False
+resurrectedObject_I = None
+resurrectedObject_J = None
+resurrectedObject_K = None
+resurrectedObject_L = None
+resurrectedObject_M = None
+resurrectedObject_N = None
+
+class ResurrectableDummyClass():
+
+ def __init__(self, name):
+ self.name = name
+ self.doResurrection = True
+
+ def __str__(self):
+ return self.name
+
+
+class ResurrectableDummyClassNew(object):
+
+ def __init__(self, name):
+ self.name = name
+ self.doResurrection = True
+
+ def __str__(self):
+ return self.name
+
+
+def __del__I(self):
+ global resurrectedObject_I
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_I = self
+
+def __del__J(self):
+ global resurrectedObject_J
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_J = self
+
+def __del__K(self):
+ global resurrectedObject_K
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_K = self
+
+def __del__L(self):
+ global resurrectedObject_L
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_L = self
+
+def __del__M(self):
+ global resurrectedObject_M
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_M = self
+
+def __del__N(self):
+ global resurrectedObject_N
+ finalizeMsgList.append(str(self)+" finalized (ResurrectableDummyClass)")
+ if verbose:
+ print str(self)+" finalized (ResurrectableDummyClass)"
+ if self.doResurrection:
+ resurrectedObject_N = self
+
+delI = __del__I
+delJ = __del__J
+delK = __del__K
+delL = __del__L
+delM = __del__M
+delN = __del__N
+
+
+class DummyClass():
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+
+class DummyClassDel():
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyClassDel)")
+ if verbose:
+ print str(self)+" finalized (DummyClassDel)"
+
+
+class DummyClassNew(object):
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+class DummyClassDelNew(object):
+
+ def __init__(self, name):
+ self.name = name
+
+ def __str__(self):
+ return self.name
+
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyClassDelNew)")
+ if verbose:
+ print str(self)+" finalized (DummyClassDelNew)"
+
+class DummyFileClassNew(file):
+
+ def __init__(self, name):
+ self.name0 = name
+
+ def __str__(self):
+ return self.name0
+
+ def __del__(self):
+ finalizeMsgList.append(str(self)+" finalized (DummyFileClassNew)")
+ if verbose:
+ print str(self)+" finalized (DummyFileClassNew)"
+
+
+def __del__class(self):
+ finalizeMsgList.append(str(self)+" finalized (acquired by class)")
+ if verbose:
+ print str(self)+" finalized (acquired by class)"
+
+def __del__object(self):
+ finalizeMsgList.append(str(self)+" finalized (acquired by object)")
+ if verbose:
+ print str(self)+" finalized (acquired by object)"
+
+def __del__object0():
+ finalizeMsgList.append("_ finalized (acquired by object)")
+ if verbose:
+ print "_ finalized (acquired by object)"
+
+delClass = __del__class
+delObject = __del__object
+delObject0 = __del__object0
+
+class TestFinalizers(unittest.TestCase):
+ def test_finalizer_builtin_oldStyleClass(self):
+ A = DummyClassDel("A")
+ A = None
+ runGCIfJython()
+ assert("A finalized (DummyClassDel)" in finalizeMsgList)
+
+ def test_classAcquiresFinalizer_beforeInstanciation_oldStyleClass(self):
+ DummyClass.__del__ = delClass
+ B = DummyClass("B")
+ B = None
+ runGCIfJython()
+ assert("B finalized (acquired by class)" in finalizeMsgList)
+ del DummyClass.__del__
+
+ def test_classAcquiresFinalizer_afterInstanciation_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer call
+ C = DummyClass("C")
+ DummyClass.__del__ = delClass
+ try:
+ C.__ensure_finalizer__()
+ except:
+ pass
+ C = None
+ runGCIfJython()
+ assert("C finalized (acquired by class)" in finalizeMsgList)
+ del DummyClass.__del__
+
+ def test_instanceAcquiresFinalizer_bound_oldStyleClass(self):
+ D = DummyClassDel("D")
+ dl = types.MethodType(delObject, D.name)
+ D.__del__ = dl
+ D = None
+ runGCIfJython()
+ assert("D finalized (DummyClassDel)" not in finalizeMsgList)
+ assert("D finalized (acquired by object)" in finalizeMsgList)
+
+ def test_finalizer_builtin_newStyleClass(self):
+ E = DummyClassDelNew("E")
+ E = None
+ runGCIfJython()
+ assert("E finalized (DummyClassDelNew)" in finalizeMsgList)
+
+ def test_classAcquiresFinalizer_beforeInstanciation_newStyleClass(self):
+ DummyClassNew.__del__ = delClass
+ F = DummyClassNew("F")
+ F = None
+ runGCIfJython()
+ assert("F finalized (acquired by class)" in finalizeMsgList)
+ del DummyClassNew.__del__
+
+ def test_classAcquiresFinalizer_afterInstanciation_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer call
+ G = DummyClassNew("G")
+ DummyClassNew.__del__ = delClass
+ try:
+ G.__ensure_finalizer__()
+ except:
+ pass
+ G = None
+ runGCIfJython()
+ assert("G finalized (acquired by class)" in finalizeMsgList)
+ del DummyClassNew.__del__
+
+ def test_instanceAcquiresFinalizer_bound_newStyleClass(self):
+ """
+ It seems, CPython prohibits new style instances from acquiring a finalizer.
+ """
+ H = DummyClassDelNew("H")
+ H.__del__ = types.MethodType(delObject, H.name)
+ H = None
+ runGCIfJython()
+ assert("H finalized (DummyClassDelNew)" in finalizeMsgList)
+ assert("H finalized (acquired by object)" not in finalizeMsgList)
+
+ def test_instanceAcquiresFinalizer_bound_newStyleClass2(self):
+ """
+ It seems, CPython prohibits new style instances from acquiring a finalizer.
+ If one calls the instance-acquired __del__ manually, it works, but the gc
+ will still call the old one.
+ """
+ H = DummyClassDelNew("H2")
+ H.__del__ = types.MethodType(delObject, H.name)
+ H.__del__()
+ H = None
+ runGCIfJython()
+ assert("H2 finalized (DummyClassDelNew)" in finalizeMsgList)
+ assert("H2 finalized (acquired by object)" in finalizeMsgList)
+
+ def test_objectResurrection_oldStyleClass(self):
+ ResurrectableDummyClass.__del__ = delI
+ I = ResurrectableDummyClass("I")
+ I = None
+ runGCIfJython()
+ assert("I finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_I) == "I")
+
+ def test_objectDoubleResurrection_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClass.__del__ = delJ
+ J = ResurrectableDummyClass("J")
+ J = None
+
+ runGCIfJython()
+ assert("J finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ global resurrectedObject_J
+ assert(str(resurrectedObject_J) == "J")
+ J = resurrectedObject_J
+ resurrectedObject_J = None
+ assert(resurrectedObject_J is None)
+ try:
+ #For Jython one can restore the finalizer manually.
+ #This is offered as an easy fix if the CPython behavior
+ #in this test should be needed for some reason.
+ J.__ensure_finalizer__()
+ except:
+ pass
+ J = None
+
+ runGCIfJython()
+ assert(str(resurrectedObject_J) == "J")
+ resurrectedObject_J.doResurrection = False
+ try:
+ #again...
+ resurrectedObject_J.__ensure_finalizer__()
+ except:
+ pass
+ resurrectedObject_J = None
+
+ runGCIfJython()
+ assert(resurrectedObject_J is None)
+
+
+ def test_objectDoubleResurrectionAndFinalize_oldStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClass.__del__ = delK
+ K = ResurrectableDummyClass("K")
+ K = None
+
+ runGCIfJython()
+ assert("K finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ finalizeMsgList.remove("K finalized (ResurrectableDummyClass)")
+ assert("K finalized (ResurrectableDummyClass)" not in finalizeMsgList)
+ global resurrectedObject_K
+ assert(str(resurrectedObject_K) == "K")
+ K = resurrectedObject_K
+ resurrectedObject_K = None
+ assert(resurrectedObject_K is None)
+ try:
+ K.__ensure_finalizer__()
+ except:
+ pass
+ K = None
+
+ runGCIfJython()
+ assert("K finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_K) == "K")
+
+ def test_objectResurrection_newStyleClass(self):
+ ResurrectableDummyClassNew.__del__ = delL
+ L = ResurrectableDummyClassNew("L")
+ L = None
+ runGCIfJython()
+ assert("L finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_L) == "L")
+
+ def test_objectDoubleResurrection_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClassNew.__del__ = delM
+ M = ResurrectableDummyClassNew("M")
+ M = None
+
+ runGCIfJython()
+ assert("M finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ global resurrectedObject_M
+ assert(str(resurrectedObject_M) == "M")
+ M = resurrectedObject_M
+ resurrectedObject_M = None
+ assert(resurrectedObject_M is None)
+ try:
+ M.__ensure_finalizer__()
+ except:
+ pass
+ M = None
+
+ runGCIfJython()
+ assert(str(resurrectedObject_M) == "M")
+
+ def test_objectDoubleResurrectionAndFinalize_newStyleClass(self):
+ #okay to fail in Jython without the manual ensureFinalizer calls
+ ResurrectableDummyClassNew.__del__ = delN
+ N = ResurrectableDummyClassNew("N")
+ N = None
+
+ runGCIfJython()
+ assert("N finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ finalizeMsgList.remove("N finalized (ResurrectableDummyClass)")
+ assert("N finalized (ResurrectableDummyClass)" not in finalizeMsgList)
+ global resurrectedObject_N
+ assert(str(resurrectedObject_N) == "N")
+ N = resurrectedObject_N
+ resurrectedObject_N = None
+ assert(resurrectedObject_N is None)
+ try:
+ N.__ensure_finalizer__()
+ except:
+ pass
+ N = None
+
+ runGCIfJython()
+ assert("N finalized (ResurrectableDummyClass)" in finalizeMsgList)
+ assert(str(resurrectedObject_N) == "N")
+
+ def test_file_overwrite_del(self):
+ O = DummyFileClassNew("O")
+ O = None
+
+ runGCIfJython()
+ assert("O finalized (DummyFileClassNew)" in finalizeMsgList)
+
+if __name__ == '__main__':
+ unittest.main()
+
diff --git a/src/org/python/antlr/ast/AssertDerived.java b/src/org/python/antlr/ast/AssertDerived.java
--- a/src/org/python/antlr/ast/AssertDerived.java
+++ b/src/org/python/antlr/ast/AssertDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AssertDerived extends Assert implements Slotted {
+public class AssertDerived extends Assert implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/AssignDerived.java b/src/org/python/antlr/ast/AssignDerived.java
--- a/src/org/python/antlr/ast/AssignDerived.java
+++ b/src/org/python/antlr/ast/AssignDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AssignDerived extends Assign implements Slotted {
+public class AssignDerived extends Assign implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/AttributeDerived.java b/src/org/python/antlr/ast/AttributeDerived.java
--- a/src/org/python/antlr/ast/AttributeDerived.java
+++ b/src/org/python/antlr/ast/AttributeDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AttributeDerived extends Attribute implements Slotted {
+public class AttributeDerived extends Attribute implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/AugAssignDerived.java b/src/org/python/antlr/ast/AugAssignDerived.java
--- a/src/org/python/antlr/ast/AugAssignDerived.java
+++ b/src/org/python/antlr/ast/AugAssignDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AugAssignDerived extends AugAssign implements Slotted {
+public class AugAssignDerived extends AugAssign implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/BinOpDerived.java b/src/org/python/antlr/ast/BinOpDerived.java
--- a/src/org/python/antlr/ast/BinOpDerived.java
+++ b/src/org/python/antlr/ast/BinOpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BinOpDerived extends BinOp implements Slotted {
+public class BinOpDerived extends BinOp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/BoolOpDerived.java b/src/org/python/antlr/ast/BoolOpDerived.java
--- a/src/org/python/antlr/ast/BoolOpDerived.java
+++ b/src/org/python/antlr/ast/BoolOpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BoolOpDerived extends BoolOp implements Slotted {
+public class BoolOpDerived extends BoolOp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/BreakDerived.java b/src/org/python/antlr/ast/BreakDerived.java
--- a/src/org/python/antlr/ast/BreakDerived.java
+++ b/src/org/python/antlr/ast/BreakDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BreakDerived extends Break implements Slotted {
+public class BreakDerived extends Break implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/CallDerived.java b/src/org/python/antlr/ast/CallDerived.java
--- a/src/org/python/antlr/ast/CallDerived.java
+++ b/src/org/python/antlr/ast/CallDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class CallDerived extends Call implements Slotted {
+public class CallDerived extends Call implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ClassDefDerived.java b/src/org/python/antlr/ast/ClassDefDerived.java
--- a/src/org/python/antlr/ast/ClassDefDerived.java
+++ b/src/org/python/antlr/ast/ClassDefDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ClassDefDerived extends ClassDef implements Slotted {
+public class ClassDefDerived extends ClassDef implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/CompareDerived.java b/src/org/python/antlr/ast/CompareDerived.java
--- a/src/org/python/antlr/ast/CompareDerived.java
+++ b/src/org/python/antlr/ast/CompareDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class CompareDerived extends Compare implements Slotted {
+public class CompareDerived extends Compare implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ContinueDerived.java b/src/org/python/antlr/ast/ContinueDerived.java
--- a/src/org/python/antlr/ast/ContinueDerived.java
+++ b/src/org/python/antlr/ast/ContinueDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ContinueDerived extends Continue implements Slotted {
+public class ContinueDerived extends Continue implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/DeleteDerived.java b/src/org/python/antlr/ast/DeleteDerived.java
--- a/src/org/python/antlr/ast/DeleteDerived.java
+++ b/src/org/python/antlr/ast/DeleteDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class DeleteDerived extends Delete implements Slotted {
+public class DeleteDerived extends Delete implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/DictDerived.java b/src/org/python/antlr/ast/DictDerived.java
--- a/src/org/python/antlr/ast/DictDerived.java
+++ b/src/org/python/antlr/ast/DictDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class DictDerived extends Dict implements Slotted {
+public class DictDerived extends Dict implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/EllipsisDerived.java b/src/org/python/antlr/ast/EllipsisDerived.java
--- a/src/org/python/antlr/ast/EllipsisDerived.java
+++ b/src/org/python/antlr/ast/EllipsisDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class EllipsisDerived extends Ellipsis implements Slotted {
+public class EllipsisDerived extends Ellipsis implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExceptHandlerDerived.java b/src/org/python/antlr/ast/ExceptHandlerDerived.java
--- a/src/org/python/antlr/ast/ExceptHandlerDerived.java
+++ b/src/org/python/antlr/ast/ExceptHandlerDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExceptHandlerDerived extends ExceptHandler implements Slotted {
+public class ExceptHandlerDerived extends ExceptHandler implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExecDerived.java b/src/org/python/antlr/ast/ExecDerived.java
--- a/src/org/python/antlr/ast/ExecDerived.java
+++ b/src/org/python/antlr/ast/ExecDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExecDerived extends Exec implements Slotted {
+public class ExecDerived extends Exec implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExprDerived.java b/src/org/python/antlr/ast/ExprDerived.java
--- a/src/org/python/antlr/ast/ExprDerived.java
+++ b/src/org/python/antlr/ast/ExprDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExprDerived extends Expr implements Slotted {
+public class ExprDerived extends Expr implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExpressionDerived.java b/src/org/python/antlr/ast/ExpressionDerived.java
--- a/src/org/python/antlr/ast/ExpressionDerived.java
+++ b/src/org/python/antlr/ast/ExpressionDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExpressionDerived extends Expression implements Slotted {
+public class ExpressionDerived extends Expression implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ExtSliceDerived.java b/src/org/python/antlr/ast/ExtSliceDerived.java
--- a/src/org/python/antlr/ast/ExtSliceDerived.java
+++ b/src/org/python/antlr/ast/ExtSliceDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ExtSliceDerived extends ExtSlice implements Slotted {
+public class ExtSliceDerived extends ExtSlice implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ForDerived.java b/src/org/python/antlr/ast/ForDerived.java
--- a/src/org/python/antlr/ast/ForDerived.java
+++ b/src/org/python/antlr/ast/ForDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ForDerived extends For implements Slotted {
+public class ForDerived extends For implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/FunctionDefDerived.java b/src/org/python/antlr/ast/FunctionDefDerived.java
--- a/src/org/python/antlr/ast/FunctionDefDerived.java
+++ b/src/org/python/antlr/ast/FunctionDefDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class FunctionDefDerived extends FunctionDef implements Slotted {
+public class FunctionDefDerived extends FunctionDef implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/GeneratorExpDerived.java b/src/org/python/antlr/ast/GeneratorExpDerived.java
--- a/src/org/python/antlr/ast/GeneratorExpDerived.java
+++ b/src/org/python/antlr/ast/GeneratorExpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class GeneratorExpDerived extends GeneratorExp implements Slotted {
+public class GeneratorExpDerived extends GeneratorExp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/GlobalDerived.java b/src/org/python/antlr/ast/GlobalDerived.java
--- a/src/org/python/antlr/ast/GlobalDerived.java
+++ b/src/org/python/antlr/ast/GlobalDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class GlobalDerived extends Global implements Slotted {
+public class GlobalDerived extends Global implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/IfDerived.java b/src/org/python/antlr/ast/IfDerived.java
--- a/src/org/python/antlr/ast/IfDerived.java
+++ b/src/org/python/antlr/ast/IfDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IfDerived extends If implements Slotted {
+public class IfDerived extends If implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/IfExpDerived.java b/src/org/python/antlr/ast/IfExpDerived.java
--- a/src/org/python/antlr/ast/IfExpDerived.java
+++ b/src/org/python/antlr/ast/IfExpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IfExpDerived extends IfExp implements Slotted {
+public class IfExpDerived extends IfExp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ImportDerived.java b/src/org/python/antlr/ast/ImportDerived.java
--- a/src/org/python/antlr/ast/ImportDerived.java
+++ b/src/org/python/antlr/ast/ImportDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ImportDerived extends Import implements Slotted {
+public class ImportDerived extends Import implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ImportFromDerived.java b/src/org/python/antlr/ast/ImportFromDerived.java
--- a/src/org/python/antlr/ast/ImportFromDerived.java
+++ b/src/org/python/antlr/ast/ImportFromDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ImportFromDerived extends ImportFrom implements Slotted {
+public class ImportFromDerived extends ImportFrom implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/IndexDerived.java b/src/org/python/antlr/ast/IndexDerived.java
--- a/src/org/python/antlr/ast/IndexDerived.java
+++ b/src/org/python/antlr/ast/IndexDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IndexDerived extends Index implements Slotted {
+public class IndexDerived extends Index implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/InteractiveDerived.java b/src/org/python/antlr/ast/InteractiveDerived.java
--- a/src/org/python/antlr/ast/InteractiveDerived.java
+++ b/src/org/python/antlr/ast/InteractiveDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class InteractiveDerived extends Interactive implements Slotted {
+public class InteractiveDerived extends Interactive implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/LambdaDerived.java b/src/org/python/antlr/ast/LambdaDerived.java
--- a/src/org/python/antlr/ast/LambdaDerived.java
+++ b/src/org/python/antlr/ast/LambdaDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LambdaDerived extends Lambda implements Slotted {
+public class LambdaDerived extends Lambda implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ListCompDerived.java b/src/org/python/antlr/ast/ListCompDerived.java
--- a/src/org/python/antlr/ast/ListCompDerived.java
+++ b/src/org/python/antlr/ast/ListCompDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ListCompDerived extends ListComp implements Slotted {
+public class ListCompDerived extends ListComp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ListDerived.java b/src/org/python/antlr/ast/ListDerived.java
--- a/src/org/python/antlr/ast/ListDerived.java
+++ b/src/org/python/antlr/ast/ListDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ListDerived extends List implements Slotted {
+public class ListDerived extends List implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ModuleDerived.java b/src/org/python/antlr/ast/ModuleDerived.java
--- a/src/org/python/antlr/ast/ModuleDerived.java
+++ b/src/org/python/antlr/ast/ModuleDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ModuleDerived extends Module implements Slotted {
+public class ModuleDerived extends Module implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/NameDerived.java b/src/org/python/antlr/ast/NameDerived.java
--- a/src/org/python/antlr/ast/NameDerived.java
+++ b/src/org/python/antlr/ast/NameDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NameDerived extends Name implements Slotted {
+public class NameDerived extends Name implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/NumDerived.java b/src/org/python/antlr/ast/NumDerived.java
--- a/src/org/python/antlr/ast/NumDerived.java
+++ b/src/org/python/antlr/ast/NumDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NumDerived extends Num implements Slotted {
+public class NumDerived extends Num implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/PassDerived.java b/src/org/python/antlr/ast/PassDerived.java
--- a/src/org/python/antlr/ast/PassDerived.java
+++ b/src/org/python/antlr/ast/PassDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PassDerived extends Pass implements Slotted {
+public class PassDerived extends Pass implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/PrintDerived.java b/src/org/python/antlr/ast/PrintDerived.java
--- a/src/org/python/antlr/ast/PrintDerived.java
+++ b/src/org/python/antlr/ast/PrintDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PrintDerived extends Print implements Slotted {
+public class PrintDerived extends Print implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/RaiseDerived.java b/src/org/python/antlr/ast/RaiseDerived.java
--- a/src/org/python/antlr/ast/RaiseDerived.java
+++ b/src/org/python/antlr/ast/RaiseDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class RaiseDerived extends Raise implements Slotted {
+public class RaiseDerived extends Raise implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ReprDerived.java b/src/org/python/antlr/ast/ReprDerived.java
--- a/src/org/python/antlr/ast/ReprDerived.java
+++ b/src/org/python/antlr/ast/ReprDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ReprDerived extends Repr implements Slotted {
+public class ReprDerived extends Repr implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/ReturnDerived.java b/src/org/python/antlr/ast/ReturnDerived.java
--- a/src/org/python/antlr/ast/ReturnDerived.java
+++ b/src/org/python/antlr/ast/ReturnDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ReturnDerived extends Return implements Slotted {
+public class ReturnDerived extends Return implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/SliceDerived.java b/src/org/python/antlr/ast/SliceDerived.java
--- a/src/org/python/antlr/ast/SliceDerived.java
+++ b/src/org/python/antlr/ast/SliceDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class SliceDerived extends Slice implements Slotted {
+public class SliceDerived extends Slice implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/StrDerived.java b/src/org/python/antlr/ast/StrDerived.java
--- a/src/org/python/antlr/ast/StrDerived.java
+++ b/src/org/python/antlr/ast/StrDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class StrDerived extends Str implements Slotted {
+public class StrDerived extends Str implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/SubscriptDerived.java b/src/org/python/antlr/ast/SubscriptDerived.java
--- a/src/org/python/antlr/ast/SubscriptDerived.java
+++ b/src/org/python/antlr/ast/SubscriptDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class SubscriptDerived extends Subscript implements Slotted {
+public class SubscriptDerived extends Subscript implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/SuiteDerived.java b/src/org/python/antlr/ast/SuiteDerived.java
--- a/src/org/python/antlr/ast/SuiteDerived.java
+++ b/src/org/python/antlr/ast/SuiteDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class SuiteDerived extends Suite implements Slotted {
+public class SuiteDerived extends Suite implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/TryExceptDerived.java b/src/org/python/antlr/ast/TryExceptDerived.java
--- a/src/org/python/antlr/ast/TryExceptDerived.java
+++ b/src/org/python/antlr/ast/TryExceptDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class TryExceptDerived extends TryExcept implements Slotted {
+public class TryExceptDerived extends TryExcept implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/TryFinallyDerived.java b/src/org/python/antlr/ast/TryFinallyDerived.java
--- a/src/org/python/antlr/ast/TryFinallyDerived.java
+++ b/src/org/python/antlr/ast/TryFinallyDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class TryFinallyDerived extends TryFinally implements Slotted {
+public class TryFinallyDerived extends TryFinally implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/TupleDerived.java b/src/org/python/antlr/ast/TupleDerived.java
--- a/src/org/python/antlr/ast/TupleDerived.java
+++ b/src/org/python/antlr/ast/TupleDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class TupleDerived extends Tuple implements Slotted {
+public class TupleDerived extends Tuple implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/UnaryOpDerived.java b/src/org/python/antlr/ast/UnaryOpDerived.java
--- a/src/org/python/antlr/ast/UnaryOpDerived.java
+++ b/src/org/python/antlr/ast/UnaryOpDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class UnaryOpDerived extends UnaryOp implements Slotted {
+public class UnaryOpDerived extends UnaryOp implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/WhileDerived.java b/src/org/python/antlr/ast/WhileDerived.java
--- a/src/org/python/antlr/ast/WhileDerived.java
+++ b/src/org/python/antlr/ast/WhileDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class WhileDerived extends While implements Slotted {
+public class WhileDerived extends While implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/WithDerived.java b/src/org/python/antlr/ast/WithDerived.java
--- a/src/org/python/antlr/ast/WithDerived.java
+++ b/src/org/python/antlr/ast/WithDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class WithDerived extends With implements Slotted {
+public class WithDerived extends With implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/YieldDerived.java b/src/org/python/antlr/ast/YieldDerived.java
--- a/src/org/python/antlr/ast/YieldDerived.java
+++ b/src/org/python/antlr/ast/YieldDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class YieldDerived extends Yield implements Slotted {
+public class YieldDerived extends Yield implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/aliasDerived.java b/src/org/python/antlr/ast/aliasDerived.java
--- a/src/org/python/antlr/ast/aliasDerived.java
+++ b/src/org/python/antlr/ast/aliasDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class aliasDerived extends alias implements Slotted {
+public class aliasDerived extends alias implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/argumentsDerived.java b/src/org/python/antlr/ast/argumentsDerived.java
--- a/src/org/python/antlr/ast/argumentsDerived.java
+++ b/src/org/python/antlr/ast/argumentsDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class argumentsDerived extends arguments implements Slotted {
+public class argumentsDerived extends arguments implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/comprehensionDerived.java b/src/org/python/antlr/ast/comprehensionDerived.java
--- a/src/org/python/antlr/ast/comprehensionDerived.java
+++ b/src/org/python/antlr/ast/comprehensionDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class comprehensionDerived extends comprehension implements Slotted {
+public class comprehensionDerived extends comprehension implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/ast/keywordDerived.java b/src/org/python/antlr/ast/keywordDerived.java
--- a/src/org/python/antlr/ast/keywordDerived.java
+++ b/src/org/python/antlr/ast/keywordDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class keywordDerived extends keyword implements Slotted {
+public class keywordDerived extends keyword implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/AddDerived.java b/src/org/python/antlr/op/AddDerived.java
--- a/src/org/python/antlr/op/AddDerived.java
+++ b/src/org/python/antlr/op/AddDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AddDerived extends Add implements Slotted {
+public class AddDerived extends Add implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/AndDerived.java b/src/org/python/antlr/op/AndDerived.java
--- a/src/org/python/antlr/op/AndDerived.java
+++ b/src/org/python/antlr/op/AndDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AndDerived extends And implements Slotted {
+public class AndDerived extends And implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/AugLoadDerived.java b/src/org/python/antlr/op/AugLoadDerived.java
--- a/src/org/python/antlr/op/AugLoadDerived.java
+++ b/src/org/python/antlr/op/AugLoadDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AugLoadDerived extends AugLoad implements Slotted {
+public class AugLoadDerived extends AugLoad implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/AugStoreDerived.java b/src/org/python/antlr/op/AugStoreDerived.java
--- a/src/org/python/antlr/op/AugStoreDerived.java
+++ b/src/org/python/antlr/op/AugStoreDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class AugStoreDerived extends AugStore implements Slotted {
+public class AugStoreDerived extends AugStore implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/BitAndDerived.java b/src/org/python/antlr/op/BitAndDerived.java
--- a/src/org/python/antlr/op/BitAndDerived.java
+++ b/src/org/python/antlr/op/BitAndDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BitAndDerived extends BitAnd implements Slotted {
+public class BitAndDerived extends BitAnd implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/BitOrDerived.java b/src/org/python/antlr/op/BitOrDerived.java
--- a/src/org/python/antlr/op/BitOrDerived.java
+++ b/src/org/python/antlr/op/BitOrDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BitOrDerived extends BitOr implements Slotted {
+public class BitOrDerived extends BitOr implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/BitXorDerived.java b/src/org/python/antlr/op/BitXorDerived.java
--- a/src/org/python/antlr/op/BitXorDerived.java
+++ b/src/org/python/antlr/op/BitXorDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class BitXorDerived extends BitXor implements Slotted {
+public class BitXorDerived extends BitXor implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/DelDerived.java b/src/org/python/antlr/op/DelDerived.java
--- a/src/org/python/antlr/op/DelDerived.java
+++ b/src/org/python/antlr/op/DelDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class DelDerived extends Del implements Slotted {
+public class DelDerived extends Del implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/DivDerived.java b/src/org/python/antlr/op/DivDerived.java
--- a/src/org/python/antlr/op/DivDerived.java
+++ b/src/org/python/antlr/op/DivDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class DivDerived extends Div implements Slotted {
+public class DivDerived extends Div implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/EqDerived.java b/src/org/python/antlr/op/EqDerived.java
--- a/src/org/python/antlr/op/EqDerived.java
+++ b/src/org/python/antlr/op/EqDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class EqDerived extends Eq implements Slotted {
+public class EqDerived extends Eq implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/FloorDivDerived.java b/src/org/python/antlr/op/FloorDivDerived.java
--- a/src/org/python/antlr/op/FloorDivDerived.java
+++ b/src/org/python/antlr/op/FloorDivDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class FloorDivDerived extends FloorDiv implements Slotted {
+public class FloorDivDerived extends FloorDiv implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/GtDerived.java b/src/org/python/antlr/op/GtDerived.java
--- a/src/org/python/antlr/op/GtDerived.java
+++ b/src/org/python/antlr/op/GtDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class GtDerived extends Gt implements Slotted {
+public class GtDerived extends Gt implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/GtEDerived.java b/src/org/python/antlr/op/GtEDerived.java
--- a/src/org/python/antlr/op/GtEDerived.java
+++ b/src/org/python/antlr/op/GtEDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class GtEDerived extends GtE implements Slotted {
+public class GtEDerived extends GtE implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/InDerived.java b/src/org/python/antlr/op/InDerived.java
--- a/src/org/python/antlr/op/InDerived.java
+++ b/src/org/python/antlr/op/InDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class InDerived extends In implements Slotted {
+public class InDerived extends In implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/InvertDerived.java b/src/org/python/antlr/op/InvertDerived.java
--- a/src/org/python/antlr/op/InvertDerived.java
+++ b/src/org/python/antlr/op/InvertDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class InvertDerived extends Invert implements Slotted {
+public class InvertDerived extends Invert implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/IsDerived.java b/src/org/python/antlr/op/IsDerived.java
--- a/src/org/python/antlr/op/IsDerived.java
+++ b/src/org/python/antlr/op/IsDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IsDerived extends Is implements Slotted {
+public class IsDerived extends Is implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/IsNotDerived.java b/src/org/python/antlr/op/IsNotDerived.java
--- a/src/org/python/antlr/op/IsNotDerived.java
+++ b/src/org/python/antlr/op/IsNotDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class IsNotDerived extends IsNot implements Slotted {
+public class IsNotDerived extends IsNot implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/LShiftDerived.java b/src/org/python/antlr/op/LShiftDerived.java
--- a/src/org/python/antlr/op/LShiftDerived.java
+++ b/src/org/python/antlr/op/LShiftDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LShiftDerived extends LShift implements Slotted {
+public class LShiftDerived extends LShift implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/LoadDerived.java b/src/org/python/antlr/op/LoadDerived.java
--- a/src/org/python/antlr/op/LoadDerived.java
+++ b/src/org/python/antlr/op/LoadDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LoadDerived extends Load implements Slotted {
+public class LoadDerived extends Load implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/LtDerived.java b/src/org/python/antlr/op/LtDerived.java
--- a/src/org/python/antlr/op/LtDerived.java
+++ b/src/org/python/antlr/op/LtDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LtDerived extends Lt implements Slotted {
+public class LtDerived extends Lt implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/LtEDerived.java b/src/org/python/antlr/op/LtEDerived.java
--- a/src/org/python/antlr/op/LtEDerived.java
+++ b/src/org/python/antlr/op/LtEDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class LtEDerived extends LtE implements Slotted {
+public class LtEDerived extends LtE implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/ModDerived.java b/src/org/python/antlr/op/ModDerived.java
--- a/src/org/python/antlr/op/ModDerived.java
+++ b/src/org/python/antlr/op/ModDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ModDerived extends Mod implements Slotted {
+public class ModDerived extends Mod implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/MultDerived.java b/src/org/python/antlr/op/MultDerived.java
--- a/src/org/python/antlr/op/MultDerived.java
+++ b/src/org/python/antlr/op/MultDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class MultDerived extends Mult implements Slotted {
+public class MultDerived extends Mult implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/NotDerived.java b/src/org/python/antlr/op/NotDerived.java
--- a/src/org/python/antlr/op/NotDerived.java
+++ b/src/org/python/antlr/op/NotDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NotDerived extends Not implements Slotted {
+public class NotDerived extends Not implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/NotEqDerived.java b/src/org/python/antlr/op/NotEqDerived.java
--- a/src/org/python/antlr/op/NotEqDerived.java
+++ b/src/org/python/antlr/op/NotEqDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NotEqDerived extends NotEq implements Slotted {
+public class NotEqDerived extends NotEq implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/NotInDerived.java b/src/org/python/antlr/op/NotInDerived.java
--- a/src/org/python/antlr/op/NotInDerived.java
+++ b/src/org/python/antlr/op/NotInDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class NotInDerived extends NotIn implements Slotted {
+public class NotInDerived extends NotIn implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/OrDerived.java b/src/org/python/antlr/op/OrDerived.java
--- a/src/org/python/antlr/op/OrDerived.java
+++ b/src/org/python/antlr/op/OrDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class OrDerived extends Or implements Slotted {
+public class OrDerived extends Or implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/ParamDerived.java b/src/org/python/antlr/op/ParamDerived.java
--- a/src/org/python/antlr/op/ParamDerived.java
+++ b/src/org/python/antlr/op/ParamDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ParamDerived extends Param implements Slotted {
+public class ParamDerived extends Param implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/PowDerived.java b/src/org/python/antlr/op/PowDerived.java
--- a/src/org/python/antlr/op/PowDerived.java
+++ b/src/org/python/antlr/op/PowDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PowDerived extends Pow implements Slotted {
+public class PowDerived extends Pow implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/RShiftDerived.java b/src/org/python/antlr/op/RShiftDerived.java
--- a/src/org/python/antlr/op/RShiftDerived.java
+++ b/src/org/python/antlr/op/RShiftDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class RShiftDerived extends RShift implements Slotted {
+public class RShiftDerived extends RShift implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/StoreDerived.java b/src/org/python/antlr/op/StoreDerived.java
--- a/src/org/python/antlr/op/StoreDerived.java
+++ b/src/org/python/antlr/op/StoreDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class StoreDerived extends Store implements Slotted {
+public class StoreDerived extends Store implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/SubDerived.java b/src/org/python/antlr/op/SubDerived.java
--- a/src/org/python/antlr/op/SubDerived.java
+++ b/src/org/python/antlr/op/SubDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class SubDerived extends Sub implements Slotted {
+public class SubDerived extends Sub implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/UAddDerived.java b/src/org/python/antlr/op/UAddDerived.java
--- a/src/org/python/antlr/op/UAddDerived.java
+++ b/src/org/python/antlr/op/UAddDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class UAddDerived extends UAdd implements Slotted {
+public class UAddDerived extends UAdd implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/antlr/op/USubDerived.java b/src/org/python/antlr/op/USubDerived.java
--- a/src/org/python/antlr/op/USubDerived.java
+++ b/src/org/python/antlr/op/USubDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class USubDerived extends USub implements Slotted {
+public class USubDerived extends USub implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/ClasspathPyImporterDerived.java b/src/org/python/core/ClasspathPyImporterDerived.java
--- a/src/org/python/core/ClasspathPyImporterDerived.java
+++ b/src/org/python/core/ClasspathPyImporterDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ClasspathPyImporterDerived extends ClasspathPyImporter implements Slotted {
+public class ClasspathPyImporterDerived extends ClasspathPyImporter implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,9 +19,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public ClasspathPyImporterDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -978,6 +997,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/Py.java b/src/org/python/core/Py.java
--- a/src/org/python/core/Py.java
+++ b/src/org/python/core/Py.java
@@ -837,27 +837,27 @@
* @throws ClassNotFoundException if the class wasn't found by the class loader
*/
private static Class> findClassInternal(String name, String reason) throws ClassNotFoundException {
- ClassLoader classLoader = Py.getSystemState().getClassLoader();
+ ClassLoader classLoader = Py.getSystemState().getClassLoader();
if (classLoader != null) {
- if (reason != null) {
- writeDebug("import", "trying " + name + " as " + reason +
- " in sys.classLoader");
- }
+ if (reason != null) {
+ writeDebug("import", "trying " + name + " as " + reason +
+ " in sys.classLoader");
+ }
return loadAndInitClass(name, classLoader);
}
if (!syspathJavaLoaderRestricted) {
try {
classLoader = imp.getSyspathJavaLoader();
if (classLoader != null && reason != null) {
- writeDebug("import", "trying " + name + " as " + reason +
- " in SysPathJavaLoader");
+ writeDebug("import", "trying " + name + " as " + reason +
+ " in SysPathJavaLoader");
}
} catch (SecurityException e) {
syspathJavaLoaderRestricted = true;
}
}
if (syspathJavaLoaderRestricted) {
- classLoader = imp.getParentClassLoader();
+ classLoader = imp.getParentClassLoader();
if (classLoader != null && reason != null) {
writeDebug("import", "trying " + name + " as " + reason +
" in Jython's parent class loader");
@@ -865,20 +865,20 @@
}
if (classLoader != null) {
try {
- return loadAndInitClass(name, classLoader);
+ return loadAndInitClass(name, classLoader);
} catch (ClassNotFoundException cnfe) {
// let the default classloader try
- // XXX: by trying another classloader that may not be on a
- // parent/child relationship with the Jython's parent
- // classsloader we are risking some nasty class loading
- // problems (such as having two incompatible copies for
- // the same class that is itself a dependency of two
- // classes loaded from these two different class loaders)
+ // XXX: by trying another classloader that may not be on a
+ // parent/child relationship with the Jython's parent
+ // classsloader we are risking some nasty class loading
+ // problems (such as having two incompatible copies for
+ // the same class that is itself a dependency of two
+ // classes loaded from these two different class loaders)
}
}
if (reason != null) {
- writeDebug("import", "trying " + name + " as " + reason +
- " in context class loader, for backwards compatibility");
+ writeDebug("import", "trying " + name + " as " + reason +
+ " in context class loader, for backwards compatibility");
}
return loadAndInitClass(name, Thread.currentThread().getContextClassLoader());
}
@@ -890,7 +890,7 @@
*/
public static Class> findClass(String name) {
try {
- return findClassInternal(name, null);
+ return findClassInternal(name, null);
} catch (ClassNotFoundException e) {
// e.printStackTrace();
return null;
@@ -930,7 +930,7 @@
// We *need* to initialize classes on findClass/findClassEx, so that import
// statements can trigger static initializers
private static Class> loadAndInitClass(String name, ClassLoader loader) throws ClassNotFoundException {
- return Class.forName(name, true, loader);
+ return Class.forName(name, true, loader);
}
diff --git a/src/org/python/core/PyArrayDerived.java b/src/org/python/core/PyArrayDerived.java
--- a/src/org/python/core/PyArrayDerived.java
+++ b/src/org/python/core/PyArrayDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyArrayDerived extends PyArray implements Slotted {
+public class PyArrayDerived extends PyArray implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyBaseExceptionDerived.java b/src/org/python/core/PyBaseExceptionDerived.java
--- a/src/org/python/core/PyBaseExceptionDerived.java
+++ b/src/org/python/core/PyBaseExceptionDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyBaseExceptionDerived extends PyBaseException implements Slotted {
+public class PyBaseExceptionDerived extends PyBaseException implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,9 +19,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyBaseExceptionDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -978,6 +997,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyByteArrayDerived.java b/src/org/python/core/PyByteArrayDerived.java
--- a/src/org/python/core/PyByteArrayDerived.java
+++ b/src/org/python/core/PyByteArrayDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyByteArrayDerived extends PyByteArray implements Slotted {
+public class PyByteArrayDerived extends PyByteArray implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyClass.java b/src/org/python/core/PyClass.java
--- a/src/org/python/core/PyClass.java
+++ b/src/org/python/core/PyClass.java
@@ -3,6 +3,7 @@
import org.python.expose.ExposedNew;
import org.python.expose.ExposedType;
+import org.python.core.finalization.FinalizeTrigger;
/**
* The classic Python class.
@@ -185,11 +186,9 @@
@Override
public PyObject __call__(PyObject[] args, String[] keywords) {
PyInstance inst;
- if (__del__ == null) {
- inst = new PyInstance(this);
- } else {
- // the class defined a __del__ method
- inst = new PyFinalizableInstance(this);
+ inst = new PyInstance(this);
+ if (__del__ != null) {
+ inst.finalizeTrigger = FinalizeTrigger.makeTrigger(inst);
}
inst.__init__(args, keywords);
return inst;
diff --git a/src/org/python/core/PyClassMethodDerived.java b/src/org/python/core/PyClassMethodDerived.java
--- a/src/org/python/core/PyClassMethodDerived.java
+++ b/src/org/python/core/PyClassMethodDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyClassMethodDerived extends PyClassMethod implements Slotted {
+public class PyClassMethodDerived extends PyClassMethod implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyComplexDerived.java b/src/org/python/core/PyComplexDerived.java
--- a/src/org/python/core/PyComplexDerived.java
+++ b/src/org/python/core/PyComplexDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyComplexDerived extends PyComplex implements Slotted {
+public class PyComplexDerived extends PyComplex implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,real,imaginary);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyDictionaryDerived.java b/src/org/python/core/PyDictionaryDerived.java
--- a/src/org/python/core/PyDictionaryDerived.java
+++ b/src/org/python/core/PyDictionaryDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyDictionaryDerived extends PyDictionary implements Slotted {
+public class PyDictionaryDerived extends PyDictionary implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyEnumerateDerived.java b/src/org/python/core/PyEnumerateDerived.java
--- a/src/org/python/core/PyEnumerateDerived.java
+++ b/src/org/python/core/PyEnumerateDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyEnumerateDerived extends PyEnumerate implements Slotted {
+public class PyEnumerateDerived extends PyEnumerate implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,seq,start);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyFile.java b/src/org/python/core/PyFile.java
--- a/src/org/python/core/PyFile.java
+++ b/src/org/python/core/PyFile.java
@@ -8,6 +8,8 @@
import java.io.OutputStream;
import java.util.concurrent.Callable;
+import org.python.core.finalization.FinalizableBuiltin;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.core.io.BinaryIOWrapper;
import org.python.core.io.BufferedIOBase;
import org.python.core.io.BufferedRandom;
@@ -33,7 +35,7 @@
* The Python file type. Wraps an {@link TextIOBase} object.
*/
@ExposedType(name = "file", doc = BuiltinDocs.file_doc)
-public class PyFile extends PyObject {
+public class PyFile extends PyObject implements FinalizableBuiltin {
public static final PyType TYPE = PyType.fromClass(PyFile.class);
@@ -80,21 +82,26 @@
/** The file's closer object; ensures the file is closed at
* shutdown */
private Closer closer;
+
+ public FinalizeTrigger finalizeTrigger;
- public PyFile() {}
+ public PyFile() {finalizeTrigger = FinalizeTrigger.makeTrigger(this);}
public PyFile(PyType subType) {
super(subType);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
public PyFile(RawIOBase raw, String name, String mode, int bufsize) {
parseMode(mode);
file___init__(raw, name, mode, bufsize);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
public PyFile(InputStream istream, String name, String mode, int bufsize, boolean closefd) {
parseMode(mode);
file___init__(new StreamIO(istream, closefd), name, mode, bufsize);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
/**
@@ -126,6 +133,7 @@
public PyFile(OutputStream ostream, String name, String mode, int bufsize, boolean closefd) {
parseMode(mode);
file___init__(new StreamIO(ostream, closefd), name, mode, bufsize);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
/**
@@ -153,6 +161,7 @@
public PyFile(String name, String mode, int bufsize) {
file___init__(new FileIO(name, parseMode(mode)), name, mode, bufsize);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
@ExposedNew
@@ -674,8 +683,7 @@
}
@Override
- protected void finalize() throws Throwable {
- super.finalize();
+ public void __del_builtin__() {
if (closer != null) {
closer.close();
}
diff --git a/src/org/python/core/PyFileDerived.java b/src/org/python/core/PyFileDerived.java
--- a/src/org/python/core/PyFileDerived.java
+++ b/src/org/python/core/PyFileDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyFileDerived extends PyFile implements Slotted {
+public class PyFileDerived extends PyFile implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyFinalizableInstance.java b/src/org/python/core/PyFinalizableInstance.java
deleted file mode 100644
--- a/src/org/python/core/PyFinalizableInstance.java
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) Corporation for National Research Initiatives
-// These are just like normal instances, except that their classes included
-// a definition for __del__(), i.e. Python's finalizer. These two instance
-// types have to be separated due to Java performance issues.
-
-package org.python.core;
-
-
-/**
- * A python class instance with __del__ defined.
- *
- * This is a special class due to performance. Defining
- * finalize() on a class, makes the class a lot slower.
- */
-public class PyFinalizableInstance extends PyInstance {
-
- public PyFinalizableInstance(PyClass iclass) {
- super(iclass);
- }
-
- // __del__ method is invoked upon object finalization.
- @Override
- protected void finalize() {
- try {
- instclass.__del__.__call__(this);
- } catch (PyException exc) {
- // Try to get the right method description.
- PyObject method = instclass.__del__;
- try {
- method = __findattr__("__del__");
- } catch (PyException e) {
- // nothing we can do
- }
- Py.writeUnraisable(exc, method);
- }
- }
-}
diff --git a/src/org/python/core/PyFloatDerived.java b/src/org/python/core/PyFloatDerived.java
--- a/src/org/python/core/PyFloatDerived.java
+++ b/src/org/python/core/PyFloatDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyFloatDerived extends PyFloat implements Slotted {
+public class PyFloatDerived extends PyFloat implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,v);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyFrozenSetDerived.java b/src/org/python/core/PyFrozenSetDerived.java
--- a/src/org/python/core/PyFrozenSetDerived.java
+++ b/src/org/python/core/PyFrozenSetDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyFrozenSetDerived extends PyFrozenSet implements Slotted {
+public class PyFrozenSetDerived extends PyFrozenSet implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,data);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyGenerator.java b/src/org/python/core/PyGenerator.java
--- a/src/org/python/core/PyGenerator.java
+++ b/src/org/python/core/PyGenerator.java
@@ -1,12 +1,14 @@
/* Copyright (c) Jython Developers */
package org.python.core;
+import org.python.core.finalization.FinalizableBuiltin;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.expose.ExposedGet;
import org.python.expose.ExposedMethod;
import org.python.expose.ExposedType;
@ExposedType(name = "generator", base = PyObject.class, isBaseType = false)
-public class PyGenerator extends PyIterator {
+public class PyGenerator extends PyIterator implements FinalizableBuiltin {
public static final PyType TYPE = PyType.fromClass(PyGenerator.class);
@@ -20,6 +22,8 @@
protected boolean gi_running;
private PyObject closure;
+
+ public FinalizeTrigger finalizeTrigger;
public PyGenerator(PyFrame frame, PyObject closure) {
super(TYPE);
@@ -28,6 +32,7 @@
gi_code = gi_frame.f_code;
}
this.closure = closure;
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
public PyObject send(PyObject value) {
@@ -105,9 +110,9 @@
gi_frame.setGeneratorInput(ex);
return next();
}
-
+
@Override
- protected void finalize() throws Throwable {
+ public void __del_builtin__() {
if (gi_frame == null || gi_frame.f_lasti == -1) {
return;
}
@@ -127,8 +132,6 @@
} catch (Throwable t) {
// but we currently ignore any Java exception completely. perhaps we
// can also output something meaningful too?
- } finally {
- super.finalize();
}
}
diff --git a/src/org/python/core/PyInstance.java b/src/org/python/core/PyInstance.java
--- a/src/org/python/core/PyInstance.java
+++ b/src/org/python/core/PyInstance.java
@@ -6,14 +6,20 @@
import org.python.expose.ExposedType;
import org.python.expose.MethodType;
+import org.python.core.finalization.FinalizablePyObject;
+import org.python.core.finalization.FinalizeTrigger;
+
/**
* An instance of a classic Python class.
*/
@ExposedType(name = "instance", isBaseType = false)
-public class PyInstance extends PyObject {
+public class PyInstance extends PyObject implements FinalizablePyObject {
public static final PyType TYPE = PyType.fromClass(PyInstance.class);
+ public FinalizeTrigger finalizeTrigger;
+ private static JavaFunc __ensure_finalizer__Function;
+
// xxx doc, final name
public transient PyClass instclass;
@@ -147,9 +153,27 @@
return ifindfunction(name);
}
+ public static void ensureFinalizer(PyObject[] args, String[] kws) {
+ FinalizeTrigger.ensureFinalizer((PyInstance) args[0]);
+ }
+
+ private static JavaFunc makeFunction__ensure_finalizer__() {
+ try {
+ return new JavaFunc(
+ PyInstance.class.getMethod("ensureFinalizer",
+ PyObject[].class, String[].class));
+ } catch (Exception e) {return null;} //cannot happen
+ }
+
protected PyObject ifindlocal(String name) {
if (name == "__dict__") return __dict__;
if (name == "__class__") return instclass;
+ if (name == "__ensure_finalizer__") {
+ if (__ensure_finalizer__Function == null) {
+ __ensure_finalizer__Function = makeFunction__ensure_finalizer__();
+ }
+ return new PyMethod(__ensure_finalizer__Function, this, instclass);
+ }
if (__dict__ == null) return null;
return __dict__.__finditem__(name);
@@ -263,6 +287,9 @@
if (name == "__class__") {
if (value instanceof PyClass) {
instclass = (PyClass) value;
+ if (instclass.__del__ != null && finalizeTrigger == null) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__class__ must be set to a class");
}
@@ -278,6 +305,9 @@
} else {
__dict__.__setitem__(name, value);
}
+ if (name == "__del__" && finalizeTrigger == null) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
}
protected void noField(String name, PyObject value) {
@@ -1909,4 +1939,24 @@
return super.__ixor__(o);
}
+ @Override
+ public void __del__() {
+ try {
+ PyObject method = __findattr__("__del__");
+ if (method != null) {
+ method.__call__();
+ } else if (instclass.__del__ != null) {
+ instclass.__del__.__call__(this);
+ }
+ } catch (PyException exc) {
+ // Try to get the right method description.
+ PyObject method = instclass.__del__;
+ try {
+ method = __findattr__("__del__");
+ } catch (PyException e) {
+ // nothing we can do
+ }
+ Py.writeUnraisable(exc, method);
+ }
+ }
}
diff --git a/src/org/python/core/PyIntegerDerived.java b/src/org/python/core/PyIntegerDerived.java
--- a/src/org/python/core/PyIntegerDerived.java
+++ b/src/org/python/core/PyIntegerDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyIntegerDerived extends PyInteger implements Slotted {
+public class PyIntegerDerived extends PyInteger implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,v);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyListDerived.java b/src/org/python/core/PyListDerived.java
--- a/src/org/python/core/PyListDerived.java
+++ b/src/org/python/core/PyListDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyListDerived extends PyList implements Slotted {
+public class PyListDerived extends PyList implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyLongDerived.java b/src/org/python/core/PyLongDerived.java
--- a/src/org/python/core/PyLongDerived.java
+++ b/src/org/python/core/PyLongDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyLongDerived extends PyLong implements Slotted {
+public class PyLongDerived extends PyLong implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,v);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyModuleDerived.java b/src/org/python/core/PyModuleDerived.java
--- a/src/org/python/core/PyModuleDerived.java
+++ b/src/org/python/core/PyModuleDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyModuleDerived extends PyModule implements Slotted {
+public class PyModuleDerived extends PyModule implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,9 +19,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyModuleDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -978,6 +997,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyObject.java b/src/org/python/core/PyObject.java
--- a/src/org/python/core/PyObject.java
+++ b/src/org/python/core/PyObject.java
@@ -8,6 +8,7 @@
import java.util.List;
import java.util.Map;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.expose.ExposedClassMethod;
import org.python.expose.ExposedDelete;
import org.python.expose.ExposedGet;
@@ -99,6 +100,21 @@
return new_.for_type == subtype ? new PyObject() : new PyObjectDerived(subtype);
}
+ /**
+ *
+ * From Jython 2.7 on, {@code PyObject}s must not have finalizers directly.
+ * If a finalizer, a.k.a. {@code __del__} is needed, follow the instructions in the
+ * documentation of {@link org.python.core.finalization.FinalizablePyObject}.
+ *
+ *
+ * Note that this empty finalizer implementation is optimized away by the JVM
+ * (See {@link http://www.javaspecialists.eu/archive/Issue170.html}).
+ * So {@code PyObject}s are not expensively treaded as finalizable objects by the
+ * GC. Its only intention is to prevent subclasses from having Java-style finalizers.
+ *
+ */
+ protected final void finalize() throws Throwable {}
+
@ExposedMethod(doc = BuiltinDocs.object___init___doc)
final void object___init__(PyObject[] args, String[] keywords) {
}
@@ -223,6 +239,12 @@
return __repr__();
}
+ @ExposedMethod
+ public void __ensure_finalizer__() {
+ //PyObjects that implement HasFinalizeTrigger shall implement this method via:
+ //FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyUnicode __unicode__() {
return new PyUnicode(__str__());
}
diff --git a/src/org/python/core/PyObjectDerived.java b/src/org/python/core/PyObjectDerived.java
--- a/src/org/python/core/PyObjectDerived.java
+++ b/src/org/python/core/PyObjectDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyObjectDerived extends PyObject implements Slotted {
+public class PyObjectDerived extends PyObject implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyPropertyDerived.java b/src/org/python/core/PyPropertyDerived.java
--- a/src/org/python/core/PyPropertyDerived.java
+++ b/src/org/python/core/PyPropertyDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyPropertyDerived extends PyProperty implements Slotted {
+public class PyPropertyDerived extends PyProperty implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PySetDerived.java b/src/org/python/core/PySetDerived.java
--- a/src/org/python/core/PySetDerived.java
+++ b/src/org/python/core/PySetDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PySetDerived extends PySet implements Slotted {
+public class PySetDerived extends PySet implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyStringDerived.java b/src/org/python/core/PyStringDerived.java
--- a/src/org/python/core/PyStringDerived.java
+++ b/src/org/python/core/PyStringDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyStringDerived extends PyString implements Slotted {
+public class PyStringDerived extends PyString implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,v);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PySuperDerived.java b/src/org/python/core/PySuperDerived.java
--- a/src/org/python/core/PySuperDerived.java
+++ b/src/org/python/core/PySuperDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PySuperDerived extends PySuper implements Slotted {
+public class PySuperDerived extends PySuper implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyTupleDerived.java b/src/org/python/core/PyTupleDerived.java
--- a/src/org/python/core/PyTupleDerived.java
+++ b/src/org/python/core/PyTupleDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyTupleDerived extends PyTuple implements Slotted {
+public class PyTupleDerived extends PyTuple implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,elements);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyType.java b/src/org/python/core/PyType.java
--- a/src/org/python/core/PyType.java
+++ b/src/org/python/core/PyType.java
@@ -82,7 +82,7 @@
protected boolean needs_weakref;
/** Whether finalization is required for this type's instances (implements __del__). */
- private boolean needs_finalizer;
+ protected boolean needs_finalizer;
/** Whether this type's __getattribute__ is object.__getattribute__. */
private volatile boolean usesObjectGetattribute;
@@ -310,7 +310,7 @@
if (wantWeak) {
createWeakrefSlot();
}
- needs_finalizer = lookup_mro("__del__") != null;
+ needs_finalizer = needsFinalizer();
}
/**
@@ -568,6 +568,24 @@
}
/**
+ * Offers public read-only access to the protected field needs_finalizer.
+ *
+ * @return a boolean indicating whether the type implements __del__
+ */
+ public final boolean needsFinalizer() {
+ //It might be sluggish to assume that if a finalizer was needed
+ //once, this would never change. However since an expensive
+ //FinalizeTrigger was created anyway, it won't hurt to keep it.
+ //Whether there actually is a __del__ in the dict will be checked
+ //again when the finalizer runs.
+ if (needs_finalizer) return true;
+ else {
+ needs_finalizer = lookup_mro("__del__") != null;
+ return needs_finalizer;
+ }
+ }
+
+ /**
* Ensures that the physical layout between this type and other are compatible.
* Raises a TypeError if not.
*/
diff --git a/src/org/python/core/PyTypeDerived.java b/src/org/python/core/PyTypeDerived.java
--- a/src/org/python/core/PyTypeDerived.java
+++ b/src/org/python/core/PyTypeDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyTypeDerived extends PyType implements Slotted {
+public class PyTypeDerived extends PyType implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,9 +19,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyTypeDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -978,6 +997,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/PyUnicodeDerived.java b/src/org/python/core/PyUnicodeDerived.java
--- a/src/org/python/core/PyUnicodeDerived.java
+++ b/src/org/python/core/PyUnicodeDerived.java
@@ -2,8 +2,12 @@
package org.python.core;
import java.io.Serializable;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyUnicodeDerived extends PyUnicode implements Slotted {
+public class PyUnicodeDerived extends PyUnicode implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -15,6 +19,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -28,6 +44,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -42,6 +61,9 @@
super(subtype,string);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1002,6 +1024,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/core/finalization/FinalizableBuiltin.java b/src/org/python/core/finalization/FinalizableBuiltin.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizableBuiltin.java
@@ -0,0 +1,18 @@
+package org.python.core.finalization;
+
+/**
+ * See documentation of {@link FinalizablePyObject}.
+ */
+
+public interface FinalizableBuiltin extends HasFinalizeTrigger {
+ /**
+ * {@code __del_builtin__} is the built-in's own finalizer, while
+ * {@code __del_derived__} refers to an instance's in-dict {@code __del__}.
+ * A FinalizeTrigger calls {@code __del_derived__} first and
+ * - if existent - {@code __del_builtin__} after that. A plain {@code __del__}
+ * would behave as overwritten by {@code __del__Derived}, i.e. won't be called
+ * if the type implements {@code FinalizablePyObjectDerived} while
+ * {@code __del_builtin__} is called in any case.
+ */
+ public void __del_builtin__();
+}
diff --git a/src/org/python/core/finalization/FinalizablePyObject.java b/src/org/python/core/finalization/FinalizablePyObject.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizablePyObject.java
@@ -0,0 +1,90 @@
+package org.python.core.finalization;
+
+/**
+ *
+ * This interface allows {@code PyObject}s to have finalizers.
+ * Alternatively one can use
+ * {@link org.python.core.finalization.FinalizableBuiltin}.
+ *
+ *
+ * The difference is that {@code __del__} can be overwritten by a
+ * new-style subclass's {@code __del__}-method on Python-side, while
+ * {@code __del_builtin__} is always called. If a Python-side
+ * finalizer exists, {@code __del_builtin__} will be called after the
+ * Python-side finalizer has been processed.
+ *
+ *
+ * One can even implement both interfaces.
+ * If both interfaces are implemented, the {@code FinalizeTrigger} will
+ * call {@code __del__} first and then {@code __del_builtin__}. If a
+ * new-style subclass has an own, Python-side {@code __del__}-method, this
+ * overwrites the Java-implemented {@code __del__}, but not
+ * {@code __del_builtin__}, which will be called after the Python-side
+ * finalizer.
+ *
+ *
+ * If you are writing a custom built-in that shall directly
+ * extend {@link org.python.core.PyObject} and have a finalizer, you can simply
+ * extend {@link org.python.core.finalization.PyFinalizableObject}
+ * and overwrite its {@code __del__}-method.
+ * Follow the instructions below, starting at 4).
+ *
+ *
+ * If you want to extend some subclass of PyObject that does not yet implement
+ * this interface, you have to take care of the following steps:
+ *
+ *
+ * Let your subclass implement {@code FinalizablePyObject}
+ * (or {@link org.python.core.finalization.FinalizableBuiltin}).
+ *
+ *
+ * Let it have a member
+ * {@code public FinalizeTrigger finalizeTrigger;}
+ * Other scopes also work, but might fail with security managers.
+ *
+ *
+ * In every constructor initialize this member via
+ * {@code finalizeTrigger = FinalizeTrigger.makeTrigger(this);}
+ * or
+ * {@code FinalizeTrigger.ensureFinalizer(this);}
+ * The latter is a better abstraction, but slightly less performant,
+ * since it uses reflection.
+ *
+ *
+ * Write your {@code __del__}-method however you intend it.
+ * (or {@code __del__Builtin} if
+ * {@link org.python.core.finalization.FinalizableBuiltin} was used)
+ *
+ *
+ * (optional)
+ * If your finalizer resurrects the object (Python allows this) and you wish the
+ * finalizer to run again on next collection of the object:
+ * In the block where the resurrection occurs, let your {@code __del__}- or
+ * {@code __del_builtin__}-method call
+ * {@code FinalizeTrigger.ensureFinalizer(this);}.
+ *
+ *
+ *
+ *
+ * Note: Regarding to object resurrection, Jython currently behaves like CPython >= 3.4.
+ * That means the finalizer {@code __del__} or {@code __del_builtin__} is called only the
+ * first time an object gets gc'ed. If pre 3.4. behavior is required for some reason (i.e.
+ * have the finalizer called repeatedly on every collection after a resurrection), one can
+ * achieve this manually via step 5).
+ *
+ *
+ * It is possible to switch finalization on and off at any desired time for a certain object.
+ * This can be helpful if it is only necessary to have {@code __del__} or
+ * {@code __del_builtin__} called for certain configurations of an object.
+ *
+ *
+ * To turn off the finalizer, call
+ * {@code finalizeTrigger.clear();}
+ * To turn it on again, call
+ * {@code finalizeTrigger.trigger(this);}
+ *
+ */
+
+public interface FinalizablePyObject extends HasFinalizeTrigger {
+ public void __del__();
+}
diff --git a/src/org/python/core/finalization/FinalizablePyObjectDerived.java b/src/org/python/core/finalization/FinalizablePyObjectDerived.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizablePyObjectDerived.java
@@ -0,0 +1,23 @@
+package org.python.core.finalization;
+
+/**
+ * This interface should never be used directly in any hand-written code.
+ * It should only appear in automatically generated {@code fooDerived}-classes.
+ *
+ * To use finalizers in hand-written classes read the instructions at
+ * {@link org.python.core.finalization.FinalizablePyObject}.
+ *
+ */
+public interface FinalizablePyObjectDerived extends HasFinalizeTrigger {
+
+ /**
+ * {@code __del_builtin__} is the built-in's own finalizer, while
+ * {@code __del_derived__} refers to an instance's in-dict {@code __del__}.
+ * A FinalizeTrigger calls {@code __del_derived__} first and
+ * - if existent - {@code __del_builtin__} after that. A plain {@code __del__}
+ * would behave as overwritten by {@code __del_derived__}, i.e. won't be called
+ * if the type implements {@code FinalizablePyObjectDerived} while
+ * {@code __del_builtin__} is called in any case.
+ */
+ public void __del_derived__();
+}
diff --git a/src/org/python/core/finalization/FinalizeTrigger.java b/src/org/python/core/finalization/FinalizeTrigger.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizeTrigger.java
@@ -0,0 +1,101 @@
+package org.python.core.finalization;
+
+import java.lang.reflect.Field;
+
+/**
+ * To use finalizers on {@code PyObject}s, read the documentation of
+ * {@link org.python.core.finalization.FinalizablePyObject}.
+ */
+public class FinalizeTrigger {
+
+ /**
+ * This optional factory hook allows to replace the
+ * default {@code FinalizeTrigger}. It is f.i. needed by JyNI.
+ */
+ public static FinalizeTriggerFactory factory;
+
+ public static FinalizeTrigger makeTrigger(HasFinalizeTrigger toFinalize) {
+ if (factory != null) {
+ return factory.makeTrigger(toFinalize);
+ } else {
+ return new FinalizeTrigger(toFinalize);
+ }
+ }
+
+ /**
+ * Recreates the {@code FinalizeTrigger} of the given object. This makes sure that
+ * once the resurrected object is gc'ed again, its {@code __del__}-method will be
+ * called again.
+ */
+ public static void ensureFinalizer(HasFinalizeTrigger resurrect) {
+ FinalizeTrigger trigger = makeTrigger(resurrect);
+ setFinalizeTrigger(resurrect, trigger);
+ }
+
+ public static void setFinalizeTrigger(HasFinalizeTrigger toFinalize, FinalizeTrigger trigger) {
+ Field triggerField;
+ try {
+ triggerField = toFinalize.getClass().getDeclaredField("finalizeTrigger");
+ } catch (NoSuchFieldException nfe) {
+ throw new IllegalArgumentException(toFinalize.getClass()+" must have a field finalizeTrigger.");
+ }
+ try {
+ triggerField.set(toFinalize, trigger);
+ } catch (IllegalAccessException iae) {
+ try {
+ triggerField.setAccessible(true);
+ triggerField.set(toFinalize, trigger);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("finalizeTrigger in "+toFinalize.getClass()+" must be accessible.");
+ }
+ }
+ }
+
+ public static FinalizeTrigger getFinalizeTrigger(HasFinalizeTrigger toFinalize) {
+ Field triggerField;
+ try {
+ triggerField = toFinalize.getClass().getDeclaredField("finalizeTrigger");
+ } catch (NoSuchFieldException nfe) {
+ throw new IllegalArgumentException(toFinalize.getClass()+" must have a field finalizeTrigger.");
+ }
+ try {
+ return (FinalizeTrigger) triggerField.get(toFinalize);
+ } catch (IllegalAccessException iae) {
+ try {
+ triggerField.setAccessible(true);
+ return (FinalizeTrigger) triggerField.get(toFinalize);
+ } catch (Exception e) {
+ throw new IllegalArgumentException("finalizeTrigger in "+toFinalize.getClass()+" must be accessible.");
+ }
+ }
+ }
+
+
+ protected HasFinalizeTrigger toFinalize;
+
+ public void clear() {
+ toFinalize = null;
+ }
+
+ public void trigger(HasFinalizeTrigger toFinalize)
+ {
+ this.toFinalize = toFinalize;
+ }
+
+ protected FinalizeTrigger(HasFinalizeTrigger toFinalize) {
+ this.toFinalize = toFinalize;
+ }
+
+ protected void finalize() throws Throwable {
+ if (toFinalize != null) {
+ if (toFinalize instanceof FinalizablePyObjectDerived) {
+ ((FinalizablePyObjectDerived) toFinalize).__del_derived__();
+ } else if (toFinalize instanceof FinalizablePyObject) {
+ ((FinalizablePyObject) toFinalize).__del__();
+ }
+ if (toFinalize instanceof FinalizableBuiltin) {
+ ((FinalizableBuiltin) toFinalize).__del_builtin__();
+ }
+ }
+ }
+}
diff --git a/src/org/python/core/finalization/FinalizeTriggerFactory.java b/src/org/python/core/finalization/FinalizeTriggerFactory.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/FinalizeTriggerFactory.java
@@ -0,0 +1,6 @@
+package org.python.core.finalization;
+
+public interface FinalizeTriggerFactory {
+
+ public FinalizeTrigger makeTrigger(HasFinalizeTrigger toFinalize);
+}
diff --git a/src/org/python/core/finalization/HasFinalizeTrigger.java b/src/org/python/core/finalization/HasFinalizeTrigger.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/HasFinalizeTrigger.java
@@ -0,0 +1,13 @@
+package org.python.core.finalization;
+
+/**
+ * This is a pure marker-interface to indicate that a
+ * {@link org.python.core.PyObject} has a field declaration
+ * {@code FinalizeTrigger finalizeTrigger;}
+ * and thus can be treated by Jython's finalization API.
+ *
+ * For detailed instructions how to use finalizers in Jython, see
+ * {@link org.python.core.finalization.FinalizablePyObject}.
+ */
+public interface HasFinalizeTrigger {
+}
diff --git a/src/org/python/core/finalization/PyFinalizableObject.java b/src/org/python/core/finalization/PyFinalizableObject.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/core/finalization/PyFinalizableObject.java
@@ -0,0 +1,17 @@
+package org.python.core.finalization;
+
+import org.python.core.PyObject;;
+
+/**
+ * For detailed intructions how to use finalizers on PyObjects,
+ * read the documentation of {@link org.python.core.finalization.FinalizablePyObject}.
+ */
+public abstract class PyFinalizableObject extends PyObject implements FinalizablePyObject {
+
+ public FinalizeTrigger finalizeTrigger;
+
+ public PyFinalizableObject() {
+ super();
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
+}
diff --git a/src/org/python/modules/PyStructDerived.java b/src/org/python/modules/PyStructDerived.java
--- a/src/org/python/modules/PyStructDerived.java
+++ b/src/org/python/modules/PyStructDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyStructDerived extends PyStruct implements Slotted {
+public class PyStructDerived extends PyStruct implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype,format);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_collections/PyDefaultDictDerived.java b/src/org/python/modules/_collections/PyDefaultDictDerived.java
--- a/src/org/python/modules/_collections/PyDefaultDictDerived.java
+++ b/src/org/python/modules/_collections/PyDefaultDictDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyDefaultDictDerived extends PyDefaultDict implements Slotted {
+public class PyDefaultDictDerived extends PyDefaultDict implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_collections/PyDequeDerived.java b/src/org/python/modules/_collections/PyDequeDerived.java
--- a/src/org/python/modules/_collections/PyDequeDerived.java
+++ b/src/org/python/modules/_collections/PyDequeDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyDequeDerived extends PyDeque implements Slotted {
+public class PyDequeDerived extends PyDeque implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_csv/PyDialectDerived.java b/src/org/python/modules/_csv/PyDialectDerived.java
--- a/src/org/python/modules/_csv/PyDialectDerived.java
+++ b/src/org/python/modules/_csv/PyDialectDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyDialectDerived extends PyDialect implements Slotted {
+public class PyDialectDerived extends PyDialect implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyDialectDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_functools/PyPartialDerived.java b/src/org/python/modules/_functools/PyPartialDerived.java
--- a/src/org/python/modules/_functools/PyPartialDerived.java
+++ b/src/org/python/modules/_functools/PyPartialDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyPartialDerived extends PyPartial implements Slotted {
+public class PyPartialDerived extends PyPartial implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_io/PyFileIODerived.java b/src/org/python/modules/_io/PyFileIODerived.java
--- a/src/org/python/modules/_io/PyFileIODerived.java
+++ b/src/org/python/modules/_io/PyFileIODerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyFileIODerived extends PyFileIO implements Slotted {
+public class PyFileIODerived extends PyFileIO implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyFileIODerived(PyType subtype,PyObject file,OpenMode mode,boolean closefd) {
super(subtype,file,mode,closefd);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_io/PyIOBase.java b/src/org/python/modules/_io/PyIOBase.java
--- a/src/org/python/modules/_io/PyIOBase.java
+++ b/src/org/python/modules/_io/PyIOBase.java
@@ -16,6 +16,8 @@
import org.python.core.PyType;
import org.python.core.PyUnicode;
import org.python.core.buffer.SimpleStringBuffer;
+import org.python.core.finalization.FinalizableBuiltin;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.core.io.FileIO;
import org.python.expose.ExposedGet;
import org.python.expose.ExposedMethod;
@@ -38,20 +40,24 @@
* in Python.
*/
@ExposedType(name = "_io._IOBase", doc = PyIOBase.doc)
-public class PyIOBase extends PyObject {
+public class PyIOBase extends PyObject implements FinalizableBuiltin {
public static final PyType TYPE = PyType.fromClass(PyIOBase.class);
/** The ioDelegate's closer object; ensures the stream is closed at shutdown */
private Closer closer;
+
+ public FinalizeTrigger finalizeTrigger;
protected PyIOBase() {
this(TYPE);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
protected PyIOBase(PyType subtype) {
super(subtype);
closer = new Closer(this, Py.getSystemState());
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
/**
@@ -726,10 +732,9 @@
}
@Override
- protected void finalize() throws Throwable {
+ public void __del_builtin__() {
closer.dismiss();
invoke("close");
- super.finalize();
}
/** Convenience method providing the exception in the _checkWhatever() methods. */
diff --git a/src/org/python/modules/_io/PyIOBaseDerived.java b/src/org/python/modules/_io/PyIOBaseDerived.java
--- a/src/org/python/modules/_io/PyIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyIOBaseDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyIOBaseDerived extends PyIOBase implements Slotted {
+public class PyIOBaseDerived extends PyIOBase implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyIOBaseDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_io/PyRawIOBaseDerived.java b/src/org/python/modules/_io/PyRawIOBaseDerived.java
--- a/src/org/python/modules/_io/PyRawIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyRawIOBaseDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyRawIOBaseDerived extends PyRawIOBase implements Slotted {
+public class PyRawIOBaseDerived extends PyRawIOBase implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyRawIOBaseDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/_weakref/ReferenceTypeDerived.java b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
--- a/src/org/python/modules/_weakref/ReferenceTypeDerived.java
+++ b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ReferenceTypeDerived extends ReferenceType implements Slotted {
+public class ReferenceTypeDerived extends ReferenceType implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype,gref,callback);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyBZ2CompressorDerived extends PyBZ2Compressor implements Slotted {
+public class PyBZ2CompressorDerived extends PyBZ2Compressor implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyBZ2DecompressorDerived extends PyBZ2Decompressor implements Slotted {
+public class PyBZ2DecompressorDerived extends PyBZ2Decompressor implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/bz2/PyBZ2File.java b/src/org/python/modules/bz2/PyBZ2File.java
--- a/src/org/python/modules/bz2/PyBZ2File.java
+++ b/src/org/python/modules/bz2/PyBZ2File.java
@@ -24,6 +24,9 @@
import org.python.core.PySequence;
import org.python.core.PyString;
import org.python.core.PyType;
+import org.python.core.finalization.FinalizablePyObject;
+import org.python.core.finalization.FinalizableBuiltin;
+import org.python.core.finalization.FinalizeTrigger;
import org.python.core.io.BinaryIOWrapper;
import org.python.core.io.BufferedReader;
import org.python.core.io.BufferedWriter;
@@ -37,7 +40,7 @@
import org.python.expose.ExposedType;
@ExposedType(name = "bz2.BZ2File")
-public class PyBZ2File extends PyObject {
+public class PyBZ2File extends PyObject implements FinalizablePyObject, FinalizableBuiltin {
public static final PyType TYPE = PyType.fromClass(PyBZ2File.class);
private int buffering;
@@ -58,20 +61,23 @@
private boolean needReadBufferInit = false;
private boolean inReadMode = false;
private boolean inWriteMode = false;
+
+ public FinalizeTrigger finalizeTrigger;
public PyBZ2File() {
super(TYPE);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
public PyBZ2File(PyType subType) {
super(subType);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
@Override
- protected void finalize() throws Throwable {
+ public void __del_builtin__() {
BZ2File_close();
- super.finalize();
}
@ExposedNew
@@ -151,6 +157,7 @@
}
}
+ @Override
@ExposedMethod
public void __del__() {
BZ2File_close();
diff --git a/src/org/python/modules/bz2/PyBZ2FileDerived.java b/src/org/python/modules/bz2/PyBZ2FileDerived.java
--- a/src/org/python/modules/bz2/PyBZ2FileDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2FileDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyBZ2FileDerived extends PyBZ2File implements Slotted {
+public class PyBZ2FileDerived extends PyBZ2File implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/PyTeeIteratorDerived.java b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
--- a/src/org/python/modules/itertools/PyTeeIteratorDerived.java
+++ b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyTeeIteratorDerived extends PyTeeIterator implements Slotted {
+public class PyTeeIteratorDerived extends PyTeeIterator implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/chainDerived.java b/src/org/python/modules/itertools/chainDerived.java
--- a/src/org/python/modules/itertools/chainDerived.java
+++ b/src/org/python/modules/itertools/chainDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class chainDerived extends chain implements Slotted {
+public class chainDerived extends chain implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/combinationsDerived.java b/src/org/python/modules/itertools/combinationsDerived.java
--- a/src/org/python/modules/itertools/combinationsDerived.java
+++ b/src/org/python/modules/itertools/combinationsDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class combinationsDerived extends combinations implements Slotted {
+public class combinationsDerived extends combinations implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
--- a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
+++ b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class combinationsWithReplacementDerived extends combinationsWithReplacement implements Slotted {
+public class combinationsWithReplacementDerived extends combinationsWithReplacement implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/compressDerived.java b/src/org/python/modules/itertools/compressDerived.java
--- a/src/org/python/modules/itertools/compressDerived.java
+++ b/src/org/python/modules/itertools/compressDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class compressDerived extends compress implements Slotted {
+public class compressDerived extends compress implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/countDerived.java b/src/org/python/modules/itertools/countDerived.java
--- a/src/org/python/modules/itertools/countDerived.java
+++ b/src/org/python/modules/itertools/countDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class countDerived extends count implements Slotted {
+public class countDerived extends count implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/cycleDerived.java b/src/org/python/modules/itertools/cycleDerived.java
--- a/src/org/python/modules/itertools/cycleDerived.java
+++ b/src/org/python/modules/itertools/cycleDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class cycleDerived extends cycle implements Slotted {
+public class cycleDerived extends cycle implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/dropwhileDerived.java b/src/org/python/modules/itertools/dropwhileDerived.java
--- a/src/org/python/modules/itertools/dropwhileDerived.java
+++ b/src/org/python/modules/itertools/dropwhileDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class dropwhileDerived extends dropwhile implements Slotted {
+public class dropwhileDerived extends dropwhile implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/groupbyDerived.java b/src/org/python/modules/itertools/groupbyDerived.java
--- a/src/org/python/modules/itertools/groupbyDerived.java
+++ b/src/org/python/modules/itertools/groupbyDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class groupbyDerived extends groupby implements Slotted {
+public class groupbyDerived extends groupby implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/ifilterDerived.java b/src/org/python/modules/itertools/ifilterDerived.java
--- a/src/org/python/modules/itertools/ifilterDerived.java
+++ b/src/org/python/modules/itertools/ifilterDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ifilterDerived extends ifilter implements Slotted {
+public class ifilterDerived extends ifilter implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/ifilterfalseDerived.java b/src/org/python/modules/itertools/ifilterfalseDerived.java
--- a/src/org/python/modules/itertools/ifilterfalseDerived.java
+++ b/src/org/python/modules/itertools/ifilterfalseDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class ifilterfalseDerived extends ifilterfalse implements Slotted {
+public class ifilterfalseDerived extends ifilterfalse implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/isliceDerived.java b/src/org/python/modules/itertools/isliceDerived.java
--- a/src/org/python/modules/itertools/isliceDerived.java
+++ b/src/org/python/modules/itertools/isliceDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class isliceDerived extends islice implements Slotted {
+public class isliceDerived extends islice implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/izipDerived.java b/src/org/python/modules/itertools/izipDerived.java
--- a/src/org/python/modules/itertools/izipDerived.java
+++ b/src/org/python/modules/itertools/izipDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class izipDerived extends izip implements Slotted {
+public class izipDerived extends izip implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/izipLongestDerived.java b/src/org/python/modules/itertools/izipLongestDerived.java
--- a/src/org/python/modules/itertools/izipLongestDerived.java
+++ b/src/org/python/modules/itertools/izipLongestDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class izipLongestDerived extends izipLongest implements Slotted {
+public class izipLongestDerived extends izipLongest implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/permutationsDerived.java b/src/org/python/modules/itertools/permutationsDerived.java
--- a/src/org/python/modules/itertools/permutationsDerived.java
+++ b/src/org/python/modules/itertools/permutationsDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class permutationsDerived extends permutations implements Slotted {
+public class permutationsDerived extends permutations implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/productDerived.java b/src/org/python/modules/itertools/productDerived.java
--- a/src/org/python/modules/itertools/productDerived.java
+++ b/src/org/python/modules/itertools/productDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class productDerived extends product implements Slotted {
+public class productDerived extends product implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/repeatDerived.java b/src/org/python/modules/itertools/repeatDerived.java
--- a/src/org/python/modules/itertools/repeatDerived.java
+++ b/src/org/python/modules/itertools/repeatDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class repeatDerived extends repeat implements Slotted {
+public class repeatDerived extends repeat implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/starmapDerived.java b/src/org/python/modules/itertools/starmapDerived.java
--- a/src/org/python/modules/itertools/starmapDerived.java
+++ b/src/org/python/modules/itertools/starmapDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class starmapDerived extends starmap implements Slotted {
+public class starmapDerived extends starmap implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/itertools/takewhileDerived.java b/src/org/python/modules/itertools/takewhileDerived.java
--- a/src/org/python/modules/itertools/takewhileDerived.java
+++ b/src/org/python/modules/itertools/takewhileDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class takewhileDerived extends takewhile implements Slotted {
+public class takewhileDerived extends takewhile implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/random/PyRandomDerived.java b/src/org/python/modules/random/PyRandomDerived.java
--- a/src/org/python/modules/random/PyRandomDerived.java
+++ b/src/org/python/modules/random/PyRandomDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyRandomDerived extends PyRandom implements Slotted {
+public class PyRandomDerived extends PyRandom implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/thread/PyLocalDerived.java b/src/org/python/modules/thread/PyLocalDerived.java
--- a/src/org/python/modules/thread/PyLocalDerived.java
+++ b/src/org/python/modules/thread/PyLocalDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class PyLocalDerived extends PyLocal implements Slotted {
+public class PyLocalDerived extends PyLocal implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,9 +20,24 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
public PyLocalDerived(PyType subtype) {
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -979,6 +998,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/org/python/modules/zipimport/zipimporterDerived.java b/src/org/python/modules/zipimport/zipimporterDerived.java
--- a/src/org/python/modules/zipimport/zipimporterDerived.java
+++ b/src/org/python/modules/zipimport/zipimporterDerived.java
@@ -3,8 +3,12 @@
import java.io.Serializable;
import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;
-public class zipimporterDerived extends zipimporter implements Slotted {
+public class zipimporterDerived extends zipimporter implements Slotted,FinalizablePyObjectDerived {
+
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +20,18 @@
private PyObject[]slots;
+ public void __del_derived__() {
+ PyType self_type=getType();
+ PyObject impl=self_type.lookup("__del__");
+ if (impl!=null) {
+ impl.__get__(this,self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
+
private PyObject dict;
public PyObject fastGetDict() {
@@ -29,6 +45,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap||newDict instanceof PyDictionary) {
dict=newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__"))!=null&&finalizeTrigger==null) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
} else {
throw Py.TypeError("__dict__ must be set to a Dictionary "+newDict.getClass().getName());
}
@@ -43,6 +62,9 @@
super(subtype);
slots=new PyObject[subtype.getNumSlots()];
dict=subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
+ }
}
public PyString __str__() {
@@ -1003,6 +1025,8 @@
PyObject impl=self_type.lookup("__setattr__");
if (impl!=null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
diff --git a/src/templates/gderived-defs b/src/templates/gderived-defs
--- a/src/templates/gderived-defs
+++ b/src/templates/gderived-defs
@@ -4,8 +4,11 @@
package org.python.core;
import java.io.Serializable;
+ import org.python.core.finalization.FinalizeTrigger;
+ import org.python.core.finalization.FinalizablePyObjectDerived;
- public class `concat`(`base,Derived) extends `base implements Slotted {
+ public class `concat`(`base,Derived) extends `base implements Slotted, FinalizablePyObjectDerived {
+ public FinalizeTrigger finalizeTrigger;
public PyObject getSlot(int index) {
return slots[index];
@@ -16,6 +19,18 @@
}
private PyObject[] slots;
+
+ public void __del_derived__() {
+ PyType self_type = getType();
+ PyObject impl = self_type.lookup("__del__");
+ if (impl != null) {
+ impl.__get__(this, self_type).__call__();
+ }
+ }
+
+ public void __ensure_finalizer__() {
+ FinalizeTrigger.ensureFinalizer(this);
+ }
`decls;
}
@@ -81,6 +96,9 @@
public void setDict(PyObject newDict) {
if (newDict instanceof PyStringMap || newDict instanceof PyDictionary ) {
dict = newDict;
+ if (dict.__finditem__(PyString.fromInterned("__del__")) != null && finalizeTrigger == null) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
}
else {
throw Py.TypeError("__dict__ must be set to a Dictionary " + newDict.getClass().getName());
@@ -96,6 +114,9 @@
public `concat`(`base,Derived)(PyType subtype,`extraargs) {
super(subtype,`extra);
slots = new PyObject[subtype.getNumSlots()];
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
}
define: (ClassBodyDeclarations)ctr_userdict
@@ -103,6 +124,9 @@
super(subtype,`extra);
slots = new PyObject[subtype.getNumSlots()];
dict = subtype.instDict();
+ if (subtype.needsFinalizer()) {
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
+ }
}
define: (ClassBodyDeclarations)toString
diff --git a/src/templates/gderived.py b/src/templates/gderived.py
--- a/src/templates/gderived.py
+++ b/src/templates/gderived.py
@@ -8,7 +8,7 @@
import directives
import java_parser
import java_templating
-from java_templating import JavaTemplate,jast_make,jast
+from java_templating import JavaTemplate, jast_make, jast
org_python_dir = os.path.join(os.path.dirname(os.path.abspath(scriptdir)),
'org', 'python')
@@ -19,22 +19,24 @@
package org.python.%s;
import java.io.Serializable;
-import org.python.core.*;"""
+import org.python.core.*;
+import org.python.core.finalization.FinalizeTrigger;
+import org.python.core.finalization.FinalizablePyObjectDerived;"""
modif_re = re.compile(r"(?:\((\w+)\))?(\w+)")
# os.path.samefile unavailable on Windows before Python v3.2
-if hasattr(os.path,"samefile"):
+if hasattr(os.path, "samefile"):
# Good: available on this platform
os_path_samefile = os.path.samefile
else:
- def os_path_samefile(a,b):
+ def os_path_samefile(a, b):
'Files are considered the same if their absolute paths are equal'
return os.path.abspath(a)==os.path.abspath(b)
class Gen:
- priority_order = ['require','define','base_class',
+ priority_order = ['require', 'define', 'base_class',
'want_dict',
'ctr',
'incl',
@@ -44,7 +46,7 @@
'no_toString'
]
- def __init__(self,bindings=None,priority_order=None):
+ def __init__(self, bindings=None, priority_order=None):
if bindings is None:
self.global_bindings = { 'csub': java_templating.csub,
'concat': java_templating.concat,
@@ -64,35 +66,35 @@
self.no_toString = False
self.ctr_done = 0
- def debug(self,bindings):
- for name,val in bindings.items():
- if isinstance(val,JavaTemplate):
+ def debug(self, bindings):
+ for name, val in bindings.items():
+ if isinstance(val, JavaTemplate):
print "%s:" % name
print val.texpand({})
- def invalid(self,dire,value):
- raise Exception,"invalid '%s': %s" % (dire,value)
+ def invalid(self, dire, value):
+ raise Exception,"invalid '%s': %s" % (dire, value)
- def get_aux(self,name):
+ def get_aux(self, name):
if self.auxiliary is None:
- aux_gen = Gen(priority_order=['require','define'])
- directives.execute(directives.load(os.path.join(scriptdir,'gderived-defs')),aux_gen)
+ aux_gen = Gen(priority_order=['require', 'define'])
+ directives.execute(directives.load(os.path.join(scriptdir, 'gderived-defs')), aux_gen)
self.auxiliary = aux_gen.global_bindings
return self.auxiliary[name]
- def dire_require(self,name,parm,body):
+ def dire_require(self, name, parm, body):
if body is not None:
- self.invalid('require','non-empty body')
- sub_gen = Gen(bindings=self.global_bindings, priority__order=['require','define'])
- directives.execute(directives.load(parm.strip()),sub_gen)
+ self.invalid('require', 'non-empty body')
+ sub_gen = Gen(bindings=self.global_bindings, priority__order=['require', 'define'])
+ directives.execute(directives.load(parm.strip()), sub_gen)
- def dire_define(self,name,parm,body):
+ def dire_define(self, name, parm, body):
parms = parm.split()
if not parms:
- self.invalid('define',parm)
+ self.invalid('define', parm)
parsed_name = modif_re.match(parms[0])
if not parsed_name:
- self.invalid('define',parm)
+ self.invalid('define', parm)
templ_kind = parsed_name.group(1)
templ_name = parsed_name.group(2)
if templ_kind is None:
@@ -104,40 +106,40 @@
start = templ_kind)
self.global_bindings[templ_name] = templ
- def dire_base_class(self,name,parm,body):
+ def dire_base_class(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
if self.base_class is None:
self.base_class = JavaTemplate(parm.strip())
self.global_bindings['base'] = self.base_class
- def dire_want_dict(self,name,parm,body):
+ def dire_want_dict(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
if self.want_dict is None:
self.want_dict = {"true": 1, "false": 0}[parm.strip()]
- def dire_no_toString(self,name,parm,body):
+ def dire_no_toString(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
self.no_toString = True
- def dire_incl(self,name,parm,body):
+ def dire_incl(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
directives.execute(directives.load(parm.strip()+'.derived'),self)
- def dire_ctr(self,name,parm,body):
+ def dire_ctr(self, name, parm, body):
if self.ctr_done:
return
if body is not None:
- self.invalid(name,"non-empty body")
+ self.invalid(name, "non-empty body")
if self.want_dict:
self.add_decl(self.get_aux('userdict'))
ctr = self.get_aux('ctr_userdict')
else:
ctr = self.get_aux('ctr')
- extraargs = JavaTemplate(parm.strip(),start="FormalParameterListOpt")
+ extraargs = JavaTemplate(parm.strip(), start="FormalParameterListOpt")
def visit(node):
if isinstance(node, jast.VariableDeclaratorId):
yield node.Identifier
@@ -145,20 +147,20 @@
for child in node.children:
for x in visit(child):
yield x
- extra = jast_make(jast.Expressions, [jast_make(jast.Primary,Identifier=x,ArgumentsOpt=None) for x in visit(extraargs.fragment)])
+ extra = jast_make(jast.Expressions, [jast_make(jast.Primary, Identifier=x, ArgumentsOpt=None) for x in visit(extraargs.fragment)])
extra = JavaTemplate(extra)
self.add_decl(ctr.tbind({'base': self.base_class, 'extraargs': extraargs, 'extra': extra}))
self.ctr_done = 1
- def add_decl(self,templ):
+ def add_decl(self, templ):
pair = self.get_aux('pair')
self.decls = pair.tbind({'trailer': self.decls, 'last': templ})
- def dire_unary1(self,name,parm,body):
+ def dire_unary1(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
parms = parm.split()
- if len(parms) not in (1,2,3):
- self.invalid(name,parm)
+ if len(parms) not in (1, 2, 3):
+ self.invalid(name, parm)
meth_name = parms[0]
if len(parms) == 1:
unary_body = self.get_aux('unary')
@@ -176,28 +178,28 @@
'rettype': JavaTemplate(rettype_class)}))
- def dire_binary(self,name,parm,body):
+ def dire_binary(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
meth_names = parm.split()
binary_body = self.get_aux('binary')
for meth_name in meth_names:
self.add_decl(binary_body.tbind({'binary': JavaTemplate(meth_name)}))
- def dire_ibinary(self,name,parm,body):
+ def dire_ibinary(self, name, parm, body):
if body is not None:
- self.invalid(name,'non-empty body')
+ self.invalid(name, 'non-empty body')
meth_names = parm.split()
binary_body = self.get_aux('ibinary')
for meth_name in meth_names:
self.add_decl(binary_body.tbind({'binary': JavaTemplate(meth_name)}))
- def dire_rest(self,name,parm,body):
+ def dire_rest(self, name, parm, body):
if parm:
- self.invalid(name,'non-empty parm')
+ self.invalid(name, 'non-empty parm')
if body is None:
return
- self.add_decl(JavaTemplate(body,start='ClassBodyDeclarations'))
+ self.add_decl(JavaTemplate(body, start='ClassBodyDeclarations'))
def generate(self):
if not self.no_toString:
@@ -209,10 +211,10 @@
if (lazy and
os.path.exists(outfile) and
os.stat(fn).st_mtime < os.stat(outfile).st_mtime):
- return
+ return
print 'Processing %s into %s' % (fn, outfile)
gen = Gen()
- directives.execute(directives.load(fn),gen)
+ directives.execute(directives.load(fn), gen)
result = gen.generate()
result = hack_derived_header(outfile, result)
print >> open(outfile, 'w'), result
@@ -240,30 +242,29 @@
header = DERIVED_HEADER % '.'.join(dirs)
result[0:num - 1] = header.splitlines()
break
+
+ return '\n'.join(result)
- return '\n'.join(result)
-
+
if __name__ == '__main__':
from gexpose import load_mappings, usage
lazy = False
if len(sys.argv) > 4:
usage()
- sys.exit(1)
+ sys.exit(1)
if len(sys.argv) >= 2:
- if '--help' in sys.argv:
- usage()
- sys.exit(0)
- elif '--lazy' in sys.argv:
- lazy = True
- sys.argv.remove('--lazy')
+ if '--help' in sys.argv:
+ usage()
+ sys.exit(0)
+ elif '--lazy' in sys.argv:
+ lazy = True
+ sys.argv.remove('--lazy')
if len(sys.argv) == 1:
- for template, mapping in load_mappings().items():
- if template.endswith('derived'):
- process(mapping[0], mapping[1], lazy)
+ for template, mapping in load_mappings().items():
+ if template.endswith('derived'):
+ process(mapping[0], mapping[1], lazy)
elif len(sys.argv) == 2:
- mapping = load_mappings()[sys.argv[1]]
+ mapping = load_mappings()[sys.argv[1]]
process(mapping[0], mapping[1], lazy)
else:
process(sys.argv[1], sys.argv[2], lazy)
-
-
diff --git a/src/templates/object.derived b/src/templates/object.derived
--- a/src/templates/object.derived
+++ b/src/templates/object.derived
@@ -318,6 +318,8 @@
PyObject impl = self_type.lookup("__setattr__");
if (impl != null) {
impl.__get__(this,self_type).__call__(PyString.fromInterned(name),value);
+ //CPython does not support instance-acquired finalizers.
+ //So we don't check for __del__ here.
return;
}
super.__setattr__(name,value);
@@ -429,4 +431,3 @@
}
return super.__coerce_ex__(o);
}
-
--
Repository URL: http://hg.python.org/jython
From jython-checkins at python.org Thu Sep 4 06:35:44 2014
From: jython-checkins at python.org (jim.baker)
Date: Thu, 4 Sep 2014 06:35:44 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython=3A_Modified_=5F=5Fensure=5Ffin?=
=?utf-8?q?alizer=5F=5F_to_work_without_using_reflection_and_added_some?=
Message-ID: <3hpTjD3LkVz7Lkc@mail.python.org>
http://hg.python.org/jython/rev/54f36c4c72d1
changeset: 7364:54f36c4c72d1
parent: 7362:5397c1f405c5
user: Stefan Richthofer
date: Thu Aug 28 06:06:02 2014 +0200
summary:
Modified __ensure_finalizer__ to work without using reflection and added some paragraphs to the documentation in FinalizablePyObject (stating use cases fo __ensure_finalizer__ and specifying that it is not possible to overwrite __ensure_finalizer__ on Python side).
files:
src/org/python/antlr/ast/AssertDerived.java | 2 +-
src/org/python/antlr/ast/AssignDerived.java | 2 +-
src/org/python/antlr/ast/AttributeDerived.java | 2 +-
src/org/python/antlr/ast/AugAssignDerived.java | 2 +-
src/org/python/antlr/ast/BinOpDerived.java | 2 +-
src/org/python/antlr/ast/BoolOpDerived.java | 2 +-
src/org/python/antlr/ast/BreakDerived.java | 2 +-
src/org/python/antlr/ast/CallDerived.java | 2 +-
src/org/python/antlr/ast/ClassDefDerived.java | 2 +-
src/org/python/antlr/ast/CompareDerived.java | 2 +-
src/org/python/antlr/ast/ContinueDerived.java | 2 +-
src/org/python/antlr/ast/DeleteDerived.java | 2 +-
src/org/python/antlr/ast/DictDerived.java | 2 +-
src/org/python/antlr/ast/EllipsisDerived.java | 2 +-
src/org/python/antlr/ast/ExceptHandlerDerived.java | 2 +-
src/org/python/antlr/ast/ExecDerived.java | 2 +-
src/org/python/antlr/ast/ExprDerived.java | 2 +-
src/org/python/antlr/ast/ExpressionDerived.java | 2 +-
src/org/python/antlr/ast/ExtSliceDerived.java | 2 +-
src/org/python/antlr/ast/ForDerived.java | 2 +-
src/org/python/antlr/ast/FunctionDefDerived.java | 2 +-
src/org/python/antlr/ast/GeneratorExpDerived.java | 2 +-
src/org/python/antlr/ast/GlobalDerived.java | 2 +-
src/org/python/antlr/ast/IfDerived.java | 2 +-
src/org/python/antlr/ast/IfExpDerived.java | 2 +-
src/org/python/antlr/ast/ImportDerived.java | 2 +-
src/org/python/antlr/ast/ImportFromDerived.java | 2 +-
src/org/python/antlr/ast/IndexDerived.java | 2 +-
src/org/python/antlr/ast/InteractiveDerived.java | 2 +-
src/org/python/antlr/ast/LambdaDerived.java | 2 +-
src/org/python/antlr/ast/ListCompDerived.java | 2 +-
src/org/python/antlr/ast/ListDerived.java | 2 +-
src/org/python/antlr/ast/ModuleDerived.java | 2 +-
src/org/python/antlr/ast/NameDerived.java | 2 +-
src/org/python/antlr/ast/NumDerived.java | 2 +-
src/org/python/antlr/ast/PassDerived.java | 2 +-
src/org/python/antlr/ast/PrintDerived.java | 2 +-
src/org/python/antlr/ast/RaiseDerived.java | 2 +-
src/org/python/antlr/ast/ReprDerived.java | 2 +-
src/org/python/antlr/ast/ReturnDerived.java | 2 +-
src/org/python/antlr/ast/SliceDerived.java | 2 +-
src/org/python/antlr/ast/StrDerived.java | 2 +-
src/org/python/antlr/ast/SubscriptDerived.java | 2 +-
src/org/python/antlr/ast/SuiteDerived.java | 2 +-
src/org/python/antlr/ast/TryExceptDerived.java | 2 +-
src/org/python/antlr/ast/TryFinallyDerived.java | 2 +-
src/org/python/antlr/ast/TupleDerived.java | 2 +-
src/org/python/antlr/ast/UnaryOpDerived.java | 2 +-
src/org/python/antlr/ast/WhileDerived.java | 2 +-
src/org/python/antlr/ast/WithDerived.java | 2 +-
src/org/python/antlr/ast/YieldDerived.java | 2 +-
src/org/python/antlr/ast/aliasDerived.java | 2 +-
src/org/python/antlr/ast/argumentsDerived.java | 2 +-
src/org/python/antlr/ast/comprehensionDerived.java | 2 +-
src/org/python/antlr/ast/keywordDerived.java | 2 +-
src/org/python/antlr/op/AddDerived.java | 2 +-
src/org/python/antlr/op/AndDerived.java | 2 +-
src/org/python/antlr/op/AugLoadDerived.java | 2 +-
src/org/python/antlr/op/AugStoreDerived.java | 2 +-
src/org/python/antlr/op/BitAndDerived.java | 2 +-
src/org/python/antlr/op/BitOrDerived.java | 2 +-
src/org/python/antlr/op/BitXorDerived.java | 2 +-
src/org/python/antlr/op/DelDerived.java | 2 +-
src/org/python/antlr/op/DivDerived.java | 2 +-
src/org/python/antlr/op/EqDerived.java | 2 +-
src/org/python/antlr/op/FloorDivDerived.java | 2 +-
src/org/python/antlr/op/GtDerived.java | 2 +-
src/org/python/antlr/op/GtEDerived.java | 2 +-
src/org/python/antlr/op/InDerived.java | 2 +-
src/org/python/antlr/op/InvertDerived.java | 2 +-
src/org/python/antlr/op/IsDerived.java | 2 +-
src/org/python/antlr/op/IsNotDerived.java | 2 +-
src/org/python/antlr/op/LShiftDerived.java | 2 +-
src/org/python/antlr/op/LoadDerived.java | 2 +-
src/org/python/antlr/op/LtDerived.java | 2 +-
src/org/python/antlr/op/LtEDerived.java | 2 +-
src/org/python/antlr/op/ModDerived.java | 2 +-
src/org/python/antlr/op/MultDerived.java | 2 +-
src/org/python/antlr/op/NotDerived.java | 2 +-
src/org/python/antlr/op/NotEqDerived.java | 2 +-
src/org/python/antlr/op/NotInDerived.java | 2 +-
src/org/python/antlr/op/OrDerived.java | 2 +-
src/org/python/antlr/op/ParamDerived.java | 2 +-
src/org/python/antlr/op/PowDerived.java | 2 +-
src/org/python/antlr/op/RShiftDerived.java | 2 +-
src/org/python/antlr/op/StoreDerived.java | 2 +-
src/org/python/antlr/op/SubDerived.java | 2 +-
src/org/python/antlr/op/UAddDerived.java | 2 +-
src/org/python/antlr/op/USubDerived.java | 2 +-
src/org/python/core/ClasspathPyImporterDerived.java | 2 +-
src/org/python/core/PyArrayDerived.java | 2 +-
src/org/python/core/PyBaseExceptionDerived.java | 2 +-
src/org/python/core/PyByteArrayDerived.java | 2 +-
src/org/python/core/PyClassMethodDerived.java | 2 +-
src/org/python/core/PyComplexDerived.java | 2 +-
src/org/python/core/PyDictionaryDerived.java | 2 +-
src/org/python/core/PyEnumerateDerived.java | 2 +-
src/org/python/core/PyFileDerived.java | 2 +-
src/org/python/core/PyFloatDerived.java | 2 +-
src/org/python/core/PyFrozenSetDerived.java | 2 +-
src/org/python/core/PyInstance.java | 2 +-
src/org/python/core/PyIntegerDerived.java | 2 +-
src/org/python/core/PyListDerived.java | 2 +-
src/org/python/core/PyLongDerived.java | 2 +-
src/org/python/core/PyModuleDerived.java | 2 +-
src/org/python/core/PyObjectDerived.java | 2 +-
src/org/python/core/PyPropertyDerived.java | 2 +-
src/org/python/core/PySetDerived.java | 2 +-
src/org/python/core/PyStringDerived.java | 2 +-
src/org/python/core/PySuperDerived.java | 2 +-
src/org/python/core/PyTupleDerived.java | 2 +-
src/org/python/core/PyTypeDerived.java | 2 +-
src/org/python/core/PyUnicodeDerived.java | 2 +-
src/org/python/core/finalization/FinalizablePyObject.java | 19 ++++++++++
src/org/python/modules/PyStructDerived.java | 2 +-
src/org/python/modules/_collections/PyDefaultDictDerived.java | 2 +-
src/org/python/modules/_collections/PyDequeDerived.java | 2 +-
src/org/python/modules/_csv/PyDialectDerived.java | 2 +-
src/org/python/modules/_functools/PyPartialDerived.java | 2 +-
src/org/python/modules/_io/PyFileIODerived.java | 2 +-
src/org/python/modules/_io/PyIOBaseDerived.java | 2 +-
src/org/python/modules/_io/PyRawIOBaseDerived.java | 2 +-
src/org/python/modules/_weakref/ReferenceTypeDerived.java | 2 +-
src/org/python/modules/bz2/PyBZ2CompressorDerived.java | 2 +-
src/org/python/modules/bz2/PyBZ2DecompressorDerived.java | 2 +-
src/org/python/modules/bz2/PyBZ2FileDerived.java | 2 +-
src/org/python/modules/itertools/PyTeeIteratorDerived.java | 2 +-
src/org/python/modules/itertools/chainDerived.java | 2 +-
src/org/python/modules/itertools/combinationsDerived.java | 2 +-
src/org/python/modules/itertools/combinationsWithReplacementDerived.java | 2 +-
src/org/python/modules/itertools/compressDerived.java | 2 +-
src/org/python/modules/itertools/countDerived.java | 2 +-
src/org/python/modules/itertools/cycleDerived.java | 2 +-
src/org/python/modules/itertools/dropwhileDerived.java | 2 +-
src/org/python/modules/itertools/groupbyDerived.java | 2 +-
src/org/python/modules/itertools/ifilterDerived.java | 2 +-
src/org/python/modules/itertools/ifilterfalseDerived.java | 2 +-
src/org/python/modules/itertools/isliceDerived.java | 2 +-
src/org/python/modules/itertools/izipDerived.java | 2 +-
src/org/python/modules/itertools/izipLongestDerived.java | 2 +-
src/org/python/modules/itertools/permutationsDerived.java | 2 +-
src/org/python/modules/itertools/productDerived.java | 2 +-
src/org/python/modules/itertools/repeatDerived.java | 2 +-
src/org/python/modules/itertools/starmapDerived.java | 2 +-
src/org/python/modules/itertools/takewhileDerived.java | 2 +-
src/org/python/modules/random/PyRandomDerived.java | 2 +-
src/org/python/modules/thread/PyLocalDerived.java | 2 +-
src/org/python/modules/zipimport/zipimporterDerived.java | 2 +-
src/templates/gderived-defs | 2 +-
149 files changed, 167 insertions(+), 148 deletions(-)
diff --git a/src/org/python/antlr/ast/AssertDerived.java b/src/org/python/antlr/ast/AssertDerived.java
--- a/src/org/python/antlr/ast/AssertDerived.java
+++ b/src/org/python/antlr/ast/AssertDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/AssignDerived.java b/src/org/python/antlr/ast/AssignDerived.java
--- a/src/org/python/antlr/ast/AssignDerived.java
+++ b/src/org/python/antlr/ast/AssignDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/AttributeDerived.java b/src/org/python/antlr/ast/AttributeDerived.java
--- a/src/org/python/antlr/ast/AttributeDerived.java
+++ b/src/org/python/antlr/ast/AttributeDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/AugAssignDerived.java b/src/org/python/antlr/ast/AugAssignDerived.java
--- a/src/org/python/antlr/ast/AugAssignDerived.java
+++ b/src/org/python/antlr/ast/AugAssignDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/BinOpDerived.java b/src/org/python/antlr/ast/BinOpDerived.java
--- a/src/org/python/antlr/ast/BinOpDerived.java
+++ b/src/org/python/antlr/ast/BinOpDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/BoolOpDerived.java b/src/org/python/antlr/ast/BoolOpDerived.java
--- a/src/org/python/antlr/ast/BoolOpDerived.java
+++ b/src/org/python/antlr/ast/BoolOpDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/BreakDerived.java b/src/org/python/antlr/ast/BreakDerived.java
--- a/src/org/python/antlr/ast/BreakDerived.java
+++ b/src/org/python/antlr/ast/BreakDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/CallDerived.java b/src/org/python/antlr/ast/CallDerived.java
--- a/src/org/python/antlr/ast/CallDerived.java
+++ b/src/org/python/antlr/ast/CallDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ClassDefDerived.java b/src/org/python/antlr/ast/ClassDefDerived.java
--- a/src/org/python/antlr/ast/ClassDefDerived.java
+++ b/src/org/python/antlr/ast/ClassDefDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/CompareDerived.java b/src/org/python/antlr/ast/CompareDerived.java
--- a/src/org/python/antlr/ast/CompareDerived.java
+++ b/src/org/python/antlr/ast/CompareDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ContinueDerived.java b/src/org/python/antlr/ast/ContinueDerived.java
--- a/src/org/python/antlr/ast/ContinueDerived.java
+++ b/src/org/python/antlr/ast/ContinueDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/DeleteDerived.java b/src/org/python/antlr/ast/DeleteDerived.java
--- a/src/org/python/antlr/ast/DeleteDerived.java
+++ b/src/org/python/antlr/ast/DeleteDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/DictDerived.java b/src/org/python/antlr/ast/DictDerived.java
--- a/src/org/python/antlr/ast/DictDerived.java
+++ b/src/org/python/antlr/ast/DictDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/EllipsisDerived.java b/src/org/python/antlr/ast/EllipsisDerived.java
--- a/src/org/python/antlr/ast/EllipsisDerived.java
+++ b/src/org/python/antlr/ast/EllipsisDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ExceptHandlerDerived.java b/src/org/python/antlr/ast/ExceptHandlerDerived.java
--- a/src/org/python/antlr/ast/ExceptHandlerDerived.java
+++ b/src/org/python/antlr/ast/ExceptHandlerDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ExecDerived.java b/src/org/python/antlr/ast/ExecDerived.java
--- a/src/org/python/antlr/ast/ExecDerived.java
+++ b/src/org/python/antlr/ast/ExecDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ExprDerived.java b/src/org/python/antlr/ast/ExprDerived.java
--- a/src/org/python/antlr/ast/ExprDerived.java
+++ b/src/org/python/antlr/ast/ExprDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ExpressionDerived.java b/src/org/python/antlr/ast/ExpressionDerived.java
--- a/src/org/python/antlr/ast/ExpressionDerived.java
+++ b/src/org/python/antlr/ast/ExpressionDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ExtSliceDerived.java b/src/org/python/antlr/ast/ExtSliceDerived.java
--- a/src/org/python/antlr/ast/ExtSliceDerived.java
+++ b/src/org/python/antlr/ast/ExtSliceDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ForDerived.java b/src/org/python/antlr/ast/ForDerived.java
--- a/src/org/python/antlr/ast/ForDerived.java
+++ b/src/org/python/antlr/ast/ForDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/FunctionDefDerived.java b/src/org/python/antlr/ast/FunctionDefDerived.java
--- a/src/org/python/antlr/ast/FunctionDefDerived.java
+++ b/src/org/python/antlr/ast/FunctionDefDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/GeneratorExpDerived.java b/src/org/python/antlr/ast/GeneratorExpDerived.java
--- a/src/org/python/antlr/ast/GeneratorExpDerived.java
+++ b/src/org/python/antlr/ast/GeneratorExpDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/GlobalDerived.java b/src/org/python/antlr/ast/GlobalDerived.java
--- a/src/org/python/antlr/ast/GlobalDerived.java
+++ b/src/org/python/antlr/ast/GlobalDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/IfDerived.java b/src/org/python/antlr/ast/IfDerived.java
--- a/src/org/python/antlr/ast/IfDerived.java
+++ b/src/org/python/antlr/ast/IfDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/IfExpDerived.java b/src/org/python/antlr/ast/IfExpDerived.java
--- a/src/org/python/antlr/ast/IfExpDerived.java
+++ b/src/org/python/antlr/ast/IfExpDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ImportDerived.java b/src/org/python/antlr/ast/ImportDerived.java
--- a/src/org/python/antlr/ast/ImportDerived.java
+++ b/src/org/python/antlr/ast/ImportDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ImportFromDerived.java b/src/org/python/antlr/ast/ImportFromDerived.java
--- a/src/org/python/antlr/ast/ImportFromDerived.java
+++ b/src/org/python/antlr/ast/ImportFromDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/IndexDerived.java b/src/org/python/antlr/ast/IndexDerived.java
--- a/src/org/python/antlr/ast/IndexDerived.java
+++ b/src/org/python/antlr/ast/IndexDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/InteractiveDerived.java b/src/org/python/antlr/ast/InteractiveDerived.java
--- a/src/org/python/antlr/ast/InteractiveDerived.java
+++ b/src/org/python/antlr/ast/InteractiveDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/LambdaDerived.java b/src/org/python/antlr/ast/LambdaDerived.java
--- a/src/org/python/antlr/ast/LambdaDerived.java
+++ b/src/org/python/antlr/ast/LambdaDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ListCompDerived.java b/src/org/python/antlr/ast/ListCompDerived.java
--- a/src/org/python/antlr/ast/ListCompDerived.java
+++ b/src/org/python/antlr/ast/ListCompDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ListDerived.java b/src/org/python/antlr/ast/ListDerived.java
--- a/src/org/python/antlr/ast/ListDerived.java
+++ b/src/org/python/antlr/ast/ListDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ModuleDerived.java b/src/org/python/antlr/ast/ModuleDerived.java
--- a/src/org/python/antlr/ast/ModuleDerived.java
+++ b/src/org/python/antlr/ast/ModuleDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/NameDerived.java b/src/org/python/antlr/ast/NameDerived.java
--- a/src/org/python/antlr/ast/NameDerived.java
+++ b/src/org/python/antlr/ast/NameDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/NumDerived.java b/src/org/python/antlr/ast/NumDerived.java
--- a/src/org/python/antlr/ast/NumDerived.java
+++ b/src/org/python/antlr/ast/NumDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/PassDerived.java b/src/org/python/antlr/ast/PassDerived.java
--- a/src/org/python/antlr/ast/PassDerived.java
+++ b/src/org/python/antlr/ast/PassDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/PrintDerived.java b/src/org/python/antlr/ast/PrintDerived.java
--- a/src/org/python/antlr/ast/PrintDerived.java
+++ b/src/org/python/antlr/ast/PrintDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/RaiseDerived.java b/src/org/python/antlr/ast/RaiseDerived.java
--- a/src/org/python/antlr/ast/RaiseDerived.java
+++ b/src/org/python/antlr/ast/RaiseDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ReprDerived.java b/src/org/python/antlr/ast/ReprDerived.java
--- a/src/org/python/antlr/ast/ReprDerived.java
+++ b/src/org/python/antlr/ast/ReprDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/ReturnDerived.java b/src/org/python/antlr/ast/ReturnDerived.java
--- a/src/org/python/antlr/ast/ReturnDerived.java
+++ b/src/org/python/antlr/ast/ReturnDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/SliceDerived.java b/src/org/python/antlr/ast/SliceDerived.java
--- a/src/org/python/antlr/ast/SliceDerived.java
+++ b/src/org/python/antlr/ast/SliceDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/StrDerived.java b/src/org/python/antlr/ast/StrDerived.java
--- a/src/org/python/antlr/ast/StrDerived.java
+++ b/src/org/python/antlr/ast/StrDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/SubscriptDerived.java b/src/org/python/antlr/ast/SubscriptDerived.java
--- a/src/org/python/antlr/ast/SubscriptDerived.java
+++ b/src/org/python/antlr/ast/SubscriptDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/SuiteDerived.java b/src/org/python/antlr/ast/SuiteDerived.java
--- a/src/org/python/antlr/ast/SuiteDerived.java
+++ b/src/org/python/antlr/ast/SuiteDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/TryExceptDerived.java b/src/org/python/antlr/ast/TryExceptDerived.java
--- a/src/org/python/antlr/ast/TryExceptDerived.java
+++ b/src/org/python/antlr/ast/TryExceptDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/TryFinallyDerived.java b/src/org/python/antlr/ast/TryFinallyDerived.java
--- a/src/org/python/antlr/ast/TryFinallyDerived.java
+++ b/src/org/python/antlr/ast/TryFinallyDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/TupleDerived.java b/src/org/python/antlr/ast/TupleDerived.java
--- a/src/org/python/antlr/ast/TupleDerived.java
+++ b/src/org/python/antlr/ast/TupleDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/UnaryOpDerived.java b/src/org/python/antlr/ast/UnaryOpDerived.java
--- a/src/org/python/antlr/ast/UnaryOpDerived.java
+++ b/src/org/python/antlr/ast/UnaryOpDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/WhileDerived.java b/src/org/python/antlr/ast/WhileDerived.java
--- a/src/org/python/antlr/ast/WhileDerived.java
+++ b/src/org/python/antlr/ast/WhileDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/WithDerived.java b/src/org/python/antlr/ast/WithDerived.java
--- a/src/org/python/antlr/ast/WithDerived.java
+++ b/src/org/python/antlr/ast/WithDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/YieldDerived.java b/src/org/python/antlr/ast/YieldDerived.java
--- a/src/org/python/antlr/ast/YieldDerived.java
+++ b/src/org/python/antlr/ast/YieldDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/aliasDerived.java b/src/org/python/antlr/ast/aliasDerived.java
--- a/src/org/python/antlr/ast/aliasDerived.java
+++ b/src/org/python/antlr/ast/aliasDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/argumentsDerived.java b/src/org/python/antlr/ast/argumentsDerived.java
--- a/src/org/python/antlr/ast/argumentsDerived.java
+++ b/src/org/python/antlr/ast/argumentsDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/comprehensionDerived.java b/src/org/python/antlr/ast/comprehensionDerived.java
--- a/src/org/python/antlr/ast/comprehensionDerived.java
+++ b/src/org/python/antlr/ast/comprehensionDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/ast/keywordDerived.java b/src/org/python/antlr/ast/keywordDerived.java
--- a/src/org/python/antlr/ast/keywordDerived.java
+++ b/src/org/python/antlr/ast/keywordDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/AddDerived.java b/src/org/python/antlr/op/AddDerived.java
--- a/src/org/python/antlr/op/AddDerived.java
+++ b/src/org/python/antlr/op/AddDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/AndDerived.java b/src/org/python/antlr/op/AndDerived.java
--- a/src/org/python/antlr/op/AndDerived.java
+++ b/src/org/python/antlr/op/AndDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/AugLoadDerived.java b/src/org/python/antlr/op/AugLoadDerived.java
--- a/src/org/python/antlr/op/AugLoadDerived.java
+++ b/src/org/python/antlr/op/AugLoadDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/AugStoreDerived.java b/src/org/python/antlr/op/AugStoreDerived.java
--- a/src/org/python/antlr/op/AugStoreDerived.java
+++ b/src/org/python/antlr/op/AugStoreDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/BitAndDerived.java b/src/org/python/antlr/op/BitAndDerived.java
--- a/src/org/python/antlr/op/BitAndDerived.java
+++ b/src/org/python/antlr/op/BitAndDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/BitOrDerived.java b/src/org/python/antlr/op/BitOrDerived.java
--- a/src/org/python/antlr/op/BitOrDerived.java
+++ b/src/org/python/antlr/op/BitOrDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/BitXorDerived.java b/src/org/python/antlr/op/BitXorDerived.java
--- a/src/org/python/antlr/op/BitXorDerived.java
+++ b/src/org/python/antlr/op/BitXorDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/DelDerived.java b/src/org/python/antlr/op/DelDerived.java
--- a/src/org/python/antlr/op/DelDerived.java
+++ b/src/org/python/antlr/op/DelDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/DivDerived.java b/src/org/python/antlr/op/DivDerived.java
--- a/src/org/python/antlr/op/DivDerived.java
+++ b/src/org/python/antlr/op/DivDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/EqDerived.java b/src/org/python/antlr/op/EqDerived.java
--- a/src/org/python/antlr/op/EqDerived.java
+++ b/src/org/python/antlr/op/EqDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/FloorDivDerived.java b/src/org/python/antlr/op/FloorDivDerived.java
--- a/src/org/python/antlr/op/FloorDivDerived.java
+++ b/src/org/python/antlr/op/FloorDivDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/GtDerived.java b/src/org/python/antlr/op/GtDerived.java
--- a/src/org/python/antlr/op/GtDerived.java
+++ b/src/org/python/antlr/op/GtDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/GtEDerived.java b/src/org/python/antlr/op/GtEDerived.java
--- a/src/org/python/antlr/op/GtEDerived.java
+++ b/src/org/python/antlr/op/GtEDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/InDerived.java b/src/org/python/antlr/op/InDerived.java
--- a/src/org/python/antlr/op/InDerived.java
+++ b/src/org/python/antlr/op/InDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/InvertDerived.java b/src/org/python/antlr/op/InvertDerived.java
--- a/src/org/python/antlr/op/InvertDerived.java
+++ b/src/org/python/antlr/op/InvertDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/IsDerived.java b/src/org/python/antlr/op/IsDerived.java
--- a/src/org/python/antlr/op/IsDerived.java
+++ b/src/org/python/antlr/op/IsDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/IsNotDerived.java b/src/org/python/antlr/op/IsNotDerived.java
--- a/src/org/python/antlr/op/IsNotDerived.java
+++ b/src/org/python/antlr/op/IsNotDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/LShiftDerived.java b/src/org/python/antlr/op/LShiftDerived.java
--- a/src/org/python/antlr/op/LShiftDerived.java
+++ b/src/org/python/antlr/op/LShiftDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/LoadDerived.java b/src/org/python/antlr/op/LoadDerived.java
--- a/src/org/python/antlr/op/LoadDerived.java
+++ b/src/org/python/antlr/op/LoadDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/LtDerived.java b/src/org/python/antlr/op/LtDerived.java
--- a/src/org/python/antlr/op/LtDerived.java
+++ b/src/org/python/antlr/op/LtDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/LtEDerived.java b/src/org/python/antlr/op/LtEDerived.java
--- a/src/org/python/antlr/op/LtEDerived.java
+++ b/src/org/python/antlr/op/LtEDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/ModDerived.java b/src/org/python/antlr/op/ModDerived.java
--- a/src/org/python/antlr/op/ModDerived.java
+++ b/src/org/python/antlr/op/ModDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/MultDerived.java b/src/org/python/antlr/op/MultDerived.java
--- a/src/org/python/antlr/op/MultDerived.java
+++ b/src/org/python/antlr/op/MultDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/NotDerived.java b/src/org/python/antlr/op/NotDerived.java
--- a/src/org/python/antlr/op/NotDerived.java
+++ b/src/org/python/antlr/op/NotDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/NotEqDerived.java b/src/org/python/antlr/op/NotEqDerived.java
--- a/src/org/python/antlr/op/NotEqDerived.java
+++ b/src/org/python/antlr/op/NotEqDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/NotInDerived.java b/src/org/python/antlr/op/NotInDerived.java
--- a/src/org/python/antlr/op/NotInDerived.java
+++ b/src/org/python/antlr/op/NotInDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/OrDerived.java b/src/org/python/antlr/op/OrDerived.java
--- a/src/org/python/antlr/op/OrDerived.java
+++ b/src/org/python/antlr/op/OrDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/ParamDerived.java b/src/org/python/antlr/op/ParamDerived.java
--- a/src/org/python/antlr/op/ParamDerived.java
+++ b/src/org/python/antlr/op/ParamDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/PowDerived.java b/src/org/python/antlr/op/PowDerived.java
--- a/src/org/python/antlr/op/PowDerived.java
+++ b/src/org/python/antlr/op/PowDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/RShiftDerived.java b/src/org/python/antlr/op/RShiftDerived.java
--- a/src/org/python/antlr/op/RShiftDerived.java
+++ b/src/org/python/antlr/op/RShiftDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/StoreDerived.java b/src/org/python/antlr/op/StoreDerived.java
--- a/src/org/python/antlr/op/StoreDerived.java
+++ b/src/org/python/antlr/op/StoreDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/SubDerived.java b/src/org/python/antlr/op/SubDerived.java
--- a/src/org/python/antlr/op/SubDerived.java
+++ b/src/org/python/antlr/op/SubDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/UAddDerived.java b/src/org/python/antlr/op/UAddDerived.java
--- a/src/org/python/antlr/op/UAddDerived.java
+++ b/src/org/python/antlr/op/UAddDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/antlr/op/USubDerived.java b/src/org/python/antlr/op/USubDerived.java
--- a/src/org/python/antlr/op/USubDerived.java
+++ b/src/org/python/antlr/op/USubDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/ClasspathPyImporterDerived.java b/src/org/python/core/ClasspathPyImporterDerived.java
--- a/src/org/python/core/ClasspathPyImporterDerived.java
+++ b/src/org/python/core/ClasspathPyImporterDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public ClasspathPyImporterDerived(PyType subtype) {
diff --git a/src/org/python/core/PyArrayDerived.java b/src/org/python/core/PyArrayDerived.java
--- a/src/org/python/core/PyArrayDerived.java
+++ b/src/org/python/core/PyArrayDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyBaseExceptionDerived.java b/src/org/python/core/PyBaseExceptionDerived.java
--- a/src/org/python/core/PyBaseExceptionDerived.java
+++ b/src/org/python/core/PyBaseExceptionDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyBaseExceptionDerived(PyType subtype) {
diff --git a/src/org/python/core/PyByteArrayDerived.java b/src/org/python/core/PyByteArrayDerived.java
--- a/src/org/python/core/PyByteArrayDerived.java
+++ b/src/org/python/core/PyByteArrayDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyClassMethodDerived.java b/src/org/python/core/PyClassMethodDerived.java
--- a/src/org/python/core/PyClassMethodDerived.java
+++ b/src/org/python/core/PyClassMethodDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyComplexDerived.java b/src/org/python/core/PyComplexDerived.java
--- a/src/org/python/core/PyComplexDerived.java
+++ b/src/org/python/core/PyComplexDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyDictionaryDerived.java b/src/org/python/core/PyDictionaryDerived.java
--- a/src/org/python/core/PyDictionaryDerived.java
+++ b/src/org/python/core/PyDictionaryDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyEnumerateDerived.java b/src/org/python/core/PyEnumerateDerived.java
--- a/src/org/python/core/PyEnumerateDerived.java
+++ b/src/org/python/core/PyEnumerateDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyFileDerived.java b/src/org/python/core/PyFileDerived.java
--- a/src/org/python/core/PyFileDerived.java
+++ b/src/org/python/core/PyFileDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyFloatDerived.java b/src/org/python/core/PyFloatDerived.java
--- a/src/org/python/core/PyFloatDerived.java
+++ b/src/org/python/core/PyFloatDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyFrozenSetDerived.java b/src/org/python/core/PyFrozenSetDerived.java
--- a/src/org/python/core/PyFrozenSetDerived.java
+++ b/src/org/python/core/PyFrozenSetDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyInstance.java b/src/org/python/core/PyInstance.java
--- a/src/org/python/core/PyInstance.java
+++ b/src/org/python/core/PyInstance.java
@@ -154,7 +154,7 @@
}
public static void ensureFinalizer(PyObject[] args, String[] kws) {
- FinalizeTrigger.ensureFinalizer((PyInstance) args[0]);
+ ((PyInstance) args[0]).finalizeTrigger = FinalizeTrigger.makeTrigger((PyInstance) args[0]);
}
private static JavaFunc makeFunction__ensure_finalizer__() {
diff --git a/src/org/python/core/PyIntegerDerived.java b/src/org/python/core/PyIntegerDerived.java
--- a/src/org/python/core/PyIntegerDerived.java
+++ b/src/org/python/core/PyIntegerDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyListDerived.java b/src/org/python/core/PyListDerived.java
--- a/src/org/python/core/PyListDerived.java
+++ b/src/org/python/core/PyListDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyLongDerived.java b/src/org/python/core/PyLongDerived.java
--- a/src/org/python/core/PyLongDerived.java
+++ b/src/org/python/core/PyLongDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyModuleDerived.java b/src/org/python/core/PyModuleDerived.java
--- a/src/org/python/core/PyModuleDerived.java
+++ b/src/org/python/core/PyModuleDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyModuleDerived(PyType subtype) {
diff --git a/src/org/python/core/PyObjectDerived.java b/src/org/python/core/PyObjectDerived.java
--- a/src/org/python/core/PyObjectDerived.java
+++ b/src/org/python/core/PyObjectDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyPropertyDerived.java b/src/org/python/core/PyPropertyDerived.java
--- a/src/org/python/core/PyPropertyDerived.java
+++ b/src/org/python/core/PyPropertyDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PySetDerived.java b/src/org/python/core/PySetDerived.java
--- a/src/org/python/core/PySetDerived.java
+++ b/src/org/python/core/PySetDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyStringDerived.java b/src/org/python/core/PyStringDerived.java
--- a/src/org/python/core/PyStringDerived.java
+++ b/src/org/python/core/PyStringDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PySuperDerived.java b/src/org/python/core/PySuperDerived.java
--- a/src/org/python/core/PySuperDerived.java
+++ b/src/org/python/core/PySuperDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyTupleDerived.java b/src/org/python/core/PyTupleDerived.java
--- a/src/org/python/core/PyTupleDerived.java
+++ b/src/org/python/core/PyTupleDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/PyTypeDerived.java b/src/org/python/core/PyTypeDerived.java
--- a/src/org/python/core/PyTypeDerived.java
+++ b/src/org/python/core/PyTypeDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyTypeDerived(PyType subtype) {
diff --git a/src/org/python/core/PyUnicodeDerived.java b/src/org/python/core/PyUnicodeDerived.java
--- a/src/org/python/core/PyUnicodeDerived.java
+++ b/src/org/python/core/PyUnicodeDerived.java
@@ -28,7 +28,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/core/finalization/FinalizablePyObject.java b/src/org/python/core/finalization/FinalizablePyObject.java
--- a/src/org/python/core/finalization/FinalizablePyObject.java
+++ b/src/org/python/core/finalization/FinalizablePyObject.java
@@ -62,6 +62,10 @@
* In the block where the resurrection occurs, let your {@code __del__}- or
* {@code __del_builtin__}-method call
* {@code FinalizeTrigger.ensureFinalizer(this);}.
+ * If you implement {@code __del__} in Python and need this functionality, you can
+ * simply call {@code someObject.__ensure_finalizer__()}
+ * Note that this is Jython specific and should be surrounded by a {@code try/except}
+ * block to ensure compatibility with other Python implementations.
*
*
*
@@ -73,6 +77,21 @@
* achieve this manually via step 5).
*
*
+ * The built-in function {@code __ensure_finalizer__} is also useful if a class acquires a
+ * finalizer after instances have already been created. Usually only those instances that were
+ * created after their class acquired the finalizer will actually be finalized (in contrast to
+ * CPython).
+ * However, one can manually tell earlier created instances to become finalizable by
+ * calling {@code __ensure_finalizer__()} on them. As mentioned above, it is recommended to
+ * surround this with a {@code try/except} block to ensure compatibility with other Python
+ * implementations.
+ *
+ *
+ * Note that it is not possible to overwrite {@code __ensure_finalizer__} on Python side.
+ * If one overwrites {@code __ensure_finalizer__} on Python side, Jython will ignore the
+ * overwrite-implementation and still call the original one.
+ *
+ *
* It is possible to switch finalization on and off at any desired time for a certain object.
* This can be helpful if it is only necessary to have {@code __del__} or
* {@code __del_builtin__} called for certain configurations of an object.
diff --git a/src/org/python/modules/PyStructDerived.java b/src/org/python/modules/PyStructDerived.java
--- a/src/org/python/modules/PyStructDerived.java
+++ b/src/org/python/modules/PyStructDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/_collections/PyDefaultDictDerived.java b/src/org/python/modules/_collections/PyDefaultDictDerived.java
--- a/src/org/python/modules/_collections/PyDefaultDictDerived.java
+++ b/src/org/python/modules/_collections/PyDefaultDictDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/_collections/PyDequeDerived.java b/src/org/python/modules/_collections/PyDequeDerived.java
--- a/src/org/python/modules/_collections/PyDequeDerived.java
+++ b/src/org/python/modules/_collections/PyDequeDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/_csv/PyDialectDerived.java b/src/org/python/modules/_csv/PyDialectDerived.java
--- a/src/org/python/modules/_csv/PyDialectDerived.java
+++ b/src/org/python/modules/_csv/PyDialectDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyDialectDerived(PyType subtype) {
diff --git a/src/org/python/modules/_functools/PyPartialDerived.java b/src/org/python/modules/_functools/PyPartialDerived.java
--- a/src/org/python/modules/_functools/PyPartialDerived.java
+++ b/src/org/python/modules/_functools/PyPartialDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/_io/PyFileIODerived.java b/src/org/python/modules/_io/PyFileIODerived.java
--- a/src/org/python/modules/_io/PyFileIODerived.java
+++ b/src/org/python/modules/_io/PyFileIODerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyFileIODerived(PyType subtype,PyObject file,OpenMode mode,boolean closefd) {
diff --git a/src/org/python/modules/_io/PyIOBaseDerived.java b/src/org/python/modules/_io/PyIOBaseDerived.java
--- a/src/org/python/modules/_io/PyIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyIOBaseDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyIOBaseDerived(PyType subtype) {
diff --git a/src/org/python/modules/_io/PyRawIOBaseDerived.java b/src/org/python/modules/_io/PyRawIOBaseDerived.java
--- a/src/org/python/modules/_io/PyRawIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyRawIOBaseDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyRawIOBaseDerived(PyType subtype) {
diff --git a/src/org/python/modules/_weakref/ReferenceTypeDerived.java b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
--- a/src/org/python/modules/_weakref/ReferenceTypeDerived.java
+++ b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/bz2/PyBZ2FileDerived.java b/src/org/python/modules/bz2/PyBZ2FileDerived.java
--- a/src/org/python/modules/bz2/PyBZ2FileDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2FileDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/PyTeeIteratorDerived.java b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
--- a/src/org/python/modules/itertools/PyTeeIteratorDerived.java
+++ b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/chainDerived.java b/src/org/python/modules/itertools/chainDerived.java
--- a/src/org/python/modules/itertools/chainDerived.java
+++ b/src/org/python/modules/itertools/chainDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/combinationsDerived.java b/src/org/python/modules/itertools/combinationsDerived.java
--- a/src/org/python/modules/itertools/combinationsDerived.java
+++ b/src/org/python/modules/itertools/combinationsDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
--- a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
+++ b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/compressDerived.java b/src/org/python/modules/itertools/compressDerived.java
--- a/src/org/python/modules/itertools/compressDerived.java
+++ b/src/org/python/modules/itertools/compressDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/countDerived.java b/src/org/python/modules/itertools/countDerived.java
--- a/src/org/python/modules/itertools/countDerived.java
+++ b/src/org/python/modules/itertools/countDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/cycleDerived.java b/src/org/python/modules/itertools/cycleDerived.java
--- a/src/org/python/modules/itertools/cycleDerived.java
+++ b/src/org/python/modules/itertools/cycleDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/dropwhileDerived.java b/src/org/python/modules/itertools/dropwhileDerived.java
--- a/src/org/python/modules/itertools/dropwhileDerived.java
+++ b/src/org/python/modules/itertools/dropwhileDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/groupbyDerived.java b/src/org/python/modules/itertools/groupbyDerived.java
--- a/src/org/python/modules/itertools/groupbyDerived.java
+++ b/src/org/python/modules/itertools/groupbyDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/ifilterDerived.java b/src/org/python/modules/itertools/ifilterDerived.java
--- a/src/org/python/modules/itertools/ifilterDerived.java
+++ b/src/org/python/modules/itertools/ifilterDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/ifilterfalseDerived.java b/src/org/python/modules/itertools/ifilterfalseDerived.java
--- a/src/org/python/modules/itertools/ifilterfalseDerived.java
+++ b/src/org/python/modules/itertools/ifilterfalseDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/isliceDerived.java b/src/org/python/modules/itertools/isliceDerived.java
--- a/src/org/python/modules/itertools/isliceDerived.java
+++ b/src/org/python/modules/itertools/isliceDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/izipDerived.java b/src/org/python/modules/itertools/izipDerived.java
--- a/src/org/python/modules/itertools/izipDerived.java
+++ b/src/org/python/modules/itertools/izipDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/izipLongestDerived.java b/src/org/python/modules/itertools/izipLongestDerived.java
--- a/src/org/python/modules/itertools/izipLongestDerived.java
+++ b/src/org/python/modules/itertools/izipLongestDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/permutationsDerived.java b/src/org/python/modules/itertools/permutationsDerived.java
--- a/src/org/python/modules/itertools/permutationsDerived.java
+++ b/src/org/python/modules/itertools/permutationsDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/productDerived.java b/src/org/python/modules/itertools/productDerived.java
--- a/src/org/python/modules/itertools/productDerived.java
+++ b/src/org/python/modules/itertools/productDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/repeatDerived.java b/src/org/python/modules/itertools/repeatDerived.java
--- a/src/org/python/modules/itertools/repeatDerived.java
+++ b/src/org/python/modules/itertools/repeatDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/starmapDerived.java b/src/org/python/modules/itertools/starmapDerived.java
--- a/src/org/python/modules/itertools/starmapDerived.java
+++ b/src/org/python/modules/itertools/starmapDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/takewhileDerived.java b/src/org/python/modules/itertools/takewhileDerived.java
--- a/src/org/python/modules/itertools/takewhileDerived.java
+++ b/src/org/python/modules/itertools/takewhileDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/random/PyRandomDerived.java b/src/org/python/modules/random/PyRandomDerived.java
--- a/src/org/python/modules/random/PyRandomDerived.java
+++ b/src/org/python/modules/random/PyRandomDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/thread/PyLocalDerived.java b/src/org/python/modules/thread/PyLocalDerived.java
--- a/src/org/python/modules/thread/PyLocalDerived.java
+++ b/src/org/python/modules/thread/PyLocalDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyLocalDerived(PyType subtype) {
diff --git a/src/org/python/modules/zipimport/zipimporterDerived.java b/src/org/python/modules/zipimport/zipimporterDerived.java
--- a/src/org/python/modules/zipimport/zipimporterDerived.java
+++ b/src/org/python/modules/zipimport/zipimporterDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/templates/gderived-defs b/src/templates/gderived-defs
--- a/src/templates/gderived-defs
+++ b/src/templates/gderived-defs
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
`decls;
--
Repository URL: http://hg.python.org/jython
From jython-checkins at python.org Thu Sep 4 06:35:45 2014
From: jython-checkins at python.org (jim.baker)
Date: Thu, 4 Sep 2014 06:35:45 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython=3A_Fixed_some_more_tab_occurre?=
=?utf-8?q?nces_and_refined_the_doc_of_FinalizeTriggerFactory?=
Message-ID: <3hpTjF65WGz7Lk4@mail.python.org>
http://hg.python.org/jython/rev/d84a896267cc
changeset: 7365:d84a896267cc
user: Stefan Richthofer
date: Thu Aug 28 23:35:44 2014 +0200
summary:
Fixed some more tab occurrences and refined the doc of FinalizeTriggerFactory and the factory hook in FinalizeTrigger. Instead of just pointing out that it is needed by JyNI, the doc now states that the hook is reserved for use by JyNI. This is neccessary because if another extension would use it, this would possibly interfere with JyNI, yielding unforeseeable results. And honestly I really can't imagine a usecase for it other than JyNI ;)
files:
src/org/python/core/PyInstance.java | 5 +++--
src/org/python/core/finalization/FinalizablePyObject.java | 2 +-
src/org/python/core/finalization/FinalizeTrigger.java | 5 +++--
src/org/python/core/finalization/FinalizeTriggerFactory.java | 7 +++++--
src/templates/gderived-defs | 10 +++++-----
5 files changed, 17 insertions(+), 12 deletions(-)
diff --git a/src/org/python/core/PyInstance.java b/src/org/python/core/PyInstance.java
--- a/src/org/python/core/PyInstance.java
+++ b/src/org/python/core/PyInstance.java
@@ -154,9 +154,10 @@
}
public static void ensureFinalizer(PyObject[] args, String[] kws) {
- ((PyInstance) args[0]).finalizeTrigger = FinalizeTrigger.makeTrigger((PyInstance) args[0]);
+ ((PyInstance) args[0]).finalizeTrigger = FinalizeTrigger.makeTrigger(
+ (PyInstance) args[0]);
}
-
+
private static JavaFunc makeFunction__ensure_finalizer__() {
try {
return new JavaFunc(
diff --git a/src/org/python/core/finalization/FinalizablePyObject.java b/src/org/python/core/finalization/FinalizablePyObject.java
--- a/src/org/python/core/finalization/FinalizablePyObject.java
+++ b/src/org/python/core/finalization/FinalizablePyObject.java
@@ -58,7 +58,7 @@
*
* (optional)
* If your finalizer resurrects the object (Python allows this) and you wish the
- * finalizer to run again on next collection of the object:
+ * finalizer to run again on next collection of the object:
* In the block where the resurrection occurs, let your {@code __del__}- or
* {@code __del_builtin__}-method call
* {@code FinalizeTrigger.ensureFinalizer(this);}.
+ * If you implement {@code __del__} in Python and need this functionality, you can
+ * simply call {@code someObject.__ensure_finalizer__()}
+ * Note that this is Jython specific and should be surrounded by a {@code try/except}
+ * block to ensure compatibility with other Python implementations.
*
*
*
@@ -73,6 +77,21 @@
* achieve this manually via step 5).
*
*
+ * The built-in function {@code __ensure_finalizer__} is also useful if a class acquires a
+ * finalizer after instances have already been created. Usually only those instances that were
+ * created after their class acquired the finalizer will actually be finalized (in contrast to
+ * CPython).
+ * However, one can manually tell earlier created instances to become finalizable by
+ * calling {@code __ensure_finalizer__()} on them. As mentioned above, it is recommended to
+ * surround this with a {@code try/except} block to ensure compatibility with other Python
+ * implementations.
+ *
+ *
+ * Note that it is not possible to overwrite {@code __ensure_finalizer__} on Python side.
+ * If one overwrites {@code __ensure_finalizer__} on Python side, Jython will ignore the
+ * overwrite-implementation and still call the original one.
+ *
+ *
* It is possible to switch finalization on and off at any desired time for a certain object.
* This can be helpful if it is only necessary to have {@code __del__} or
* {@code __del_builtin__} called for certain configurations of an object.
diff --git a/src/org/python/core/finalization/FinalizeTrigger.java b/src/org/python/core/finalization/FinalizeTrigger.java
--- a/src/org/python/core/finalization/FinalizeTrigger.java
+++ b/src/org/python/core/finalization/FinalizeTrigger.java
@@ -9,8 +9,9 @@
public class FinalizeTrigger {
/**
- * This optional factory hook allows to replace the
- * default {@code FinalizeTrigger}. It is f.i. needed by JyNI.
+ * This factory hook is reserved for use by JyNI.
+ * It allows to replace the default {@code FinalizeTrigger}.
+ * JyNI needs it to support garbage collection.
*/
public static FinalizeTriggerFactory factory;
diff --git a/src/org/python/core/finalization/FinalizeTriggerFactory.java b/src/org/python/core/finalization/FinalizeTriggerFactory.java
--- a/src/org/python/core/finalization/FinalizeTriggerFactory.java
+++ b/src/org/python/core/finalization/FinalizeTriggerFactory.java
@@ -1,6 +1,9 @@
package org.python.core.finalization;
+/**
+ * Reserved for use by JyNI.
+ */
public interface FinalizeTriggerFactory {
-
- public FinalizeTrigger makeTrigger(HasFinalizeTrigger toFinalize);
+
+ public FinalizeTrigger makeTrigger(HasFinalizeTrigger toFinalize);
}
diff --git a/src/org/python/modules/PyStructDerived.java b/src/org/python/modules/PyStructDerived.java
--- a/src/org/python/modules/PyStructDerived.java
+++ b/src/org/python/modules/PyStructDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/_collections/PyDefaultDictDerived.java b/src/org/python/modules/_collections/PyDefaultDictDerived.java
--- a/src/org/python/modules/_collections/PyDefaultDictDerived.java
+++ b/src/org/python/modules/_collections/PyDefaultDictDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/_collections/PyDequeDerived.java b/src/org/python/modules/_collections/PyDequeDerived.java
--- a/src/org/python/modules/_collections/PyDequeDerived.java
+++ b/src/org/python/modules/_collections/PyDequeDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/_csv/PyDialectDerived.java b/src/org/python/modules/_csv/PyDialectDerived.java
--- a/src/org/python/modules/_csv/PyDialectDerived.java
+++ b/src/org/python/modules/_csv/PyDialectDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyDialectDerived(PyType subtype) {
diff --git a/src/org/python/modules/_functools/PyPartialDerived.java b/src/org/python/modules/_functools/PyPartialDerived.java
--- a/src/org/python/modules/_functools/PyPartialDerived.java
+++ b/src/org/python/modules/_functools/PyPartialDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/_io/PyFileIODerived.java b/src/org/python/modules/_io/PyFileIODerived.java
--- a/src/org/python/modules/_io/PyFileIODerived.java
+++ b/src/org/python/modules/_io/PyFileIODerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyFileIODerived(PyType subtype,PyObject file,OpenMode mode,boolean closefd) {
diff --git a/src/org/python/modules/_io/PyIOBaseDerived.java b/src/org/python/modules/_io/PyIOBaseDerived.java
--- a/src/org/python/modules/_io/PyIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyIOBaseDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyIOBaseDerived(PyType subtype) {
diff --git a/src/org/python/modules/_io/PyRawIOBaseDerived.java b/src/org/python/modules/_io/PyRawIOBaseDerived.java
--- a/src/org/python/modules/_io/PyRawIOBaseDerived.java
+++ b/src/org/python/modules/_io/PyRawIOBaseDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyRawIOBaseDerived(PyType subtype) {
diff --git a/src/org/python/modules/_weakref/ReferenceTypeDerived.java b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
--- a/src/org/python/modules/_weakref/ReferenceTypeDerived.java
+++ b/src/org/python/modules/_weakref/ReferenceTypeDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2CompressorDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
--- a/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2DecompressorDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/bz2/PyBZ2FileDerived.java b/src/org/python/modules/bz2/PyBZ2FileDerived.java
--- a/src/org/python/modules/bz2/PyBZ2FileDerived.java
+++ b/src/org/python/modules/bz2/PyBZ2FileDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/PyTeeIteratorDerived.java b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
--- a/src/org/python/modules/itertools/PyTeeIteratorDerived.java
+++ b/src/org/python/modules/itertools/PyTeeIteratorDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/chainDerived.java b/src/org/python/modules/itertools/chainDerived.java
--- a/src/org/python/modules/itertools/chainDerived.java
+++ b/src/org/python/modules/itertools/chainDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/combinationsDerived.java b/src/org/python/modules/itertools/combinationsDerived.java
--- a/src/org/python/modules/itertools/combinationsDerived.java
+++ b/src/org/python/modules/itertools/combinationsDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
--- a/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
+++ b/src/org/python/modules/itertools/combinationsWithReplacementDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/compressDerived.java b/src/org/python/modules/itertools/compressDerived.java
--- a/src/org/python/modules/itertools/compressDerived.java
+++ b/src/org/python/modules/itertools/compressDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/countDerived.java b/src/org/python/modules/itertools/countDerived.java
--- a/src/org/python/modules/itertools/countDerived.java
+++ b/src/org/python/modules/itertools/countDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/cycleDerived.java b/src/org/python/modules/itertools/cycleDerived.java
--- a/src/org/python/modules/itertools/cycleDerived.java
+++ b/src/org/python/modules/itertools/cycleDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/dropwhileDerived.java b/src/org/python/modules/itertools/dropwhileDerived.java
--- a/src/org/python/modules/itertools/dropwhileDerived.java
+++ b/src/org/python/modules/itertools/dropwhileDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/groupbyDerived.java b/src/org/python/modules/itertools/groupbyDerived.java
--- a/src/org/python/modules/itertools/groupbyDerived.java
+++ b/src/org/python/modules/itertools/groupbyDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/ifilterDerived.java b/src/org/python/modules/itertools/ifilterDerived.java
--- a/src/org/python/modules/itertools/ifilterDerived.java
+++ b/src/org/python/modules/itertools/ifilterDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/ifilterfalseDerived.java b/src/org/python/modules/itertools/ifilterfalseDerived.java
--- a/src/org/python/modules/itertools/ifilterfalseDerived.java
+++ b/src/org/python/modules/itertools/ifilterfalseDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/isliceDerived.java b/src/org/python/modules/itertools/isliceDerived.java
--- a/src/org/python/modules/itertools/isliceDerived.java
+++ b/src/org/python/modules/itertools/isliceDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/izipDerived.java b/src/org/python/modules/itertools/izipDerived.java
--- a/src/org/python/modules/itertools/izipDerived.java
+++ b/src/org/python/modules/itertools/izipDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/izipLongestDerived.java b/src/org/python/modules/itertools/izipLongestDerived.java
--- a/src/org/python/modules/itertools/izipLongestDerived.java
+++ b/src/org/python/modules/itertools/izipLongestDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/permutationsDerived.java b/src/org/python/modules/itertools/permutationsDerived.java
--- a/src/org/python/modules/itertools/permutationsDerived.java
+++ b/src/org/python/modules/itertools/permutationsDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/productDerived.java b/src/org/python/modules/itertools/productDerived.java
--- a/src/org/python/modules/itertools/productDerived.java
+++ b/src/org/python/modules/itertools/productDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/repeatDerived.java b/src/org/python/modules/itertools/repeatDerived.java
--- a/src/org/python/modules/itertools/repeatDerived.java
+++ b/src/org/python/modules/itertools/repeatDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/starmapDerived.java b/src/org/python/modules/itertools/starmapDerived.java
--- a/src/org/python/modules/itertools/starmapDerived.java
+++ b/src/org/python/modules/itertools/starmapDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/itertools/takewhileDerived.java b/src/org/python/modules/itertools/takewhileDerived.java
--- a/src/org/python/modules/itertools/takewhileDerived.java
+++ b/src/org/python/modules/itertools/takewhileDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/random/PyRandomDerived.java b/src/org/python/modules/random/PyRandomDerived.java
--- a/src/org/python/modules/random/PyRandomDerived.java
+++ b/src/org/python/modules/random/PyRandomDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/org/python/modules/thread/PyLocalDerived.java b/src/org/python/modules/thread/PyLocalDerived.java
--- a/src/org/python/modules/thread/PyLocalDerived.java
+++ b/src/org/python/modules/thread/PyLocalDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
public PyLocalDerived(PyType subtype) {
diff --git a/src/org/python/modules/zipimport/zipimporterDerived.java b/src/org/python/modules/zipimport/zipimporterDerived.java
--- a/src/org/python/modules/zipimport/zipimporterDerived.java
+++ b/src/org/python/modules/zipimport/zipimporterDerived.java
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger=FinalizeTrigger.makeTrigger(this);
}
private PyObject dict;
diff --git a/src/templates/gderived-defs b/src/templates/gderived-defs
--- a/src/templates/gderived-defs
+++ b/src/templates/gderived-defs
@@ -17,11 +17,11 @@
public void setSlot(int index, PyObject value) {
slots[index] = value;
}
-
+
private PyObject[] slots;
-
+
public void __del_derived__() {
- PyType self_type = getType();
+ PyType self_type = getType();
PyObject impl = self_type.lookup("__del__");
if (impl != null) {
impl.__get__(this, self_type).__call__();
@@ -29,7 +29,7 @@
}
public void __ensure_finalizer__() {
- FinalizeTrigger.ensureFinalizer(this);
+ finalizeTrigger = FinalizeTrigger.makeTrigger(this);
}
`decls;
@@ -44,7 +44,7 @@
if (impl != null) {
PyObject res = impl.__get__(this,self_type).__call__(other);
if (res == Py.NotImplemented)
- return null;
+ return null;
return res;
}
return super.`binary(other);
@@ -56,7 +56,7 @@
if (impl != null) {
PyObject res = impl.__get__(this,self_type).__call__(other);
if (res == Py.NotImplemented)
- return null;
+ return null;
return res;
}
return super.`binary(other);
--
Repository URL: http://hg.python.org/jython
From jython-checkins at python.org Fri Sep 5 18:19:58 2014
From: jython-checkins at python.org (jim.baker)
Date: Fri, 5 Sep 2014 18:19:58 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython=3A_Add_new_jythonlib_module_to?=
=?utf-8?q?_support_libraries_in_stdlib_that_are?=
Message-ID: <3hqPHL0vh4z7Ljp@mail.python.org>
http://hg.python.org/jython/rev/7a96264b09ab
changeset: 7368:7a96264b09ab
user: Jim Baker
date: Fri Sep 05 10:19:32 2014 -0600
summary:
Add new jythonlib module to support libraries in stdlib that are
written in Python (examples: _socket, threading) that need more
precise integration from Java and Jython's runtime.
For now, this includes building dicts with arbitrary ConcurrentMap
backing, especially for Google Guava's MapMaker, without seeing
boxing/unboxing issues moving between Java and Python code.
Fixes http://bugs.jython.org/issue2192
Unblocks http://bugs.jython.org/issue1631
files:
Lib/_socket.py | 9 +-
Lib/jythonlib.py | 16 ++
Lib/test/test_threading_jy.py | 2 +-
Lib/threading.py | 19 ++-
build.xml | 2 +-
src/org/python/core/PyDictionary.java | 7 +-
src/org/python/modules/Setup.java | 59 +++++----
src/org/python/modules/_jythonlib/_jythonlib.java | 23 +++
src/org/python/modules/_jythonlib/dict_builder.java | 40 ++++++
src/org/python/modules/_threading/_threading.java | 19 +--
10 files changed, 141 insertions(+), 55 deletions(-)
diff --git a/Lib/_socket.py b/Lib/_socket.py
--- a/Lib/_socket.py
+++ b/Lib/_socket.py
@@ -13,11 +13,11 @@
from contextlib import contextmanager
from functools import partial, wraps
from itertools import chain
+from jythonlib import MapMaker, dict_builder
from numbers import Number
from StringIO import StringIO
from threading import Condition, Lock
from types import MethodType, NoneType
-from weakref import WeakKeyDictionary
import java
from java.io import IOException, InterruptedIOException
@@ -428,7 +428,7 @@
def __init__(self):
self.queue = LinkedBlockingQueue()
self.registered = dict() # fd -> eventmask
- self.socks2fd = WeakKeyDictionary() # sock -> fd
+ self.socks2fd = dict_builder(MapMaker().weakKeys().makeMap)() # sock -> fd
def notify(self, sock, exception=None, hangup=False):
notification = _PollNotification(
@@ -566,7 +566,6 @@
def exceptionCaught(self, ctx, cause):
log.debug("Channel caught exception %s", cause, extra={"sock": self.sock})
self.sock._notify_selectors(exception=cause)
- ctx.fireExceptionCaught(cause)
class ChildSocketHandler(ChannelInitializer):
@@ -885,8 +884,8 @@
self.accepted_children = 1 # include the parent as well to simplify close logic
b = ServerBootstrap()
- self.parent_group = NioEventLoopGroup(2, DaemonThreadFactory("Jython-Netty-Parent-%s"))
- self.child_group = NioEventLoopGroup(2, DaemonThreadFactory("Jython-Netty-Child-%s"))
+ self.parent_group = NioEventLoopGroup(10, DaemonThreadFactory("Jython-Netty-Parent-%s"))
+ self.child_group = NioEventLoopGroup(10, DaemonThreadFactory("Jython-Netty-Child-%s"))
b.group(self.parent_group, self.child_group)
b.channel(NioServerSocketChannel)
b.option(ChannelOption.SO_BACKLOG, backlog)
diff --git a/Lib/jythonlib.py b/Lib/jythonlib.py
new file mode 100644
--- /dev/null
+++ b/Lib/jythonlib.py
@@ -0,0 +1,16 @@
+from _jythonlib import *
+
+# Convenience imports, since this is the most common case for using
+# jythonlib, especially with MapMaker
+
+try:
+ # jarjar-ed version
+ import org.python.google.common as guava
+ from org.python.google.common.collect import MapMaker
+ from org.python.google.common.cache import CacheBuilder, CacheLoader
+except ImportError:
+ # dev version from extlibs
+ import com.google.common as guava
+ from com.google.common.collect import MapMaker
+ from com.google.common.cache import CacheBuilder, CacheLoader
+
diff --git a/Lib/test/test_threading_jy.py b/Lib/test/test_threading_jy.py
--- a/Lib/test/test_threading_jy.py
+++ b/Lib/test/test_threading_jy.py
@@ -112,7 +112,7 @@
def test_main():
test_support.run_unittest(
JavaIntegrationTestCase,
- MemoryLeakTestCase,
+ #MemoryLeakTestCase,
ThreadingTestCase,
TwistedTestCase)
diff --git a/Lib/threading.py b/Lib/threading.py
--- a/Lib/threading.py
+++ b/Lib/threading.py
@@ -4,13 +4,15 @@
from java.util.concurrent.locks import ReentrantLock
from org.python.util import jython
from org.python.core import Py
+from jythonlib import CacheBuilder, CacheLoader, MapMaker, dict_builder
from thread import _newFunctionThread
from thread import _local as local
-from _threading import Lock, RLock, Condition, _Lock, _RLock, _threads, _active, _jthread_to_pythread, _register_thread, _unregister_thread
+from _threading import Lock, RLock, Condition, _Lock, _RLock
import java.lang.Thread
import sys as _sys
from traceback import print_exc as _print_exc
+
# Rename some stuff so "from threading import *" is safe
__all__ = ['activeCount', 'active_count', 'Condition', 'currentThread',
'current_thread', 'enumerate', 'Event',
@@ -57,6 +59,8 @@
_trace_hook = func
+
+
class Semaphore(object):
def __init__(self, value=1):
if value < 0:
@@ -175,6 +179,17 @@
return Py.NoConversion
+_threads = dict_builder(MapMaker().weakValues().makeMap)()
+_active = _threads
+
+def _register_thread(jthread, pythread):
+ _threads[jthread.getId()] = pythread
+
+def _unregister_thread(jthread):
+ _threads.pop(jthread.getId(), None)
+
+
+
class Thread(JavaThread):
def __init__(self, group=None, target=None, name=None, args=None, kwargs=None):
assert group is None, "group argument must be None for now"
@@ -284,7 +299,7 @@
def currentThread():
jthread = java.lang.Thread.currentThread()
- pythread = _jthread_to_pythread[jthread]
+ pythread = _threads.get(jthread.getId())
if pythread is None:
pythread = JavaThread(jthread)
return pythread
diff --git a/build.xml b/build.xml
--- a/build.xml
+++ b/build.xml
@@ -475,7 +475,7 @@
debug="${debug}"
deprecation="${deprecation}"
nowarn="${nowarn}"
- memoryMaximumSize="512m"
+ memoryMaximumSize="1024m"
fork="true"
encoding="UTF-8">
diff --git a/src/org/python/core/PyDictionary.java b/src/org/python/core/PyDictionary.java
--- a/src/org/python/core/PyDictionary.java
+++ b/src/org/python/core/PyDictionary.java
@@ -69,6 +69,11 @@
this(TYPE, map);
}
+ public PyDictionary(ConcurrentMap backingMap, boolean useBackingMap) {
+ super(TYPE);
+ internalMap = backingMap;
+ }
+
/**
* Create a new dictionary which is populated with entries the given map.
*/
@@ -460,7 +465,7 @@
updateCommon(args, keywords, "update");
}
- private void updateCommon(PyObject[] args, String[] keywords, String methName) {
+ public void updateCommon(PyObject[] args, String[] keywords, String methName) {
int nargs = args.length - keywords.length;
if (nargs > 1) {
throw PyBuiltinCallable.DefaultInfo.unexpectedCall(nargs, false, methName, 0, 1);
diff --git a/src/org/python/modules/Setup.java b/src/org/python/modules/Setup.java
--- a/src/org/python/modules/Setup.java
+++ b/src/org/python/modules/Setup.java
@@ -27,41 +27,42 @@
// python.modules.builtin for details.
public static String[] builtinModules = {
- "jarray",
- "math",
- "thread:org.python.modules.thread.thread",
- "operator",
- "time:org.python.modules.time.Time",
+ "_ast:org.python.antlr.ast.AstModule",
+ "_codecs",
+ "_collections:org.python.modules._collections.Collections",
+ "_csv:org.python.modules._csv._csv",
+ "_functools:org.python.modules._functools._functools",
+ "_hashlib",
+ "_io:org.python.modules._io._io",
+ "_jythonlib:org.python.modules._jythonlib._jythonlib",
+ "_marshal",
"_py_compile",
+ "_random:org.python.modules.random.RandomModule",
"_sre",
- "synchronize",
+ "_systemrestart",
+ "_threading:org.python.modules._threading._threading",
+ "_weakref:org.python.modules._weakref.WeakrefModule",
+ "array:org.python.modules.ArrayModule",
+ "binascii",
+ "bz2:org.python.modules.bz2.bz2",
"cPickle",
"cStringIO",
+ "cmath",
+ "errno",
+ "exceptions:org.python.core.exceptions",
+ "gc",
+ "imp",
+ "itertools:org.python.modules.itertools.itertools",
+ "jarray",
+ "jffi:org.python.modules.jffi.jffi",
+ "math",
+ "operator",
"struct",
- "binascii",
- "exceptions:org.python.core.exceptions",
- "_codecs",
- "imp",
+ "synchronize",
+ "thread:org.python.modules.thread.thread",
+ "time:org.python.modules.time.Time",
"ucnhash",
- "_weakref:org.python.modules._weakref.WeakrefModule",
- "errno",
- "array:org.python.modules.ArrayModule",
- "_random:org.python.modules.random.RandomModule",
- "cmath",
- "itertools:org.python.modules.itertools.itertools",
"zipimport:org.python.modules.zipimport.zipimport",
- "_collections:org.python.modules._collections.Collections",
- "gc",
- "_hashlib",
- "_functools:org.python.modules._functools._functools",
- "_csv:org.python.modules._csv._csv",
- "_systemrestart",
- "_ast:org.python.antlr.ast.AstModule",
- "_marshal",
- "_threading:org.python.modules._threading._threading",
- PosixModule.getOSName() + ":org.python.modules.posix.PosixModule",
- "jffi:org.python.modules.jffi.jffi",
- "_io:org.python.modules._io._io",
- "bz2:org.python.modules.bz2.bz2"
+ PosixModule.getOSName() + ":org.python.modules.posix.PosixModule"
};
}
diff --git a/src/org/python/modules/_jythonlib/_jythonlib.java b/src/org/python/modules/_jythonlib/_jythonlib.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/modules/_jythonlib/_jythonlib.java
@@ -0,0 +1,23 @@
+/* Copyright (c) Jython Developers */
+package org.python.modules._jythonlib;
+
+import org.python.core.ClassDictInit;
+import org.python.core.PyObject;
+import org.python.core.PyString;
+
+
+public class _jythonlib implements ClassDictInit {
+
+ public static final PyString __doc__ = new PyString("jythonlib module");
+
+ public static void classDictInit(PyObject dict) {
+ dict.__setitem__("__name__", new PyString("_jythonlib"));
+ dict.__setitem__("__doc__", __doc__);
+ dict.__setitem__("__module__", new PyString("_jythonlib"));
+ dict.__setitem__("dict_builder", dict_builder.TYPE);
+
+ // Hide from Python
+ dict.__setitem__("classDictInit", null);
+ }
+
+}
diff --git a/src/org/python/modules/_jythonlib/dict_builder.java b/src/org/python/modules/_jythonlib/dict_builder.java
new file mode 100644
--- /dev/null
+++ b/src/org/python/modules/_jythonlib/dict_builder.java
@@ -0,0 +1,40 @@
+/* Copyright (c) Jython Developers */
+package org.python.modules._jythonlib;
+
+import org.python.core.PyDictionary;
+import org.python.core.PyObject;
+import org.python.core.PyType;
+
+import java.util.concurrent.ConcurrentMap;
+
+
+/* Support building PyDictionary objects with arbitrary backing ConcurrentMap objects
+ * Uses a factory for efficiency.
+ * Usage from Python: _threads = dict_builder(MapMaker().weakValues().makeMap)()
+ *
+ * Such usage avoids problems with converting from boxed Python objects to their unboxed
+ * versions, compared to building this in Java and exporting to Python via PyJavaType.
+ * So in the above example_threads dict maps from thread ID to JavaThread.
+ * But thread ID is a long, which meant that we did not have equality between long/int, as in Python
+ * JavaThread also exposes __java__ to convert to the backing thread, but this meant this would
+ * also be unboxed this way, so the wrapping thread could not be looked up!
+ */
+
+public class dict_builder extends PyObject {
+
+ public static final PyType TYPE = PyType.fromClass(dict_builder.class);
+ private final PyObject factory;
+
+ public dict_builder(PyObject factory) {
+ super();
+ this.factory = factory;
+ }
+
+ public PyObject __call__(PyObject[] args, String[] keywords) {
+ ConcurrentMap map = (ConcurrentMap) (factory.__call__().__tojava__(ConcurrentMap.class));
+ PyDictionary dict = new PyDictionary(map, true);
+ dict.updateCommon(args, keywords, "dict");
+ return dict;
+ }
+
+}
diff --git a/src/org/python/modules/_threading/_threading.java b/src/org/python/modules/_threading/_threading.java
--- a/src/org/python/modules/_threading/_threading.java
+++ b/src/org/python/modules/_threading/_threading.java
@@ -3,8 +3,7 @@
import org.python.core.ClassDictInit;
import org.python.core.Py;
import org.python.core.PyObject;
-import com.google.common.collect.MapMaker;
-import java.util.Map;
+
public class _threading implements ClassDictInit {
@@ -15,21 +14,9 @@
dict.__setitem__("_Lock", Lock.TYPE);
dict.__setitem__("_RLock", Lock.TYPE);
dict.__setitem__("Condition", Condition.TYPE);
-// dict.__setitem__("JavaThread", JavaThread.TYPE);
- }
- // internals to support threading.py, test_threading.py
- public static Map _threads = new MapMaker().weakValues().makeMap();
- public static Map _jthread_to_pythread = new MapMaker().weakKeys().weakValues().makeMap();
- public static Map _active = _threads;
-
- public static void _register_thread(Thread jthread, PyObject pythread) {
- _threads.put(jthread.getId(), pythread);
- _jthread_to_pythread.put(jthread, pythread);
- }
-
- public static void _unregister_thread(Thread jthread) {
- _threads.remove(jthread.getId());
+ // Hide from Python
+ dict.__setitem__("classDictInit", null);
}
}
--
Repository URL: http://hg.python.org/jython
From jython-checkins at python.org Sun Sep 7 05:56:58 2014
From: jython-checkins at python.org (jim.baker)
Date: Sun, 7 Sep 2014 05:56:58 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython=3A_Fix_minor_test_failures_in_?=
=?utf-8?q?test=5Fdescrtut=2C_test=5Ffloat=5Fjy=2C?=
Message-ID: <3hrJj60hsZz7Ljd@mail.python.org>
http://hg.python.org/jython/rev/7fbbad825be4
changeset: 7369:7fbbad825be4
user: Jim Baker
date: Sat Sep 06 21:56:50 2014 -0600
summary:
Fix minor test failures in test_descrtut, test_float_jy,
test_isinstance, test_pbcvm, test_platform, test_pwd, test_select_new,
test_sysconfig, and test_unicodedata, in some cases by better skips.
files:
Lib/platform.py | 1 +
Lib/pwd.py | 3 +++
Lib/test/regrtest.py | 1 +
Lib/test/test_descrtut.py | 1 +
Lib/test/test_float_jy.py | 2 +-
Lib/test/test_pbcvm.py | 5 ++++-
Lib/test/test_platform.py | 3 +++
Lib/test/test_sysconfig.py | 1 +
Lib/test/test_unicodedata.py | 24 +++++++++++++++++-------
9 files changed, 32 insertions(+), 9 deletions(-)
diff --git a/Lib/platform.py b/Lib/platform.py
--- a/Lib/platform.py
+++ b/Lib/platform.py
@@ -777,6 +777,7 @@
return release,versioninfo,machine
def _mac_ver_xml():
+ return None # Jython patch
fn = '/System/Library/CoreServices/SystemVersion.plist'
if not os.path.exists(fn):
return None
diff --git a/Lib/pwd.py b/Lib/pwd.py
--- a/Lib/pwd.py
+++ b/Lib/pwd.py
@@ -12,6 +12,7 @@
from os import _name, _posix_impl
from org.python.core.Py import newString
+import sys
if _name == 'nt':
raise ImportError, 'pwd module not supported on Windows'
@@ -48,6 +49,8 @@
Return the password database entry for the given numeric user ID.
See pwd.__doc__ for more on password database entries.
"""
+ if uid > sys.maxint or uid < 0:
+ raise KeyError
entry = _posix_impl.getpwuid(uid)
if not entry:
raise KeyError(uid)
diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -1307,6 +1307,7 @@
test_peepholer
test_pyclbr
test_pyexpat
+ test_select_new
test_stringprep
test_threadsignals
test_transformer
diff --git a/Lib/test/test_descrtut.py b/Lib/test/test_descrtut.py
--- a/Lib/test/test_descrtut.py
+++ b/Lib/test/test_descrtut.py
@@ -182,6 +182,7 @@
'__delitem__',
'__delslice__',
'__doc__',
+ '__ensure_finalizer__',
'__eq__',
'__format__',
'__ge__',
diff --git a/Lib/test/test_float_jy.py b/Lib/test/test_float_jy.py
--- a/Lib/test/test_float_jy.py
+++ b/Lib/test/test_float_jy.py
@@ -14,7 +14,7 @@
def test_float_repr(self):
self.assertEqual(repr(12345678.000000005), '12345678.000000006')
self.assertEqual(repr(12345678.0000000005), '12345678.0')
- self.assertEqual(repr(math.pi**-100), '1.9275814160560206e-50')
+ self.assertRegexpMatches(repr(math.pi**-100), '1.927581416056020[0-9]e-50')
self.assertEqual(repr(-1.0), '-1.0')
self.assertEqual(repr(-9876.543210), '-9876.54321')
self.assertEqual(repr(0.123456789e+35), '1.23456789e+34')
diff --git a/Lib/test/test_pbcvm.py b/Lib/test/test_pbcvm.py
--- a/Lib/test/test_pbcvm.py
+++ b/Lib/test/test_pbcvm.py
@@ -66,7 +66,10 @@
def test_main():
- test_support.run_unittest(PyBytecodeTest, AdhocRegrtest)
+ test_support.run_unittest(
+ PyBytecodeTest,
+ # AdhocRegrtest # reinstate once we have Python bytecode compilation, too hard to coordinate otherwise
+ )
if __name__ == "__main__":
test_main()
diff --git a/Lib/test/test_platform.py b/Lib/test/test_platform.py
--- a/Lib/test/test_platform.py
+++ b/Lib/test/test_platform.py
@@ -5,12 +5,14 @@
import subprocess
from test import test_support
+from test.test_support import is_jython
class PlatformTest(unittest.TestCase):
def test_architecture(self):
res = platform.architecture()
if hasattr(os, "symlink"):
+ @unittest.skipIf(is_jython, "Cannot just symlink Jython startup script")
def test_architecture_via_symlink(self): # issue3762
def get(python):
cmd = [python, '-c',
@@ -162,6 +164,7 @@
def test_win32_ver(self):
res = platform.win32_ver()
+ @unittest.skipIf(is_jython, "No uname support in Jython")
def test_mac_ver(self):
res = platform.mac_ver()
diff --git a/Lib/test/test_sysconfig.py b/Lib/test/test_sysconfig.py
--- a/Lib/test/test_sysconfig.py
+++ b/Lib/test/test_sysconfig.py
@@ -240,6 +240,7 @@
'java_user'}
self.assertEqual({name for name in get_scheme_names()}, wanted)
+ @unittest.skipIf(is_jython, "Cannot just symlink Jython startup script")
def test_symlink(self):
# Issue 7880
symlink = get_attribute(os, "symlink")
diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
--- a/Lib/test/test_unicodedata.py
+++ b/Lib/test/test_unicodedata.py
@@ -17,15 +17,23 @@
### Run tests
+
+def all_codepoints():
+ for i in xrange(sys.maxunicode+1):
+ if i >= 0xD800 and i <= 0xDFFF:
+ continue
+ yield i
+
+
class UnicodeMethodsTest(unittest.TestCase):
# update this, if the database changes
expectedchecksum = '4504dffd035baea02c5b9de82bebc3d65e0e0baf'
- @unittest.skipIf(test.test_support.is_jython, "Jython uses ICU4J")
+ @unittest.skipIf(test.test_support.is_jython, "Jython uses ICU4J, so checksum tests are not meaningful")
def test_method_checksum(self):
h = hashlib.sha1()
- for i in range(0x10000):
+ for i in all_codepoints():
char = unichr(i)
data = [
# Predicates (single char)
@@ -82,7 +90,7 @@
# update this, if the database changes
expectedchecksum = '6ccf1b1a36460d2694f9b0b0f0324942fe70ede6'
- @unittest.skipIf(test.test_support.is_jython, "Jython uses ICU4J")
+ @unittest.skipIf(test.test_support.is_jython, "Jython uses ICU4J, so checksum tests are not meaningful")
def test_function_checksum(self):
data = []
h = hashlib.sha1()
@@ -246,7 +254,7 @@
# i.e. if a character has a decimal value,
# its numeric value should be the same.
count = 0
- for i in xrange(0x10000):
+ for i in all_codepoints():
c = unichr(i)
dec = self.db.decimal(c, -1)
if dec != -1:
@@ -259,7 +267,7 @@
# i.e. if a character has a digit value,
# its numeric value should be the same.
count = 0
- for i in xrange(0x10000):
+ for i in all_codepoints():
c = unichr(i)
dec = self.db.digit(c, -1)
if dec != -1:
@@ -282,12 +290,14 @@
self.assertTrue(u"\u1d79".upper()==u'\ua77d')
self.assertTrue(u".".upper()==u".")
+
+
def test_bug_5828(self):
self.assertEqual(u"\u1d79".lower(), u"\u1d79")
# Only U+0000 should have U+0000 as its upper/lower/titlecase variant
self.assertEqual(
[
- c for c in range(sys.maxunicode+1)
+ c for c in all_codepoints()
if u"\x00" in unichr(c).lower()+unichr(c).upper()+unichr(c).title()
],
[0]
@@ -300,7 +310,7 @@
self.assertEqual(u"\u01c6".title(), u"\u01c5")
def test_linebreak_7643(self):
- for i in range(0x10000):
+ for i in all_codepoints():
lines = (unichr(i) + u'A').splitlines()
if i in (0x0a,
# 0x0b,
--
Repository URL: http://hg.python.org/jython
From jython-checkins at python.org Tue Sep 9 03:05:50 2014
From: jython-checkins at python.org (jim.baker)
Date: Tue, 9 Sep 2014 03:05:50 +0200 (CEST)
Subject: [Jython-checkins] =?utf-8?q?jython=3A_Support_standard_Python_sem?=
=?utf-8?q?antics_for_proxied_java_objects_that?=
Message-ID: <3hsSpk58C0z7LjN@mail.python.org>
http://hg.python.org/jython/rev/864bbec6ddb5
changeset: 7370:864bbec6ddb5
user: Santoso Wijaya
date: Mon Sep 08 18:39:48 2014 -0600
summary:
Support standard Python semantics for proxied java objects that
implement java.util.Map. Such maps may or may not be concurrent.
Note that d[key_not_present] no longer returns None, but raises
KeyError, which means this behavior now matches standard dict
semantics.
Fixes http://bugs.jython.org/issue1631
files:
Lib/test/test_dict.py | 115 ++--
Lib/test/test_dict_jy.py | 51 ++-
src/org/python/core/PyJavaType.java | 376 +++++++++++++++-
3 files changed, 478 insertions(+), 64 deletions(-)
diff --git a/Lib/test/test_dict.py b/Lib/test/test_dict.py
--- a/Lib/test/test_dict.py
+++ b/Lib/test/test_dict.py
@@ -6,13 +6,17 @@
class DictTest(unittest.TestCase):
+
+ _class = None
+
+ def _make_dict(self, pydict):
+ return pydict if not self._class else self._class(pydict)
+
def test_constructor(self):
# calling built-in types without argument must return empty
- self.assertEqual(dict(), {})
- self.assertIsNot(dict(), {})
+ self.assertEqual(self._make_dict(dict()), {})
+ self.assertIsNot(self._make_dict(dict()), {})
- @unittest.skipIf(test_support.is_jython,
- "FIXME: check Jython again when __format__ works better.")
def test_literal_constructor(self):
# check literal constructor for different sized dicts
# (to exercise the BUILD_MAP oparg).
@@ -22,16 +26,16 @@
random.shuffle(items)
formatted_items = ('{!r}: {:d}'.format(k, v) for k, v in items)
dictliteral = '{' + ', '.join(formatted_items) + '}'
- self.assertEqual(eval(dictliteral), dict(items))
+ self.assertEqual(self._make_dict(eval(dictliteral)), dict(items))
def test_bool(self):
- self.assertIs(not {}, True)
- self.assertTrue({1: 2})
- self.assertIs(bool({}), False)
- self.assertIs(bool({1: 2}), True)
+ self.assertIs(not self._make_dict({}), True)
+ self.assertTrue(self._make_dict({1: 2}))
+ self.assertIs(bool(self._make_dict({})), False)
+ self.assertIs(bool(self._make_dict({1: 2})), True)
def test_keys(self):
- d = {}
+ d = self._make_dict({})
self.assertEqual(d.keys(), [])
d = {'a': 1, 'b': 2}
k = d.keys()
@@ -41,26 +45,28 @@
self.assertRaises(TypeError, d.keys, None)
def test_values(self):
- d = {}
+ d = self._make_dict({})
self.assertEqual(d.values(), [])
- d = {1:2}
+
+ d = self._make_dict({1:2})
self.assertEqual(d.values(), [2])
self.assertRaises(TypeError, d.values, None)
def test_items(self):
- d = {}
+ d = self._make_dict({})
self.assertEqual(d.items(), [])
- d = {1:2}
+ d = self._make_dict({1:2})
self.assertEqual(d.items(), [(1, 2)])
self.assertRaises(TypeError, d.items, None)
def test_has_key(self):
- d = {}
+ d = self._make_dict({})
self.assertFalse(d.has_key('a'))
- d = {'a': 1, 'b': 2}
+
+ d = self._make_dict({'a': 1, 'b': 2})
k = d.keys()
k.sort()
self.assertEqual(k, ['a', 'b'])
@@ -68,11 +74,12 @@
self.assertRaises(TypeError, d.has_key)
def test_contains(self):
- d = {}
+ d = self._make_dict({})
self.assertNotIn('a', d)
self.assertFalse('a' in d)
self.assertTrue('a' not in d)
- d = {'a': 1, 'b': 2}
+
+ d = self._make_dict({'a': 1, 'b': 2})
self.assertIn('a', d)
self.assertIn('b', d)
self.assertNotIn('c', d)
@@ -80,13 +87,14 @@
self.assertRaises(TypeError, d.__contains__)
def test_len(self):
- d = {}
+ d = self._make_dict({})
self.assertEqual(len(d), 0)
- d = {'a': 1, 'b': 2}
+
+ d = self._make_dict({'a': 1, 'b': 2})
self.assertEqual(len(d), 2)
def test_getitem(self):
- d = {'a': 1, 'b': 2}
+ d = self._make_dict({'a': 1, 'b': 2})
self.assertEqual(d['a'], 1)
self.assertEqual(d['b'], 2)
d['c'] = 3
@@ -104,7 +112,7 @@
def __hash__(self):
return 24
- d = {}
+ d = self._make_dict({})
d[BadEq()] = 42
self.assertRaises(KeyError, d.__getitem__, 23)
@@ -124,14 +132,14 @@
self.assertRaises(Exc, d.__getitem__, x)
def test_clear(self):
- d = {1:1, 2:2, 3:3}
+ d = self._make_dict({1:1, 2:2, 3:3})
d.clear()
self.assertEqual(d, {})
self.assertRaises(TypeError, d.clear, None)
def test_update(self):
- d = {}
+ d = self._make_dict({})
d.update({1:100})
d.update({2:20})
d.update({1:1, 2:2, 3:3})
@@ -202,13 +210,13 @@
def next(self):
raise Exc()
- self.assertRaises(Exc, {}.update, badseq())
-
- self.assertRaises(ValueError, {}.update, [(1, 2, 3)])
+ d = self._make_dict({})
+ self.assertRaises(Exc, d.update, badseq())
+ self.assertRaises(ValueError, d.update, [(1, 2, 3)])
def test_fromkeys(self):
self.assertEqual(dict.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
- d = {}
+ d = self._make_dict({})
self.assertIsNot(d.fromkeys('abc'), d)
self.assertEqual(d.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
self.assertEqual(d.fromkeys((4,5),0), {4:0, 5:0})
@@ -257,16 +265,17 @@
self.assertEqual(dict.fromkeys(d, 0), dict(zip(range(6), [0]*6)))
def test_copy(self):
- d = {1:1, 2:2, 3:3}
+ d = self._make_dict({1:1, 2:2, 3:3})
self.assertEqual(d.copy(), {1:1, 2:2, 3:3})
- self.assertEqual({}.copy(), {})
+ self.assertEqual(self._make_dict({}).copy(), {})
self.assertRaises(TypeError, d.copy, None)
def test_get(self):
- d = {}
+ d = self._make_dict({})
self.assertIs(d.get('c'), None)
self.assertEqual(d.get('c', 3), 3)
- d = {'a': 1, 'b': 2}
+
+ d = self._make_dict({'a': 1, 'b': 2})
self.assertIs(d.get('c'), None)
self.assertEqual(d.get('c', 3), 3)
self.assertEqual(d.get('a'), 1)
@@ -276,7 +285,7 @@
def test_setdefault(self):
# dict.setdefault()
- d = {}
+ d = self._make_dict({})
self.assertIs(d.setdefault('key0'), None)
d.setdefault('key0', [])
self.assertIs(d.setdefault('key0'), None)
@@ -314,7 +323,7 @@
self.eq_count += 1
return id(self) == id(other)
hashed1 = Hashed()
- y = {hashed1: 5}
+ y = self._make_dict({hashed1: 5})
hashed2 = Hashed()
y.setdefault(hashed2, [])
self.assertEqual(hashed1.hash_count, 1)
@@ -345,12 +354,12 @@
self.assertFalse(a)
self.assertFalse(b)
- d = {}
+ d = self._make_dict({})
self.assertRaises(KeyError, d.popitem)
def test_pop(self):
# Tests for pop with specified key
- d = {}
+ d = self._make_dict({})
k, v = 'abc', 'def'
d[k] = v
self.assertRaises(KeyError, d.pop, 'ghi')
@@ -364,7 +373,7 @@
# (for 64-bit archs). See SF bug #689659.
x = 4503599627370496L
y = 4503599627370496
- h = {x: 'anything', y: 'something else'}
+ h = self._make_dict({x: 'anything', y: 'something else'})
self.assertEqual(h[x], h[y])
self.assertEqual(d.pop(k, v), v)
@@ -390,18 +399,19 @@
def test_mutatingiteration(self):
# changing dict size during iteration
- d = {}
+ d = self._make_dict({})
d[1] = 1
with self.assertRaises(RuntimeError):
for i in d:
d[i+1] = 1
def test_repr(self):
- d = {}
+ d = self._make_dict({})
self.assertEqual(repr(d), '{}')
d[1] = 2
self.assertEqual(repr(d), '{1: 2}')
- d = {}
+
+ d = self._make_dict({})
d[1] = d
self.assertEqual(repr(d), '{1: {...}}')
@@ -411,12 +421,12 @@
def __repr__(self):
raise Exc()
- d = {1: BadRepr()}
+ d = self._make_dict({1: BadRepr()})
self.assertRaises(Exc, repr, d)
def test_le(self):
- self.assertFalse({} < {})
- self.assertFalse({1: 2} < {1L: 2L})
+ self.assertFalse(self._make_dict({}) < {})
+ self.assertFalse(self._make_dict({1: 2}) < {1L: 2L})
class Exc(Exception): pass
@@ -426,8 +436,8 @@
def __hash__(self):
return 42
- d1 = {BadCmp(): 1}
- d2 = {1: 1}
+ d1 = self._make_dict({BadCmp(): 1})
+ d2 = self._make_dict({1: 1})
with self.assertRaises(Exc):
d1 < d2
@@ -435,7 +445,7 @@
def test_missing(self):
# Make sure dict doesn't have a __missing__ method
self.assertFalse(hasattr(dict, "__missing__"))
- self.assertFalse(hasattr({}, "__missing__"))
+ self.assertFalse(hasattr(self._make_dict({}), "__missing__"))
# Test several cases:
# (D) subclass defines __missing__ method returning a value
# (E) subclass defines __missing__ method raising RuntimeError
@@ -477,7 +487,7 @@
def test_tuple_keyerror(self):
# SF #1576657
- d = {}
+ d = self._make_dict({})
with self.assertRaises(KeyError) as c:
d[(1,)]
self.assertEqual(c.exception.args, ((1,),))
@@ -496,7 +506,7 @@
raise CustomException
return other
- d = {}
+ d = self._make_dict({})
x1 = BadDictKey()
x2 = BadDictKey()
d[x1] = 1
@@ -519,7 +529,7 @@
# exactly the right order, and I can't think of a randomized approach
# that would be *likely* to hit a failing case in reasonable time.
- d = {}
+ d = self._make_dict({})
for i in range(5):
d[i] = i
for i in range(5):
@@ -538,7 +548,7 @@
if resizing:
d.clear()
return False
- d = {}
+ d = self._make_dict({})
resizing = False
d[X()] = 1
d[X()] = 2
@@ -553,8 +563,9 @@
# Bug #3537: if an empty but presized dict with a size larger
# than 7 was in the freelist, it triggered an assertion failure
with self.assertRaises(ZeroDivisionError):
- d = {'a': 1 // 0, 'b': None, 'c': None, 'd': None, 'e': None,
- 'f': None, 'g': None, 'h': None}
+ d = self._make_dict(
+ {'a': 1 // 0, 'b': None, 'c': None, 'd': None, 'e': None,
+ 'f': None, 'g': None, 'h': None})
d = {}
def test_container_iterator(self):
diff --git a/Lib/test/test_dict_jy.py b/Lib/test/test_dict_jy.py
--- a/Lib/test/test_dict_jy.py
+++ b/Lib/test/test_dict_jy.py
@@ -2,6 +2,7 @@
import java
import unittest
from collections import defaultdict
+import test_dict
class DictInitTest(unittest.TestCase):
def testInternalSetitemInInit(self):
@@ -120,6 +121,27 @@
x.put((1,2), "xyz")
y = dict(x)
self.assertEqual(set(y.items()), set([('a', 1), ('b', 2), ('c', 3), ((1,2), "xyz")]))
+
+ def test_hashmap_builtin_pymethods(self):
+ x = java.util.HashMap()
+ x['a'] = 1
+ x[(1, 2)] = 'xyz'
+ self.assertEqual({tup for tup in x.iteritems()}, {('a', 1), ((1, 2), 'xyz')})
+ self.assertEqual(str(x), repr(x))
+ self.assertEqual(type(str(x)), type(repr(x)))
+
+ def test_hashtable_equal(self):
+ for d in ({}, {1:2}):
+ x = java.util.Hashtable(d)
+ self.assertEqual(x, d)
+ self.assertEqual(d, x)
+ self.assertEqual(x, java.util.HashMap(d))
+
+ def test_hashtable_remove(self):
+ x = java.util.Hashtable({})
+ with self.assertRaises(KeyError):
+ del x[0]
+
def test_hashtable(self):
x = java.util.Hashtable()
x.put('a', 1)
@@ -130,9 +152,36 @@
self.assertEqual(set(y.items()), set([('a', 1), ('b', 2), ('c', 3), ((1,2), "xyz")]))
+class JavaDictTest(test_dict.DictTest):
+
+ _class = java.util.HashMap
+
+ def test_copy_java_hashtable(self):
+ x = java.util.Hashtable()
+ xc = x.copy()
+ self.assertEqual(type(x), type(xc))
+
+ def test_fromkeys(self):
+ super(JavaDictTest, self).test_fromkeys()
+ self.assertEqual(self._class.fromkeys('abc'), {'a':None, 'b':None, 'c':None})
+
+ def test_repr_value_None(self):
+ x = self._class({1:None})
+ self.assertEqual(repr(x), '{1: None}')
+
+ def test_set_return_None(self):
+ x = self._class({1:2})
+ self.assertEqual(x.__setitem__(1, 3), None)
+ self.assertEqual(x.__getitem__(1), 3)
+
+ def test_del_return_None(self):
+ x = self._class({1:2})
+ self.assertEqual(x.__delitem__(1), None)
+ self.assertEqual(len(x), 0)
+
def test_main():
- test_support.run_unittest(DictInitTest, DictCmpTest, DerivedDictTest, JavaIntegrationTest)
+ test_support.run_unittest(DictInitTest, DictCmpTest, DerivedDictTest, JavaIntegrationTest, JavaDictTest)
if __name__ == '__main__':
test_main()
diff --git a/src/org/python/core/PyJavaType.java b/src/org/python/core/PyJavaType.java
--- a/src/org/python/core/PyJavaType.java
+++ b/src/org/python/core/PyJavaType.java
@@ -67,6 +67,7 @@
java.util.concurrent.TimeUnit.class);
private static Map, PyBuiltinMethod[]> collectionProxies;
+ private static Map, PyBuiltinMethod[]> postCollectionProxies;
/**
* Other Java classes this type has MRO conflicts with. This doesn't matter for Java method
@@ -531,9 +532,16 @@
} else {
dict.__setitem__("__init__", reflctr);
}
- for (Map.Entry, PyBuiltinMethod[]> entry : getCollectionProxies().entrySet()) {
- if (entry.getKey() == forClass) {
- for (PyBuiltinMethod meth : entry.getValue()) {
+ PyBuiltinMethod[] collectionProxyMethods = getCollectionProxies().get(forClass);
+ if (collectionProxyMethods != null) {
+ for (PyBuiltinMethod meth : collectionProxyMethods) {
+ addMethod(meth);
+ }
+ }
+ // allow for some methods to override the Java type's as a late injection
+ for (Class> type : getPostCollectionProxies().keySet()) {
+ if (type.isAssignableFrom(forClass)) {
+ for (PyBuiltinMethod meth : getPostCollectionProxies().get(type)) {
addMethod(meth);
}
}
@@ -896,11 +904,25 @@
super(name, numArgs);
}
+ protected MapMethod(String name, int minArgs, int maxArgs) {
+ super(name, minArgs, maxArgs);
+ }
+
protected Map