google / openhtf

The open-source hardware testing framework.
Apache License 2.0
525 stars 214 forks source link

Exceptions raised getting code info should not crash the framework. #230

Closed grybmadsci closed 8 years ago

grybmadsci commented 8 years ago

Traceback (most recent call last): File "/usr/lib/python2.7/runpy.py", line 162, 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 File "build/bdist.linux-x86_64/egg/tbtech/tests/metrology.py", line 78, in File "/usr/local/lib/python2.7/dist-packages/openhtf/util/measurements.py", line 383, in decorate phase = openhtf.PhaseInfo.WrapOrCopy(wrapped_phase) File "/usr/local/lib/python2.7/dist-packages/openhtf/init.py", line 312, in WrapOrCopy func = cls(func, test_record.CodeInfo.ForFunction(func)) File "/usr/local/lib/python2.7/dist-packages/openhtf/io/test_record.py", line 98, in ForFunction source = inspect.getsource(func) File "/usr/lib/python2.7/inspect.py", line 701, in getsource lines, lnum = getsourcelines(object) File "/usr/lib/python2.7/inspect.py", line 690, in getsourcelines lines, lnum = findsource(object) File "/usr/lib/python2.7/inspect.py", line 538, in findsource raise IOError('could not get source code') IOError: could not get source code

grybmadsci commented 8 years ago

I only see this outside a virtualenv, haven't investigated the root cause yet, but at the very least this should be a warning a a fatal crash and burn.

fahhem commented 8 years ago

Even the python stacktrace couldn't get the source code, and it looks like you might be doing something fancy with compiled python or a ZipImporter? I agree, we should wrap the getsource functions with a try-except. I can take this one if you haven't started it

grybmadsci commented 8 years ago

I don't think we were doing anything fancy, just running on an ubuntu install, but outside a virtualenv.

jettisonjoe commented 8 years ago

Outside a virtualenv, meaning using the default system python?

grybmadsci commented 8 years ago

Yep, default system python on Ubuntu.