Skip to content

eds: Fix exception in comment parsing with hexadecimal line count.#279

Merged
af-silva merged 1 commit intocanopen-python:masterfrom
acolomb:fix-eds-linecount-crash
Nov 10, 2021
Merged

eds: Fix exception in comment parsing with hexadecimal line count.#279
af-silva merged 1 commit intocanopen-python:masterfrom
acolomb:fix-eds-linecount-crash

Conversation

@acolomb
Copy link
Copy Markdown
Member

@acolomb acolomb commented Nov 9, 2021

This fixes a bug introduced in #254, which immediately broke parsing of my EDS files.

Inside an EDS file's [Comments] section, the Lines attribute may be expressed as a hexadecimal number prefixed with 0x. The ConfigParser.getint() method however does not support such a format.

Switch to the default int() constructor with a base=0 argument to enable auto-detection of this condition. The same is done for basically every other numeric value in the EDS importer.

Inside an EDS file's [Comments] section, the Lines attribute may be
expressed as a hexadecimal number prefixed with 0x.  The
ConfigParser.getint() method however does not support such a format.

Switch to the default int() constructor with a base=0 argument to
enable auto-detection of this condition.  The same is done for
basically every other numeric value in the EDS importer.
@acolomb
Copy link
Copy Markdown
Member Author

acolomb commented Nov 9, 2021

Please have a look @unsanded.

@unsanded
Copy link
Copy Markdown
Contributor

unsanded commented Nov 9, 2021

Oh good one. I think i missed that one. I started to use getInt everywhere, but i found out that int(...,0) is the right way.

@af-silva af-silva merged commit 99bb97b into canopen-python:master Nov 10, 2021
@acolomb acolomb deleted the fix-eds-linecount-crash branch November 10, 2021 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants