Skip to content
This repository was archived by the owner on Jun 12, 2024. It is now read-only.

IPv4Network __getitem__ does not return update network ips when IPv4Network.ip is changed #101

@GoogleCodeExporter

Description

@GoogleCodeExporter
To reproduce the problem
>>> from ipaddr import IPv4Network, IPv4Address
>>> n = IPv4Network("192.168.1.134/24")
>>> n[0]
IPv4Address('192.168.1.0')
>>> n.ip = IPv4Address("10.10.1.34")
>>> n.ip
IPv4Address('10.10.1.34')
>>> n[0]
IPv4Address('192.168.1.0')

I would expect that after changing the ip of an IPv4Network instance the 
network would also be updated. This behaviour is "somewhat" true when changing 
the netmask.

As you can see from the example below:
>>> from ipaddr import IPv4Network, IPv4Address
>>> n = IPv4Network("192.168.34.45/24")
>>> n.netmask = IPv4Address("255.255.0.0")
>>> n[0]
IPv4Address('192.168.0.0')

When __getitem__ is used initially it returns the correct result. Any 
subsequent call though produces faulty results

>>> n.netmask = IPv4Address("255.255.255.0")
>>> n[0]
IPv4Address('192.168.0.0')

Platform: Debian wheezy
Version: 2.1.10-1

Original issue reported on code.google.com by [email protected] on 14 Feb 2013 at 3:29

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions