summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJeff Forcier <jeff@bitprophet.org>2012-04-19 15:19:59 -0700
committerJeff Forcier <jeff@bitprophet.org>2012-09-23 16:19:40 -0700
commit1a033dc596d5c3c03a41fee2698d0089debc7313 (patch)
tree2041916a820c19ead00af2b099bc0e55b6d29a14
parentef9b25188529dac439e5bc0549b00fa58bf27d01 (diff)
safe type checking (isinstance instead of type-is)
Maintainer note: added changelog entry. (cherry picked from commit 8917d83221f2422f1c4c3e6fb8538ea9e1f9a150)
-rw-r--r--CHANGES3
-rw-r--r--paramiko/sftp_client.py8
2 files changed, 7 insertions, 4 deletions
diff --git a/CHANGES b/CHANGES
index 69c1caf7..be3b2ad7 100644
--- a/CHANGES
+++ b/CHANGES
@@ -4,6 +4,9 @@ Temporary, post-Paramiko changelog while we get our sh!t together.
* #15: Implemented parameter substitution in SSHConfig, matching the
implementation of `ssh_config(5)`. Thanks to Olle Lundberg for the patch.
+* #24: Switch some internal type checking to use `isinstance` to help prevent
+ problems with client libraries using subclasses of builtin types. Thanks to
+ Alex Morega for the patch.
## ssh 1.7.13 (2012-02-13)
diff --git a/paramiko/sftp_client.py b/paramiko/sftp_client.py
index 79a77614..f446ba3d 100644
--- a/paramiko/sftp_client.py
+++ b/paramiko/sftp_client.py
@@ -641,13 +641,13 @@ class SFTPClient (BaseSFTP):
msg = Message()
msg.add_int(self.request_number)
for item in arg:
- if type(item) is int:
+ if isinstance(item, int):
msg.add_int(item)
- elif type(item) is long:
+ elif isinstance(item, long):
msg.add_int64(item)
- elif type(item) is str:
+ elif isinstance(item, str):
msg.add_string(item)
- elif type(item) is SFTPAttributes:
+ elif isinstance(item, SFTPAttributes):
item._pack(msg)
else:
raise Exception('unknown type for %r type %r' % (item, type(item)))