Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fix fallback match being created when lazystr failed decoding #154

Merged
merged 5 commits into from Dec 23, 2021

Conversation

Ousret
Copy link
Owner

@Ousret Ousret commented Dec 23, 2021

Close #153
Thanks to the detailed report in #153 I am able to fix a rare edge case.

@Ousret Ousret added bug Something isn't working detection Related to the charset detection mechanism, chaos/mess/coherence labels Dec 23, 2021
@codecov-commenter
Copy link

codecov-commenter commented Dec 23, 2021

Codecov Report

Merging #154 (4334a8a) into master (12a10a6) will decrease coverage by 0.06%.
The diff coverage is 90.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #154      +/-   ##
==========================================
- Coverage   89.51%   89.44%   -0.07%     
==========================================
  Files          11       11              
  Lines        1192     1194       +2     
==========================================
+ Hits         1067     1068       +1     
- Misses        125      126       +1     
Impacted Files Coverage Δ
charset_normalizer/api.py 87.15% <90.00%> (-0.35%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 12a10a6...4334a8a. Read the comment docs.

@Ousret Ousret merged commit 0fe3d54 into master Dec 23, 2021
@Ousret Ousret deleted the bugfix-fallback-unchecked branch December 23, 2021 07:34
@JensTimmerman
Copy link

any Idea when this fix will be released? I think I am also hitting this issue.

Traceback (most recent call last):
  File "normalize.py", line 72, in <module>
    normalizefiles(filelist)
  File "normalize.py", line 46, in normalizefiles
    origlines = set(str(from_path(orig).best()).split('\n'))
  File "/usr/local/lib/python3.6/site-packages/charset_normalizer/api.py", line 518, in from_path
    explain,
  File "/usr/local/lib/python3.6/site-packages/charset_normalizer/api.py", line 491, in from_fp
    explain,
  File "/usr/local/lib/python3.6/site-packages/charset_normalizer/api.py", line 452, in from_bytes
    and fallback_u8.fingerprint != fallback_ascii.fingerprint
  File "/usr/local/lib/python3.6/site-packages/charset_normalizer/models.py", line 274, in fingerprint
    return sha256(self.output()).hexdigest()
  File "/usr/local/lib/python3.6/site-packages/charset_normalizer/models.py", line 265, in output
    self._output_payload = str(self).encode(encoding, "replace")
  File "/usr/local/lib/python3.6/site-packages/charset_normalizer/models.py", line 114, in __str__
    self._string = str(self._payload, self._encoding, "strict")
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd1 in position 6185428: ordinal not in range(128)

@Ousret Ousret mentioned this pull request Jan 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working detection Related to the charset detection mechanism, chaos/mess/coherence
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] UnicodeDecodeError: 'ascii' codec can't decode when using detect
3 participants