This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author jaraco
Recipients amaury.forgeotdarc, eric.araujo, jaraco, methane, mnewman, r.david.murray, tati_alchueyr
Date 2021-05-25.02:32:43
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1621909964.23.0.0406319425118.issue5758@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2021-05-25 02:32:44jaracosetrecipients: + jaraco, amaury.forgeotdarc, eric.araujo, r.david.murray, mnewman, methane, tati_alchueyr
2021-05-25 02:32:44jaracosetmessageid: <1621909964.23.0.0406319425118.issue5758@roundup.psfhosted.org>
2021-05-25 02:32:44jaracolinkissue5758 messages
2021-05-25 02:32:43jaracocreate