[Jython-checkins] jython: Some cosmetics in PyObject and PyType.

stefan.richthofer jython-checkins at python.org
Wed Nov 19 21:35:14 CET 2014


https://hg.python.org/jython/rev/eb61f21316bc
changeset:   7417:eb61f21316bc
user:        Stefan Richthofer <stefan.richthofer at gmx.de>
date:        Wed Nov 19 21:34:52 2014 +0100
summary:
  Some cosmetics in PyObject and PyType.
Cleaned comments, fixed typos and tabs.

files:
  src/org/python/core/PyObject.java |  10 +++++--
  src/org/python/core/PyType.java   |  25 ++++++++++--------
  2 files changed, 21 insertions(+), 14 deletions(-)


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
@@ -109,7 +109,7 @@
      * <p>
      * 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
+     * So {@code PyObject}s are not expensively treated as finalizable objects by the
      * GC. Its only intention is to prevent subclasses from having Java-style finalizers.
      * </p>
      */
@@ -239,10 +239,14 @@
         return __repr__();
     }
 
+    /**
+     * PyObjects that implement
+     * <code>org.python.core.finalization.HasFinalizeTrigger</code>
+     * shall implement this method via:<br>
+     * <code>FinalizeTrigger.ensureFinalizer(this);</code>
+     **/
     @ExposedMethod
     public void __ensure_finalizer__() {
-        //PyObjects that implement HasFinalizeTrigger shall implement this method via:
-    	//FinalizeTrigger.ensureFinalizer(this);
     }
 
     public PyUnicode __unicode__() {
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
@@ -573,16 +573,19 @@
      * @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;
-    	}
+        /*
+         * 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;
+        }
     }
 
     /**
@@ -1989,7 +1992,7 @@
     }
 
     /**
-     * A thead safe, non-blocking version of Armin Rigo's mro cache.
+     * A thread safe, non-blocking version of Armin Rigo's mro cache.
      */
     static class MethodCache {
 

-- 
Repository URL: https://hg.python.org/jython


More information about the Jython-checkins mailing list