From 61932d50b97c7e5beb713038bff5dcca18160db2 Mon Sep 17 00:00:00 2001 From: lericson Date: Mon, 22 Mar 2010 21:06:03 +0100 Subject: [PATCH] Check for minor version requirement --- README.rst | 1 + _pylibmcmodule.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/README.rst b/README.rst index 05e19f8..07104a3 100644 --- a/README.rst +++ b/README.rst @@ -55,6 +55,7 @@ New in version 1.0 - Lots of documentation fixes and other nice things like that. - Nailed what appears to be the last outstanding memory leak. + - Explicitly require libmemcached 0.32 or newer. New in version 0.9 ------------------ diff --git a/_pylibmcmodule.c b/_pylibmcmodule.c index ddfd705..0a22269 100644 --- a/_pylibmcmodule.c +++ b/_pylibmcmodule.c @@ -1210,8 +1210,19 @@ PyMODINIT_FUNC init_pylibmc(void) { PyObject *module, *exc_objs; PylibMC_Behavior *b; PylibMC_McErr *err; + int libmemcached_version_minor; char name[128]; + /* Check minimum requirement of libmemcached version */ + libmemcached_version_minor = \ + atoi(strchr(LIBMEMCACHED_VERSION_STRING, '.') + 1); + if (libmemcached_version_minor < 32) { + PyErr_Format(PyExc_RuntimeError, + "pylibmc requires >= libmemcached 0.32, was compiled with %s", + LIBMEMCACHED_VERSION_STRING); + return; + } + if (PyType_Ready(&PylibMC_ClientType) < 0) { return; }