Sarcasm / compdb

The compilation database Swiss army knife
MIT License
295 stars 23 forks source link

FileNotFoundError is not defined in python2.7 #5

Closed 3v1n0 closed 6 years ago

3v1n0 commented 6 years ago

When using this with python2.7 (so it does by default when installing with pip in my 14.04 ubuntu system), it fails with:

No handlers could be found for logger "compdb.includedb"
Traceback (most recent call last):
  File "/home/marco/.local/bin/compdb", line 9, in <module>
    load_entry_point('compdb==0.1.1', 'console_scripts', 'compdb')()
  File "/home/marco/.local/lib/python2.7/site-packages/compdb/cli.py", line 280, in main
    command.execute(config, args.args)
  File "/home/marco/.local/lib/python2.7/site-packages/compdb/cli.py", line 89, in execute
    included_by_database = builder.build(database)
  File "/home/marco/.local/lib/python2.7/site-packages/compdb/includedb.py", line 263, in build
    pp.preprocess(compile_command)
  File "/home/marco/.local/lib/python2.7/site-packages/compdb/includedb.py", line 52, in preprocess
    quote, header_name = next(iter_stack[-1])
  File "/home/marco/.local/lib/python2.7/site-packages/compdb/includedb.py", line 109, in _iter_includes
    except FileNotFoundError as exc:
NameError: global name 'FileNotFoundError' is not defined

Defininig it as an IOError works as expected:

try:
    FileNotFoundError
except NameError:
    FileNotFoundError = IOError

Ah, and in order to see errors, I also needed to add to includedb.py logging.basicConfig()

Sarcasm commented 6 years ago

Thank you for reporting the issue. I used your fix.

Regarding the logging configuration, I had a commit pending locally (0cd1de34b469b68296d9a9c4338a8c98969db312) which I also pushed too.