Skip to content

Commit 6d3a89f

Browse files
committed
Add Python 3.9-3.10 compatibility for PEP 678 exception notes
Add hasattr(e, 'add_note') checks before calling add_note() to ensure compatibility with Python 3.9 and 3.10 where PEP 678 exception notes are not available. The enhanced HTTP status context will only be added in Python 3.11+ while maintaining backward compatibility.
1 parent 94499f7 commit 6d3a89f

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

botocore/parsers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def _do_error_parse(self, response, shape):
598598
status_message = http.client.responses.get(
599599
response['status_code'], ''
600600
)
601-
if status_message:
601+
if status_message and hasattr(e, 'add_note'):
602602
e.add_note(f"HTTP {response['status_code']}: {status_message}")
603603
raise
604604
parsed = self._build_name_to_xml_node(root)
@@ -1461,7 +1461,7 @@ def _parse_error_from_body(self, response):
14611461
status_message = http.client.responses.get(
14621462
response['status_code'], ''
14631463
)
1464-
if status_message:
1464+
if status_message and hasattr(e, 'add_note'):
14651465
e.add_note(f"HTTP {response['status_code']}: {status_message}")
14661466
raise
14671467
parsed = self._build_name_to_xml_node(root)

0 commit comments

Comments
 (0)