summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan Walker <brendan.walker@pelotoncycle.com>2017-02-14 22:59:06 -0500
committerBrendan Walker <brendan.walker@pelotoncycle.com>2017-02-14 22:59:06 -0500
commit8d37d612f34af48fa2be6165b6143860afaabf93 (patch)
treec589013c7e104fae4409e55f191763383dfd26b6
parent993420ab24b23feb06bf3d7223b702e9bfe896fd (diff)
downloadpymemcache-8d37d612f34af48fa2be6165b6143860afaabf93.tar.gz
Comparing ord(character) so its compatible with python 2 and 3
-rw-r--r--pymemcache/client/base.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/pymemcache/client/base.py b/pymemcache/client/base.py
index 94e9a57..64c4580 100644
--- a/pymemcache/client/base.py
+++ b/pymemcache/client/base.py
@@ -97,19 +97,21 @@ def _check_key(key, allow_unicode_keys, key_prefix=b''):
raise MemcacheIllegalInputError("Key is too long: '%r'" % (key,))
for c in key:
- if c == b' ':
+ if isinstance(c, VALID_STRING_TYPES):
+ c = ord(c)
+ if c == ord(b' '):
raise MemcacheIllegalInputError(
"Key contains space: '%r'" % (key,)
)
- elif c == b'\n':
+ elif c == ord(b'\n'):
raise MemcacheIllegalInputError(
"Key contains newline: '%r'" % (key,)
)
- elif c == b'\00':
+ elif c == ord(b'\00'):
raise MemcacheIllegalInputError(
"Key contains null character: '%r'" % (key,)
)
- elif c == b'\r':
+ elif c == ord(b'\r'):
raise MemcacheIllegalInputError(
"Key contains carriage return: '%r'" % (key,)
)