-
Notifications
You must be signed in to change notification settings - Fork 243
Add missing autoreset in Packer.pack_ext_type #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -861,6 +861,10 @@ def pack_ext_type(self, typecode, data): | |
| self._buffer.write(b"\xc9" + struct.pack(">I", L)) | ||
| self._buffer.write(struct.pack("B", typecode)) | ||
| self._buffer.write(data) | ||
| if self._autoreset: | ||
| ret = self._buffer.getvalue() | ||
| self._buffer = BytesIO() | ||
| return ret | ||
|
Comment on lines
+864
to
+867
|
||
|
|
||
| def _pack_array_header(self, n): | ||
| if n <= 0x0F: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a regression test that asserts
Packer().pack_ext_type(...)returns the packed bytes when autoreset is enabled, and that the internal buffer is cleared (e.g., a subsequentpacker.pack(99)should not include the previously packed ext bytes). This would have caught the original bug and will prevent it from reappearing.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot apply changes based on this feedback