-
Notifications
You must be signed in to change notification settings - Fork 33
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
Update project to Python3 (2.7 -> 3.6) #91
Conversation
Primarily: / -> // when we want integer math correctly handling bytes vs str's
Great! I'm tired of typing |
There still are some errors, though. |
Can you be more specific? This project is rather stale and had several issues on |
Like a TypeError when trying to place a block, and lots of server errors while trying to handle another server error. I can fix the block-break animations, though. |
The crash on block break due to audio just needs a rename:
|
I guess the errors are happening because I'm using Python 3.7. Does this work for Python 3.7? |
I patched ManagedSoundPlayer on Python 3.7 works for me, though I did accidentally try loading the python3 branch with python2, resulting in a corrupted save file that I then had to manually delete. https://pyglet.readthedocs.io/en/pyglet-1.2-maintenance/api/pyglet/resource/pyglet.resource.get_settings_path.html shows where the saves are. |
I just deleted the |
Oh, and the TypeError I was getting earlier was |
Another error, right when I connected to a server. `TypeError: can't concat str to bytes |
Everything's working. |
In the interest of getting |
May want to review commit-by-commit.
The
2to3
tool handled most of the quick replacements, however there were 2 main areas it wasn't able to detect which required some care:/
->//
when we specifically want integer math. In Python2,5 / 2
== 2, whereas5 / 2.0
== 2.5. As of Python3,/
always means float math, and//
always means integer math - but lots of our code was relying on resulting ints (and Pyglet would blow up upon being given floats...)str
vsbytes
, especially relevant as this project makes heavy use of raw bytes operations in both the saving/loading and networking.Additionally, as Python3.5 added support for (compile-time) type hints, I added a number of them to help clarify the distinction between
str
andbytes
. Cython uses those type hints instead of needing a separate.pyd
definitions file, which seems nice.Everything appears to work about as well as on Python2, with likely a few bugs/inaccuracies fixed due to Python3's generally stricter handling, and possibly a few new crashes caused by that strictness.
As py2exe doesn't seem to support the latest Python3.x, I've updated setup.py to use
cx_Freeze
, which can also produce all-dependencies-bundled zips, helping #71 alongCloses #87
Closes #78