Skip to content

Commit 2bb50ba

Browse files
author
James William Pye
committed
Fix IP6 connector and integer-ize 'port'.
IP6 wasn't setting host and port, and IP4 wasn't casting port to an integer. (ValueError early is better than later)
1 parent b1e8597 commit 2bb50ba

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

postgresql/driver/pq3.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2551,9 +2551,9 @@ def socket_factory_sequence(self):
25512551
return self._socketcreators
25522552

25532553
def __init__(self,
2554+
host : "IPv4 Address (str)" = None,
2555+
port : int = None,
25542556
ipv = 4,
2555-
host = None,
2556-
port = None,
25572557
**kw
25582558
):
25592559
if ipv != self.ipv:
@@ -2563,7 +2563,7 @@ def __init__(self,
25632563
if port is None:
25642564
raise TypeError("`port` is a required keyword and cannot be `None`")
25652565
self.host = host
2566-
self.port = port
2566+
self.port = int(port)
25672567
# constant socket connector
25682568
self._socketcreator = SocketCreator(
25692569
(socket.AF_INET4, socket.SOCK_STREAM), (self.host, self.port)
@@ -2579,13 +2579,20 @@ class IP6(SocketConnector):
25792579
def socket_factory_sequence(self):
25802580
return self._socketcreators
25812581

2582-
def __init__(self, host = None, port = None, ipv = 6, **kw):
2582+
def __init__(self,
2583+
host : "IPv6 Address (str)" = None,
2584+
port : int = None,
2585+
ipv = 6,
2586+
**kw
2587+
):
25832588
if ipv != self.ipv:
25842589
raise TypeError("`ipv` keyword must be `6`")
25852590
if host is None:
25862591
raise TypeError("`host` is a required keyword and cannot be `None`")
25872592
if port is None:
25882593
raise TypeError("`port` is a required keyword and cannot be `None`")
2594+
self.host = host
2595+
self.port = int(port)
25892596
# constant socket connector
25902597
self._socketcreator = SocketCreator(
25912598
(socket.AF_INET6, socket.SOCK_STREAM), (self.host, self.port)

0 commit comments

Comments
 (0)