[Python-checkins] cpython: Remove dead code from _multiprocessing

antoine.pitrou python-checkins at python.org
Mon May 9 20:55:08 CEST 2011


http://hg.python.org/cpython/rev/5dbc23e48fb0
changeset:   69989:5dbc23e48fb0
user:        Antoine Pitrou <solipsis at pitrou.net>
date:        Mon May 09 20:55:03 2011 +0200
summary:
  Remove dead code from _multiprocessing

files:
  Modules/_multiprocessing/multiprocessing.c |  12 +--
  Modules/_multiprocessing/multiprocessing.h |  45 ----------
  Modules/_multiprocessing/semaphore.c       |   4 +-
  3 files changed, 3 insertions(+), 58 deletions(-)


diff --git a/Modules/_multiprocessing/multiprocessing.c b/Modules/_multiprocessing/multiprocessing.c
--- a/Modules/_multiprocessing/multiprocessing.c
+++ b/Modules/_multiprocessing/multiprocessing.c
@@ -16,7 +16,6 @@
 
 PyObject *create_win32_namespace(void);
 
-PyObject *pickle_dumps, *pickle_loads, *pickle_protocol;
 PyObject *ProcessError, *BufferTooShort;
 
 /*
@@ -177,7 +176,7 @@
     if (PyObject_AsWriteBuffer(obj, &buffer, &buffer_len) < 0)
         return NULL;
 
-    return Py_BuildValue("N" F_PY_SSIZE_T,
+    return Py_BuildValue("Nn",
                          PyLong_FromVoidPtr(buffer), buffer_len);
 }
 
@@ -231,15 +230,6 @@
     if (!module)
         return NULL;
 
-    /* Get copy of objects from pickle */
-    temp = PyImport_ImportModule(PICKLE_MODULE);
-    if (!temp)
-        return NULL;
-    pickle_dumps = PyObject_GetAttrString(temp, "dumps");
-    pickle_loads = PyObject_GetAttrString(temp, "loads");
-    pickle_protocol = PyObject_GetAttrString(temp, "HIGHEST_PROTOCOL");
-    Py_XDECREF(temp);
-
     /* Get copy of BufferTooShort */
     temp = PyImport_ImportModule("multiprocessing");
     if (!temp)
diff --git a/Modules/_multiprocessing/multiprocessing.h b/Modules/_multiprocessing/multiprocessing.h
--- a/Modules/_multiprocessing/multiprocessing.h
+++ b/Modules/_multiprocessing/multiprocessing.h
@@ -64,20 +64,6 @@
 
 
 /*
- * Make sure Py_ssize_t available
- */
-
-#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN)
-   typedef int Py_ssize_t;
-#  define PY_SSIZE_T_MAX INT_MAX
-#  define PY_SSIZE_T_MIN INT_MIN
-#  define F_PY_SSIZE_T "i"
-#  define PyInt_FromSsize_t(n) PyInt_FromLong((long)n)
-#else
-#  define F_PY_SSIZE_T "n"
-#endif
-
-/*
  * Format codes
  */
 
@@ -105,12 +91,6 @@
 #  define T_SEM_HANDLE T_POINTER
 #endif
 
-#if PY_VERSION_HEX >= 0x03000000
-#  define F_RBUFFER "y"
-#else
-#  define F_RBUFFER "s"
-#endif
-
 /*
  * Error codes which can be returned by functions called without GIL
  */
@@ -127,37 +107,12 @@
  * Externs - not all will really exist on all platforms
  */
 
-extern PyObject *pickle_dumps;
-extern PyObject *pickle_loads;
-extern PyObject *pickle_protocol;
 extern PyObject *BufferTooShort;
 extern PyTypeObject SemLockType;
 extern PyTypeObject PipeConnectionType;
 extern HANDLE sigint_event;
 
 /*
- * Py3k compatibility
- */
-
-#if PY_VERSION_HEX >= 0x03000000
-#  define PICKLE_MODULE "pickle"
-#  define FROM_FORMAT PyUnicode_FromFormat
-#  define PyInt_FromLong PyLong_FromLong
-#  define PyInt_FromSsize_t PyLong_FromSsize_t
-#else
-#  define PICKLE_MODULE "cPickle"
-#  define FROM_FORMAT PyString_FromFormat
-#endif
-
-#ifndef PyVarObject_HEAD_INIT
-#  define PyVarObject_HEAD_INIT(type, size) PyObject_HEAD_INIT(type) size,
-#endif
-
-#ifndef Py_TPFLAGS_HAVE_WEAKREFS
-#  define Py_TPFLAGS_HAVE_WEAKREFS 0
-#endif
-
-/*
  * Miscellaneous
  */
 
diff --git a/Modules/_multiprocessing/semaphore.c b/Modules/_multiprocessing/semaphore.c
--- a/Modules/_multiprocessing/semaphore.c
+++ b/Modules/_multiprocessing/semaphore.c
@@ -481,7 +481,7 @@
 static PyObject *
 semlock_count(SemLockObject *self)
 {
-    return PyInt_FromLong((long)self->count);
+    return PyLong_FromLong((long)self->count);
 }
 
 static PyObject *
@@ -505,7 +505,7 @@
        the number of waiting threads */
     if (sval < 0)
         sval = 0;
-    return PyInt_FromLong((long)sval);
+    return PyLong_FromLong((long)sval);
 #endif
 }
 

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list