Author: Florin Papa <[email protected]>
Branch: resource_warning
Changeset: r83566:c7b7a1ea6010
Date: 2016-04-07 16:31 +0300
http://bitbucket.org/pypy/pypy/changeset/c7b7a1ea6010/

Log:    (florin, antocuni) Rename resource_warning to track_resources

diff --git a/pypy/module/_file/interp_file.py b/pypy/module/_file/interp_file.py
--- a/pypy/module/_file/interp_file.py
+++ b/pypy/module/_file/interp_file.py
@@ -44,7 +44,7 @@
 
     def __init__(self, space):
         self.space = space
-        if self.space.sys.resource_warning_enabled:
+        if self.space.sys.track_resources:
             self.w_tb = self.space.format_traceback()
 
     def __del__(self):
@@ -57,7 +57,7 @@
 
     def destructor(self):
         assert isinstance(self, W_File)
-        if self.space.sys.resource_warning_enabled:
+        if self.space.sys.track_resources:
             w_repr = self.space.repr(self)
             str_repr = self.space.str_w(w_repr)
             w_msg = self.space.wrap("WARNING: unclosed file: " + str_repr)
diff --git a/pypy/module/_file/test/test_file.py 
b/pypy/module/_file/test/test_file.py
--- a/pypy/module/_file/test/test_file.py
+++ b/pypy/module/_file/test/test_file.py
@@ -266,15 +266,15 @@
         if '__pypy__' in sys.builtin_module_names:
             assert repr(self.temppath) in g.getvalue()
 
-    def test_resource_warning(self):
+    def test_track_resources(self):
         import os, gc, sys, cStringIO
         import re
         if '__pypy__' not in sys.builtin_module_names:
             skip("pypy specific test")
         def fn(flag1, flag2):
-            sys.pypy_set_resource_warning(flag1)
+            sys.pypy_set_track_resources(flag1)
             f = self.file(self.temppath, 'w')
-            sys.pypy_set_resource_warning(flag2)
+            sys.pypy_set_track_resources(flag2)
             g = cStringIO.StringIO()
             preverr = sys.stderr
             try:
@@ -283,24 +283,24 @@
                 gc.collect() # force __del__ to be called
             finally:
                 sys.stderr = preverr
-                sys.pypy_set_resource_warning(False)
+                sys.pypy_set_track_resources(False)
             return g.getvalue()
 
-        # check with resource_warning disabled
+        # check with track_resources disabled
         assert fn(False, False) == ""
         #
-        # check with resource_warning enabled
+        # check with track_resources enabled
         msg = fn(True, True)
         assert self.regex_search(r"""
         WARNING: unclosed file: <open file .*>
         Created at \(most recent call last\):
-          File ".*", line .*, in test_resource_warning
+          File ".*", line .*, in test_track_resources
           File ".*", line .*, in fn
           File ".*", line .*, in anonymous
         """, msg)
         #
-        # check with resource_warning enabled in the destructor BUT with a
-        # file which was created when resource_warning was disabled
+        # check with track_resources enabled in the destructor BUT with a
+        # file which was created when track_resources was disabled
         msg = fn(False, True)
         assert self.regex_search("WARNING: unclosed file: <open file .*>", msg)
         assert "Created at" not in msg
diff --git a/pypy/module/sys/__init__.py b/pypy/module/sys/__init__.py
--- a/pypy/module/sys/__init__.py
+++ b/pypy/module/sys/__init__.py
@@ -19,7 +19,7 @@
         self.defaultencoding = "ascii"
         self.filesystemencoding = None
         self.debug = True
-        self.resource_warning_enabled = False
+        self.track_resources = False
 
     interpleveldefs = {
         '__name__'              : '(space.wrap("sys"))',
@@ -54,7 +54,7 @@
         '_current_frames'       : 'currentframes._current_frames',
         'setrecursionlimit'     : 'vm.setrecursionlimit',
         'getrecursionlimit'     : 'vm.getrecursionlimit',
-        'pypy_set_resource_warning' : 'vm.set_resource_warning',
+        'pypy_set_track_resources' : 'vm.set_track_resources',
         'setcheckinterval'      : 'vm.setcheckinterval',
         'getcheckinterval'      : 'vm.getcheckinterval',
         'exc_info'              : 'vm.exc_info',
diff --git a/pypy/module/sys/vm.py b/pypy/module/sys/vm.py
--- a/pypy/module/sys/vm.py
+++ b/pypy/module/sys/vm.py
@@ -65,8 +65,8 @@
     return space.wrap(space.sys.recursionlimit)
 
 @unwrap_spec(flag=bool)
-def set_resource_warning(space, flag):
-    space.sys.resource_warning_enabled = flag
+def set_track_resources(space, flag):
+    space.sys.track_resources = flag
 
 @unwrap_spec(interval=int)
 def setcheckinterval(space, interval):
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to