Skip to content

Add missing parameters to FakeChunkedResponseBody readline - #189

Open
danigm wants to merge 1 commit into
h2non:masterfrom
danigm:fix-tests-urllib3
Open

danigm wants to merge 1 commit into
h2non:masterfrom
danigm:fix-tests-urllib3

Conversation

@danigm

@danigm danigm commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

After this commit in urllib3, the readline method is called with the size parameter, so the readline method should accept that: urllib3/urllib3@cd770b05

The patch adds *args and **kwargs and ignore them, as we are calling read_chunk with whole=True so I assume that the size in *args can be ignored.

Description

This issue was raised as part of the opensuse python-pook package, tests start to fail after the urllib3 update with the following stack trace:


    def test_chunked_response_list():
>       assert_chunked_response(['a', 'b', 'c'], ['a', 'b', 'c'])

tests/unit/interceptors/urllib3_test.py:24: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
pook/api.py:118: in wrapper
    fn(*args, **kw)
tests/unit/interceptors/urllib3_test.py:18: in assert_chunked_response
    chunks = list(r.read_chunked())
/usr/lib/python3.13/site-packages/urllib3/response.py:1462: in read_chunked
    self._update_chunk_length()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <urllib3.response.HTTPResponse object at 0x7f0120dc4130>

    def _update_chunk_length(self) -> None:
        # First, we'll figure out length of a chunk and then
        # we'll try to read it from socket.
        if self.chunk_left is not None:
            return None
>       line = self._fp.fp.readline(_MAX_CHUNK_LINE_LENGTH + 1)  # type: ignore[union-attr]
E       TypeError: FakeChunkedResponseBody.readline() takes 1 positional argument but 2 were given

/usr/lib/python3.13/site-packages/urllib3/response.py:1376: TypeError

After this commit in urllib3, the readline method is called with the
size parameter, so the readline method should accept that:
urllib3/urllib3@cd770b05

The patch adds *args and **kwargs and ignore them, as we are calling
read_chunk with whole=True so I assume that the size in *args can be
ignored.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant