labscript-suite-temp-2 / labscript_utils

Shared modules used by the labscript suite. Includes a graphical exception handler, debug tools, configuration management, cross platform filepath conversions, unit conversions and custom GUI widgets.
Other
0 stars 0 forks source link

Double import denier breaks python3 stuff #16

Closed philipstarkey closed 6 years ago

philipstarkey commented 6 years ago

Original report (archived issue) by Jan Werkmann (Bitbucket: PhyNerd, GitHub: PhyNerd).


In modules where labscrupt_utils is imported the command python -m module_name_here leads to a exception:

#!python

Traceback (most recent call last):
  File "/Users/janwerkmann/anaconda/envs/snowflakes/lib/python3.6/runpy.py", line 185, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/Users/janwerkmann/anaconda/envs/snowflakes/lib/python3.6/runpy.py", line 142, in _get_module_details
    return _get_module_details(pkg_main_name, error)
  File "/Users/janwerkmann/anaconda/envs/snowflakes/lib/python3.6/runpy.py", line 155, in _get_module_details
    code = loader.get_code(mod_name)

I did a bit of debugging and it seems to be caused by loader being of type <labscript_utils.double_import_denier.Loader object at 0x10e910438>. So we should maybe fix that for python 3 compat. Fun fact python filepath_to_module still works.

philipstarkey commented 6 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Ah, I see.

My "loader" object didn't implement the entire Python 3 spec for loader objects, but the Python docs assured me that that the Python 2 spec would be sufficient. Looks like this isn't the case for running modules as main using the -m flag in Python 3. Should be fixed by pull request #38.

philipstarkey commented 6 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Merged in cbillington/labscript_utils/bugfix (pull request #38)

Fix issue #16

Approved-by: Jan Werkmann jan.wrk.fb@gmail.com

→ \<\<cset 2447f55408f4a7d3ff1d84957f217387b56eea55>>

philipstarkey commented 6 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Fix issue #16 by inheriting from the default Loader object.

→ \<\<cset 3295705dc5a4f8d79011e4927636f1bd70cb7a69>>

philipstarkey commented 6 years ago

Original comment by Chris Billington (Bitbucket: cbillington, GitHub: chrisjbillington).


Merged in cbillington/labscript_utils/bugfix (pull request #38)

Fix issue #16

Approved-by: Jan Werkmann jan.wrk.fb@gmail.com

→ \<\<cset 2447f55408f4a7d3ff1d84957f217387b56eea55>>