[Python-checkins] r83949 - in python/branches/py3k: Include/pyport.h Misc/NEWS Modules/_elementtree.c Modules/_hashopenssl.c Objects/abstract.c Objects/bytearrayobject.c Objects/bytesobject.c Objects/capsule.c Objects/memoryobject.c Objects/unicodectype.c Objects/unicodeobject.c Python/getargs.c Python/modsupport.c

alexander.belopolsky python-checkins at python.org
Wed Aug 11 19:31:17 CEST 2010


Author: alexander.belopolsky
Date: Wed Aug 11 19:31:17 2010
New Revision: 83949

Log:
Issue #2443: Added a new macro, Py_VA_COPY, which is equivalent to C99
va_copy, but available on all python platforms.  Untabified a few
unrelated files.


Modified:
   python/branches/py3k/Include/pyport.h
   python/branches/py3k/Misc/NEWS
   python/branches/py3k/Modules/_elementtree.c
   python/branches/py3k/Modules/_hashopenssl.c
   python/branches/py3k/Objects/abstract.c
   python/branches/py3k/Objects/bytearrayobject.c
   python/branches/py3k/Objects/bytesobject.c
   python/branches/py3k/Objects/capsule.c
   python/branches/py3k/Objects/memoryobject.c
   python/branches/py3k/Objects/unicodectype.c
   python/branches/py3k/Objects/unicodeobject.c
   python/branches/py3k/Python/getargs.c
   python/branches/py3k/Python/modsupport.c

Modified: python/branches/py3k/Include/pyport.h
==============================================================================
--- python/branches/py3k/Include/pyport.h	(original)
+++ python/branches/py3k/Include/pyport.h	Wed Aug 11 19:31:17 2010
@@ -822,4 +822,14 @@
 #define Py_ULL(x) Py_LL(x##U)
 #endif
 
+#ifdef VA_LIST_IS_ARRAY
+#define Py_VA_COPY(x, y) Py_MEMCPY((x), (y), sizeof(va_list))
+#else
+#ifdef __va_copy
+#define Py_VA_COPY __va_copy
+#else
+#define Py_VA_COPY(x, y) (x) = (y)
+#endif
+#endif
+
 #endif /* Py_PYPORT_H */

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Wed Aug 11 19:31:17 2010
@@ -583,6 +583,10 @@
 C-API
 -----
 
+- Issue #2443: A new macro, `Py_VA_COPY`, copies the state of the
+  variable argument list.  `Py_VA_COPY` is equivalent to C99
+  `va_copy`, but available on all python platforms.
+
 - PySlice_GetIndicesEx now clips the step to [-PY_SSIZE_T_MAX, PY_SSIZE_T_MAX]
   instead of [-PY_SSIZE_T_MAX-1, PY_SSIZE_T_MAX].  This makes it safe to do
   "step = -step" when reversing a slice.

Modified: python/branches/py3k/Modules/_elementtree.c
==============================================================================
--- python/branches/py3k/Modules/_elementtree.c	(original)
+++ python/branches/py3k/Modules/_elementtree.c	Wed Aug 11 19:31:17 2010
@@ -2870,15 +2870,15 @@
 
 
 static struct PyModuleDef _elementtreemodule = {
-	PyModuleDef_HEAD_INIT,
-	"_elementtree",
-	NULL,
-	-1,
-	_functions,
-	NULL,
-	NULL,
-	NULL,
-	NULL
+        PyModuleDef_HEAD_INIT,
+        "_elementtree",
+        NULL,
+        -1,
+        _functions,
+        NULL,
+        NULL,
+        NULL,
+        NULL
 };
 
 PyMODINIT_FUNC
@@ -2890,12 +2890,12 @@
 
     /* Initialize object types */
     if (PyType_Ready(&TreeBuilder_Type) < 0)
-	return NULL;
+        return NULL;
     if (PyType_Ready(&Element_Type) < 0)
-	return NULL;
+        return NULL;
 #if defined(USE_EXPAT)
     if (PyType_Ready(&XMLParser_Type) < 0)
