Skip to content
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

modify serialization to check for text plan content type #2649

Merged
merged 8 commits into from
Jun 21, 2024
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

fix deserialization from vendored msrest code for text plain responses
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class RawDeserializer:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree with Laurent that we had better keep consistent with azure-core

return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def deserialize_from_text(cls, data: Optional[Union[AnyStr, IO]], content_type:
# Remove Byte Order Mark if present in string
data_as_str = data_as_str.lstrip(_BOM)

if content_type is None:
if content_type is None or content_type == "text/plain":
return data

if cls.JSON_REGEXP.match(content_type):
Expand Down
Loading
Loading