PythonCharmers/python-future

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

Open

#332 ouverte le 22 mars 2018

Voir sur GitHub
 (0 commentaires) (0 réactions) (0 assignés)Python (327 forks)batch import
help wantedquestion

Métriques du dépôt

Stars
 (1 172 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

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?

Guide contributeur