-	return NULL;
+        return NULL;
 #endif
 
     m = PyModule_Create(&_elementtreemodule);
@@ -2905,8 +2905,8 @@
     /* The code below requires that the module gets already added
        to sys.modules. */
     PyDict_SetItemString(PyImport_GetModuleDict(),
-			 _elementtreemodule.m_name,
-			 m);
+                         _elementtreemodule.m_name,
+                         m);
 
     /* python glue code */
 

Modified: python/branches/py3k/Modules/_hashopenssl.c
==============================================================================
--- python/branches/py3k/Modules/_hashopenssl.c	(original)
+++ python/branches/py3k/Modules/_hashopenssl.c	Wed Aug 11 19:31:17 2010
@@ -559,7 +559,7 @@
     CONSTRUCTOR_METH_DEF(sha384),
     CONSTRUCTOR_METH_DEF(sha512),
 #endif
-    {NULL,	NULL}		 /* Sentinel */
+    {NULL,      NULL}            /* Sentinel */
 };
 
 

Modified: python/branches/py3k/Objects/abstract.c
==============================================================================
--- python/branches/py3k/Objects/abstract.c	(original)
+++ python/branches/py3k/Objects/abstract.c	Wed Aug 11 19:31:17 2010
@@ -2311,15 +2311,7 @@
     va_list countva;
     PyObject *result, *tmp;
 
-#ifdef VA_LIST_IS_ARRAY
-    memcpy(countva, va, sizeof(va_list));
-#else
-#ifdef __va_copy
-    __va_copy(countva, va);
-#else
-    countva = va;
-#endif
-#endif
+        Py_VA_COPY(countva, va);
 
     while (((PyObject *)va_arg(countva, PyObject *)) != NULL)
         ++n;

Modified: python/branches/py3k/Objects/bytearrayobject.c
==============================================================================
--- python/branches/py3k/Objects/bytearrayobject.c	(original)
+++ python/branches/py3k/Objects/bytearrayobject.c	Wed Aug 11 19:31:17 2010
@@ -936,12 +936,12 @@
 static PyObject *
 bytearray_str(PyObject *op)
 {
-	if (Py_BytesWarningFlag) {
-		if (PyErr_WarnEx(PyExc_BytesWarning,
-				 "str() on a bytearray instance", 1))
-			return NULL;
-	}
-	return bytearray_repr((PyByteArrayObject*)op);
+        if (Py_BytesWarningFlag) {
+                if (PyErr_WarnEx(PyExc_BytesWarning,
+                                 "str() on a bytearray instance", 1))
+                        return NULL;
+        }
+        return bytearray_repr((PyByteArrayObject*)op);
 }
 
 static PyObject *
@@ -1458,7 +1458,7 @@
 static PyObject *
 bytearray_maketrans(PyObject *null, PyObject *args)
 {
-	return _Py_bytes_maketrans(args);
+        return _Py_bytes_maketrans(args);
 }
 
 

Modified: python/branches/py3k/Objects/bytesobject.c
==============================================================================
--- python/branches/py3k/Objects/bytesobject.c	(original)
+++ python/branches/py3k/Objects/bytesobject.c	Wed Aug 11 19:31:17 2010
@@ -173,15 +173,7 @@
     char *s;
     PyObject* string;
 
