summaryrefslogtreecommitdiffstats
path: root/Lib/ipaddress.py
Commit message (Collapse)AuthorAgeFilesLines
* [3.8] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges ↵Petr Viktorin2024-05-071-17/+78
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (GH-113179) (GH-113186) (GH-118177) (GH-118479) The _private_networks variables, used by various is_private implementations, were missing some ranges and at the same time had overly strict ranges (where there are more specific ranges considered globally reachable by the IANA registries). This patch updates the ranges with what was missing or otherwise incorrect. 100.64.0.0/10 is left alone, for now, as it's been made special in [1]. The _address_exclude_many() call returns 8 networks for IPv4, 121 networks for IPv6. [1] https://github.com/python/cpython/issues/61602 In 3.10 and below, is_private checks whether the network and broadcast address are both private. In later versions (where the test wss backported from), it checks whether they both are in the same private network. For 0.0.0.0/0, both 0.0.0.0 and 255.225.255.255 are private, but one is in 0.0.0.0/8 ("This network") and the other in 255.255.255.255/32 ("Limited broadcast"). --------- Co-authored-by: Jakub Stasiak <jakub@stasiak.at>
* [3.8] bpo-36384: Leading zeros in IPv4 addresses are no longer tolerated ↵achraf-mer2021-08-171-0/+5
| | | | | | | | | | | | (GH-25099) (GH-27801) Reverts commit e653d4d8e820a7a004ad399530af0135b45db27a and makes parsing even more strict. Like socket.inet_pton() any leading zero is now treated as invalid input. Signed-off-by: Christian Heimes <christian@python.org> Co-authored-by: Łukasz Langa <lukasz@langa.pl>
* [3.8] bpo-28577: Special case added to IP v4 and v6 hosts for /32 and /128 ↵Pete Wicken2021-04-261-0/+4
| | | | | | | | networks (GH-18757) (#25536) The `.hosts()` method now returns the single address present in a /32 or /128 network.. (cherry picked from commit 8e9c47a947954c997d4b725f4551d50a1d896722) Co-authored-by: Pete Wicken <2273100+JamoBox@users.noreply.github.com>
* bpo-41482: Fix error in ipaddress.IPv4Network docstring (GH-21736)Miss Islington (bot)2020-08-051-1/+1
| | | | | (cherry picked from commit 52f98424a55e14f05dfa7483cc0faf634a61c9ff) Co-authored-by: Eric L. Frederich <eric.frederich@gmail.com>
* bpo-41004: Resolve hash collisions for IPv4Interface and IPv6Interface ↵Miss Islington (bot)2020-06-291-2/+2
| | | | | | | | | | | (GH-21033) The __hash__() methods of classes IPv4Interface and IPv6Interface had issue of generating constant hash values of 32 and 128 respectively causing hash collisions. The fix uses the hash() function to generate hash values for the objects instead of XOR operation (cherry picked from commit b30ee26e366bf509b7538d79bfec6c6d38d53f28) Co-authored-by: Ravi Teja P <rvteja92@gmail.com>
* bpo-36845: validate integer network prefix when constructing IP networks ↵Nicolai Moore2019-05-141-0/+4
| | | | (GH-13298)
* bpo-25430: improve performance of IPNetwork.__contains__ (GH-1785)gescheit2019-04-301-2/+1
| | | make a compare in bit-operation manner.
* bpo-27860: ipaddress: fix Interface missed some attributes (GH-12836)Inada Naoki2019-04-151-70/+40
| | | | | | | IPv4Interface and IPv6Interface did not has netmask and hostmask attributes when its argument is bytes or int. This commit extracts method for constructors of Network and Interface, and ensure Interface class always provides them.
* bpo-27860: use cached_property (GH-12832)Inada Naoki2019-04-151-26/+7
| | | | * cached_property is more efficient than hand crafted cache. * In IPv[46]Network, `self.network.prefixlen` is same to `self._prefixlen`.
* bpo-35734: ipaddress: remove unused methods (GH-11591)Rémi Lapeyre2019-04-131-55/+0
|
* bpo-36384: Remove check for leading zeroes in IPv4 addresses (GH-12577)Joel Croteau2019-03-301-6/+0
| | | | | | | | | Stop rejecting IPv4 octets with leading zeroes as ambiguously octal. Plenty of other tools generate decimal IPv4 octets with leading zeroes, so keeping this check hurts interoperability. Patch by Joel Croteau.
* bpo-27683: Fix a regression for host() of ipaddress network objects (GH-6016)Xiang Zhang2018-03-211-71/+38
| | | | | | The result of host() was not empty when the network is constructed by a tuple containing an integer mask and only 1 bit left for addresses.
* ipaddress: Use str.isascii() instead of frozenset (GH-5811)INADA Naoki2018-02-231-3/+2
|
* bpo-20825: Containment test for ip_network in ip_network.Cheryl Sabella2017-10-221-6/+23
|
* bpo-29931 fix __lt__ check in ipaddress.ip_interface for both v4 and v6. (#879)s-sanjay2017-04-011-2/+4
| | | | | | | | the original logic was just comparing the network address but this is wrong because if the network address is equal then we need to compare the ip address for breaking the tie add more ip_interface comparison tests
* Issue #20508: Improve exception message of IPv{4,6}Network.__getitem__Berker Peksag2016-06-111-2/+2
| | | | Patch by Gareth Rees.
* Issue #21386: Implement missing IPv4Address.is_global propertyBerker Peksag2016-06-111-0/+7
| | | | | | It was documented since 07a5610bae9d. Initial patch by Roger Luethi.
* Issue #26457: Fixed the subnets() methods in IP network classes for the caseSerhiy Storchaka2016-03-011-9/+9
| | | | | when resulting prefix length is equal to maximal prefix length. Based on patch by Xiang Zhang.
* Issue #16261: Converted some bare except statements to except statementsSerhiy Storchaka2015-05-201-2/+2
| | | | with specified exception type. Original patch by Ramchandra Apte.
* Issue #23103: Reduced the memory consumption of IPv4Address and IPv6Address.Serhiy Storchaka2015-03-071-13/+12
|
* Issue #23268: Fixed bugs in the comparison of ipaddress classes.Serhiy Storchaka2015-01-261-40/+7
|\
| * Issue #23268: Fixed bugs in the comparison of ipaddress classes.Serhiy Storchaka2015-01-261-40/+7
| |
* | Issue #23266: Restore the performance of ipaddress.collapse_addresses() whithSerhiy Storchaka2015-01-181-20/+16
| | | | | | | | duplicated addresses and simplify the code.
* | Issue #23133: Pickling of ipaddress objects now produces more compact andSerhiy Storchaka2015-01-181-7/+14
| | | | | | | | portable representation.
* | Issue #23266: Much faster implementation of ipaddress.collapse_addresses() ↵Antoine Pitrou2015-01-181-6/+10
| | | | | | | | when there are many non-consecutive addresses.
* | PEP 479: Use the return-keyword instead of raising StopIteration inside a ↵Raymond Hettinger2014-11-231-1/+1
| | | | | | | | generators.
* | Issue #22823: Use set literals instead of creating a set from a listRaymond Hettinger2014-11-091-1/+1
| |
* | Issue #22186: Fix typos in Lib/.Berker Peksag2014-10-191-1/+1
|\ \ | |/ | | | | Patch by Févry Thibault.
| * Issue #22186: Fix typos in Lib/.Berker Peksag2014-10-191-1/+1
| | | | | | | | Patch by Févry Thibault.
* | Refactor precomputed constants in the ipaddress module (suggested by ↵Antoine Pitrou2014-05-231-58/+67
| | | | | | | | Charles-François)
* | Issue #21513: Speedup some properties of IP addresses (IPv4Address, ↵Antoine Pitrou2014-05-231-51/+69
| | | | | | | | IPv6Address) such as .is_private or .is_multicast.
* | Issue #20826: Optimize ipaddress.collapse_addresses().Antoine Pitrou2014-05-151-27/+26
| |
* | Issue #21487: Optimize ipaddress.summarize_address_range() and ↵Antoine Pitrou2014-05-151-21/+7
| | | | | | | | ipaddress.{IPv4Network,IPv6Network}.subnets().
* | Issue #21486: Optimize parsing of netmasks in ipaddress.IPv4Network and ↵Antoine Pitrou2014-05-151-79/+119
| | | | | | | | ipaddress.IPv6Network.
* | Issue #16531: ipaddress.IPv4Network and ipaddress.IPv6Network now accept an ↵Antoine Pitrou2014-05-121-21/+74
| | | | | | | | (address, netmask) tuple argument, so as to easily construct network objects from existing addresses.
* | Issue #20480: Add ipaddress.reverse_pointer. Patch by Leon Weber.Eric V. Smith2014-04-141-0/+29
|/
* Issue #19157: Include the broadcast address in the usuable hosts for IPv6Peter Moody2014-03-111-0/+12
| | | | in ipaddress.
* Merge fix for #18805 from 3.3Nick Coghlan2014-02-081-65/+83
|\
| * Issue #18805: better netmask validation in ipaddressNick Coghlan2014-02-081-65/+83
| |
* | #17400: correct handling of 100.64.0.0/10, fixing the docs and updating NEWSPeter Moody2013-10-241-12/+15
| |
* | #17400: fix documentation, add cache to is_global and correctly handle ↵Peter Moody2013-10-221-3/+5
| | | | | | | | 100.64.0.0/10
* | #17400; ipaddress should make it easy to identify rfc6598 addressesPeter Moody2013-10-211-11/+65
|/
* #18705: fix a number of typos. Patch by Févry Thibault.Ezio Melotti2013-08-171-2/+2
|
* Fix a few typos and a double semicolon. Patch by Eitan Adler.Ezio Melotti2013-01-271-1/+1
|
* Issue #15888: fixing problems in ipaddress doctests. Patch by Chris JerdonekEli Bendersky2012-10-071-3/+4
|
* Close #14814: Avoid depending on struct by using newer features. Also use ↵Nick Coghlan2012-08-201-8/+6
| | | | enumerate where appropriate (patch by Serhiy Storchaka). Declaring PEP 3144 final at this point - any further changes to code or docs can go in new issues.
* Issue #14814: document the Interface APIs and fix various problems with the ↵Nick Coghlan2012-08-201-3/+6
| | | | string representations (initial patch by Eli Bendersky).
* Issue #14814: Remove redundant property from interface objects - prefixlen ↵Nick Coghlan2012-08-051-9/+1
| | | | can be accessed via the associated network object
* Issue 14814: Docs work showed some more cases of networks pretending to be ↵Nick Coghlan2012-08-051-180/+224
| | | | addresses and highlighted the weird approach to implementing the 'is_whatever' properties. Impl now illustrates far more clearly that networks have a property if both their network and broadcast addresses have that property
* Close #15559: Implementing __index__ creates a nasty interaction with the ↵Nick Coghlan2012-08-051-6/+0
| | | | bytes constructor. At least for 3.3, ipaddress objects must now be explicitly converted with int() and thus can't be passed directly to the hex() builtin.