Project

General

Profile

Actions

Bug #6363

closed

Support Python 3

Added by M T over 5 years ago. Updated about 5 years ago.

Status:
Rejected
Priority:
High
Assignee:
-
Category:
-
Target version:
-
Start date:
01/09/2019
Due date:
12/31/2019
% Done:

0%

Estimated time:
Chirp Version:
daily
Model affected:
(All models)
Platform:
All
Debug Log:
I read the instructions above:

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

2to3.patch (455 KB) 2to3.patch Update to Python 3 with PyGObject (most of the way there) M T, 01/28/2019 07:38 PM
2to3.patch.gz (88.3 KB) 2to3.patch.gz SUPERSEDES ALL PRIOR PATCHES SUBMITTED IN THIS ISSUE - Update to Python 3 with PyGObject (most of the way there) M T, 01/28/2019 11:01 PM
Actions #1

Updated by M T about 5 years ago

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.

Actions #2

Updated by M T about 5 years ago

A couple more improvements (ignore previous patch).

Actions #3

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.

Actions

Also available in: Atom PDF