summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2017-12-18 11:58:09 -0800
committerJeff Forcier <jeff@bitprophet.org>2017-12-18 12:20:47 -0800
commitcd57cf0ba7d29cd97ceafe692c9aa3e2d68c0ef6 (patch)
treeb329e0e2577420e41159e9425744b1d5aadfc53f
parent664568f662a028b1056ddd43191706f8d6de87a5 (diff)
Fold py3compat.bytestring() into py3compat.b()
Super unclear to me why both existed, even tho both were apparently added at the same time, in the great 2013 python3-ening.
-rw-r--r--paramiko/auth_handler.py4
-rw-r--r--paramiko/py3compat.py9
-rw-r--r--paramiko/sftp_client.py4
3 files changed, 4 insertions, 13 deletions
diff --git a/paramiko/auth_handler.py b/paramiko/auth_handler.py
index a1ce5e3b..3b894de7 100644
--- a/paramiko/auth_handler.py
+++ b/paramiko/auth_handler.py
@@ -39,7 +39,7 @@ from paramiko.common import (
cMSG_USERAUTH_BANNER
)
from paramiko.message import Message
-from paramiko.py3compat import bytestring
+from paramiko.py3compat import b
from paramiko.ssh_exception import (
SSHException, AuthenticationException, BadAuthenticationType,
PartialAuthentication,
@@ -256,7 +256,7 @@ class AuthHandler (object):
m.add_string(self.auth_method)
if self.auth_method == 'password':
m.add_boolean(False)
- password = bytestring(self.password)
+ password = b(self.password)
m.add_string(password)
elif self.auth_method == 'publickey':
m.add_boolean(True)
diff --git a/paramiko/py3compat.py b/paramiko/py3compat.py
index cb9de412..0d888a3c 100644
--- a/paramiko/py3compat.py
+++ b/paramiko/py3compat.py
@@ -23,12 +23,6 @@ if PY2:
import __builtin__ as builtins
- def bytestring(s): # NOQA
- if isinstance(s, unicode): # NOQA
- return s.encode('utf-8')
- return s
-
-
byte_ord = ord # NOQA
byte_chr = chr # NOQA
@@ -111,9 +105,6 @@ else:
decodebytes = base64.decodebytes
encodebytes = base64.encodebytes
- def bytestring(s):
- return s
-
def byte_ord(c):
# In case we're handed a string instead of an int.
if not isinstance(c, int):
diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py
index b344dff3..31dc234c 100644
--- a/paramiko/sftp_client.py
+++ b/paramiko/sftp_client.py
@@ -28,7 +28,7 @@ from paramiko import util
from paramiko.channel import Channel
from paramiko.message import Message
from paramiko.common import INFO, DEBUG, o777
-from paramiko.py3compat import bytestring, b, u, long
+from paramiko.py3compat import b, u, long
from paramiko.sftp import (
BaseSFTP, CMD_OPENDIR, CMD_HANDLE, SFTPError, CMD_READDIR, CMD_NAME,
CMD_CLOSE, SFTP_FLAG_READ, SFTP_FLAG_WRITE, SFTP_FLAG_CREATE,
@@ -489,7 +489,7 @@ class SFTPClient(BaseSFTP, ClosingContextManager):
"""
dest = self._adjust_cwd(dest)
self._log(DEBUG, 'symlink({!r}, {!r})'.format(source, dest))
- source = bytestring(source)
+ source = b(source)
self._request(CMD_SYMLINK, source, dest)
def chmod(self, path, mode):