Skip to content
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

TypeError after 2to3 #25

Open
nittanycolonial opened this issue Apr 19, 2017 · 5 comments
Open

TypeError after 2to3 #25

nittanycolonial opened this issue Apr 19, 2017 · 5 comments

Comments

@nittanycolonial
Copy link

nittanycolonial commented Apr 19, 2017

I have used 2to3 to run this library and I keep on running into a TypeError of:

TypeError: unsupported operand type(s) for >>: 'float' and 'int'

def get_lexographically_next_bit_sequence(self, bits): t = (bits | (bits - 1)) + 1 next = t | ((((t & -t) // (bits & -bits)) >> 1) - 1) yield next while True: t = (next | (next - 1)) + 1 next = t | ((((t & -t) // (next & -next)) >> 1) - 1) yield next

I have tried other parts of the library and they work, so I'm pretty confident that 2to3 worked fine. It's only when I load the evaluator that this message pops up. Any thoughts?

@furuutsuponchisamurai
Copy link

I have the same issue while running go.py.

@mpenkov
Copy link
Contributor

mpenkov commented Aug 20, 2017

/ means float division in Python 3. If you want integer division, use /. Unfortunately, 2to3 isn't smart enough to take care of this for you.

There's a PR here that takes care of Py3 compatibility: #21 (apparently duplicated by #23).

@nittanycolonial
Copy link
Author

@mpenkov thanks but did your answer not format properly? I guess I'm not seeing a difference in the slashes as you mention them. I have tried using both / and // in my code and it will still not work.

@mpenkov
Copy link
Contributor

mpenkov commented Aug 28, 2017

@nittanycolonial Whoops. Here's what I meant:

If you want integer division, use //

Have a look at the pull-requests I mentioned for more info.

@luchaoo7
Copy link

Hello guys, I did a pull to the original project and I couldn't seem to get it working straight away on python3.5. I've forked the project and it now works with python3.5.

The main things were:
1.) Python 2 does floor division with the / operator, Python 3 introduced // for floor division.
2.) For some reason after having done 2to3 conversion, I was getting a byte object in the section of the code and had to change it to string for it to work.

hope this helps.

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

4 participants