cantools: database as_dbc_string() TypeError using bitstruct.c
Python Version: 3.8.5 Cantools Version 34.2.0+ OS: Windows 10 (1909)
This works fine in cantools version 34.1.0. From the commits it appears there was a change from using bistruct to using bitstruct.c. Reverting this change in 34.2.0 does fix the issue.
Further analysis shows bitstruct was at version 8.10.0, updating to 8.11.1 can also resolve the issue.
I am no expert but I think this means that the setup.py needs to have the required bitstruct version upped?
Test code
import cantools
dbc = cantools.database.load_file("vehicle.dbc",strict=False)
cantools.database.dump_file(dbc,"vehicle2.dbc")
Error Messages
File "c:\anaconda3\envs\py38-logger-tool\lib\site-packages\cantools\database\__init__.py", line 216, in dump_file
output = database.as_dbc_string()
File "c:\anaconda3\envs\py38-logger-tool\lib\site-packages\cantools\database\can\database.py", line 279, in as_dbc_string
return dbc.dump_string(InternalDatabase(self._messages,
File "c:\anaconda3\envs\py38-logger-tool\lib\site-packages\cantools\database\can\formats\dbc.py", line 1524, in dump_string
database = deepcopy(database)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 270, in _reconstruct
state = deepcopy(state, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 205, in _deepcopy_list
append(deepcopy(a, memo))
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 270, in _reconstruct
state = deepcopy(state, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 146, in deepcopy
y = copier(x, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 230, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 172, in deepcopy
y = _reconstruct(x, memo, *rv)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 264, in _reconstruct
y = func(*args)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 263, in <genexpr>
args = (deepcopy(arg, memo) for arg in args)
File "c:\anaconda3\envs\py38-logger-tool\lib\copy.py", line 161, in deepcopy
rv = reductor(4)
TypeError: cannot pickle 'bitstruct.c.CompiledFormatDict' object
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (9 by maintainers)
@andlaus I’ll give it a try during the weekend, so no need for you to work on it right now.
done: https://github.com/eerimoq/bitstruct/issues/24
bitstruct did not update when doing pip cantools uninstall/install. Will make another release to add require bitstruct >= 8.12.1. Done.