python / cpython

The Python programming language
https://www.python.org
Other
62.58k stars 30.03k forks source link

Readd __index__ support on ipaddress objects #72953

Open 99ffcaa5-b43b-4e8e-a35e-9c890007b9cd opened 7 years ago

99ffcaa5-b43b-4e8e-a35e-9c890007b9cd commented 7 years ago
BPO 28767
Nosy @ncoghlan, @benjaminp, @serhiy-storchaka, @MojoVampire

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = None created_at = labels = ['3.7'] title = 'Readd __index__ support on ipaddress objects' updated_at = user = 'https://github.com/MojoVampire' ``` bugs.python.org fields: ```python activity = actor = 'josh.r' assignee = 'none' closed = False closed_date = None closer = None components = [] creation = creator = 'josh.r' dependencies = [] files = [] hgrepos = [] issue_num = 28767 keywords = [] message_count = 3.0 messages = ['281384', '281385', '289959'] nosy_count = 4.0 nosy_names = ['ncoghlan', 'benjamin.peterson', 'serhiy.storchaka', 'josh.r'] pr_nums = [] priority = 'normal' resolution = None stage = None status = 'open' superseder = None type = None url = 'https://bugs.python.org/issue28767' versions = ['Python 3.4', 'Python 3.5', 'Python 3.6', 'Python 3.7'] ```

99ffcaa5-b43b-4e8e-a35e-9c890007b9cd commented 7 years ago

It looks like, due to bpo-16722, in bpo-15559, __index__ was removed from ipaddress objects. bpo-16722 was fixed a few months later, but the comments asking for it to be readded were put on a closed issue, so no one noticed.

Can __index__ support be readded now? Should be as simple as undoing https://hg.python.org/cpython/rev/5abea8a43f19 (probably manually, assuming the subsequent history would make a direct rollback nonfeasible).

Nosying the folks involved in fixing the original bugs.

serhiy-storchaka commented 7 years ago

Why __index__ support is needed?

99ffcaa5-b43b-4e8e-a35e-9c890007b9cd commented 7 years ago

From the original bugs, it looks like people liked being able to directly produce the hex of the IP addresses using hex(). I'll admit I'm only +0.5 on restoring __index__; having them be equivalent to int, not just convertable, doesn't seem critical. I just noticed the original bugs (don't even remember why I found them) and figured the functionality should be restored, per the comments on those bugs.