-
Notifications
You must be signed in to change notification settings - Fork 386
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
Python3.12 compatibility / drop 'future' dependency #742
Comments
a more complete solution would be to just drop all those occurences of |
also note that
since Python3.12 has arrived, this needs to be handled somehow: --- python-canmatrix.orig/versioneer.py
+++ python-canmatrix/versioneer.py
@@ -336,9 +336,9 @@
# configparser.NoOptionError (if it lacks "VCS="). See the docstring at
# the top of versioneer.py for instructions on writing your setup.cfg .
setup_cfg = os.path.join(root, "setup.cfg")
- parser = configparser.SafeConfigParser()
+ parser = configparser.ConfigParser()
with open(setup_cfg, "r") as f:
- parser.readfp(f)
+ parser.read_file(f)
VCS = parser.get("versioneer", "VCS") # mandatory
def get(parser, name): this patch requires Python>=3.2 which is probably acceptable (or not) |
in my original post, i missed that there are a few imports of the so here's a more complete patch to get rid of Index: python-canmatrix-1.0~github/setup.py
===================================================================
--- python-canmatrix-1.0~github.orig/setup.py
+++ python-canmatrix-1.0~github/setup.py
@@ -83,7 +83,6 @@ setup(
"attrs>=19.2.0",
"click",
"enum34; python_version < '3.4'",
- "future",
"importlib-metadata; python_version < '3.8'",
"six",
"typing; python_version < '3.5'",
Index: python-canmatrix-1.0~github/src/canmatrix/formats/sym.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/sym.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/sym.py
@@ -100,11 +100,7 @@ def format_float(f): # type: (typing.An
def create_signal(db, signal): # type: (canmatrix.CanMatrix, canmatrix.Signal) -> str
output = ""
- if sys.version_info > (3, 0):
- quote_name = not signal.name.isidentifier()
- else:
- from future.utils import isidentifier
- quote_name = not isidentifier(signal.name)
+ quote_name = not signal.name.isidentifier()
if quote_name:
output += 'Var="%s" ' % signal.name
else:
Index: python-canmatrix-1.0~github/src/canmatrix/canmatrix.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/canmatrix.py
+++ python-canmatrix-1.0~github/src/canmatrix/canmatrix.py
@@ -40,7 +40,6 @@ import warnings
from builtins import *
import attr
-from past.builtins import basestring
from six.moves import zip_longest
import canmatrix.copy
@@ -432,7 +431,7 @@ class Signal(object):
if not (self.min <= value <= self.max):
value = self.min
- if isinstance(value, basestring):
+ if isinstance(value, str):
for value_key, value_string in self.values.items():
if value_string == value:
value = value_key
Index: python-canmatrix-1.0~github/src/canmatrix/formats/xls.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/xls.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/xls.py
@@ -30,7 +30,6 @@ import logging
import typing
from builtins import *
-import past.builtins
import xlrd
import xlwt
@@ -540,7 +539,7 @@ def load(file, **options):
unit = ""
factor = sh.cell(row_num, index['function']).value
- if isinstance(factor, past.builtins.basestring):
+ if isinstance(factor, str):
factor = factor.strip()
if " " in factor and factor[0].isdigit():
(factor, unit) = factor.strip().split(" ", 1)
Index: python-canmatrix-1.0~github/src/canmatrix/formats/yaml.py
===================================================================
--- python-canmatrix-1.0~github.orig/src/canmatrix/formats/yaml.py
+++ python-canmatrix-1.0~github/src/canmatrix/formats/yaml.py
@@ -30,7 +30,6 @@ import typing
from builtins import *
import yaml
-from past.builtins import long, unicode
import canmatrix
@@ -43,8 +42,6 @@ except ImportError:
representers = False
try:
yaml.add_representer(int, SafeRepresenter.represent_int)
- yaml.add_representer(long, SafeRepresenter.represent_long)
- yaml.add_representer(unicode, SafeRepresenter.represent_unicode)
yaml.add_representer(str, SafeRepresenter.represent_unicode)
yaml.add_representer(list, SafeRepresenter.represent_list)
representers = True
@@ -67,7 +64,7 @@ def dump(db, f, **options): # type: (ca
# f = open(filename, "w")
if representers:
- f.write(unicode(yaml.dump(new_db)))
+ f.write(yaml.dump(new_db))
else:
f.write(yaml.dump(new_db).encode('utf8'))
Index: python-canmatrix-1.0~github/mypy.ini
===================================================================
--- python-canmatrix-1.0~github.orig/mypy.ini
+++ python-canmatrix-1.0~github/mypy.ini
@@ -34,5 +34,5 @@ ignore_errors = True
ignore_errors = True
# other settings:
-[mypy-xlsxwriter,past,past.builtins,pathlib2]
+[mypy-xlsxwriter,pathlib2]
ignore_missing_imports = True notes
|
sorry to have created additional work. i could (and would) of course have done the PRs myself, but wanted to get your feedback first to see if i was on the right track (and it was easier for my actual workflow (while preparing the Debian packages) to just paste the diffs for now) |
canmatrix
depends onfuture
, but it seems thatfuture
is not really compatible with Python3.12 (yet?).One possible solution is to fix
future
, butfuture
is a compat layer for Py2/Py3, but according to https://github.com/ebroecker/canmatrix/releases/tag/1.0, we've seen the "Last py2 release", so it's probably time to drop cruft.canmatrix
uses a single function fromfuture
, which can trivially be implemented in ordinary Pythonhere's a patch that eliminates the use of
future
, but requires Python3:The text was updated successfully, but these errors were encountered: