Mercurial > cpython-lru_cache-weakref
annotate Python/symtable.c @ 31058:bf7df48012cb 2.3
Py_Finalize(): disabled the second call of cyclic gc, and added extensive
comments about why both calls to cyclic gc here can cause problems.
Already fixed on the trunk. Since the calls were introduced in 2.3,
that's the end of it.
| author | Tim Peters <tim.peters@gmail.com> |
|---|---|
| date | Mon, 01 Dec 2003 22:13:12 +0000 |
| parents | 3aaf24b949df |
| children | 302d399cfd37 |
| rev | line source |
|---|---|
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
1 #include "Python.h" |
|
16799
08d937107fe6
Improved __future__ parser; still more to do
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16781
diff
changeset
|
2 #include "compile.h" |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
3 #include "symtable.h" |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
4 #include "graminit.h" |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
5 #include "structmember.h" |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
6 |
|
21325
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
7 /* The compiler uses this function to load a PySymtableEntry object |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
8 for a code block. Each block is loaded twice, once during the |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
9 symbol table pass and once during the code gen pass. Entries |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
10 created during the first pass are cached for the second pass, using |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
11 the st_symbols dictionary. |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
12 |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
13 The cache is keyed by st_nscopes. Each code block node in a |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
14 module's parse tree can be assigned a unique id based on the order |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
15 in which the nodes are visited by the compiler. This strategy |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
16 works so long as the symbol table and codegen passes visit the same |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
17 nodes in the same order. |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
18 */ |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
19 |
|
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
20 |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
21 PyObject * |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
22 PySymtableEntry_New(struct symtable *st, char *name, int type, int lineno) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
23 { |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
24 PySymtableEntryObject *ste = NULL; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
25 PyObject *k, *v; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
26 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
27 k = PyInt_FromLong(st->st_nscopes++); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
28 if (k == NULL) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
29 goto fail; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
30 v = PyDict_GetItem(st->st_symbols, k); |
|
21325
8a26bb369f53
Add a comment explaining the st_symbols cache.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21314
diff
changeset
|
31 if (v) { |
|
21314
4d5098cfa781
PySymtableEntry_New(): I'm not sure what this routine is doing, but it
Tim Peters <tim.peters@gmail.com>
parents:
21179
diff
changeset
|
32 Py_DECREF(k); |
|
16753
51977af230fa
Fix for bug 133489: compiler leaks memory
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16539
diff
changeset
|
33 Py_INCREF(v); |
|
51977af230fa
Fix for bug 133489: compiler leaks memory
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16539
diff
changeset
|
34 return v; |
|
51977af230fa
Fix for bug 133489: compiler leaks memory
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16539
diff
changeset
|
35 } |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
36 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
37 ste = (PySymtableEntryObject *)PyObject_New(PySymtableEntryObject, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
38 &PySymtableEntry_Type); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
39 ste->ste_table = st; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
40 ste->ste_id = k; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
41 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
42 v = PyString_FromString(name); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
43 if (v == NULL) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
44 goto fail; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
45 ste->ste_name = v; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
46 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
47 v = PyDict_New(); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
48 if (v == NULL) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
49 goto fail; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
50 ste->ste_symbols = v; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
51 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
52 v = PyList_New(0); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
53 if (v == NULL) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
54 goto fail; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
55 ste->ste_varnames = v; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
56 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
57 v = PyList_New(0); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
58 if (v == NULL) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
59 goto fail; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
60 ste->ste_children = v; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
61 |
|
16781
5a1230de436a
Preliminary support for future nested scopes
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16753
diff
changeset
|
62 ste->ste_optimized = 0; |
|
21179
485422900ef0
SF bug #488687 reported by Neal Norwitz
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21090
diff
changeset
|
63 ste->ste_opt_lineno = 0; |
|
29226
3aaf24b949df
Backport fix for SF bug 734869 and sundry compiler cleanups.
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
21325
diff
changeset
|
64 ste->ste_tmpname = 0; |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
65 ste->ste_lineno = lineno; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
66 switch (type) { |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
67 case funcdef: |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
68 case lambdef: |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
69 ste->ste_type = TYPE_FUNCTION; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
70 break; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
71 case classdef: |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
72 ste->ste_type = TYPE_CLASS; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
73 break; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
74 case single_input: |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
75 case eval_input: |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
76 case file_input: |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
77 ste->ste_type = TYPE_MODULE; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
78 break; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
79 } |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
80 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
81 if (st->st_cur == NULL) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
82 ste->ste_nested = 0; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
83 else if (st->st_cur->ste_nested |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
84 || st->st_cur->ste_type == TYPE_FUNCTION) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
85 ste->ste_nested = 1; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
86 else |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
87 ste->ste_nested = 0; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
88 ste->ste_child_free = 0; |
|
18148
7bc473b2c654
Merging the gen-branch into the main line, at Guido's direction. Yay!
Tim Peters <tim.peters@gmail.com>
parents:
16799
diff
changeset
|
89 ste->ste_generator = 0; |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
90 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
91 if (PyDict_SetItem(st->st_symbols, ste->ste_id, (PyObject *)ste) < 0) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
92 goto fail; |
|
16753
51977af230fa
Fix for bug 133489: compiler leaks memory
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
16539
diff
changeset
|
93 |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
94 return (PyObject *)ste; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
95 fail: |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
96 Py_XDECREF(ste); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
97 return NULL; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
98 } |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
99 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
100 static PyObject * |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
101 ste_repr(PySymtableEntryObject *ste) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
102 { |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
103 char buf[256]; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
104 |
|
21090
5e25c669741c
ste_repr(): Conversion of sprintf() to PyOS_snprintf() for buffer
Barry Warsaw <barry@python.org>
parents:
20012
diff
changeset
|
105 PyOS_snprintf(buf, sizeof(buf), |
|
5e25c669741c
ste_repr(): Conversion of sprintf() to PyOS_snprintf() for buffer
Barry Warsaw <barry@python.org>
parents:
20012
diff
changeset
|
106 "<symtable entry %.100s(%ld), line %d>", |
|
5e25c669741c
ste_repr(): Conversion of sprintf() to PyOS_snprintf() for buffer
Barry Warsaw <barry@python.org>
parents:
20012
diff
changeset
|
107 PyString_AS_STRING(ste->ste_name), |
|
5e25c669741c
ste_repr(): Conversion of sprintf() to PyOS_snprintf() for buffer
Barry Warsaw <barry@python.org>
parents:
20012
diff
changeset
|
108 PyInt_AS_LONG(ste->ste_id), |
|
5e25c669741c
ste_repr(): Conversion of sprintf() to PyOS_snprintf() for buffer
Barry Warsaw <barry@python.org>
parents:
20012
diff
changeset
|
109 ste->ste_lineno); |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
110 return PyString_FromString(buf); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
111 } |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
112 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
113 static void |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
114 ste_dealloc(PySymtableEntryObject *ste) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
115 { |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
116 ste->ste_table = NULL; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
117 Py_XDECREF(ste->ste_id); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
118 Py_XDECREF(ste->ste_name); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
119 Py_XDECREF(ste->ste_symbols); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
120 Py_XDECREF(ste->ste_varnames); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
121 Py_XDECREF(ste->ste_children); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
122 PyObject_Del(ste); |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
123 } |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
124 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
125 #define OFF(x) offsetof(PySymtableEntryObject, x) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
126 |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
127 static PyMemberDef ste_memberlist[] = { |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
128 {"id", T_OBJECT, OFF(ste_id), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
129 {"name", T_OBJECT, OFF(ste_name), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
130 {"symbols", T_OBJECT, OFF(ste_symbols), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
131 {"varnames", T_OBJECT, OFF(ste_varnames), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
132 {"children", T_OBJECT, OFF(ste_children), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
133 {"type", T_INT, OFF(ste_type), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
134 {"lineno", T_INT, OFF(ste_lineno), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
135 {"optimized",T_INT, OFF(ste_optimized), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
136 {"nested", T_INT, OFF(ste_nested), READONLY}, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
137 {NULL} |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
138 }; |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
139 |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
140 PyTypeObject PySymtableEntry_Type = { |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
141 PyObject_HEAD_INIT(&PyType_Type) |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
142 0, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
143 "symtable entry", |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
144 sizeof(PySymtableEntryObject), |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
145 0, |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
146 (destructor)ste_dealloc, /* tp_dealloc */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
147 0, /* tp_print */ |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
148 0, /* tp_getattr */ |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
149 0, /* tp_setattr */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
150 0, /* tp_compare */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
151 (reprfunc)ste_repr, /* tp_repr */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
152 0, /* tp_as_number */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
153 0, /* tp_as_sequence */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
154 0, /* tp_as_mapping */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
155 0, /* tp_hash */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
156 0, /* tp_call */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
157 0, /* tp_str */ |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
158 PyObject_GenericGetAttr, /* tp_getattro */ |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
159 0, /* tp_setattro */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
160 0, /* tp_as_buffer */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
161 Py_TPFLAGS_DEFAULT, /* tp_flags */ |
|
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
162 0, /* tp_doc */ |
|
20012
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
163 0, /* tp_traverse */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
164 0, /* tp_clear */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
165 0, /* tp_richcompare */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
166 0, /* tp_weaklistoffset */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
167 0, /* tp_iter */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
168 0, /* tp_iternext */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
169 0, /* tp_methods */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
170 ste_memberlist, /* tp_members */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
171 0, /* tp_getset */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
172 0, /* tp_base */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
173 0, /* tp_dict */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
174 0, /* tp_descr_get */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
175 0, /* tp_descr_set */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
176 0, /* tp_dictoffset */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
177 0, /* tp_init */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
178 0, /* tp_alloc */ |
|
3faabf54b8b8
Add optional docstrings to member descriptors. For backwards
Guido van Rossum <guido@python.org>
parents:
18148
diff
changeset
|
179 0, /* tp_new */ |
|
16539
a47d93ef103a
Relax the rules for using 'from ... import *' and exec in the presence
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff
changeset
|
180 }; |
