Bug #6363
closedSupport Python 3
0%
Description
Python 2 is approaching its EOL in less than a year: https://pythonclock.org/
Many repos are removing support for it, including Homebrew.
Please consider refactoring Chirp's code base to be Python 3 compatible.
Files
Updated by M T about 5 years ago
- File 2to3.patch 2to3.patch added
The attached patch should get you a long way to Python 3 with PyGObject. Many things are still not working, but should be relatively simple to correct. The main issues are:
- Python 3 division @/@ is real by default. This means that @int(1) / int(2)@ will yield @float(0.5)@. Floor (integer) division is explicitly designated by the @//@ operator. I have tried to use floor division where it is obviously correct (e.g., with byte math), but the rest of the code base will need to be audited (esp. around frequency calculations in many of the drivers). (Mind your modulo @%@ operators too, since Python 3 will happily accept @float@s as operands there, too.)
- Files are special now. @file(…)@ is gone, and, depending on the mode, @open(…)@ will give you one of an @io.TextIOBase@ (that deals in Unicode) and an @io.RawIOBase@ (that deals in @bytes@). (See https://docs.python.org/3/library/io.html for details.) String constants in Python 3 are all Unicode, so you really need to be precise about exactly which you want to use in each context. This will likely take some careful review and experimentation. Some frustration may ensue, but I'm happy to pair with you on these as they come up, if helpful. (There's a learning curve.)
Please let me know if I can provide any additional assistance. I recommend trying to apply this patch soon before too many changes are made to the existing code base to avoid merge conflicts.
Updated by M T about 5 years ago
- File 2to3.patch.gz 2to3.patch.gz added
A couple more improvements (ignore previous patch).
Updated by Dan Smith about 5 years ago
- Status changed from New to Rejected
I'm closing this a s a dupe of #495 along with the others. Some more details are available in there.
Thanks for your patch, it got me thinking about some things. I'm not interested in applying something so large to the tree and hoping for the best. A lot of things need a lot of work to continue working sanely. I'm going to send a mail to the list soon with some details about the start. I hope you and anyone else that is interested in working on this can jump on that and help out.