Closed zakv closed 2 years ago
@zakv, assuming this all still looks good to you, I'm happy to merge this.
Maybe we should get @chrisjbillington's eyes on this first? From https://github.com/labscript-suite/labscript/issues/71 it seems like he might have un-merged changes related to importing unit conversion classes. Maybe he's already fixed it and merging this PR might create a merge conflict later on?
This fix is orthogonal to labscript-suite/labscript#71 (which I've just submitted a PR for - labscript-suite/labscript#84), so go ahead!
Previously in
unitconversions._All._import_all()
,self.__all__
wasn't always changed fromNone
to an empty list before appending things to it. In particular that wouldn't happen when explicitly calling._All._import_all()
instead of using its__getitem__()
method first. That would raiseAttributeError: 'NoneType' object has no attribute 'append'
. This PR edits._All._import_all()
to ensure that it is always set to an empty list before appending things to it.During startup, the blacs code here would suppress that error. It assumes that the
AttributeError
was raised because the desired unit conversion class didn't exist in the module, which would cause a somewhat misleading error message to be logged. Took me a while with a debugger to figure out that python can import the module, it just fails to import because_All._import_all()
errors out first.