From d9a1c5611bb7284da35bdbf4e3f039c95181669d Mon Sep 17 00:00:00 2001 From: Mark Dickinson Date: Sat, 17 Jan 2009 18:00:58 +0000 Subject: [PATCH] Merged revisions 68650-68653 via svnmerge from svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r68650 | mark.dickinson | 2009-01-17 09:45:37 +0000 (Sat, 17 Jan 2009) | 2 lines Remove a couple of references to long in the c-api docs ........ r68651 | mark.dickinson | 2009-01-17 10:04:45 +0000 (Sat, 17 Jan 2009) | 2 lines Issue #4910, patch 3/3: rename nb_long to nb_reserved ........ r68652 | mark.dickinson | 2009-01-17 10:21:23 +0000 (Sat, 17 Jan 2009) | 2 lines Fix a few more references to long integers in the docs. ........ r68653 | mark.dickinson | 2009-01-17 10:48:28 +0000 (Sat, 17 Jan 2009) | 2 lines Remove attempted long->int conversions in py3k version of float.as_integer_ratio. ........ --- Doc/c-api/arg.rst | 8 ++++---- Doc/c-api/intro.rst | 2 +- Doc/c-api/number.rst | 4 ++-- Doc/c-api/typeobj.rst | 12 +++++++++--- Doc/library/math.rst | 2 +- Doc/library/reprlib.rst | 2 +- Include/object.h | 2 +- Misc/NEWS | 3 +++ Modules/datetimemodule.c | 2 +- Objects/boolobject.c | 2 +- Objects/complexobject.c | 2 +- Objects/floatobject.c | 8 +------- Objects/longobject.c | 2 +- Objects/setobject.c | 2 +- Objects/typeobject.c | 4 ---- Objects/weakrefobject.c | 2 +- PC/winreg.c | 2 +- 17 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Doc/c-api/arg.rst b/Doc/c-api/arg.rst index 96068d988af2..dfedf972feb7 100644 --- a/Doc/c-api/arg.rst +++ b/Doc/c-api/arg.rst @@ -489,11 +489,11 @@ and the following format units are left untouched. ``H`` (integer) [unsigned short int] Convert a C :ctype:`unsigned short int` to a Python integer object. - ``I`` (integer/long) [unsigned int] - Convert a C :ctype:`unsigned int` to a Python long integer object. + ``I`` (integer) [unsigned int] + Convert a C :ctype:`unsigned int` to a Python integer object. - ``k`` (integer/long) [unsigned long] - Convert a C :ctype:`unsigned long` to a Python long integer object. + ``k`` (integer) [unsigned long] + Convert a C :ctype:`unsigned long` to a Python integer object. ``L`` (long) [PY_LONG_LONG] Convert a C :ctype:`long long` to a Python integer object. Only available diff --git a/Doc/c-api/intro.rst b/Doc/c-api/intro.rst index d165f166307f..33e6060d6576 100644 --- a/Doc/c-api/intro.rst +++ b/Doc/c-api/intro.rst @@ -607,7 +607,7 @@ extra checks are performed: * Sanity checks of the input arguments are added to frame creation. -* The storage for long ints is initialized with a known invalid pattern to catch +* The storage for ints is initialized with a known invalid pattern to catch reference to uninitialized digits. * Low-level tracing and extra exception checking are added to the runtime diff --git a/Doc/c-api/number.rst b/Doc/c-api/number.rst index d11e3b180d24..e7c5f61d6246 100644 --- a/Doc/c-api/number.rst +++ b/Doc/c-api/number.rst @@ -252,7 +252,7 @@ Number Protocol .. cfunction:: PyObject* PyNumber_Index(PyObject *o) - Returns the *o* converted to a Python int or long on success or *NULL* with a + Returns the *o* converted to a Python int on success or *NULL* with a :exc:`TypeError` exception raised on failure. @@ -268,7 +268,7 @@ Number Protocol .. cfunction:: Py_ssize_t PyNumber_AsSsize_t(PyObject *o, PyObject *exc) Returns *o* converted to a Py_ssize_t value if *o* can be interpreted as an - integer. If *o* can be converted to a Python int or long but the attempt to + integer. If *o* can be converted to a Python int but the attempt to convert to a Py_ssize_t value would raise an :exc:`OverflowError`, then the *exc* argument is the type of exception that will be raised (usually :exc:`IndexError` or :exc:`OverflowError`). If *exc* is *NULL*, then the diff --git a/Doc/c-api/typeobj.rst b/Doc/c-api/typeobj.rst index 83559862512b..6d98d6b86454 100644 --- a/Doc/c-api/typeobj.rst +++ b/Doc/c-api/typeobj.rst @@ -135,7 +135,7 @@ type objects) *must* have the :attr:`ob_size` field. :attr:`ob_size` field, and the instance size is :attr:`tp_basicsize` plus N times :attr:`tp_itemsize`, where N is the "length" of the object. The value of N is typically stored in the instance's :attr:`ob_size` field. There are - exceptions: for example, long ints use a negative :attr:`ob_size` to indicate a + exceptions: for example, ints use a negative :attr:`ob_size` to indicate a negative number, and N is ``abs(ob_size)`` there. Also, the presence of an :attr:`ob_size` field in the instance layout doesn't mean that the instance structure is variable-length (for example, the structure for the list type has @@ -812,7 +812,7 @@ type objects) *must* have the :attr:`ob_size` field. where :attr:`tp_basicsize`, :attr:`tp_itemsize` and :attr:`tp_dictoffset` are taken from the type object, and :attr:`ob_size` is taken from the instance. The - absolute value is taken because long ints use the sign of :attr:`ob_size` to + absolute value is taken because ints use the sign of :attr:`ob_size` to store the sign of the number. (There's never a need to do this calculation yourself; it is done for you by :cfunc:`_PyObject_GetDictPtr`.) @@ -1057,7 +1057,7 @@ Number Object Structures binaryfunc nb_xor; binaryfunc nb_or; unaryfunc nb_int; - unaryfunc nb_long; + void *nb_reserved; unaryfunc nb_float; binaryfunc nb_inplace_add; @@ -1088,6 +1088,12 @@ Number Object Structures ``Py_NotImplemented``, if another error occurred they must return ``NULL`` and set an exception. + .. note:: + + The :cdata:`nb_reserved` field should always be ``NULL``. It + was previously called :cdata:`nb_long`, and was renamed in + Python 3.0.1. + .. _mapping-structs: diff --git a/Doc/library/math.rst b/Doc/library/math.rst index f171ec1a3f9e..ab39424373c9 100644 --- a/Doc/library/math.rst +++ b/Doc/library/math.rst @@ -118,7 +118,7 @@ Number-theoretic and representation functions .. function:: trunc(x) Return the :class:`Real` value *x* truncated to an :class:`Integral` (usually - a long integer). Delegates to ``x.__trunc__()``. + an integer). Delegates to ``x.__trunc__()``. Note that :func:`frexp` and :func:`modf` have a different call/return pattern diff --git a/Doc/library/reprlib.rst b/Doc/library/reprlib.rst index c1364a371020..0da29fc9bfc5 100644 --- a/Doc/library/reprlib.rst +++ b/Doc/library/reprlib.rst @@ -65,7 +65,7 @@ which format specific object types. .. attribute:: Repr.maxlong - Maximum number of characters in the representation for a long integer. Digits + Maximum number of characters in the representation for an integer. Digits are dropped from the middle. The default is ``40``. diff --git a/Include/object.h b/Include/object.h index 0d20ecc003c0..c0f61813555c 100644 --- a/Include/object.h +++ b/Include/object.h @@ -219,7 +219,7 @@ typedef struct { binaryfunc nb_xor; binaryfunc nb_or; unaryfunc nb_int; - unaryfunc nb_long; + void *nb_reserved; /* the slot formerly known as nb_long */ unaryfunc nb_float; binaryfunc nb_inplace_add; diff --git a/Misc/NEWS b/Misc/NEWS index ce02ad627977..1bd6c05083e8 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -12,6 +12,9 @@ What's New in Python 3.0.1? Core and Builtins ----------------- +- Issue #4910: Rename nb_long slot to nb_reserved, and change its + type to (void *). + - Issue #4935: The overflow checking code in the expandtabs() method common to str, bytes and bytearray could be optimized away by the compiler, letting the interpreter segfault instead of raising an error. diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c index 702b6b984bb4..98ae2bd2244f 100644 --- a/Modules/datetimemodule.c +++ b/Modules/datetimemodule.c @@ -2111,7 +2111,7 @@ static PyNumberMethods delta_as_number = { 0, /*nb_xor*/ 0, /*nb_or*/ 0, /*nb_int*/ - 0, /*nb_long*/ + 0, /*nb_reserved*/ 0, /*nb_float*/ 0, /*nb_inplace_add*/ 0, /*nb_inplace_subtract*/ diff --git a/Objects/boolobject.c b/Objects/boolobject.c index 6916b9f8035f..eac31b994352 100644 --- a/Objects/boolobject.c +++ b/Objects/boolobject.c @@ -109,7 +109,7 @@ static PyNumberMethods bool_as_number = { bool_xor, /* nb_xor */ bool_or, /* nb_or */ 0, /* nb_int */ - 0, /* nb_long */ + 0, /* nb_reserved */ 0, /* nb_float */ 0, /* nb_inplace_add */ 0, /* nb_inplace_subtract */ diff --git a/Objects/complexobject.c b/Objects/complexobject.c index a7fd7dc55835..879d71c56527 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -1060,7 +1060,7 @@ static PyNumberMethods complex_as_number = { 0, /* nb_xor */ 0, /* nb_or */ complex_int, /* nb_int */ - 0, /* nb_long */ + 0, /* nb_reserved */ complex_float, /* nb_float */ 0, /* nb_inplace_add */ 0, /* nb_inplace_subtract */ diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 7292ca568977..a05b3c6a049d 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -1495,12 +1495,6 @@ float_as_integer_ratio(PyObject *v, PyObject *unused) py_exponent = NULL; } - /* Returns ints instead of longs where possible */ - INPLACE_UPDATE(numerator, PyNumber_Int(numerator)); - if (numerator == NULL) goto error; - INPLACE_UPDATE(denominator, PyNumber_Int(denominator)); - if (denominator == NULL) goto error; - result_pair = PyTuple_Pack(2, numerator, denominator); #undef INPLACE_UPDATE @@ -1798,7 +1792,7 @@ static PyNumberMethods float_as_number = { 0, /*nb_xor*/ 0, /*nb_or*/ float_trunc, /*nb_int*/ - 0, /*nb_long*/ + 0, /*nb_reserved*/ float_float, /*nb_float*/ 0, /* nb_inplace_add */ 0, /* nb_inplace_subtract */ diff --git a/Objects/longobject.c b/Objects/longobject.c index dc03f47e79ae..40689fbee203 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -3759,7 +3759,7 @@ static PyNumberMethods long_as_number = { long_xor, /*nb_xor*/ long_or, /*nb_or*/ long_long, /*nb_int*/ - 0, /*nb_long*/ + 0, /*nb_reserved*/ long_float, /*nb_float*/ 0, /* nb_inplace_add */ 0, /* nb_inplace_subtract */ diff --git a/Objects/setobject.c b/Objects/setobject.c index d3243dd77a3c..d5d96cad03eb 100644 --- a/Objects/setobject.c +++ b/Objects/setobject.c @@ -2082,7 +2082,7 @@ static PyNumberMethods set_as_number = { (binaryfunc)set_xor, /*nb_xor*/ (binaryfunc)set_or, /*nb_or*/ 0, /*nb_int*/ - 0, /*nb_long*/ + 0, /*nb_reserved*/ 0, /*nb_float*/ 0, /*nb_inplace_add*/ (binaryfunc)set_isub, /*nb_inplace_subtract*/ diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 8f2e01e00cff..cdf4e41fc6a3 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -3602,7 +3602,6 @@ inherit_slots(PyTypeObject *type, PyTypeObject *base) COPYNUM(nb_xor); COPYNUM(nb_or); COPYNUM(nb_int); - COPYNUM(nb_long); COPYNUM(nb_float); COPYNUM(nb_inplace_add); COPYNUM(nb_inplace_subtract); @@ -4827,7 +4826,6 @@ SLOT1BIN(slot_nb_xor, nb_xor, "__xor__", "__rxor__") SLOT1BIN(slot_nb_or, nb_or, "__or__", "__ror__") SLOT0(slot_nb_int, "__int__") -SLOT0(slot_nb_long, "__long__") SLOT0(slot_nb_float, "__float__") SLOT1(slot_nb_inplace_add, "__iadd__", PyObject *, "O") SLOT1(slot_nb_inplace_subtract, "__isub__", PyObject *, "O") @@ -5443,8 +5441,6 @@ static slotdef slotdefs[] = { RBINSLOT("__ror__", nb_or, slot_nb_or, "|"), UNSLOT("__int__", nb_int, slot_nb_int, wrap_unaryfunc, "int(x)"), - UNSLOT("__long__", nb_long, slot_nb_long, wrap_unaryfunc, - "int(x)"), UNSLOT("__float__", nb_float, slot_nb_float, wrap_unaryfunc, "float(x)"), NBSLOT("__index__", nb_index, slot_nb_index, wrap_unaryfunc, diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 538b21cbf49b..b65e5fdd34d4 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -594,7 +594,7 @@ static PyNumberMethods proxy_as_number = { proxy_xor, /*nb_xor*/ proxy_or, /*nb_or*/ proxy_int, /*nb_int*/ - 0, /*nb_long*/ + 0, /*nb_reserved*/ proxy_float, /*nb_float*/ proxy_iadd, /*nb_inplace_add*/ proxy_isub, /*nb_inplace_subtract*/ diff --git a/PC/winreg.c b/PC/winreg.c index 7316fcd94e55..3abefa8437e3 100644 --- a/PC/winreg.c +++ b/PC/winreg.c @@ -451,7 +451,7 @@ static PyNumberMethods PyHKEY_NumberMethods = PyHKEY_binaryFailureFunc, /* nb_xor */ PyHKEY_binaryFailureFunc, /* nb_or */ PyHKEY_intFunc, /* nb_int */ - 0, /* nb_long */ + 0, /* nb_reserved */ PyHKEY_unaryFailureFunc, /* nb_float */ }; -- 2.47.3