Closed
Description
What happened?
Given a subclass of AbstractContainer
called ContainerSubclass
, if ContainerSubclass.__init__
raises an error, then AbstractContainer.__read_io
will not be initialized. During the error handling process, apparently __del__
is called on the partially initialized ContainerSubclass
object. That results in an AttributeError
that __read_io
does not exist. This exception is ignored, but we should avoid this by checking to see whether it exists before deleting it.
Steps to Reproduce
>>> import pynwb
>>> from pynwb import TimeSeries
>>> TimeSeries(
... name="test_ts1",
... data=[0, 1, 2, 3, 4, 5],
... unit="grams",
... timestamps=[0.0, 0.1, 0.2, 0.3, 0.4, 0.5],
... continuity="wrong",
... )
Exception ignored in: <function AbstractContainer.__del__ at 0x117e95990>
Traceback (most recent call last):
File "/Users/rly/Documents/NWB/hdmf/src/hdmf/container.py", line 197, in __del__
del self.__read_io
AttributeError: _AbstractContainer__read_io
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Users/rly/Documents/NWB/hdmf/src/hdmf/utils.py", line 643, in func_call
pargs = _check_args(args, kwargs)
File "/Users/rly/Documents/NWB/hdmf/src/hdmf/utils.py", line 636, in _check_args
raise ExceptionType(msg)
ValueError: TimeSeries.__init__: forbidden value for 'continuity' (got 'wrong', expected ['continuous', 'instantaneous', 'step'])
Traceback
No response
Operating System
macOS
Python Executable
Conda
Python Version
3.11
Package Versions
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
- Have you checked the Contributing document?
- Have you ensured this bug was not already reported?