question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

database as_dbc_string() TypeError using bitstruct.c

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (9 by maintainers)

github_iconTop GitHub Comments

2reactions
eerimoqcommented, Nov 19, 2021

@andlaus I’ll give it a try during the weekend, so no need for you to work on it right now.

2reactions
andlauscommented, Nov 18, 2021
Read more comments on GitHub >

github_iconTop Results From Across the Web

bitstruct - Interpret strings as packed binary data — bitstruct ...
To use bitstruct.c , do import bitstruct.c as bitstruct . ... Bit endianness and byte order are not yet supported. byteswap() can only...
Read more >
bitstruct - PyPI
This module performs conversions between Python values and C bit field structs represented as Python byte strings.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found