{"action":"opened","issue":{"url":"https://api.github.com/repos/PythonCharmers/python-future/issues/187","labels_url":"https://api.github.com/repos/PythonCharmers/python-future/issues/187/labels{/name}","comments_url":"https://api.github.com/repos/PythonCharmers/python-future/issues/187/comments","events_url":"https://api.github.com/repos/PythonCharmers/python-future/issues/187/events","html_url":"https://github.com/PythonCharmers/python-future/issues/187","id":118282839,"number":187,"title":"Should isinstance(newint(...), int) return True for Python 2 when value is inside int bounds?","user":{"login":"posita","id":222581,"avatar_url":"https://avatars.githubusercontent.com/u/222581?v=3","gravatar_id":"","url":"https://api.github.com/users/posita","html_url":"https://github.com/posita","followers_url":"https://api.github.com/users/posita/followers","following_url":"https://api.github.com/users/posita/following{/other_user}","gists_url":"https://api.github.com/users/posita/gists{/gist_id}","starred_url":"https://api.github.com/users/posita/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/posita/subscriptions","organizations_url":"https://api.github.com/users/posita/orgs","repos_url":"https://api.github.com/users/posita/repos","events_url":"https://api.github.com/users/posita/events{/privacy}","received_events_url":"https://api.github.com/users/posita/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-22T19:22:53Z","updated_at":"2015-11-22T19:22:53Z","closed_at":null,"body":"Consider the following on PyPy (which uses a pure python version of `datetime`:\r\n\r\n```py\r\nPython 2.7.10 (f3ad1e1e1d6215e20d34bb65ab85ff9188c9f559, Sep 04 2015, 05:13:03)\r\n[PyPy 2.6.1 with GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>>> import datetime\r\n>>>> datetime.__file__\r\n'/.../lib/pypy/lib_pypy/datetime.pyc'\r\n>>>> from builtins import int as _int\r\n>>>> i = int(1431216000)\r\n>>>> j = long(i)\r\n>>>> k = _int(i)\r\n>>>> isinstance(i, int)\r\nTrue\r\n>>>> isinstance(i, long)\r\nFalse\r\n>>>> isinstance(j, int)\r\nFalse\r\n>>>> isinstance(j, long)\r\nTrue\r\n>>>> isinstance(k, int)\r\nFalse\r\n>>>> isinstance(k, long)\r\nTrue\r\n>>>> datetime.timedelta(seconds=i)\r\ndatetime.timedelta(16565)\r\n>>>> datetime.timedelta(seconds=j)\r\ndatetime.timedelta(16565)\r\n>>>> datetime.timedelta(seconds=k)\r\nTraceback (most recent call last):\r\n  File \"<stdin>\", line 1, in <module>\r\n  File \"/.../lib/pypy/lib_pypy/datetime.py\", line 491, in __new__\r\n    assert isinstance(s, int)\r\nAssertionError\r\n```\r\n\r\nThis does not happen on cPython, which uses a C implementation of `datetime`:\r\n\r\n```py\r\nPython 2.7.10 (default, Sep 24 2015, 10:13:45)\r\n[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin\r\nType \"help\", \"copyright\", \"credits\" or \"license\" for more information.\r\n>>> import datetime\r\n>>> datetime.__file__\r\n'/.../lib/python2.7/lib-dynload/datetime.so'\r\n>>> from builtins import int as _int\r\n>>> i = int(1431216000)\r\n>>> j = long(i)\r\n>>> k = _int(i)\r\n>>> isinstance(i, int)\r\nTrue\r\n>>> isinstance(i, long)\r\nFalse\r\n>>> isinstance(j, int)\r\nFalse\r\n>>> isinstance(j, long)\r\nTrue\r\n>>> isinstance(k, int)\r\nFalse\r\n>>> isinstance(k, long)\r\nTrue\r\n>>> datetime.timedelta(seconds=i)\r\ndatetime.timedelta(16565)\r\n>>> datetime.timedelta(seconds=j)\r\ndatetime.timedelta(16565)\r\n>>> datetime.timedelta(seconds=k)\r\ndatetime.timedelta(16565)\r\n```\r\n\r\nI'm not sure whether this is a problem with PyPy, or `future` or something else, but what if `isinstance(newint(x), int)` evaluated to `True` iff `x <= sys.maxint and x >= (-sys.maxint - 1)`? Would that be absurd or break things? It is, after all, called `int`, but behaves exclusively like a `long` with respect to the above context in Python 2."}}