parent
314562c437
commit
725134931b
@ -1754,9 +1754,10 @@ static int _PylibMC_CheckKey(PyObject *key) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int _PylibMC_CheckKeyStringAndSize(char *key, Py_ssize_t size) {
|
static int _PylibMC_CheckKeyStringAndSize(char *key, Py_ssize_t size) {
|
||||||
if (size > MEMCACHED_MAX_KEY) {
|
/* libmemcached pads max_key_size with one byte for null termination */
|
||||||
|
if (size >= MEMCACHED_MAX_KEY) {
|
||||||
PyErr_Format(PyExc_ValueError, "key too long, max is %d",
|
PyErr_Format(PyExc_ValueError, "key too long, max is %d",
|
||||||
MEMCACHED_MAX_KEY);
|
MEMCACHED_MAX_KEY - 1);
|
||||||
return 0;
|
return 0;
|
||||||
#ifdef NO_EMPTY_KEYS /* I wish... */
|
#ifdef NO_EMPTY_KEYS /* I wish... */
|
||||||
} else if (size == 0) {
|
} else if (size == 0) {
|
||||||
|
7
tests.py
7
tests.py
@ -256,6 +256,13 @@ Ormod's Zero-byte Adventure Story
|
|||||||
True
|
True
|
||||||
>>> bc.get_multi(["\0\0"])
|
>>> bc.get_multi(["\0\0"])
|
||||||
{'\x00\x00': 'ORMOD'}
|
{'\x00\x00': 'ORMOD'}
|
||||||
|
|
||||||
|
Test server/client max length
|
||||||
|
>>> mc.get('x'*250)
|
||||||
|
>>> mc.get('x'*251)
|
||||||
|
Traceback (most recent call last):
|
||||||
|
...
|
||||||
|
ValueError: key too long, max is 250
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Used to test pickling.
|
# Used to test pickling.
|
||||||
|
Reference in New Issue
Block a user