Skip to content

Issue in binascii.{a2b,b2a}_qp functions with newlines characters #127696

@picnixz

Description

@picnixz

Bug report

Bug description:

This was detected here: https://github.com/python/cpython/actions/runs/12200589926/job/34037087571#step:22:214

>>> import binascii
>>> x = b'\n\r\n'
>>> y = binascii.b2a_qp(x, quotetabs=False, istext=True, header=False)
>>> z = binascii.a2b_qp(y, header=False)
>>> x
b'\n\r\n'
>>> y
'\n\n'
>>> z
b'\n\n'

I think the issue should only concern new lines characters like that but I honestly don't know whether this is the expected result or not. Note that the docs say:

If the optional argument header is present and false, newline characters will be encoded as well; otherwise linefeed conversion might corrupt the binary data stream.

So it appears that '\r\n' is not correctly encoded as such. I'll investigate.

CPython versions tested on:

CPython main branch

Operating systems tested on:

No response

Related

Metadata

Metadata

Assignees

Labels

extension-modulesC modules in the Modules dirtype-bugAn unexpected behavior, bug, or error

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions