Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Address review comments.
  • Loading branch information
serhiy-storchaka committed Feb 20, 2019
commit 6f2a051a0f8785ccc1c7f7f9cb342cf84e1b7008
12 changes: 6 additions & 6 deletions Doc/c-api/long.rst
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. c:function:: unsigned long PyLong_AsUnsignedLongMask(PyObject *obj)

Return a C :c:type:`unsigned long` representation of *obj*. If *obj*
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
:meth:`__int__` method (if present) to convert it to a
:c:type:`PyLongObject`.
is not an instance of :c:type:`PyLongObject`, first call its
:meth:`__index__` or :meth:`__int__` method (if present) to convert
it to a :c:type:`PyLongObject`.

If the value of *obj* is out of range for an :c:type:`unsigned long`,
return the reduction of that value modulo ``ULONG_MAX + 1``.
Expand All @@ -300,9 +300,9 @@ distinguished from a number. Use :c:func:`PyErr_Occurred` to disambiguate.
.. c:function:: unsigned long long PyLong_AsUnsignedLongLongMask(PyObject *obj)

Return a C :c:type:`unsigned long long` representation of *obj*. If *obj*
instance of :c:type:`PyLongObject`, first call its :meth:`__index__` or
:meth:`__int__` method (if present) to convert it to a
:c:type:`PyLongObject`.
is not an instance of :c:type:`PyLongObject`, first call its
:meth:`__index__` or :meth:`__int__` method (if present) to convert
it to a :c:type:`PyLongObject`.

If the value of *obj* is out of range for an :c:type:`unsigned long long`,
return the reduction of that value modulo ``PY_ULLONG_MAX + 1``.
Expand Down
2 changes: 1 addition & 1 deletion Include/longobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ PyAPI_FUNC(PyObject *) _PyLong_FromNbInt(PyObject *);

/* Convert the given object to a PyLongObject using the nb_index or
nb_int slots, if available (the latter is deprecated).
Raise TypeError if either the nb_index and nb_int slots are not
Raise TypeError if either nb_index and nb_int slots are not
available or the result of the call to nb_index or nb_int
returns something not of type int.
Should be replaced with PyNumber_Index after the end of the
Expand Down
8 changes: 0 additions & 8 deletions Lib/test/test_structmembers.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,14 +106,6 @@ def test_bad_assignments(self):
for nonint in None, 3.2j, "full of eels", {}, []:
for attr in integer_attributes:
self.assertRaises(TypeError, setattr, ts, attr, nonint)
#for nonint in 3.2j,:
#for attr in integer_attributes:
#if attr not in ('T_BOOL', 'T_PYSSIZET'):
#with self.subTest(xx=attr):
#with self.assertWarns(DeprecationWarning):
#self.assertRaises(TypeError, setattr, ts, attr, nonint)
#for attr in ('T_BOOL', 'T_PYSSIZET'):
#self.assertRaises(TypeError, setattr, ts, attr, nonint)

def test_inplace_string(self):
self.assertEqual(ts.T_STRING_INPLACE, "hi")
Expand Down
11 changes: 8 additions & 3 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,14 @@ _PyLong_FromNbInt(PyObject *integral)
return result;
}


/* XXX Should be replaces with PyNumber_Index after the end of the
deprecation period. */
/* Convert the given object to a PyLongObject using the nb_index or
nb_int slots, if available (the latter is deprecated).
Raise TypeError if either nb_index and nb_int slots are not
available or the result of the call to nb_index or nb_int
returns something not of type int.
Should be replaced with PyNumber_Index after the end of the
deprecation period.
*/
PyObject *
_PyLong_FromNbIndexOrNbInt(PyObject *integral)
{
Expand Down
2 changes: 2 additions & 0 deletions Tools/clinic/clinic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2599,6 +2599,8 @@ def converter_init(self, *, accept={object}):

def parse_arg(self, argname, argnum):
if self.format_unit == 'i':
# XXX PyFloat_Check can be removed after the end of the
# deprecation in _PyLong_FromNbIndexOrNbInt.
return """
if (PyFloat_Check({argname})) {{{{
PyErr_SetString(PyExc_TypeError,
Expand Down