cpython: 81f229262921 (original) (raw)

Mercurial > cpython

changeset 102829:81f229262921

Issue #26984: int() now always returns an instance of exact int. [#26984]

Serhiy Storchaka storchaka@gmail.com
date Sun, 21 Aug 2016 20:03:08 +0300
parents cf18375732ae
children 81af0ab3db97
files Lib/test/test_int.py Misc/NEWS Objects/abstract.c
diffstat 3 files changed, 29 insertions(+), 13 deletions(-)[+] [-] Lib/test/test_int.py 5 Misc/NEWS 2 Objects/abstract.c 35

line wrap: on

line diff

--- a/Lib/test/test_int.py +++ b/Lib/test/test_int.py @@ -430,21 +430,24 @@ class IntTestCases(unittest.TestCase): with self.assertWarns(DeprecationWarning): n = int(bad_int) self.assertEqual(n, 1)

bad_int = BadInt2() with self.assertWarns(DeprecationWarning): n = int(bad_int) self.assertEqual(n, 1)

bad_int = TruncReturnsBadInt() with self.assertWarns(DeprecationWarning): n = int(bad_int) self.assertEqual(n, 1)

good_int = TruncReturnsIntSubclass() n = int(good_int) self.assertEqual(n, 1)

--- a/Misc/NEWS +++ b/Misc/NEWS @@ -10,6 +10,8 @@ What's New in Python 3.6.0 beta 1 Core and Builtins ----------------- +- Issue #26984: int() now always returns an instance of exact int. +

--- a/Objects/abstract.c +++ b/Objects/abstract.c @@ -1281,6 +1281,7 @@ PyNumber_AsSsize_t(PyObject *item, PyObj PyObject * PyNumber_Long(PyObject *o) {

@@ -1340,7 +1351,7 @@ PyNumber_Long(PyObject *o) PyByteArray_GET_SIZE(o), 10); if (PyObject_GetBuffer(o, &view, PyBUF_SIMPLE) == 0) {

/* Copy to NUL-terminated buffer. */ bytes = PyBytes_FromStringAndSize((const char *)view.buf, view.len);