Merge remote-tracking branch 'upstream/master' into ref/replace-deprecated-imp

This commit is contained in:
Joshua Li 2020-06-03 10:37:17 -07:00
commit 04f2135a1c
8 changed files with 10 additions and 52 deletions

View File

@ -1,6 +1,6 @@
-r requirements.txt
attrs==19.3.0
pytest==5.4.2
pytest==5.4.3
pytest-cov==2.9.0
mock==2.0.0
flake8==3.8.2

View File

@ -228,12 +228,7 @@ class FirewallClient:
pass
self.argv = argv
s1.close()
if sys.version_info < (3, 0):
# python 2.7
self.pfile = s2.makefile('wb+')
else:
# python 3.5
self.pfile = s2.makefile('rwb')
self.pfile = s2.makefile('rwb')
if e:
log('Spawning firewall manager: %r\n' % self.argv)
raise Fatal(e)

View File

@ -5,16 +5,9 @@ import errno
logprefix = ''
verbose = 0
if sys.version_info[0] == 3:
binary_type = bytes
def b(s):
return s.encode("ASCII")
else:
binary_type = str
def b(s):
return s
def b(s):
return s.encode("ASCII")
def log(s):

View File

@ -6,6 +6,7 @@ import time
import sys
import os
import platform
from shutil import which
import sshuttle.ssnet as ssnet
import sshuttle.helpers as helpers
@ -15,11 +16,6 @@ from sshuttle.ssnet import Handler, Proxy, Mux, MuxWrapper
from sshuttle.helpers import b, log, debug1, debug2, debug3, Fatal, \
resolvconf_random_nameserver
try:
from shutil import which
except ImportError:
from distutils.spawn import find_executable as which
def _ipmatch(ipstr):
# FIXME: IPv4 only

View File

@ -6,24 +6,13 @@ import zlib
import imp
import subprocess as ssubprocess
import shlex
from shlex import quote
import ipaddress
# ensure backwards compatiblity with python2.7
try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
from urllib.parse import urlparse
import sshuttle.helpers as helpers
from sshuttle.helpers import debug2
try:
# Python >= 3.5
from shlex import quote
except ImportError:
# Python 2.x
from pipes import quote
def readfile(name):
tokens = name.split(".")

View File

@ -5,7 +5,7 @@ import errno
import select
import os
from sshuttle.helpers import b, binary_type, log, debug1, debug2, debug3, Fatal
from sshuttle.helpers import b, log, debug1, debug2, debug3, Fatal
MAX_CHANNEL = 65535
LATENCY_BUFFER_SIZE = 32768
@ -382,7 +382,7 @@ class Mux(Handler):
# log('outbuf: %d %r\n' % (self.amount_queued(), ob))
def send(self, channel, cmd, data):
assert isinstance(data, binary_type)
assert isinstance(data, bytes)
assert len(data) <= 65535
p = struct.pack('!ccHHH', b('S'), b('S'), channel, cmd, len(data)) \
+ data

View File

@ -1,4 +1,3 @@
import sys
import io
import socket
from socket import AF_INET, AF_INET6
@ -193,9 +192,5 @@ def test_family_ip_tuple():
def test_family_to_string():
assert sshuttle.helpers.family_to_string(AF_INET) == "AF_INET"
assert sshuttle.helpers.family_to_string(AF_INET6) == "AF_INET6"
if sys.version_info < (3, 0):
expected = "1"
assert sshuttle.helpers.family_to_string(socket.AF_UNIX) == "1"
else:
expected = 'AddressFamily.AF_UNIX'
expected = 'AddressFamily.AF_UNIX'
assert sshuttle.helpers.family_to_string(socket.AF_UNIX) == expected

View File

@ -1,10 +0,0 @@
import sys
if sys.version_info >= (3, 0):
good_python = sys.version_info >= (3, 5)
else:
good_python = sys.version_info >= (2, 7)
collect_ignore = []
if not good_python:
collect_ignore.append("client")