Skip to content

Fix error code flag when using Python 3 #11

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

Merged
merged 1 commit into from
Dec 11, 2017
Merged

Fix error code flag when using Python 3 #11

merged 1 commit into from
Dec 11, 2017

Conversation

Dunedan
Copy link
Contributor

@Dunedan Dunedan commented Dec 7, 2017

When using Python 3 the error code flag was never set, thanks to the
division changes between Python 2 and Python 3.

The behavior before this commit was:

Python2:

>>> status_code = 403
>>> status_code / 100 == 4
True

Python3:

>>> status_code = 403
>>> status_code / 100 == 4
False

Copy link
Contributor

@haotianw465 haotianw465 left a comment

Choose a reason for hiding this comment

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

Actually if you look at https://github.com/aws/aws-xray-sdk-python/blob/master/aws_xray_sdk/core/models/entity.py#L89 whenever there is a status code set on segment/subsegment, the flags are set accordingly. I think that explains why https://github.com/aws/aws-xray-sdk-python/blob/master/tests/ext/botocore/test_botocore.py#L29 this test can pass on both python2/3. I think the logic on boto_utils.py is leftover code that should be completely removed. The entity class should be the central place to adjust the flags based on status code.

@Dunedan
Copy link
Contributor Author

Dunedan commented Dec 8, 2017

Ah, right. That explains why it wasn't caught earlier. I pushed a new commit to remove the flagging from boto_utils completely.

@haotianw465
Copy link
Contributor

Hi, this looks good to me. Could you merge your two local commits into one so I can merge that single commit to the master?

Error flags are already handled by the Entity class, so they're
redundant here.
@Dunedan
Copy link
Contributor Author

Dunedan commented Dec 11, 2017

Here you go. 😄

@haotianw465 haotianw465 merged commit dc27dc3 into aws:master Dec 11, 2017
@Dunedan Dunedan deleted the error_code_flag_python3 branch December 15, 2017 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants