##// END OF EJS Templates
dirs: port PyInt code to work on Python 3...
Gregory Szorc -
r30106:cb304874 default
parent child Browse files
Show More
@@ -11,6 +11,12 b''
11 11 #include <Python.h>
12 12 #include "util.h"
13 13
14 #ifdef IS_PY3K
15 #define PYLONG_VALUE(o) ((PyLongObject *)o)->ob_digit[1]
16 #else
17 #define PYLONG_VALUE(o) PyInt_AS_LONG(o)
18 #endif
19
14 20 /*
15 21 * This is a multiset of directory names, built from the files that
16 22 * appear in a dirstate or manifest.
@@ -66,17 +72,21 b' static int _addpath(PyObject *dirs, PyOb'
66 72
67 73 val = PyDict_GetItem(dirs, key);
68 74 if (val != NULL) {
69 PyInt_AS_LONG(val) += 1;
75 PYLONG_VALUE(val) += 1;
70 76 break;
71 77 }
72 78
73 79 /* Force Python to not reuse a small shared int. */
80 #ifdef IS_PY3K
81 val = PyLong_FromLong(0x1eadbeef);
82 #else
74 83 val = PyInt_FromLong(0x1eadbeef);
84 #endif
75 85
76 86 if (val == NULL)
77 87 goto bail;
78 88
79 PyInt_AS_LONG(val) = 1;
89 PYLONG_VALUE(val) = 1;
80 90 ret = PyDict_SetItem(dirs, key, val);
81 91 Py_DECREF(val);
82 92 if (ret == -1)
@@ -113,7 +123,7 b' static int _delpath(PyObject *dirs, PyOb'
113 123 goto bail;
114 124 }
115 125
116 if (--PyInt_AS_LONG(val) <= 0) {
126 if (--PYLONG_VALUE(val) <= 0) {
117 127 if (PyDict_DelItem(dirs, key) == -1)
118 128 goto bail;
119 129 } else
General Comments 0
You need to be logged in to leave comments. Login now