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

move to python3? #3

Open
bblfish opened this issue Jun 16, 2022 · 4 comments
Open

move to python3? #3

bblfish opened this issue Jun 16, 2022 · 4 comments

Comments

@bblfish
Copy link

bblfish commented Jun 16, 2022

There was a major change in syntax in python as it moved to python3.
It looks like the move can be automated
https://stackoverflow.com/questions/25445439/what-does-syntaxerror-missing-parentheses-in-call-to-print-mean-in-python

I tried 2to3 . -w which changes 142 files. But it gets stuck on

 File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib2to3/refactor.py", line 322, in _read_python_source
    return f.read(), encoding
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 983: invalid start byte

And I am not knowledgeable enough to continue much further at present.

@timbl
Copy link
Member

timbl commented Jun 16, 2022

Interesting ... not obvious while file actually had the unicode error?

@bblfish
Copy link
Author

bblfish commented Jun 16, 2022

I am not sure. It may be an error in the refactoring code too. It does a huge amount of refactoring and then it returns (longer version)


-        print "# ERROR: Unknown line format:", l
-    print "]."
+        print("# ERROR: Unknown line format:", l)
+    print("].")


 def do(path):
@@ -154,12 +154,12 @@
 for arg in sys.argv[1:]:
     if arg[0:1] == "-":
         if arg == "-?" or arg == "--help":
-            print
+            print()
         elif arg == "-v": verbose = 1
         elif arg == "-m": hideMailbox = 1
         elif arg == "-l": pureLDIF = 1
         else:
-            print """Bad option argument.""" + __doc__
+            print("""Bad option argument.""" + __doc__)
             sys.exit(-1)
     else:
         files.append(arg)
Traceback (most recent call last):
  File "/opt/homebrew/bin//2to3", line 5, in <module>
    sys.exit(main("lib2to3.fixes"))
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib2to3/main.py", line 263, in main
    rt.refactor(args, options.write, options.doctests_only,
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib2to3/refactor.py", line 690, in refactor
    return super(MultiprocessRefactoringTool, self).refactor(
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib2to3/refactor.py", line 284, in refactor
    self.refactor_dir(dir_or_file, write, doctests_only)
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib2to3/refactor.py", line 304, in refactor_dir
    self.refactor_file(fullname, write, doctests_only)
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib2to3/refactor.py", line 731, in refactor_file
    return super(MultiprocessRefactoringTool, self).refactor_file(
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib2to3/refactor.py", line 326, in refactor_file
    input, encoding = self._read_python_source(filename)
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/lib2to3/refactor.py", line 322, in _read_python_source
    return f.read(), encoding
  File "/opt/homebrew/Cellar/[email protected]/3.9.13_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa9 in position 983: invalid start byte

@timbl
Copy link
Member

timbl commented Jun 16, 2022

It was a bogus copyright sign in pim/lookout.py

@timbl
Copy link
Member

timbl commented Jun 16, 2022

By looking at the file it was processing just before the error

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

2 participants