Skip to content

Commit 428f064

Browse files
committed
Remove the deprecated and useless "pend" argument from
PyFloat_FromString. (fixes bug #1650903)
1 parent 9091e3a commit 428f064

6 files changed

Lines changed: 10 additions & 29 deletions

File tree

Doc/api/concrete.tex

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,9 @@ \subsection{Floating Point Objects \label{floatObjects}}
430430
\versionadded{2.2}
431431
\end{cfuncdesc}
432432

433-
\begin{cfuncdesc}{PyObject*}{PyFloat_FromString}{PyObject *str, char **pend}
433+
\begin{cfuncdesc}{PyObject*}{PyFloat_FromString}{PyObject *str}
434434
Create a \ctype{PyFloatObject} object based on the string value in
435-
\var{str}, or \NULL{} on failure. The \var{pend} argument is ignored. It
436-
remains only for backward compatibility.
435+
\var{str}, or \NULL{} on failure.
437436
\end{cfuncdesc}
438437

439438
\begin{cfuncdesc}{PyObject*}{PyFloat_FromDouble}{double v}

Doc/api/refcounts.dat

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,6 @@ PyFloat_FromDouble:double:v::
385385

386386
PyFloat_FromString:PyObject*::+1:
387387
PyFloat_FromString:PyObject*:str:0:
388-
PyFloat_FromString:char**:pend:0:ignored
389388

390389
PyFrozenSet_New:PyObject*::+1:
391390
PyFrozenSet_New:PyObject*:iterable:0:

Include/floatobject.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,8 @@ PyAPI_DATA(PyTypeObject) PyFloat_Type;
2121
#define PyFloat_Check(op) PyObject_TypeCheck(op, &PyFloat_Type)
2222
#define PyFloat_CheckExact(op) ((op)->ob_type == &PyFloat_Type)
2323

24-
/* Return Python float from string PyObject. Second argument ignored on
25-
input, and, if non-NULL, NULL is stored into *junk (this tried to serve a
26-
purpose once but can't be made to work as intended). */
27-
PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*, char** junk);
24+
/* Return Python float from string PyObject. */
25+
PyAPI_FUNC(PyObject *) PyFloat_FromString(PyObject*);
2826

2927
/* Return Python float from C double. */
3028
PyAPI_FUNC(PyObject *) PyFloat_FromDouble(double);

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ TO DO
2828
Core and Builtins
2929
-----------------
3030

31+
- The long-deprecated argument "pend" of PyFloat_FromString() has been
32+
removed.
33+
3134
- The dir() function has been extended to call the __dir__() method on
3235
its argument, if it exists. If not, it will work like before. This allows
3336
customizing the output of dir() in the presence of a __getattr__().

Objects/abstract.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ PyNumber_Float(PyObject *o)
968968
PyFloatObject *po = (PyFloatObject *)o;
969969
return PyFloat_FromDouble(po->ob_fval);
970970
}
971-
return PyFloat_FromString(o, NULL);
971+
return PyFloat_FromString(o);
972972
}
973973

974974
/* Operations on sequences */

Objects/floatobject.c

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -62,24 +62,8 @@ PyFloat_FromDouble(double fval)
6262
return (PyObject *) op;
6363
}
6464

65-
/**************************************************************************
66-
RED_FLAG 22-Sep-2000 tim
67-
PyFloat_FromString's pend argument is braindead. Prior to this RED_FLAG,
68-
69-
1. If v was a regular string, *pend was set to point to its terminating
70-
null byte. That's useless (the caller can find that without any
71-
help from this function!).
72-
73-
2. If v was a Unicode string, or an object convertible to a character
74-
buffer, *pend was set to point into stack trash (the auto temp
75-
vector holding the character buffer). That was downright dangerous.
76-
77-
Since we can't change the interface of a public API function, pend is
78-
still supported but now *officially* useless: if pend is not NULL,
79-
*pend is set to NULL.
80-
**************************************************************************/
8165
PyObject *
82-
PyFloat_FromString(PyObject *v, char **pend)
66+
PyFloat_FromString(PyObject *v)
8367
{
8468
const char *s, *last, *end;
8569
double x;
@@ -89,8 +73,6 @@ PyFloat_FromString(PyObject *v, char **pend)
8973
#endif
9074
Py_ssize_t len;
9175

92-
if (pend)
93-
*pend = NULL;
9476
if (PyString_Check(v)) {
9577
s = PyString_AS_STRING(v);
9678
len = PyString_GET_SIZE(v);
@@ -852,7 +834,7 @@ float_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
852834
if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:float", kwlist, &x))
853835
return NULL;
854836
if (PyString_Check(x))
855-
return PyFloat_FromString(x, NULL);
837+
return PyFloat_FromString(x);
856838
return PyNumber_Float(x);
857839
}
858840

0 commit comments

Comments
 (0)