Author: Brian Kearns <bdkea...@gmail.com>
Branch: elidable-canfold-exception
Changeset: r70049:f73abcc35c33
Date: 2014-03-18 05:07 -0400
http://bitbucket.org/pypy/pypy/changeset/f73abcc35c33/

Log:    could also take this approach

diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -1,4 +1,6 @@
+from __future__ import absolute_import
 import sys
+import types
 import warnings
 
 import py
@@ -58,16 +60,13 @@
 
 _elidable = elidable
 def elidable(*args, **kwargs):
-    if len(args) == 1:
+    if len(args) == 1 and isinstance(args[0], types.FunctionType):
         assert len(kwargs) == 0
         warnings.warn("@elidable is deprecated, use @elidable() instead", 
stacklevel=2)
         return _elidable()(args[0])
-    else:
-        assert len(args) == 0
-        return _elidable(**kwargs)
+    return _elidable(*args, **kwargs)
 
 def purefunction(*args, **kwargs):
-    import warnings
     warnings.warn("purefunction is deprecated, use elidable instead", 
DeprecationWarning)
     return elidable(*args, **kwargs)
 
@@ -160,7 +159,6 @@
     return decorator
 
 def purefunction_promote(*args, **kwargs):
-    import warnings
     warnings.warn("purefunction_promote is deprecated, use elidable_promote 
instead", DeprecationWarning)
     return elidable_promote(*args, **kwargs)
 
diff --git a/rpython/rlib/test/test_jit.py b/rpython/rlib/test/test_jit.py
--- a/rpython/rlib/test/test_jit.py
+++ b/rpython/rlib/test/test_jit.py
@@ -94,19 +94,25 @@
 def test_elidable():
     import warnings
     # deprecated version
-    if 1:#with warnings.catch_warnings(record=True) as w:
-        #assert not w
+    with warnings.catch_warnings(record=True) as w:
+        assert not w
         @elidable
         def f():
             pass
         assert f._elidable_function_
-        #assert "@elidable()" in w[0].message[0]
+        assert "@elidable()" in w[0].message[0]
 
     # proper version
     @elidable()
     def f():
         pass
     assert f._elidable_function_
+
+    @elidable(ValueError)
+    def f():
+        pass
+    assert f._elidable_function_
+
     @elidable(canfolderror=ValueError)
     def f():
         pass
_______________________________________________
pypy-commit mailing list
pypy-commit@python.org
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to