summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDwayne Litzenberger <dlitz@dlitz.net>2013-07-14 16:21:16 -0700
committerDwayne Litzenberger <dlitz@dlitz.net>2013-07-14 19:14:35 -0700
commitab8fc54acaa511d224a9855f9cfc253e7d280547 (patch)
tree782103f8180f437f69c20293bbde8d145304fc1c /src
parent1b309c67633759a5449cbdb38d18f86c861b53c6 (diff)
downloadpycrypto-ab8fc54acaa511d224a9855f9cfc253e7d280547.tar.gz
Py3k cleanup: staticforward and Py_TYPE
Diffstat (limited to 'src')
-rw-r--r--src/block_template.c6
-rw-r--r--src/hash_template.c4
-rw-r--r--src/pycrypto_compat.h2
-rw-r--r--src/stream_template.c4
-rw-r--r--src/winrand.c5
5 files changed, 4 insertions, 17 deletions
diff --git a/src/block_template.c b/src/block_template.c
index b8a5a17..869df41 100644
--- a/src/block_template.c
+++ b/src/block_template.c
@@ -68,12 +68,10 @@ typedef struct
* These changes also dictate using Py_TYPE to check type, and PyVarObject_HEAD_INIT(NULL, 0) to initialize
*/
#ifdef IS_PY3K
-static PyTypeObject ALGtype;
#define PyInt_CheckExact PyLong_CheckExact
#define PyInt_AS_LONG PyLong_AS_LONG
-#else
-staticforward PyTypeObject ALGtype;
#endif
+staticforward PyTypeObject ALGtype;
static ALGobject *
newALGobject(void)
@@ -186,7 +184,7 @@ ALGnew(PyObject *self, PyObject *args, PyObject *kwdict)
PyErr_SetString(PyExc_TypeError,
"'counter' keyword parameter is required with CTR mode");
return NULL;
- } else if (counter->ob_type == PCT_CounterBEType || counter->ob_type == PCT_CounterLEType) {
+ } else if (Py_TYPE(counter) == PCT_CounterBEType || Py_TYPE(counter) == PCT_CounterLEType) {
counter_shortcut = 1;
} else if (!PyCallable_Check(counter)) {
PyErr_SetString(PyExc_ValueError,
diff --git a/src/hash_template.c b/src/hash_template.c
index 1bc6847..eb98224 100644
--- a/src/hash_template.c
+++ b/src/hash_template.c
@@ -46,11 +46,7 @@ typedef struct {
/* Please see PEP3123 for a discussion of PyObject_HEAD and changes made in 3.x to make it conform to Standard C.
* These changes also dictate using Py_TYPE to check type, and PyVarObject_HEAD_INIT(NULL, 0) to initialize
*/
-#ifdef IS_PY3K
-static PyTypeObject ALGtype;
-#else
staticforward PyTypeObject ALGtype;
-#endif
static ALGobject *
newALGobject(void)
diff --git a/src/pycrypto_compat.h b/src/pycrypto_compat.h
index c9098d4..3e8f92d 100644
--- a/src/pycrypto_compat.h
+++ b/src/pycrypto_compat.h
@@ -32,6 +32,7 @@
#if PY_MAJOR_VERSION >= 3
# define IS_PY3K
# define PyInt_FromLong PyLong_FromLong
+# define staticforward static
#else
# define PyBytes_GET_SIZE PyString_GET_SIZE
# define PyBytes_FromStringAndSize PyString_FromStringAndSize
@@ -41,6 +42,7 @@
# define PyBytes_AsString PyString_AsString
# define PyBytesObject PyStringObject
# if PY_MINOR_VERSION <= 5 /* Python 2.5 and earlier */
+# define Py_TYPE(v) ((v)->ob_type)
# define PyLong_MASK MASK
# define PyLong_SHIFT SHIFT
# define PyUnicode_FromString PyString_FromString
diff --git a/src/stream_template.c b/src/stream_template.c
index 1e03f34..8c14b28 100644
--- a/src/stream_template.c
+++ b/src/stream_template.c
@@ -53,11 +53,7 @@ typedef struct
/* Please see PEP3123 for a discussion of PyObject_HEAD and changes made in 3.x to make it conform to Standard C.
* These changes also dictate using Py_TYPE to check type, and PyVarObject_HEAD_INIT(NULL, 0) to initialize
*/
-#ifdef IS_PY3K
-static PyTypeObject ALGtype;
-#else
staticforward PyTypeObject ALGtype;
-#endif
static ALGobject *
newALGobject(void)
diff --git a/src/winrand.c b/src/winrand.c
index 0528972..149ae5c 100644
--- a/src/winrand.c
+++ b/src/winrand.c
@@ -58,13 +58,8 @@ typedef struct
/* Please see PEP3123 for a discussion of PyObject_HEAD and changes made in 3.x to make it conform to Standard C.
* These changes also dictate using Py_TYPE to check type, and PyVarObject_HEAD_INIT(NULL, 0) to initialize
*/
-#ifdef IS_PY3K
-static PyTypeObject WRtype;
#define is_WRobject(v) (Py_TYPE(v) == &WRtype)
-#else
staticforward PyTypeObject WRtype;
-#define is_WRobject(v) ((v)->ob_type == &WRtype)
-#endif
static void
WRdealloc(PyObject *ptr)