[pypy-svn] pypy psycopg2compatibility: 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.
ademan
commits-noreply at bitbucket.org
Tue Dec 21 13:06:57 CET 2010
Author: Daniel Roberts <Ademan555 at gmail.com>
Branch: psycopg2compatibility
Changeset: r40157:8c5587a07805
Date: 2010-12-21 04:01 -0800
http://bitbucket.org/pypy/pypy/changeset/8c5587a07805/
Log: 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.
diff --git a/pypy/module/cpyext/floatobject.py b/pypy/module/cpyext/floatobject.py
--- a/pypy/module/cpyext/floatobject.py
+++ b/pypy/module/cpyext/floatobject.py
@@ -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)
More information about the Pypy-commit
mailing list