PythonCharmers/python-future

AttributeError: 'Py2Fixer' object has no attribute 'get_code'

Open

#332 opened on Mar 22, 2018

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Python (1,172 stars) (327 forks)batch import
help wantedquestion

Description

My python code has a dependency to some package that uses the past.autotranslate function. Therefore, it hooks the Py2Fixer to sys.meta_path, and this becomes the default loader for imported packages. When using runpy.py, this results in the following error:

Traceback (most recent call last):
  File "/home/dafne/anaconda2/envs/nlppln3/lib/python3.6/runpy.py", line 183, in _run_module_as_main
    mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
  File "/home/dafne/anaconda2/envs/nlppln3/lib/python3.6/runpy.py", line 153, in _get_module_details
    code = loader.get_code(mod_name)
AttributeError: 'Py2Fixer' object has no attribute 'get_code'

What would be the best solution to this? Would it be possible to add the get_code function to the Py2Fixer?

Contributor guide