PythonCharmers/python-future

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

Open

#332 aberto em 22 de mar. de 2018

Ver no GitHub
 (0 comments) (0 reactions) (0 assignees)Python (327 forks)batch import
help wantedquestion

Métricas do repositório

Stars
 (1.172 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

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?

Guia do colaborador