[pypy-svn] commit/pypy: 4 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Dec 21 13:06:51 CET 2010


4 new changesets in pypy:

http://bitbucket.org/pypy/pypy/changeset/2f54d43d54d6/
changeset:   r40155:2f54d43d54d6
branch:      psycopg2compatibility
user:        ademan
date:        2010-12-21 12:58:22
summary:     I must have been out of it when I wrote this test, PyFloat_FromString() takes a PyObject *
affected #:  1 file (48 bytes)

--- a/pypy/module/cpyext/test/test_floatobject.py	Fri Dec 17 19:43:48 2010 -0800
+++ b/pypy/module/cpyext/test/test_floatobject.py	Tue Dec 21 03:58:22 2010 -0800
@@ -23,9 +23,8 @@
     def test_from_string(self, space, api):
         def test_number(n, expectfail=False):
             np = lltype.nullptr(rffi.CCHARPP.TO)
-            n_str = rffi.str2charp(str(n))
-            f = api.PyFloat_FromString(n_str, np)
-            rffi.free_charp(n_str)
+            w_n = space.wrap(n)
+            f = api.PyFloat_FromString(w_n, np)
             if expectfail:
                 assert f == None
             else:


http://bitbucket.org/pypy/pypy/changeset/72d3c7738241/
changeset:   r40156:72d3c7738241
branch:      psycopg2compatibility
user:        ademan
date:        2010-12-21 12:59:35
summary:     Changed logging cpyext calls to cpyext-call and moved function __name__ lookup to import time.
affected #:  1 file (50 bytes)

--- a/pypy/module/cpyext/api.py	Tue Dec 21 03:58:22 2010 -0800
+++ b/pypy/module/cpyext/api.py	Tue Dec 21 03:59:35 2010 -0800
@@ -83,14 +83,14 @@
                 argstrs = [repr(x) for x in args]
                 argstr = ', '.join(argstrs)
 
-                debug_start('cpyext')
+                debug_start('cpyext-call')
                 self.log("%s(%s)" % (name, argstr))
                 try:
                     self.indentation += 1
                     result = f(space, *args)
                 finally:
                     self.indentation -= 1
-                    debug_stop('cpyext')
+                    debug_stop('cpyext-call')
                 self.log("%s(%s)->%s" % (name, argstr, repr(result)))
                 return result
             else:
@@ -132,14 +132,14 @@
                 argstr = ', '.join(argstrs)
                 self.enabled = True
 
-                debug_start('cpyext')
+                debug_start('cpyext-call')
                 self.log("%s(%s)" % (name, argstr))
                 try:
                     self.indentation += 1
                     result = f(*args)
                 finally:
                     self.indentation -= 1
-                    debug_stop('cpyext')
+                    debug_stop('cpyext-call')
 
                 result_format = repr(result) # TODO: format nicer!
                 self.log("%s(%s)->%s" % (name, argstr, result_format))
@@ -596,6 +596,7 @@
     fatal_value = callable.api_func.restype._defl()
 
     logged_callable = log_call(space, callable)
+    function_name = callable.__name__
 
     @specialize.ll()
     @wraps(callable)
@@ -647,10 +648,10 @@
                 if error_value is CANNOT_FAIL:
                     if not we_are_translated():
                         raise SystemError("The function '%s' was not supposed to fail.  Failed with %s"
-                                          % (callable.__name__, e))
+                                          % (function_name, e))
                     else:
                         raise SystemError("The function '%s' was not supposed to fail"
-                                          % (callable.__name__,))
+                                          % (function_name,))
                 retval = error_value
 
             elif is_PyObject(callable.api_func.restype):


http://bitbucket.org/pypy/pypy/changeset/8c5587a07805/
changeset:   r40157:8c5587a07805
branch:      psycopg2compatibility
user:        ademan
date:        2010-12-21 13:01:06
summary:     Implementation of PyFloat_FromString() is much closer to being correct, but the docs don't describe whether or not to set an error when it can't parse the string.
affected #:  1 file (173 bytes)

