analogdevicesinc / colorimeter

Application to be used with the EVAL-CN0363-PMDZ

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Build error: SyntaxError: leading zeros in decimal integer literals are not permitted;

warnes opened this issue · comments

On branch master:

$ sudo python3 setup.py install
running install
running build
running build_py
running install_lib
byte-compiling /usr/local/lib/python3.9/dist-packages/adi_colorimeter/sample_library.py to sample_library.cpython-39.pyc
  File "/usr/local/lib/python3.9/dist-packages/adi_colorimeter/sample_library.py", line 81
    os.makedirs(os.path.dirname(location), 0755)
                                              ^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers

running install_egg_info
Removing /usr/local/lib/python3.9/dist-packages/adi_colorimeter-1.0.egg-info
Writing /usr/local/lib/python3.9/dist-packages/adi_colorimeter-1.0.egg-info

System Info:

pi@wwi-demo-green:~/inoui/src/colorimeter $ lsb_release -a
No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 11 (bullseye)
Release:	11
Codename:	bullseye

pi@wwi-demo-green:~/inoui/src/colorimeter $ uname -a
Linux wwi-demo-green 5.10.103-v8+ #1530 SMP PREEMPT Tue Mar 8 13:06:35 GMT 2022 aarch64 GNU/Linux

$ python --version
Python 3.9.2

Solution:

This patch resolves this issue, as well as an issue with exception syntax:

diff --git a/lib/sample_library.py b/lib/sample_library.py
index 4c247e8..56e578d 100644
--- a/lib/sample_library.py
+++ b/lib/sample_library.py
@@ -78,7 +78,7 @@ class SampleLibrary(object):
         self.location = location
         self.samples = []
         if not os.path.exists(os.path.dirname(location)):
-            os.makedirs(os.path.dirname(location), 0755)
+            os.makedirs(os.path.dirname(location), 0o0755)
         else:
             for f in os.listdir(location):
                 f = os.path.join(location, f)
@@ -86,7 +86,7 @@ class SampleLibrary(object):
                     continue
                 try:
                     self.samples.append(Sample.load(f))
-                except Exception, e:
+                except Exception as e:
                     print(e)

     def __iter__(self):

Previous version was using python2. If you switch to python3 it's expected to fail on build since some syntax got modified between these two python version.

PR #6 updates it to python3. tested with python3.9.