Skip to content

gh-78646: Added support for bytearrray type , to create IPv4 addresss #8908

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Next Next commit
bpo-34465: Added support for bytearrray type , to create IPv4 addresss
  • Loading branch information
maddala prudvi rajkumar committed Aug 24, 2018
commit e9babbee811a9453f47d113eeb51b3c2c47f69d7
4 changes: 2 additions & 2 deletions Lib/ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -1287,11 +1287,11 @@ def __init__(self, address):
return

# Constructing from a packed address
if isinstance(address, bytes):
if isinstance(address, bytes) or isinstance(address, bytearray):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to pass a tuple to isinstance.

if isinstance(address, (bytes, bytearray)):

And there are couple of more code lines that use isinstance

self._check_packed_address(address, 4)
self._ip = int.from_bytes(address, 'big')
return

# Assume input argument to be string or any object representation
# which converts into a formatted IP string.
addr_str = str(address)
Expand Down