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.

Author joernheissler
Recipients joernheissler
Date 2018-08-22.19:48:00
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1534967280.44.0.56676864532.issue34465@psf.upfronthosting.co.za>
In-reply-to
Content
Hi,

the ipaddress module accepts `bytes' objects in the constructors.
`bytearray' however is not supported, see paste below.

Should this be supported too?


>>> import ipaddress

>>> ipaddress.IPv4Address(bytes([127, 0, 0, 1]))
IPv4Address('127.0.0.1')

>>> ipaddress.IPv4Address(bytearray([127, 0, 0, 1]))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.7/ipaddress.py", line 1301, in __init__
    self._ip = self._ip_int_from_string(addr_str)
  File "/usr/lib/python3.7/ipaddress.py", line 1135, in _ip_int_from_string
    raise AddressValueError("Expected 4 octets in %r" % ip_str)
ipaddress.AddressValueError: Expected 4 octets in "bytearray(b'\\x7f\\x00\\x00\\x01')"
History
Date User Action Args
2018-08-22 19:48:00joernheisslersetrecipients: + joernheissler
2018-08-22 19:48:00joernheisslersetmessageid: <1534967280.44.0.56676864532.issue34465@psf.upfronthosting.co.za>
2018-08-22 19:48:00joernheisslerlinkissue34465 messages
2018-08-22 19:48:00joernheisslercreate