-#ifdef VA_LIST_IS_ARRAY
-    Py_MEMCPY(count, vargs, sizeof(va_list));
-#else
-#ifdef  __va_copy
-    __va_copy(count, vargs);
-#else
-    count = vargs;
-#endif
-#endif
+    Py_VA_COPY(count, vargs);
     /* step 1: figure out how large a buffer we need */
     for (f = format; *f; f++) {
         if (*f == '%') {

Modified: python/branches/py3k/Objects/capsule.c
==============================================================================
--- python/branches/py3k/Objects/capsule.c	(original)
+++ python/branches/py3k/Objects/capsule.c	Wed Aug 11 19:31:17 2010
@@ -298,27 +298,27 @@
 
 PyTypeObject PyCapsule_Type = {
     PyVarObject_HEAD_INIT(&PyType_Type, 0)
-    "PyCapsule",		/*tp_name*/
-    sizeof(PyCapsule),		/*tp_basicsize*/
-    0,				/*tp_itemsize*/
+    "PyCapsule",                /*tp_name*/
+    sizeof(PyCapsule),          /*tp_basicsize*/
+    0,                          /*tp_itemsize*/
     /* methods */
     capsule_dealloc, /*tp_dealloc*/
-    0,				/*tp_print*/
-    0,				/*tp_getattr*/
-    0,				/*tp_setattr*/
-    0,				/*tp_reserved*/
+    0,                          /*tp_print*/
+    0,                          /*tp_getattr*/
+    0,                          /*tp_setattr*/
+    0,                          /*tp_reserved*/
     capsule_repr, /*tp_repr*/
-    0,				/*tp_as_number*/
-    0,				/*tp_as_sequence*/
-    0,				/*tp_as_mapping*/
-    0,				/*tp_hash*/
-    0,				/*tp_call*/
-    0,				/*tp_str*/
-    0,				/*tp_getattro*/
-    0,				/*tp_setattro*/
-    0,				/*tp_as_buffer*/
-    0,				/*tp_flags*/
-    PyCapsule_Type__doc__	/*tp_doc*/
+    0,                          /*tp_as_number*/
+    0,                          /*tp_as_sequence*/
+    0,                          /*tp_as_mapping*/
+    0,                          /*tp_hash*/
+    0,                          /*tp_call*/
+    0,                          /*tp_str*/
+    0,                          /*tp_getattro*/
+    0,                          /*tp_setattro*/
+    0,                          /*tp_as_buffer*/
+    0,                          /*tp_flags*/
+    PyCapsule_Type__doc__       /*tp_doc*/
 };
 
 

Modified: python/branches/py3k/Objects/memoryobject.c
==============================================================================
--- python/branches/py3k/Objects/memoryobject.c	(original)
+++ python/branches/py3k/Objects/memoryobject.c	Wed Aug 11 19:31:17 2010
@@ -775,10 +775,10 @@
 };
 
 static PySequenceMethods memory_as_sequence = {
-	0,                                  /* sq_length */
-	0,                                  /* sq_concat */
-	0,                                  /* sq_repeat */
-	(ssizeargfunc)memory_item,          /* sq_item */
+        0,                                  /* sq_length */
+        0,                                  /* sq_concat */
+        0,                                  /* sq_repeat */
+        (ssizeargfunc)memory_item,          /* sq_item */
 };
 
 /* Buffer methods */

Modified: python/branches/py3k/Objects/unicodectype.c
==============================================================================
--- python/branches/py3k/Objects/unicodectype.c	(original)
+++ python/branches/py3k/Objects/unicodectype.c	Wed Aug 11 19:31:17 2010
@@ -63,10 +63,10 @@
     int delta = ctype->title;
 
     if (ctype->flags & NODELTA_MASK)
-	return delta;
+        return delta;
 
     if (delta >= 32768)
-	    delta -= 65536;
+            delta -= 65536;
 
     return ch + delta;
 }
@@ -114,7 +114,7 @@
 int _PyUnicode_IsDecimalDigit(Py_UNICODE ch)
 {
     if (_PyUnicode_ToDecimalDigit(ch) < 0)
-	return 0;
+        return 0;
     return 1;
 }
 
@@ -131,7 +131,7 @@
 int _PyUnicode_IsDigit(Py_UNICODE ch)
 {
     if (_PyUnicode_ToDigit(ch) < 0)
-	return 0;
+        return 0;
     return 1;
 }
 
@@ -195,9 +195,9 @@
     const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
     int delta = ctype->upper;
     if (ctype->flags & NODELTA_MASK)
-	return delta;
+        return delta;
     if (delta >= 32768)
-	    delta -= 65536;
+            delta -= 65536;
     return ch + delta;
 }
 
