annotate Include/code.h @ 66978:aed2bbafa550 3.1

Blocked revisions 87324 via svnmerge ........ r87324 | r.david.murray | 2010-12-16 14:08:51 -0500 (Thu, 16 Dec 2010) | 9 lines #10719: restore messages generated on invalid compileall args Before the introduction of filename arguments to compileall it gave semi useful messages about not being able to 'list' names that weren't valid directories. This fix restores that behavior. In addition to the test for this case, the patch also adds a test for the default behavior of compileall when no arguments are provided, and fixes a bug in one of the previously added tests. ........
author R. David Murray <rdmurray@bitdance.com>
date Thu, 16 Dec 2010 19:10:16 +0000
parents 65e41bcbc25d
children 3c9232a684ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
1 /* Definitions for bytecode */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
2
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
3 #ifndef Py_CODE_H
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
4 #define Py_CODE_H
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
5 #ifdef __cplusplus
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
6 extern "C" {
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
7 #endif
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
8
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
9 /* Bytecode object */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
10 typedef struct {
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
11 PyObject_HEAD
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
12 int co_argcount; /* #arguments, except *args */
40215
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 39610
diff changeset
13 int co_kwonlyargcount; /* #keyword only arguments */
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
14 int co_nlocals; /* #local variables */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
15 int co_stacksize; /* #entries needed for evaluation stack */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
16 int co_flags; /* CO_..., see below */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
17 PyObject *co_code; /* instruction opcodes */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
18 PyObject *co_consts; /* list (constants used) */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
19 PyObject *co_names; /* list of strings (names used) */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
20 PyObject *co_varnames; /* tuple of strings (local variable names) */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
21 PyObject *co_freevars; /* tuple of strings (free variable names) */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
22 PyObject *co_cellvars; /* tuple of strings (cell variable names) */
51248
410dfd423ef1 Merged revisions 69188 via svnmerge from
Mark Dickinson <dickinsm@gmail.com>
parents: 46885
diff changeset
23 /* The rest doesn't count for hash or comparisons */
43569
19319e70fc3e Patch #1272, by Christian Heimes and Alexandre Vassalotti.
Guido van Rossum <guido@python.org>
parents: 42334
diff changeset
24 PyObject *co_filename; /* unicode (where it was loaded from) */
19319e70fc3e Patch #1272, by Christian Heimes and Alexandre Vassalotti.
Guido van Rossum <guido@python.org>
parents: 42334
diff changeset
25 PyObject *co_name; /* unicode (name, for reference) */
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
26 int co_firstlineno; /* first source line number */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
27 PyObject *co_lnotab; /* string (encoding addr<->lineno mapping) */
38453
29ae5e0fc348 Much-needed merge (using svnmerge.py this time) of trunk changes into p3yk.
Thomas Wouters <thomas@python.org>
parents: 37879
diff changeset
28 void *co_zombieframe; /* for optimization only (see frameobject.c) */
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
29 } PyCodeObject;
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
30
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
31 /* Masks for co_flags above */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
32 #define CO_OPTIMIZED 0x0001
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
33 #define CO_NEWLOCALS 0x0002
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
34 #define CO_VARARGS 0x0004
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
35 #define CO_VARKEYWORDS 0x0008
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
36 #define CO_NESTED 0x0010
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
37 #define CO_GENERATOR 0x0020
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
38 /* The CO_NOFREE flag is set if there are no free or cell variables.
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
39 This information is redundant, but it allows a single flag test
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
40 to determine whether there is any extra work to be done when the
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
41 call frame it setup.
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
42 */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
43 #define CO_NOFREE 0x0040
36602
9c0fd586475c Generators have been permanent for a while. This comment is no longer applicable.
Neal Norwitz <nnorwitz@gmail.com>
parents: 35744
diff changeset
44
55062
65e41bcbc25d Merged revisions 73782-73784 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 52641
diff changeset
45 /* These are no longer used. */
36654
6b42920accc9 Per discussion on python-dev, remove CO_GENERATOR_ALLOWED. Leave comment about not removing yet.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36602
diff changeset
46 #if 0
6b42920accc9 Per discussion on python-dev, remove CO_GENERATOR_ALLOWED. Leave comment about not removing yet.
Neal Norwitz <nnorwitz@gmail.com>
parents: 36602
diff changeset
47 #define CO_GENERATOR_ALLOWED 0x1000
55062
65e41bcbc25d Merged revisions 73782-73784 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 52641
diff changeset
48 #endif
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
49 #define CO_FUTURE_DIVISION 0x2000
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
50 #define CO_FUTURE_ABSOLUTE_IMPORT 0x4000 /* do absolute imports by default */
36726
bbf16fd024df from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents: 36712
diff changeset
51 #define CO_FUTURE_WITH_STATEMENT 0x8000
45965
91ac8049e709 Add __future__ import for print_function. It's a no-op in 3.0, but it needs to not be a syntax error.
Eric Smith <eric@trueblade.com>
parents: 44351
diff changeset
52 #define CO_FUTURE_PRINT_FUNCTION 0x10000
46120
78504d604b44 Merged revisions 61952-61953 via svnmerge from
Christian Heimes <christian@cheimes.de>
parents: 45965
diff changeset
53 #define CO_FUTURE_UNICODE_LITERALS 0x20000
36726
bbf16fd024df from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents: 36712
diff changeset
54
52641
0530aadff696 The BDFL has retired! Long live the FLUFL (Friendly Language Uncle For Life)!
Brett Cannon <bcannon@gmail.com>
parents: 51248
diff changeset
55 #define CO_FUTURE_BARRY_AS_BDFL 0x40000
0530aadff696 The BDFL has retired! Long live the FLUFL (Friendly Language Uncle For Life)!
Brett Cannon <bcannon@gmail.com>
parents: 51248
diff changeset
56
36726
bbf16fd024df from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents: 36712
diff changeset
57 /* This should be defined if a future statement modifies the syntax.
bbf16fd024df from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents: 36712
diff changeset
58 For example, when a keyword is added.
bbf16fd024df from __future__ import with_statement addon for 'with', mostly written by
Thomas Wouters <thomas@python.org>
parents: 36712
diff changeset
59 */
52641
0530aadff696 The BDFL has retired! Long live the FLUFL (Friendly Language Uncle For Life)!
Brett Cannon <bcannon@gmail.com>
parents: 51248
diff changeset
60 #define PY_PARSER_REQUIRES_FUTURE_KEYWORD
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
61
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
62 #define CO_MAXBLOCKS 20 /* Max static block nesting within a function */
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
63
35744
e7815495bb27 Use the newer names for APIs after the AST merge
Neal Norwitz <nnorwitz@gmail.com>
parents: 35742
diff changeset
64 PyAPI_DATA(PyTypeObject) PyCode_Type;
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
65
44351
86a2679dca46 #1629: Renamed Py_Size, Py_Type and Py_Refcnt to Py_SIZE, Py_TYPE and Py_REFCNT.
Christian Heimes <christian@cheimes.de>
parents: 43569
diff changeset
66 #define PyCode_Check(op) (Py_TYPE(op) == &PyCode_Type)
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
67 #define PyCode_GetNumFree(op) (PyTuple_GET_SIZE((op)->co_freevars))
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
68
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
69 /* Public interface */
35744
e7815495bb27 Use the newer names for APIs after the AST merge
Neal Norwitz <nnorwitz@gmail.com>
parents: 35742
diff changeset
70 PyAPI_FUNC(PyCodeObject *) PyCode_New(
40215
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 39610
diff changeset
71 int, int, int, int, int, PyObject *, PyObject *,
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 39610
diff changeset
72 PyObject *, PyObject *, PyObject *, PyObject *,
1cce0526d9b0 Jiwon Seo's PEP 3102 implementation.
Guido van Rossum <guido@python.org>
parents: 39610
diff changeset
73 PyObject *, PyObject *, int, PyObject *);
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
74 /* same as struct above */
35744
e7815495bb27 Use the newer names for APIs after the AST merge
Neal Norwitz <nnorwitz@gmail.com>
parents: 35742
diff changeset
75 PyAPI_FUNC(int) PyCode_Addr2Line(PyCodeObject *, int);
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
76
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
77 /* for internal use only */
37879
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
78 typedef struct _addr_pair {
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
79 int ap_lower;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
80 int ap_upper;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
81 } PyAddrPair;
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
82
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
83 /* Check whether lasti (an instruction offset) falls outside bounds
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
84 and whether it is a line number that should be traced. Returns
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
85 a line number if it should be traced or -1 if the line should not.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
86
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
87 If lasti is not within bounds, updates bounds.
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
88 */
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
89
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
90 PyAPI_FUNC(int) PyCode_CheckLineNumber(PyCodeObject* co,
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
91 int lasti, PyAddrPair *bounds);
f731859e9b3b Merge p3yk branch with the trunk up to revision 45595. This breaks a fair
Thomas Wouters <thomas@python.org>
parents: 36988
diff changeset
92
39610
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
93 PyAPI_FUNC(PyObject*) PyCode_Optimize(PyObject *code, PyObject* consts,
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
94 PyObject *names, PyObject *lineno_obj);
3674f20ac781 Merge current trunk into p3yk. This includes the PyNumber_Index API change,
Thomas Wouters <thomas@python.org>
parents: 38453
diff changeset
95
35742
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
96 #ifdef __cplusplus
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
97 }
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
98 #endif
1c4d192f1568 Merge ast-branch to head
Jeremy Hylton <jeremy@alum.mit.edu>
parents:
diff changeset
99 #endif /* !Py_CODE_H */