Fix leak in try-break.
[cython.git] / runtests.py
index 0dc20d5fa7ff4321393d48b6144242ae66c8b2a2..8e8925e1deefda6157df2d9afd19727ee401eda7 100644 (file)
@@ -482,9 +482,9 @@ if __name__ == '__main__':
     parser.add_option("--cython-only", dest="cython_only",
                       action="store_true", default=False,
                       help="only compile pyx to c, do not run C compiler or run the tests")
-    parser.add_option("--refnanny", dest="with_refnanny",
-                      action="store_true", default=False,
-                      help="also test that Cython-generated code does correct reference counting")
+    parser.add_option("--no-refnanny", dest="with_refnanny",
+                      action="store_false", default=True,
+                      help="do not regression test reference counting")
     parser.add_option("--sys-pyregr", dest="system_pyregr",
                       action="store_true", default=False,
                       help="run the regression tests of the CPython installation")
@@ -554,14 +554,10 @@ if __name__ == '__main__':
 
     if options.with_refnanny:
         from pyximport.pyxbuild import pyx_to_dll
-        import ctypes
         libpath = pyx_to_dll(os.path.join("Cython", "Runtime", "refnanny.pyx"),
                              build_in_temp=True,
                              pyxbuild_dir=os.path.join(WORKDIR, "support"))
-        ctypes.PyDLL(libpath, mode=ctypes.RTLD_GLOBAL)
-        sys.path.append(os.path.split(libpath)[0])
-        import refnanny
-        del sys.path[-1]
+        sys.path.insert(0, os.path.split(libpath)[0])
         CFLAGS.append("-DCYTHON_REFNANNY")
 
     test_bugs = False
@@ -637,4 +633,5 @@ if __name__ == '__main__':
             sys.stderr.write("   %s\n" % test)
 
     if options.with_refnanny:
+        import refnanny
         sys.stderr.write("\n".join([repr(x) for x in refnanny.reflog]))