@@ -209,9 +209,9 @@
     const _PyUnicode_TypeRecord *ctype = gettyperecord(ch);
     int delta = ctype->lower;
     if (ctype->flags & NODELTA_MASK)
-	return delta;
+        return delta;
     if (delta >= 32768)
-	    delta -= 65536;
+            delta -= 65536;
     return ch + delta;
 }
 

Modified: python/branches/py3k/Objects/unicodeobject.c
==============================================================================
--- python/branches/py3k/Objects/unicodeobject.c	(original)
+++ python/branches/py3k/Objects/unicodeobject.c	Wed Aug 11 19:31:17 2010
@@ -755,15 +755,7 @@
     char fmt[61]; /* should be enough for %0width.precisionlld */
     const char *copy;
 
-#ifdef VA_LIST_IS_ARRAY
-    Py_MEMCPY(count, vargs, sizeof(va_list));
-#else
-#ifdef  __va_copy
-    __va_copy(count, vargs);
-#else
-    count = vargs;
-#endif
-#endif
+    Py_VA_COPY(count, vargs); 
     /* step 1: count the number of %S/%R/%A/%s format specifications
      * (we call PyObject_Str()/PyObject_Repr()/PyObject_ASCII()/
      * PyUnicode_DecodeUTF8() for these objects once during step 3 and put the

Modified: python/branches/py3k/Python/getargs.c
==============================================================================
--- python/branches/py3k/Python/getargs.c	(original)
+++ python/branches/py3k/Python/getargs.c	Wed Aug 11 19:31:17 2010
@@ -105,15 +105,7 @@
 {
     va_list lva;
 
-#ifdef VA_LIST_IS_ARRAY
-    memcpy(lva, va, sizeof(va_list));
-#else
-#ifdef __va_copy
-    __va_copy(lva, va);
-#else
-    lva = va;
-#endif
-#endif
+        Py_VA_COPY(lva, va);
 
     return vgetargs1(args, format, &lva, 0);
 }
@@ -123,15 +115,7 @@
 {
     va_list lva;
 
-#ifdef VA_LIST_IS_ARRAY
-    memcpy(lva, va, sizeof(va_list));
-#else
-#ifdef __va_copy
-    __va_copy(lva, va);
-#else
-    lva = va;
-#endif
-#endif
+        Py_VA_COPY(lva, va);
 
     return vgetargs1(args, format, &lva, FLAG_SIZE_T);
 }
@@ -1376,15 +1360,7 @@
         return 0;
     }
 
-#ifdef VA_LIST_IS_ARRAY
-    memcpy(lva, va, sizeof(va_list));
-#else
-#ifdef __va_copy
-    __va_copy(lva, va);
-#else
-    lva = va;
-#endif
-#endif
+        Py_VA_COPY(lva, va);
 
     retval = vgetargskeywords(args, keywords, format, kwlist, &lva, 0);
     return retval;
@@ -1408,15 +1384,7 @@
         return 0;
     }
 
-#ifdef VA_LIST_IS_ARRAY
-    memcpy(lva, va, sizeof(va_list));
-#else
-#ifdef __va_copy
-    __va_copy(lva, va);
-#else
-    lva = va;
-#endif
-#endif
+        Py_VA_COPY(lva, va);
 
     retval = vgetargskeywords(args, keywords, format,
                               kwlist, &lva, FLAG_SIZE_T);

Modified: python/branches/py3k/Python/modsupport.c
==============================================================================
--- python/branches/py3k/Python/modsupport.c	(original)
+++ python/branches/py3k/Python/modsupport.c	Wed Aug 11 19:31:17 2010
@@ -456,15 +456,7 @@
     int n = countformat(f, '\0');
     va_list lva;
 
-#ifdef VA_LIST_IS_ARRAY
-    memcpy(lva, va, sizeof(va_list));
-#else
-#ifdef __va_copy
-    __va_copy(lva, va);
-#else
-    lva = va;
-#endif
-#endif
+        Py_VA_COPY(lva, va);
 
     if (n < 0)
         return NULL;


More information about the Python-checkins mailing list