File: issue1113244.diff

package info (click to toggle)
python2.6 2.6.6-8%2Bdeb6u3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze-lts
  • size: 65,368 kB
  • ctags: 106,965
  • sloc: ansic: 389,033; python: 375,783; asm: 9,734; sh: 4,934; makefile: 4,120; lisp: 2,933; objc: 775; xml: 62
file content (57 lines) | stat: -rw-r--r-- 2,312 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# DP: Issue #1113244: Py_XINCREF, Py_DECREF, Py_XDECREF:
# DP: Add `do { ... } while (0)' to avoid compiler warnings.

Index: python2.6-2.6.5+20100521/Include/object.h
===================================================================
--- python2.6-2.6.5+20100521.orig/Include/object.h	2010-05-21 15:54:04.071725596 +0200
+++ python2.6-2.6.5+20100521/Include/object.h	2010-05-21 15:59:45.292709562 +0200
@@ -746,11 +746,13 @@
     ((PyObject*)(op))->ob_refcnt++)
 
 #define Py_DECREF(op)                                   \
-    if (_Py_DEC_REFTOTAL  _Py_REF_DEBUG_COMMA           \
-        --((PyObject*)(op))->ob_refcnt != 0)                    \
-        _Py_CHECK_REFCNT(op)                            \
-    else                                                \
-        _Py_Dealloc((PyObject *)(op))
+    do {						\
+        if (_Py_DEC_REFTOTAL  _Py_REF_DEBUG_COMMA	\
+	    --((PyObject*)(op))->ob_refcnt != 0)	\
+	    _Py_CHECK_REFCNT(op)			\
+	else						\
+	    _Py_Dealloc((PyObject *)(op));		\
+    } while (0)
 
 /* Safely decref `op` and set `op` to NULL, especially useful in tp_clear
  * and tp_dealloc implementatons.
@@ -796,8 +798,8 @@
     } while (0)
 
 /* Macros to use in case the object pointer may be NULL: */
-#define Py_XINCREF(op) if ((op) == NULL) ; else Py_INCREF(op)
-#define Py_XDECREF(op) if ((op) == NULL) ; else Py_DECREF(op)
+#define Py_XINCREF(op) do { if ((op) == NULL) ; else Py_INCREF(op); } while (0)
+#define Py_XDECREF(op) do { if ((op) == NULL) ; else Py_DECREF(op); } while (0)
 
 /*
 These are provided as conveniences to Python runtime embedders, so that
Index: python2.6-2.6.5+20100521/Modules/readline.c
===================================================================
--- python2.6-2.6.5+20100521.orig/Modules/readline.c	2010-05-21 15:54:04.103742027 +0200
+++ python2.6-2.6.5+20100521/Modules/readline.c	2010-05-21 15:56:38.343710232 +0200
@@ -738,13 +738,13 @@
     r = PyObject_CallFunction(completion_display_matches_hook,
                               "sOi", matches[0], m, max_length);
 
-    Py_DECREF(m), m=NULL;
+    Py_DECREF(m); m=NULL;
 
     if (r == NULL ||
         (r != Py_None && PyInt_AsLong(r) == -1 && PyErr_Occurred())) {
         goto error;
     }
-    Py_XDECREF(r), r=NULL;
+    Py_XDECREF(r); r=NULL;
 
     if (0) {
     error: