Qix-/better-exceptions

fix Python 2 import

dansan opened this issue · 0 comments

The Python 2 import code for load_module() in __main__.py is broken:

(be) dtroeder@sommar:/tmp$ pip install better_exceptions
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting better_exceptions
Installing collected packages: better-exceptions
Successfully installed better-exceptions-0.2.2
(be) dtroeder@sommar:/tmp$ export BETTER_EXCEPTIONS=1
(be) dtroeder@sommar:/tmp$ python -m better_exceptions
Traceback (most recent call last):
  File "/usr/lib/python2.7/runpy.py", line 174, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "/usr/lib/python2.7/runpy.py", line 72, in _run_code
    exec code in run_globals
         │       └ {'argparse': <module 'argparse' from '/usr/lib/python2.7/argparse.pyc'>, 'parser': ArgumentParser(prog='python -m better_excepti...
         └ <code object <module> at 0x7f03cfa0b6b0, file "/tmp/be/lib/python2.7/site-packages/better_exceptions/__main__.py", line 1>
  File "/tmp/be/lib/python2.7/site-packages/better_exceptions/__main__.py", line 31, in <module>
    load_module('pystartup', startup_file)
    │                        └ '/home/dtroeder/.pythonrc.py'<function load_module at 0x7f03cf56a0c8>
  File "/tmp/be/lib/python2.7/site-packages/better_exceptions/__main__.py", line 19, in load_module
    imp.load_module('a_b', f, path, ('.py', 'U', imp.PY_SOURCE))
    │                                            └ <module 'imp' (built-in)><module 'imp' (built-in)>
NameError: global name 'f' is not defined