Skip to content

Commit

Permalink
chore: remove python 2 specific handling
Browse files Browse the repository at this point in the history
Refs: #23

Signed-off-by: Mike Fiedler <miketheman@gmail.com>
  • Loading branch information
miketheman committed Apr 10, 2020
1 parent 5f9b518 commit bd84412
Showing 1 changed file with 1 addition and 12 deletions.
13 changes: 1 addition & 12 deletions pytest_socket.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
import socket
import sys
import pytest

_true_socket = socket.socket
_true_connect = socket.socket.connect
is_py2 = sys.version_info[0] == 2


class SocketBlockedError(RuntimeError):
Expand Down Expand Up @@ -108,20 +106,11 @@ def host_from_address(address):
return host


def host_from_address_py2(address):
host = address[0]
if isinstance(host, str) or isinstance(host, unicode): # noqa F821
return host


def host_from_connect_args(args):
address = args[0]

if isinstance(address, tuple):
if is_py2:
return host_from_address_py2(address)
else:
return host_from_address(address)
return host_from_address(address)


def socket_allow_hosts(allowed=None):
Expand Down

0 comments on commit bd84412

Please sign in to comment.