PythonCharmers/python-future

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

Open

#332 创建于 2018年3月22日

在 GitHub 查看
 (0 评论) (0 反应) (0 负责人)Python (1,172 star) (327 fork)batch import
help wantedquestion

描述

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?

贡献者指南