Skip to content

Fix AttributeError when encoding detection returns None#304

Merged
weibullguy merged 8 commits intoPyCQA:masterfrom
holtvogt:fix/encoding-detection
May 11, 2025
Merged

Fix AttributeError when encoding detection returns None#304
weibullguy merged 8 commits intoPyCQA:masterfrom
holtvogt:fix/encoding-detection

Conversation

@holtvogt
Copy link
Copy Markdown
Contributor

Addresses an issue in the do_detect_encoding method where an AttributeError occurs if from_path(filename).best() returns None. The fix ensures that the default encoding (latin-1) is used as a fallback in such cases, and preventing crashes during encoding detection.

Fixes #277

@weibullguy weibullguy merged commit d526a94 into PyCQA:master May 11, 2025
7 checks passed
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.

AttributeError: 'NoneType' object has no attribute 'encoding' (from_path(filename).best().encoding)

2 participants