Skip to content

fix: handle mappers without __name__ in extract_etree error path#253

Open
Flerpharos wants to merge 1 commit into
mainfrom
fix/213-extract-etree-mapper-name
Open

fix: handle mappers without __name__ in extract_etree error path#253
Flerpharos wants to merge 1 commit into
mainfrom
fix/213-extract-etree-mapper-name

Conversation

@Flerpharos

Copy link
Copy Markdown
Collaborator

Summary

extract_etree accepts any Callable mapper, but its ValueError handler formats mapper.__name__. Valid callables such as functools.partial and callable class instances do not necessarily have __name__, so the error path raises AttributeError and masks the original parse failure instead of raising ExtractionError.

Fix

Use getattr(mapper, "__name__", repr(mapper)) so that it falls back to repr() if the __name__ attribute does not exist.

Closes #213

extract_etree accepts any Callable mapper, but its ValueError handler
formats mapper.__name__. Valid callables such as functools.partial and
callable class instances do not necessarily have __name__, so the error
path raises AttributeError and masks the original parse failure instead
of raising ExtractionError.

Fix by using getattr with a repr fallback.

Closes #213
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.

extract_etree error path crashes for mappers without __name__

1 participant