| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Currently:
```python
buffer = bytearray(b'abc\ndef')
n = buffer.find(b'\n')
data = bytes(buffer[:n + 1])
del buffer[:n + 1]
assert data == b'abc'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
assert data == b'abc'
^^^^^^^^^^^^^^
AssertionError
```
Adding in the `\n` makes the two match:
```python
buffer = bytearray(b'abc\ndef')
n = buffer.find(b'\n')
data = bytes(buffer[:n + 1])
del buffer[:n + 1]
assert data == b'abc\n'
assert buffer == bytearray(b'def')
buffer = bytearray(b'abc\ndef')
n = buffer.find(b'\n')
data = buffer.take_bytes(n + 1)
assert data == b'abc\n'
assert buffer == bytearray(b'def')
```
(cherry picked from commit cc5cf14)
Co-authored-by: Cody Maloney <cmaloney@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Currently:
Adding in the \n makes the two match:
(cherry picked from commit cc5cf14)
Co-authored-by: Cody Maloney cmaloney@users.noreply.github.com