From 274a798cc62f43fdb49dce6b16c2d5e20c8dcf01 Mon Sep 17 00:00:00 2001 From: Geert Jansen Date: Mon, 22 Dec 2014 22:54:21 -0500 Subject: [PATCH] ssl: fix for Python 2.7.9 --- gruvi/_sslcompat.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/gruvi/_sslcompat.c b/gruvi/_sslcompat.c index ee256ea..90885d7 100644 --- a/gruvi/_sslcompat.c +++ b/gruvi/_sslcompat.c @@ -130,19 +130,17 @@ typedef struct } PySSLObject; -#if PY_MAJOR_VERSION == 3 -# define CHECK_SSL_OBJ(obj) \ - do { \ - if (strcmp(Py_TYPE(obj)->tp_name, "_ssl._SSLSocket")) \ - RETURN_ERROR("expecting a _ssl._SSLSocket instance"); \ - } while (0) -#elif PY_MAJOR_VERSION == 2 -# define CHECK_SSL_OBJ(obj) \ +#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 7 && PY_MICRO_VERSION < 9 +# define SSL_OBJ_NAME "ssl.SSLContext" +#else +# define SSL_OBJ_NAME "_ssl._SSLSocket" +#endif + +#define CHECK_SSL_OBJ(obj) \ do { \ - if (strcmp(Py_TYPE(obj)->tp_name, "ssl.SSLContext")) \ - RETURN_ERROR("expecting a ssl.SSLContext instance"); \ + if (strcmp(Py_TYPE(obj)->tp_name, SSL_OBJ_NAME)) \ + RETURN_ERROR("expecting a " SSL_OBJ_NAME " instance"); \ } while (0) -#endif /* MemoryBIO type */