This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: IPv4Networkcontains raises exception on None
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Gerard Weatherby, eric.smith, r.david.murray, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2017-10-30 20:56 by Gerard Weatherby, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
ne.py Gerard Weatherby, 2017-10-30 20:56 SCCE
Pull Requests
URL Status Linked Edit
PR 4180 closed python-dev, 2017-10-30 21:08
Messages (4)
msg305250 - (view) Author: Gerard Weatherby (Gerard Weatherby) * Date: 2017-10-30 20:56
Given a IPvNetwork network
if x in network:
   ...

raises an AttributeError instead of returning False.
msg305251 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-10-30 21:19
It is not obvious that this is a bug.  Why should None be a valid value for 'in network'?
msg305262 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2017-10-31 00:19
I agree with David. And since the PR says "not other", then it makes even less sense, since it's checking for any False-y object.

I recommend closing this as "not a bug".
msg305275 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-10-31 07:07
I concur. IPvNetwork is not a general purposed collection. And even genera purposed collections can have restrictions on the arguments of "in". E.g.:

>>> [] in {}
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: unhashable type: 'list'

Similar issue already was raised (maybe not for IPvNetwork, but for other class supporting the "in" operator) and was closed with the same arguments.
History
Date User Action Args
2022-04-11 14:58:53adminsetgithub: 76086
2017-10-31 07:07:23serhiy.storchakasetresolution: fixed -> not a bug
2017-10-31 07:07:05serhiy.storchakasetstatus: open -> closed

nosy: + serhiy.storchaka
messages: + msg305275

resolution: fixed
stage: patch review -> resolved
2017-10-31 00:19:32eric.smithsetnosy: + eric.smith
messages: + msg305262
2017-10-30 21:19:28r.david.murraysetnosy: + r.david.murray
messages: + msg305251
2017-10-30 21:08:24python-devsetkeywords: + patch
stage: patch review
pull_requests: + pull_request4150
2017-10-30 20:56:08Gerard Weatherbycreate