aboutcode-org / typecode

7 stars 9 forks source link

Missing sys import in typecode/magic2.py #23

Closed tdruez closed 1 year ago

tdruez commented 2 years ago

https://github.com/nexB/typecode/blob/main/src/typecode/magic2.py#L136

  File "/Volumes/nexB/repos/scancode.io/lib/python3.10/site-packages/typecode/contenttype.py", line 32, in <module>
    from typecode import magic2
  File "/Volumes/nexB/repos/scancode.io/lib/python3.10/site-packages/typecode/magic2.py", line 378, in <module>
    libmagic = load_lib()
  File "/Volumes/nexB/repos/scancode.io/lib/python3.10/site-packages/typecode/magic2.py", line 174, in load_lib
    failover_lib = load_lib_failover()
  File "/Volumes/nexB/repos/scancode.io/lib/python3.10/site-packages/typecode/magic2.py", line 137, in load_lib_failover
    platform = 'linux' if sys.platform.startswith('linux') else sys.platform
NameError: name 'sys' is not defined

Simply move the sys import @ https://github.com/nexB/typecode/blob/main/src/typecode/magic2.py#L55 outside the trace condition.

jayvdb commented 1 year ago

This is fixed and can be closed.

jayvdb commented 1 year ago

Just noting there is another related import problem, fixed in https://github.com/nexB/typecode/pull/27