-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: Attempting to serialize bytes type causes error (5660) #5682
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
Changes from 1 commit
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 |
|---|---|---|
|
|
@@ -273,7 +273,7 @@ def pascal_to_snake(pascal_str): | |
|
|
||
|
|
||
| def is_not_primitive(obj): | ||
| return not isinstance(obj, (int, float, str, bool, datetime.datetime)) | ||
| return not isinstance(obj, (int, float, str, bool, bytes, datetime.datetime)) | ||
|
|
||
|
|
||
| def is_not_str_dict(obj): | ||
|
|
@@ -285,7 +285,7 @@ def is_primitive_list(obj): | |
|
|
||
|
|
||
| def is_primitive_class(cls): | ||
| return cls in (str, int, bool, float, datetime.datetime) | ||
| return cls in (str, int, bool, float, bytes, datetime.datetime) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Same incorrect indentation issue here. The return cls in (str, int, bool, float, bytes, datetime.datetime) |
||
|
|
||
|
|
||
| class Unassigned: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -373,6 +373,30 @@ def test_serialize_method_nested_shape(): | |
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: There's an extra blank line here (two blank lines between the previous test and this one, resulting in three blank lines total between top-level definitions). PEP 8 specifies two blank lines between top-level definitions. Minor, but CI linting may flag it. |
||
|
|
||
|
|
||
| def test_serialize_with_bytes_value_returns_bytes(): | ||
| result = serialize(b'1') | ||
| assert result == b'1' | ||
|
|
||
|
|
||
| def test_serialize_dict_with_bytes_value_returns_dict_with_bytes(): | ||
| result = serialize({'body': b'1'}) | ||
| assert result == {'body': b'1'} | ||
|
|
||
|
|
||
| def test_is_not_primitive_with_bytes_returns_false(): | ||
| assert is_not_primitive(b'hello') is False | ||
|
|
||
|
|
||
| def test_is_primitive_class_with_bytes_returns_true(): | ||
| assert is_primitive_class(bytes) is True | ||
|
|
||
|
|
||
| def test_serialize_list_with_bytes_elements(): | ||
| result = serialize([b'a', b'b']) | ||
| assert result == [b'a', b'b'] | ||
|
|
||
|
|
||
| class TestUnassignedBehavior: | ||
| """Test Unassigned class methods for proper behavior. | ||
|
|
||
|
|
||
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.
Bug: Incorrect indentation introduced. The
returnstatement now has 8 spaces of indentation (two levels) instead of the original 4 spaces (one level). This will cause anIndentationErrorat runtime since the function body was previously at 4-space indentation. Please fix: