Repository navigation
bpo-34788: Add support for scoped IPv6 addresses #13772
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
Changes from 1 commit
Commits
Show all changes
61 commits
Select commit
Hold shift + click to select a range
eb4a407
bpo-34788 Add tests for ipv6 scope_id support
8a5c94f
bpo-34788 Add support for scoped IPv6 addresses
a841e9a
bpo-34788 Add documentation for scope id support
9a3f7ec
bpo-34788 Refactor address split and validation
a17538a
bpo-34788 Convert scope_id to property
6da269e
bpo-34788 Update documentation
35750de
bpo-34788 Remove redundant check
681cfa5
bpo-34788 Fix newline
fb99b6b
bpo-34788 Documentation fix
d8bb674
📜🤖 Added by blurb_it.
blurb-it[bot] ccd83ed
bpo-34788 Update NEWS
opavlyuk dc540e9
bpo-34788 Fix NEWS filename
opavlyuk c03d4a5
bpo-34788 Add sample IPv6 to ignore list
c12e533
bpo-34788 Add sample IPv6 to ignore list
033f031
bpo-34788 Update Misc/NEWS.d
opavlyuk 27c5cf4
bpo-34788 Refactor condition
opavlyuk 3b495c0
bpo-34788 Fix excessive property call
opavlyuk 1de1ae6
Merge branch 'master' into fix-issue-34788
opavlyuk b0a4fe9
bpo-34788 Mention RFC 4007 in the docstring
opavlyuk ac19fad
bpo-34788 Remove unnecessary comma
opavlyuk 25d3ac7
bpo-34788 Add scope_id check
opavlyuk 66db707
bpo-34788 Add tests for invalid scope id
opavlyuk 064e019
bpo-34788 Improve scoped IPv6 samples
ef91d9c
bpo-34788 Remove trailing whitespaces
d0eb91b
bpo-34788 Improve scope_id documentation
0735d3f
bpo-34788 Fix susp-ignored
fb47e34
bpo-34788 Improve IPv6Address documentation
b8dffe5
bpo-34788 Move self._scope_id initialization under if statements
fc2425f
bpo-34788 Remove newline
f9d38c0
bpo-34788 Improve documentation
d8972af
bpo-34788 Consider scope id while comparing IPv6 addresses
0b37c30
bpo-34788 Update susp-ignored.csv
41ce543
bpo-34788 Update documentation
7f3fae8
bpo-34788 Update susp-ignored
6c5a845
bpo-34788 Update susp-ignored
e569cd5
bpo-34788 Update susp-ignored
3982d78
bpo-34788 Update susp-ignored
6b5198f
bpo-34788 Update susp-ignored
97a7707
bpo-34788 Update tests according to new comparison policy
6339732
bpo-34788 Update documentation
eff04f6
bpo-34788 Add 3.9 whatsnew record
06e66e9
Merge branch 'master' into fix-issue-34788
opavlyuk c25a327
bpo-34788 Improve __hash__()
84f4b3d
Merge branch 'fix-issue-34788' of github.com:opavlyuk/cpython into fi…
c6695bf
bpo-34788 Update whatsnew
d30ea41
Update Doc/whatsnew/3.9.rst
opavlyuk e971130
Update Doc/whatsnew/3.9.rst
opavlyuk 22c310e
Update Doc/whatsnew/3.9.rst
opavlyuk 5882d06
bpo-34788 Split conditional statement
opavlyuk 2c6fd54
bpo-34788 Fix eq
0ec1572
bpo-34788 Unify docstring styles
5530a79
bpo-34788 Remove unnecessary arg
2f7de77
bpo-34788 Improve comparison
ef42a2d
bpo-34788 Fix typo
641bc6b
bpo-34788 Unify scope id naming
34728d2
bpo-34788 Unify naming
af90771
Update Doc/whatsnew/3.9.rst
opavlyuk e041c2e
Merge branch 'master' into fix-issue-34788
opavlyuk 0e250bf
Merge remote-tracking branch 'origin/master' into fix-issue-34788
2c4d3d5
Cleanup Whatsnew
opavlyuk 555f59f
Fix typo
opavlyuk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
bpo-34788 Fix eq
- Loading branch information
There are no files selected for viewing
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
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.
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.
What do we want to do in the scenario that the other object doesn't have a
_scope_idattribute? AnAttributeErrorwould not be particularly clear from a user perspective when comparing the equality of two different IPv6 address objects.Returning False seems to make the most sense to me, but only in the scenario that self actually has a
_scope_idthat isn't None (since we already established that the addresses are equal at this point).Uh oh!
There was an error while loading. Please reload this page.
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.
As I see it,
IPv6Addressobject shall always have a_scope_idattribute. In case it is created from IPv6 address without scope id, the attribute would be set toNone.Case with absent
_scope_idattribute could appear only if someone removes it explicitly.May be, it would be ok to use public property
scope_idin__eq__method, and addtryblock to it?Uh oh!
There was an error while loading. Please reload this page.
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.
@opavlyuk
If the object was instantiated from the version of the
IPv6Addressclass in this PR (where_scope_idwas just added), then yes. But if it's an object instantiated from an older version of the class or some other custom implementation, then_scope_idmight not be present.IMO, it seems worthwhile to provide some basic amount of compatibility with objects that don't have a
_scope_idattribute, considering it is just being added now.The above would only cover the situations in which the
selfobject doesn't have a_scope_id, no? My concern is with theotherobject, asselfis much more likely to have a_scope_idattribute in the first place. The above situation I was referring to was whenotheris an object that wasn't instantiated from this version ofIPv6Addressor is using some other implementation.Also, in this case, I find the EAFP (
try-except) approach in my above suggestion to be more explicit than LBYL (ifhasattr()orgetattr()with default). Mostly because the situation in which the other object does not have a_scope_idis an exception and not just a general conditional to check for.A
try-exceptis generally better performance wise (when in the vast majority of cases, the exception does not occur) in comparison to usinggetattr()with a default every single time the property is accessed orif hasattr()every time__eq__()is used.What do you think @asvetlov?
Uh oh!
There was an error while loading. Please reload this page.
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.
@aeros , now I understood, and it makes sense.
At the same time, following seems more clean for me:
So, we consider, if other object has no
_scope_idattribute, then it is the same as it isNone.Having measured the execution time on Python 3.7.4 on my GNU\Linux machine, I saw that option with
getattrseems to be slightly faster in case when attribute exists and 5x faster in case with non-existent attribute.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.
I like the last version
Uh oh!
There was an error while loading. Please reload this page.
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.
I have no objections to the last version either,
self.scope_id == getattr(other, _'scope_id', None)should work fine. My main issue with the first one was usingreturn getattr(self, '_scope_id', None)as the getter for_scope_id, but that's not an issue in the most recent version.Edit: I still think the EAFP approach might be a bit more idiomatic in this case. However, if it's a significant performance difference,
getattrwith a default should be okay.Uh oh!
There was an error while loading. Please reload this page.
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.
I'm curious as to how this would perform in comparison to the above two, I might test it out later when I get the chance:
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.
@aeros I've pushed my version, but lets make the final decision after your benchmark.
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.
@opavlyuk
Sounds good to me. I should have time to evaluate it later, I've been a bit occupied recently with studying for finals and working on other projects this last week.
If it gets to the point where everything else is finished and this is the last remaining step, feel free to move ahead with the PR. At the end of the day, I think either version would be acceptable.