LEFT | RIGHT |
(no file at all) | |
1 #include "Python.h" | 1 #include "Python.h" |
2 | 2 |
3 #include "code.h" | 3 #include "code.h" |
4 #include "Python-ast.h" | 4 #include "Python-ast.h" |
5 #include "symtable.h" | 5 #include "symtable.h" |
6 | 6 |
7 static PyObject * | 7 static PyObject * |
8 symtable_symtable(PyObject *self, PyObject *args) | 8 symtable_symtable(PyObject *self, PyObject *args) |
9 { | 9 { |
10 struct symtable *st; | 10 struct symtable *st; |
11 PyObject *t; | 11 PyObject *t; |
12 | 12 |
13 char *str; | 13 char *str; |
14 char *filename; | 14 PyObject *filename; |
15 char *startstr; | 15 char *startstr; |
16 int start; | 16 int start; |
17 | 17 |
18 if (!PyArg_ParseTuple(args, "sss:symtable", &str, &filename, | 18 if (!PyArg_ParseTuple(args, "sO&s:symtable", |
19 &startstr)) | 19 &str, PyUnicode_FSDecoder, &filename, &startstr)) |
20 return NULL; | 20 return NULL; |
21 if (strcmp(startstr, "exec") == 0) | 21 if (strcmp(startstr, "exec") == 0) |
22 start = Py_file_input; | 22 start = Py_file_input; |
23 else if (strcmp(startstr, "eval") == 0) | 23 else if (strcmp(startstr, "eval") == 0) |
24 start = Py_eval_input; | 24 start = Py_eval_input; |
25 else if (strcmp(startstr, "single") == 0) | 25 else if (strcmp(startstr, "single") == 0) |
26 start = Py_single_input; | 26 start = Py_single_input; |
27 else { | 27 else { |
28 PyErr_SetString(PyExc_ValueError, | 28 PyErr_SetString(PyExc_ValueError, |
29 "symtable() arg 3 must be 'exec' or 'eval' or 'single'"); | 29 "symtable() arg 3 must be 'exec' or 'eval' or 'single'"); |
| 30 Py_DECREF(filename); |
30 return NULL; | 31 return NULL; |
31 } | 32 } |
32 st = Py_SymtableString(str, filename, start); | 33 st = Py_SymtableStringObject(str, filename, start); |
| 34 Py_DECREF(filename); |
33 if (st == NULL) | 35 if (st == NULL) |
34 return NULL; | 36 return NULL; |
35 t = st->st_blocks; | 37 t = st->st_blocks; |
36 Py_INCREF(t); | 38 Py_INCREF(t); |
37 PyMem_Free((void *)st->st_future); | 39 PyMem_Free((void *)st->st_future); |
38 PySymtable_Free(st); | 40 PySymtable_Free(st); |
39 return t; | 41 return t; |
40 } | 42 } |
41 | 43 |
42 static PyMethodDef symtable_methods[] = { | 44 static PyMethodDef symtable_methods[] = { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 | 95 |
94 PyModule_AddIntConstant(m, "SCOPE_OFF", SCOPE_OFFSET); | 96 PyModule_AddIntConstant(m, "SCOPE_OFF", SCOPE_OFFSET); |
95 PyModule_AddIntMacro(m, SCOPE_MASK); | 97 PyModule_AddIntMacro(m, SCOPE_MASK); |
96 | 98 |
97 if (PyErr_Occurred()) { | 99 if (PyErr_Occurred()) { |
98 Py_DECREF(m); | 100 Py_DECREF(m); |
99 m = 0; | 101 m = 0; |
100 } | 102 } |
101 return m; | 103 return m; |
102 } | 104 } |
LEFT | RIGHT |