Jason R. Coombs <jar...@jaraco.com> added the comment:
The patch for this change has broken code that relied on the old behavior. For example: ``` import fileinput import bz2 import pathlib target = pathlib.Path('data.bz2') target.write_bytes(bz2.compress(b'Foo\nBar\nBiz')) inp = fileinput.FileInput([str(target)], openhook=fileinput.hook_compressed) for line in inp: print(line.decode().strip()) ``` That code passes on Python3.10a6 but on 3.10b1 fails with: ``` Traceback (most recent call last): File "/Users/jaraco/code/main/cmdix/text.py", line 10, in <module> print(line.decode().strip()) AttributeError: 'str' object has no attribute 'decode'. Did you mean: 'encode'? ``` I encountered this issue in [this function and its test](https://github.com/jaraco/cmdix/blob/dc5fac3817ff9815b2f8d9a1dfad4258c14b1693/cmdix/lib.py#L165-L193). I'm struggling with how to adapt the code to provide a uniform interface on Python 3.6+. Perhaps a backport of hook_compressed is in order. ---------- nosy: +jaraco _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue5758> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com