Skip to content

Commit

Permalink
Merge pull request kurtmckee#469 from maksverver/develop
Browse files Browse the repository at this point in the history
Fix a bug in PrefixFileWrapper
  • Loading branch information
kurtmckee authored Aug 28, 2024
2 parents e571a12 + d27a9d9 commit 11990ea
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion feedparser/encodings.py
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,7 @@ def read(self, size=-1):

if self.offset < len(self.prefix):
if size < 0:
chunk = self.prefix
chunk = self.prefix[self.offset :]
else:
chunk = self.prefix[self.offset : self.offset + size]
size -= len(chunk)
Expand Down
4 changes: 4 additions & 0 deletions tests/test_encoding_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ def test_prefix_file_wrapper(factory):
assert f.read(0) == b""
assert f.read() == b"abcdef"

f = feedparser.encodings.PrefixFileWrapper(b"abc", factory(b"def"))
assert f.read(2) == b"ab"
assert f.read() == b"cdef"


# Each emoji is 4 bytes long when encoded in UTF-8.
@pytest.mark.parametrize("data", ("😀😛🤯😱", "😀a😛b🤯c😱"))
Expand Down

0 comments on commit 11990ea

Please sign in to comment.