From e9babbee811a9453f47d113eeb51b3c2c47f69d7 Mon Sep 17 00:00:00 2001 From: maddala prudvi rajkumar Date: Sat, 25 Aug 2018 01:50:33 +0530 Subject: [PATCH 1/7] bpo-34465: Added support for bytearrray type , to create IPv4 addresss --- Lib/ipaddress.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 15507d61dec8f9..bda20023d4ed86 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -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): 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) From f5df6f809489ab7d4a2aa3d569b7e630aec7fe07 Mon Sep 17 00:00:00 2001 From: maddala prudvi rajkumar Date: Sat, 25 Aug 2018 02:40:24 +0530 Subject: [PATCH 2/7] bpo-34465 Added support for bytearrray type , to create IPv4 addresss --- Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst diff --git a/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst b/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst new file mode 100644 index 00000000000000..e69de29bb2d1d6 From 16cb34617105d2e10dce885e1d3bbb40a767216c Mon Sep 17 00:00:00 2001 From: maddala prudvi rajkumar Date: Sat, 25 Aug 2018 02:47:37 +0530 Subject: [PATCH 3/7] bpo-34465: Added support for bytearrray type , to create IPv4 addresss --- .../next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst b/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst index e69de29bb2d1d6..75c4e3dd7cf706 100644 --- a/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst +++ b/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst @@ -0,0 +1,2 @@ +Addeded one more constructor that takes bytearray for creating a new IPv4 +address. \ No newline at end of file From 1f7c8ff838e3d836904fa9a8da7a7d8001138d12 Mon Sep 17 00:00:00 2001 From: maddala prudvi rajkumar Date: Sat, 25 Aug 2018 03:12:23 +0530 Subject: [PATCH 4/7] bpo-34465: Added support for bytearrray type , to create IPv4 addresss --- Lib/ipaddress.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index bda20023d4ed86..72568ff9f65ef5 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1291,7 +1291,7 @@ def __init__(self, address): 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) From d5f4260ee60c602e50c3664841b2f6379f4e44eb Mon Sep 17 00:00:00 2001 From: maddala prudvi rajkumar Date: Sat, 25 Aug 2018 18:53:32 +0530 Subject: [PATCH 5/7] bpo-34465: Added support for bytearrray type , to create IPv4 addresss --- Lib/ipaddress.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 72568ff9f65ef5..4aec346dd40ff9 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1287,7 +1287,7 @@ def __init__(self, address): return # Constructing from a packed address - if isinstance(address, bytes) or isinstance(address, bytearray): + if isinstance(address, (bytes,bytearray)): self._check_packed_address(address, 4) self._ip = int.from_bytes(address, 'big') return From ce2d003938682cf0cee4a40f93095a1d762067c2 Mon Sep 17 00:00:00 2001 From: maddala prudvi rajkumar Date: Sat, 25 Aug 2018 18:56:27 +0530 Subject: [PATCH 6/7] bpo-34465: Added support for bytearrray type , to create IPv4 address --- .../next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst b/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst index 75c4e3dd7cf706..eee64ac12ec6e5 100644 --- a/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst +++ b/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst @@ -1,2 +1 @@ -Addeded one more constructor that takes bytearray for creating a new IPv4 -address. \ No newline at end of file +Addeded support for bytearray in creating a new IPv4 address. \ No newline at end of file From 643a14cd5496a0132324bb0b38e072605098ff94 Mon Sep 17 00:00:00 2001 From: maddala prudvi rajkumar Date: Fri, 31 Aug 2018 21:58:32 +0530 Subject: [PATCH 7/7] bpo-34465: Fixed review comments --- Lib/ipaddress.py | 2 +- .../next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index 4aec346dd40ff9..8a42bf2a56ce6f 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1287,7 +1287,7 @@ def __init__(self, address): return # Constructing from a packed address - if isinstance(address, (bytes,bytearray)): + if isinstance(address, (bytes, bytearray)): self._check_packed_address(address, 4) self._ip = int.from_bytes(address, 'big') return diff --git a/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst b/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst index eee64ac12ec6e5..79b18df1e6b2d0 100644 --- a/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst +++ b/Misc/NEWS.d/next/Library/2018-08-25-02-38-50.bpo-34465.pMad01.rst @@ -1 +1 @@ -Addeded support for bytearray in creating a new IPv4 address. \ No newline at end of file +Added support for 'bytearray' type in creating a new IPv4 address. \ No newline at end of file