comparison Python/traceback.c @ 86999:01c4a0af73cf

Issue #19512, #19515: remove shared identifiers, move identifiers where they are used. Move also _Py_IDENTIFIER() defintions to the top in modified files to remove identifiers duplicated in the same file.
author Victor Stinner <victor.stinner@gmail.com>
date Thu, 07 Nov 2013 23:07:29 +0100
parents 954167ce92a3
children
comparison
equal deleted inserted replaced
86998:23f0529a8b2f 86999:01c4a0af73cf
18 #define MAX_FRAME_DEPTH 100 18 #define MAX_FRAME_DEPTH 100
19 #define MAX_NTHREADS 100 19 #define MAX_NTHREADS 100
20 20
21 /* Function from Parser/tokenizer.c */ 21 /* Function from Parser/tokenizer.c */
22 extern char * PyTokenizer_FindEncodingFilename(int, PyObject *); 22 extern char * PyTokenizer_FindEncodingFilename(int, PyObject *);
23
24 _Py_IDENTIFIER(TextIOWrapper);
25 _Py_IDENTIFIER(close);
26 _Py_IDENTIFIER(open);
27 _Py_IDENTIFIER(path);
23 28
24 static PyObject * 29 static PyObject *
25 tb_dir(PyTracebackObject *self) 30 tb_dir(PyTracebackObject *self)
26 { 31 {
27 return Py_BuildValue("[ssss]", "tb_frame", "tb_next", 32 return Py_BuildValue("[ssss]", "tb_frame", "tb_next",
150 const char* tail; 155 const char* tail;
151 PyObject *filebytes; 156 PyObject *filebytes;
152 const char* filepath; 157 const char* filepath;
153 Py_ssize_t len; 158 Py_ssize_t len;
154 PyObject* result; 159 PyObject* result;
155 _Py_IDENTIFIER(open);
156 160
157 filebytes = PyUnicode_EncodeFSDefault(filename); 161 filebytes = PyUnicode_EncodeFSDefault(filename);
158 if (filebytes == NULL) { 162 if (filebytes == NULL) {
159 PyErr_Clear(); 163 PyErr_Clear();
160 return NULL; 164 return NULL;
167 tail = filepath; 171 tail = filepath;
168 else 172 else
169 tail++; 173 tail++;
170 taillen = strlen(tail); 174 taillen = strlen(tail);
171 175
172 syspath = _PySys_GetObjectId(&_PyId_path); 176 syspath = _PySys_GetObjectId(&PyId_path);
173 if (syspath == NULL || !PyList_Check(syspath)) 177 if (syspath == NULL || !PyList_Check(syspath))
174 goto error; 178 goto error;
175 npath = PyList_Size(syspath); 179 npath = PyList_Size(syspath);
176 180
177 for (i = 0; i < npath; i++) { 181 for (i = 0; i < npath; i++) {
230 PyObject *lineobj = NULL; 234 PyObject *lineobj = NULL;
231 PyObject *res; 235 PyObject *res;
232 char buf[MAXPATHLEN+1]; 236 char buf[MAXPATHLEN+1];
233 int kind; 237 int kind;
234 void *data; 238 void *data;
235 _Py_IDENTIFIER(close);
236 _Py_IDENTIFIER(open);
237 _Py_IDENTIFIER(TextIOWrapper);
238 239
239 /* open the file */ 240 /* open the file */
240 if (filename == NULL) 241 if (filename == NULL)
241 return 0; 242 return 0;
242 243