Only import future for py2#343
Merged
srprash merged 1 commit intoaws:masterfrom Jun 24, 2022
Merged
Conversation
2db7bbf to
c45c8e6
Compare
srprash
reviewed
Jun 23, 2022
Comment on lines
+3
to
+7
| try: | ||
| from future.standard_library import install_aliases | ||
| install_aliases() | ||
| except ImportError: | ||
| pass |
Contributor
There was a problem hiding this comment.
Instead of using try-except, can we reuse the PY2 variable from compat.py?
Then this could be something like:
from aws_xray_sdk.core.utils.compat import PY2
if PY2:
from future.standard_library import install_aliases
install_aliases()
Contributor
Author
There was a problem hiding this comment.
Oh interesting! I took this path because StackOverflow says it was the status quo and I saw it used in OpenTelemetry Python Contrib, but this PY2 looks super useful so I'll change it to that :)
Contributor
There was a problem hiding this comment.
I see. That's good to know. :)
Since we already have the other mechanism, I think it would be better to just reuse for the sake of consistency.
c45c8e6 to
245c9c6
Compare
srprash
approved these changes
Jun 24, 2022
This was referenced Jun 24, 2022
michael-k
added a commit
to michael-k/aws-xray-sdk-python
that referenced
this pull request
Nov 4, 2022
An environment marker is already used for `enum34` so why do it differently for `future`? https://peps.python.org/pep-0508/#environment-markers ref aws#343
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Issue #, if available: #212
Description of changes:
If we only import
futurewhen the SDK is run on Python 2, then we don't need to import it forPython 3systems. This will prevent conflicts with people downloading conflicting versions of thefuturepackage.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Fixes: #212