--- a/pypy/module/cpyext/floatobject.py	Tue Dec 21 03:59:35 2010 -0800
+++ b/pypy/module/cpyext/floatobject.py	Tue Dec 21 04:01:06 2010 -0800
@@ -3,8 +3,6 @@
                                     build_type_checkers)
 from pypy.interpreter.error import OperationError
 
-from pypy.objspace.std.strutil import interp_string_to_float, ParseStringError
-
 PyFloat_Check, PyFloat_CheckExact = build_type_checkers("Float")
 
 @cpython_api([lltype.Float], PyObject)
@@ -28,16 +26,11 @@
     This is the equivalent of the Python expression float(o)."""
     return space.float(w_obj)
 
- at cpython_api([PyObject, rffi.CCHARPP], PyObject)
-def PyFloat_FromString(space, str, pend):
+ at cpython_api([PyObject, rffi.CCHARPP], PyObject, error=lltype.nullptr(PyObject.TO))
+def PyFloat_FromString(space, w_str, pend):
     """Create a PyFloatObject object based on the string value in str, or
     NULL on failure.  The pend argument is ignored.  It remains only for
     backward compatibility."""
     
-    str = rffi.charp2str(str)
-    try:
-        float_value = interp_string_to_float(space, str)
-    except ParseStringError, e:
-        return None
-    return space.wrap(float_value)
+    return space.call_function(space.w_float, w_str)
 


http://bitbucket.org/pypy/pypy/changeset/dcafe3478e6e/
changeset:   r40158:dcafe3478e6e
branch:      psycopg2compatibility
user:        ademan
date:        2010-12-21 13:02:20
summary:     Fixed translation errors coming from using kwargs.  debug_refcount is slightly less nice, but when used with cpyext-call it should be nicer anyways.
affected #:  1 file (224 bytes)

--- a/pypy/module/cpyext/pyobject.py	Tue Dec 21 04:01:06 2010 -0800
+++ b/pypy/module/cpyext/pyobject.py	Tue Dec 21 04:02:20 2010 -0800
@@ -255,15 +255,11 @@
 
 DEBUG_REFCOUNT = True
 
-def debug_refcount(*args, **kwargs):
+def debug_refcount(*args):
     from pypy.module.cpyext.api import cpy_logger
-    frame_stackdepth = kwargs.pop("frame_stackdepth", 2)
-    assert not kwargs
-    frame = sys._getframe(frame_stackdepth)
     debug_start('cpyext-refcount')
-    debug_print(cpy_logger.get_indent_string())
-    debug_print(frame.f_code.co_name)
-    debug_print(' '.join([frame.f_code.co_name] + [str(arg) for arg in args]))
+    debug_print(' '.join([cpy_logger.get_indent_string()] +
+                         [str(arg) for arg in args]))
     debug_stop('cpyext-refcount')
 
 def create_ref(space, w_obj, itemcount=0):
@@ -359,7 +355,7 @@
 
     obj.c_ob_refcnt -= 1
     if DEBUG_REFCOUNT:
-        debug_refcount("DECREF", obj, obj.c_ob_refcnt, frame_stackdepth=3)
+        debug_refcount("DECREF", obj, obj.c_ob_refcnt)
     if obj.c_ob_refcnt == 0:
         state = space.fromcache(RefcountState)
         ptr = rffi.cast(ADDR, obj)
@@ -392,7 +388,7 @@
     obj.c_ob_refcnt += 1
     assert obj.c_ob_refcnt > 0
     if DEBUG_REFCOUNT:
-        debug_refcount("INCREF", obj, obj.c_ob_refcnt, frame_stackdepth=3)
+        debug_refcount("INCREF", obj, obj.c_ob_refcnt)
 
 @cpython_api([PyObject], lltype.Void)
 def _Py_NewReference(space, obj):

Repository URL: https://bitbucket.org/pypy/pypy/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the Pypy-commit mailing list