-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hi,
Thanks for maintaining such an useful python module,
We @pokersource heavily use for the webservice interface of our pokerserver:
https://gna.org/projects/pokersource/
I noticed that memcache Client .get (and others methods) raise a
MemcachedStringEncodingError when given a None key, which have been
missleading when trying to fix the following bug in poker-network
https://gna.org/support/index.php?2135
You can reproduce the error with this command:
[EMAIL PROTECTED] ~/Desktop/python-memcached-1.43 $ python -c 'import
memcache; memcache.Client(["127.0.0.1:11211"]).get(None)'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "memcache.py", line 653, in get
check_key(key)
File "memcache.py", line 935, in check_key
raise Client.MemcachedStringEncodingError, ("Keys must be str()'s, not"
memcache.MemcachedStringEncodingError: Keys must be str()'s, notunicode.
Convert your unicode strings using mystring.encode(charset)!
Feel free to apply the attached patch that raise a MemcachedKeyError
error instead if supplied a None key.
Thanks in advance.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iEYEARECAAYFAkkR0SEACgkQZmEdV9SHoe6FgACfceAbIBEXrdIJMwT1IqgJf7hi
d6cAn01ngop+ir44Ta+NGVYXtW4Q+iqE
=fVgu
-----END PGP SIGNATURE-----
diff -r 894616f32c5b memcache.py
--- a/memcache.py Wed Nov 05 17:46:59 2008 +0100
+++ b/memcache.py Wed Nov 05 17:55:04 2008 +0100
@@ -929,7 +929,10 @@
Key length is > SERVER_MAX_KEY_LENGTH (Raises MemcachedKeyLength).
Contains control characters (Raises MemcachedKeyCharacterError).
Is not a string (Raises MemcachedStringEncodingError)
+ Is None (MemcachedKeyError)
"""
+ if not key:
+ raise Client.MemcachedKeyError, ("Key is None")
if type(key) == types.TupleType: key = key[1]
if not isinstance(key, str):
raise Client.MemcachedStringEncodingError, ("Keys must be str()'s, not"
diff -r 894616f32c5b test-memcache.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-memcache.py Wed Nov 05 17:55:04 2008 +0100
@@ -0,0 +1,10 @@
+import unittest
+import memcache
+
+class MemcacheTestCase(unittest.TestCase):
+ def test_check_key(self):
+ self.assertRaises(memcache.Client.MemcachedKeyError,
memcache.check_key, None)
+
+if __name__ == '__main__':
+ unittest.main()
+
_______________________________________________
Pokersource-users mailing list
[email protected]
https://mail.gna.org/listinfo/pokersource-users