rlisagor/pynetlinux — pull request #1 by ccontavalli (2013-11-01 01:01:48+00:00)
Title: Fix set_netmask() handling of negative numbers.

If the netmask happens to have the first bit set to 1, which is fairly common
(think 255.255.255.0), struct.pack(...i...) will fail, as 'i' takes signed 32
bit integers, and will refuse to take any integer >= 2^31.

The end result is that set_netmask() doesn't work for most netmasks :/

Example:
>>> struct.pack("i", 2**31)
Traceback (most recent call last):
File "", line 1, in
struct.error: 'i' format requires -2147483648 <= number <= 2147483647
>>> struct.pack("i", 2**31 - 1)
'\0xff\0xff\0xff\0xf7'