mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Merged revisions 60475-60479,60481-60488 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r60482 | raymond.hettinger | 2008-01-31 23:07:16 +0100 (Thu, 31 Jan 2008) | 1 line Minor wordsmithing on docstring ........ r60483 | mark.dickinson | 2008-01-31 23:17:37 +0100 (Thu, 31 Jan 2008) | 5 lines Issue #1678380. Fix a bug that identifies 0j and -0j when they appear in the same code unit. The fix is essentially the same as the fix for a previous bug identifying 0. and -0. ........ r60484 | christian.heimes | 2008-02-01 00:08:23 +0100 (Fri, 01 Feb 2008) | 1 line Fixed bug #1983: Return from fork() is pid_t, not int ........ r60486 | jeffrey.yasskin | 2008-02-01 07:22:46 +0100 (Fri, 01 Feb 2008) | 4 lines Move __builtins__.trunc() to math.trunc() per http://mail.python.org/pipermail/python-dev/2008-January/076626.html and issue 1965. ........ r60487 | jeffrey.yasskin | 2008-02-01 08:05:46 +0100 (Fri, 01 Feb 2008) | 3 lines Roll back r60248. It's useful to encourage users not to change Rational instances. ........ r60488 | neal.norwitz | 2008-02-01 08:22:59 +0100 (Fri, 01 Feb 2008) | 1 line Fix refleak ........
This commit is contained in:
parent
a7712090f7
commit
400adb030a
18 changed files with 598 additions and 118 deletions
|
@ -1570,40 +1570,6 @@ PyDoc_STRVAR(vars_doc,
|
|||
Without arguments, equivalent to locals().\n\
|
||||
With an argument, equivalent to object.__dict__.");
|
||||
|
||||
static PyObject *
|
||||
builtin_trunc(PyObject *self, PyObject *number)
|
||||
{
|
||||
static PyObject *trunc_str = NULL;
|
||||
PyObject *trunc;
|
||||
|
||||
if (Py_TYPE(number)->tp_dict == NULL) {
|
||||
if (PyType_Ready(Py_TYPE(number)) < 0)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (trunc_str == NULL) {
|
||||
trunc_str = PyUnicode_InternFromString("__trunc__");
|
||||
if (trunc_str == NULL)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
trunc = _PyType_Lookup(Py_TYPE(number), trunc_str);
|
||||
if (trunc == NULL) {
|
||||
PyErr_Format(PyExc_TypeError,
|
||||
"type %.100s doesn't define __trunc__ method",
|
||||
Py_TYPE(number)->tp_name);
|
||||
return NULL;
|
||||
}
|
||||
return PyObject_CallFunction(trunc, "O", number);
|
||||
}
|
||||
|
||||
PyDoc_STRVAR(trunc_doc,
|
||||
"trunc(Real) -> Integral\n\
|
||||
\n\
|
||||
returns the integral closest to x between 0 and x.");
|
||||
|
||||
|
||||
|
||||
static PyObject*
|
||||
builtin_sum(PyObject *self, PyObject *args)
|
||||
{
|
||||
|
@ -1870,7 +1836,6 @@ static PyMethodDef builtin_methods[] = {
|
|||
{"sorted", (PyCFunction)builtin_sorted, METH_VARARGS | METH_KEYWORDS, sorted_doc},
|
||||
{"sum", builtin_sum, METH_VARARGS, sum_doc},
|
||||
{"vars", builtin_vars, METH_VARARGS, vars_doc},
|
||||
{"trunc", builtin_trunc, METH_O, trunc_doc},
|
||||
{"zip", builtin_zip, METH_VARARGS, zip_doc},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue