8000 3-argument pow fails with newint arguments in Python 2 · Issue #87 · PythonCharmers/python-future · GitHub
[go: up one dir, main page]

Skip to content

3-argument pow fails with newint arguments in Python 2 #87

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
str4d opened this issue Aug 8, 2014 · 1 comment
Closed

3-argument pow fails with newint arguments in Python 2 #87

str4d opened this issue Aug 8, 2014 · 1 comment

Comments

@str4d
Copy link
Contributor
str4d commented Aug 8, 2014

In Python 3, future.builtins.int == int, and pow operates as expected.
In Python 2, future.builtins.int == newint and the 3-argument version of pow fails.

The 2-argument version works fine; it seems that in Python 2, the 2-argument version will take any int-like argument, but the 3-argument version will only take int:

>>> pow(2, 3)
8
>>> pow(int(2), 3)
8
>>> pow(int(2), 3, 3)
TypeError: __pow__() takes exactly 2 arguments (3 given)
>>> pow(2, int(3), 3)
TypeError: unsupported operand type(s) for pow(): 'int', 'newint', 'int'

Looking at the source, future.builtins.pow uses the Python 2 pow transparently, when it should be handling the presence of newints.

@edschofield
Copy link
Contributor

Fixed in v0.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
0