Skip to content

Please support chardet 6.0.0 #14

Closed

Description

@musicinmybrain

The chardet package has just released version 6.0.0, a major update with a new “encoding era” concept and a number of other significant changes.

If the upper bound from

is ignored, this leads to a regression in the tests:

$ git clone https://github.com/thombashi/mbstrdecoder.git
$ cd mbstrdecoder
$ uv venv
$ . .venv/bin/activate
(mbstrdecoder) $ uv pip install -e .[test]
(mbstrdecoder) $ pytest -v
[…]
==================================================================================== 281 passed in 0.18s ====================================================================================
|            filepath             | passed | SUBTOTAL |
| ------------------------------- | -----: | -------: |
| test/test_binary_ext_checker.py |    252 |      252 |
| test/test_func.py               |      9 |        9 |
| test/test_mbstrdecoder.py       |     20 |       20 |
| TOTAL                           |    281 |      281 |
(mbstrdecoder) $ uv pip install --upgrade chardet
[…]
 - chardet==5.2.0
 + chardet==6.0.0
(mbstrdecoder) $ pytest -v
[…]
========================================================================================= FAILURES ==========================================================================================
______________________________ Test_to_MultiByteStrDecoder_unicode.test_normal_codec_candidate[Bob\u2019s Burgers-windows-1252-windows_1252-codec_candidates4] ______________________________

self = <test_mbstrdecoder.Test_to_MultiByteStrDecoder_unicode object at 0x7fbd39286120>, value = 'Bob’s Burgers', encode = 'windows-1252', expected = 'windows_1252', codec_candidates = []

    @pytest.mark.parametrize(
        ["value", "encode", "expected", "codec_candidates"],
        [
            ["abcdefgh", "ascii", "ascii", ["utf_32_le", "utf_32"]],
            ["吾輩は猫である", "utf8", "utf_8", ["utf_32_le", "ascii"]],
            ["吾輩は猫である", "utf8", "utf_8", None],
            ["吾輩は猫である", "utf8", "utf_8", []],
            ["Bob’s Burgers", "windows-1252", "windows_1252", []],
        ],
    )
    def test_normal_codec_candidate(self, value, encode, expected, codec_candidates):
        decoder = MultiByteStrDecoder(value.encode(encode), codec_candidates)
>       assert decoder.codec == expected
E       AssertionError: assert 'big5hkscs' == 'windows_1252'
E         
E         - windows_1252
E         + big5hkscs

test/test_mbstrdecoder.py:58: AssertionError
================================================================================== short test summary info ==================================================================================
FAILED test/test_mbstrdecoder.py::Test_to_MultiByteStrDecoder_unicode::test_normal_codec_candidate[Bob\u2019s Burgers-windows-1252-windows_1252-codec_candidates4] - AssertionError: assert 'big5hkscs' == 'windows_1252'
=============================================================================== 1 failed, 280 passed in 0.20s ===============================================================================
|            filepath             | passed | failed | SUBTOTAL |
| ------------------------------- | -----: | -----: | -------: |
| test/test_binary_ext_checker.py |    252 |      0 |      252 |
| test/test_func.py               |      9 |      0 |        9 |
| test/test_mbstrdecoder.py       |     19 |      1 |       20 |
| TOTAL                           |    280 |      1 |      281 |

I’m happy to offer a PR, but I’m not sure exactly what the right approach is here.

(I am preparing to update the python-chardet package in Fedora to version 6.0.0, which will impact Fedora’s python-mbstrdecoder package. I’m trying to coordinate this change appropriately and mitigate any regressions ahead of time.)

Activity

  1. thombashi commented on May 5, 2026

    @thombashi
    Owner

    @musicinmybrain
    Thank you for your report.
    mbstrdecoder v1.1.5 now supports chardet 6.
    The failing test was flaky, so I removed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions