Mercurial > cpython-lru_cache-weakref
annotate Python/ceval.c @ 3294:2bddfb3cfcf1 legacy-trunk
don't return from main loop when error occurs
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Sun, 10 Dec 1995 04:57:42 +0000 |
| parents | d249111d4ccc |
| children | 36920bbd81a8 |
| rev | line source |
|---|---|
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
1 /*********************************************************** |
|
2062
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2052
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
d0d0a69b5ca3
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
2052
diff
changeset
|
3 The Netherlands. |
|
145
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
4 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
5 All Rights Reserved |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
6 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
9 provided that the above copyright notice appear in all copies and that |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
11 supporting documentation, and that the names of Stichting Mathematisch |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
12 Centrum or CWI not be used in advertising or publicity pertaining to |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
13 distribution of the software without specific, written prior permission. |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
14 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
22 |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
23 ******************************************************************/ |
|
853b736a6a9e
Added copyright notice.
Guido van Rossum <guido@python.org>
parents:
119
diff
changeset
|
24 |
| 86 | 25 /* Execute compiled code */ |
| 69 | 26 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
27 /* XXX TO DO: |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
28 XXX how to pass arguments to call_trace? |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
29 XXX access stuff can probably dereference NULL locals? |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
30 XXX need to extend apply() to be able to pass keyword args |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
31 XXX need to be able to call built-in functions with keyword args |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
32 XXX speed up searching for keywords by using a dictionary |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
33 XXX unknown keyword shouldn't raise KeyError? |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
34 XXX document it! |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
35 */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
36 |
| 86 | 37 #include "allobjects.h" |
| 38 | |
| 69 | 39 #include "import.h" |
| 40 #include "sysmodule.h" | |
|
2128
92da8901517e
use getbuiltins() everywhere, it defaults to getbuiltidict()
Guido van Rossum <guido@python.org>
parents:
2098
diff
changeset
|
41 #include "bltinmodule.h" |
| 69 | 42 #include "compile.h" |
| 86 | 43 #include "frameobject.h" |
| 926 | 44 #include "eval.h" |
| 86 | 45 #include "ceval.h" |
| 69 | 46 #include "opcode.h" |
| 86 | 47 #include "traceback.h" |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
48 #include "graminit.h" |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
49 #include "pythonrun.h" |
| 69 | 50 |
|
1400
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
51 #include <ctype.h> |
|
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
52 |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
53 extern int suppress_print; /* Declared in pythonrun.c, set in pythonmain.c */ |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
54 |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
55 /* Turn this on if your compiler chokes on the big switch: */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
56 /* #define CASE_TOO_BIG 1 */ |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
57 |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
58 /* Turn this on if you want to debug the interpreter: */ |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
59 /* (This can be on even if NDEBUG is defined) */ |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
60 /* #define DEBUG 1 */ |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
61 |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
62 #if defined(DEBUG) || !defined(NDEBUG) |
| 567 | 63 /* For debugging the interpreter: */ |
| 64 #define LLTRACE 1 /* Low-level trace feature */ | |
| 65 #define CHECKEXC 1 /* Double-check exception checking */ | |
| 69 | 66 #endif |
| 67 | |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
68 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
69 /* Forward declarations */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
70 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
71 static object *eval_code2 PROTO((codeobject *, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
72 object *, object *, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
73 object **, int, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
74 object **, int, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
75 object **, int, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
76 object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
77 #ifdef LLTRACE |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
78 static int prtrace PROTO((object *, char *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
79 #endif |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
80 static void call_exc_trace PROTO((object **, object**, frameobject *)); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
81 static int call_trace |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
82 PROTO((object **, object **, frameobject *, char *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
83 static object *add PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
84 static object *sub PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
85 static object *mul PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
86 static object *divide PROTO((object *, object *)); |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
87 static object *mod PROTO((object *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
88 static object *neg PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
89 static object *pos PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
90 static object *not PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
91 static object *invert PROTO((object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
92 static object *lshift PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
93 static object *rshift PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
94 static object *and PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
95 static object *xor PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
96 static object *or PROTO((object *, object *)); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
97 static object *call_builtin PROTO((object *, object *, object *)); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
98 static object *call_function PROTO((object *, object *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
99 static object *apply_subscript PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
100 static object *loop_subscript PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
101 static int slice_index PROTO((object *, int, int *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
102 static object *apply_slice PROTO((object *, object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
103 static int assign_subscript PROTO((object *, object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
104 static int assign_slice PROTO((object *, object *, object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
105 static int cmp_exception PROTO((object *, object *)); |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
106 static int cmp_member PROTO((object *, object *)); |
|
802
3d6541a2eca5
Arg of cmp_outcome becomes an int for portability to the Mac
Guido van Rossum <guido@python.org>
parents:
789
diff
changeset
|
107 static object *cmp_outcome PROTO((int, object *, object *)); |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
108 static int import_from PROTO((object *, object *, object *)); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
109 static object *build_class PROTO((object *, object *, object *)); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
110 static int access_statement PROTO((object *, object *, frameobject *)); |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
111 static int exec_statement PROTO((object *, object *, object *)); |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
112 static object *find_from_args PROTO((frameobject *, int)); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
113 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
114 |
|
746
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
115 /* Pointer to current frame, used to link new frames to */ |
|
6c0f16008bd9
lint (added prototypes for all static fns)
Guido van Rossum <guido@python.org>
parents:
708
diff
changeset
|
116 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
117 static frameobject *current_frame; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
118 |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
119 #ifdef WITH_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
120 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
121 #include <errno.h> |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
122 #include "thread.h" |
| 926 | 123 |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
124 static type_lock interpreter_lock = 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
125 static long main_thread = 0; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
126 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
127 void |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
128 init_save_thread() |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
129 { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
130 if (interpreter_lock) |
| 1179 | 131 return; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
132 interpreter_lock = allocate_lock(); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
133 acquire_lock(interpreter_lock, 1); |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
134 main_thread = get_thread_ident(); |
| 926 | 135 } |
| 136 | |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
137 #endif |
| 926 | 138 |
| 139 /* Functions save_thread and restore_thread are always defined so | |
| 140 dynamically loaded modules needn't be compiled separately for use | |
| 141 with and without threads: */ | |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
142 |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
143 object * |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
144 save_thread() |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
145 { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
146 #ifdef WITH_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
147 if (interpreter_lock) { |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
148 object *res; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
149 res = (object *)current_frame; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
150 current_frame = NULL; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
151 release_lock(interpreter_lock); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
152 return res; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
153 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
154 #endif |
|
1271
2919b448e385
* Microscopic corrections to make things compile on the Cray APP.
Guido van Rossum <guido@python.org>
parents:
1263
diff
changeset
|
155 return NULL; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
156 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
157 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
158 void |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
159 restore_thread(x) |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
160 object *x; |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
161 { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
162 #ifdef WITH_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
163 if (interpreter_lock) { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
164 int err; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
165 err = errno; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
166 acquire_lock(interpreter_lock, 1); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
167 errno = err; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
168 current_frame = (frameobject *)x; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
169 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
170 #endif |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
171 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
172 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
173 |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
174 /* Mechanism whereby asynchronously executing callbacks (e.g. UNIX |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
175 signal handlers or Mac I/O completion routines) can schedule calls |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
176 to a function to be called synchronously. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
177 The synchronous function is called with one void* argument. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
178 It should return 0 for success or -1 for failure -- failure should |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
179 be accompanied by an exception. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
180 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
181 If registry succeeds, the registry function returns 0; if it fails |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
182 (e.g. due to too many pending calls) it returns -1 (without setting |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
183 an exception condition). |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
184 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
185 Note that because registry may occur from within signal handlers, |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
186 or other asynchronous events, calling malloc() is unsafe! |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
187 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
188 #ifdef WITH_THREAD |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
189 Any thread can schedule pending calls, but only the main thread |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
190 will execute them. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
191 #endif |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
192 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
193 XXX WARNING! ASYNCHRONOUSLY EXECUTING CODE! |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
194 There are two possible race conditions: |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
195 (1) nested asynchronous registry calls; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
196 (2) registry calls made while pending calls are being processed. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
197 While (1) is very unlikely, (2) is a real possibility. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
198 The current code is safe against (2), but not against (1). |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
199 The safety against (2) is derived from the fact that only one |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
200 thread (the main thread) ever takes things out of the queue. |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
201 */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
202 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
203 #define NPENDINGCALLS 32 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
204 static struct { |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
205 int (*func) PROTO((ANY *)); |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
206 ANY *arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
207 } pendingcalls[NPENDINGCALLS]; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
208 static volatile int pendingfirst = 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
209 static volatile int pendinglast = 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
210 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
211 int |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
212 Py_AddPendingCall(func, arg) |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
213 int (*func) PROTO((ANY *)); |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
214 ANY *arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
215 { |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
216 static int busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
217 int i, j; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
218 /* XXX Begin critical section */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
219 /* XXX If you want this to be safe against nested |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
220 XXX asynchronous calls, you'll have to work harder! */ |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
221 if (busy) |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
222 return -1; |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
223 busy = 1; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
224 i = pendinglast; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
225 j = (i + 1) % NPENDINGCALLS; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
226 if (j == pendingfirst) |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
227 return -1; /* Queue full */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
228 pendingcalls[i].func = func; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
229 pendingcalls[i].arg = arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
230 pendinglast = j; |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
231 busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
232 /* XXX End critical section */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
233 return 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
234 } |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
235 |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
236 int |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
237 Py_MakePendingCalls() |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
238 { |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
239 static int busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
240 #ifdef WITH_THREAD |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
241 if (get_thread_ident() != main_thread) |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
242 return 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
243 #endif |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
244 if (busy) |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
245 return 0; |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
246 busy = 1; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
247 for (;;) { |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
248 int i; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
249 int (*func) PROTO((ANY *)); |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
250 ANY *arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
251 i = pendingfirst; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
252 if (i == pendinglast) |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
253 break; /* Queue empty */ |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
254 func = pendingcalls[i].func; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
255 arg = pendingcalls[i].arg; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
256 pendingfirst = (i + 1) % NPENDINGCALLS; |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
257 if (func(arg) < 0) { |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
258 busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
259 return -1; |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
260 } |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
261 } |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
262 busy = 0; |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
263 return 0; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
264 } |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
265 |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
266 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
267 /* Status code for main loop (reason for stack unwind) */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
268 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
269 enum why_code { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
270 WHY_NOT, /* No error */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
271 WHY_EXCEPTION, /* Exception occurred */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
272 WHY_RERAISE, /* Exception re-raised by 'finally' */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
273 WHY_RETURN, /* 'return' statement */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
274 WHY_BREAK /* 'break' statement */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
275 }; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
276 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
277 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
278 /* Backward compatible interface */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
279 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
280 object * |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
281 eval_code(co, globals, locals) |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
282 codeobject *co; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
283 object *globals; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
284 object *locals; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
285 { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
286 return eval_code2(co, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
287 globals, locals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
288 (object **)NULL, 0, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
289 (object **)NULL, 0, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
290 (object **)NULL, 0, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
291 (object *)NULL); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
292 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
293 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
294 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
295 /* Interpreter main loop */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
296 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
297 static object * |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
298 eval_code2(co, globals, locals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
299 args, argcount, kws, kwcount, defs, defcount, owner) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
300 codeobject *co; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
301 object *globals; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
302 object *locals; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
303 object **args; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
304 int argcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
305 object **kws; /* length: 2*kwcount */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
306 int kwcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
307 object **defs; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
308 int defcount; |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
309 object *owner; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
310 { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
311 register unsigned char *next_instr; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
312 register int opcode; /* Current opcode */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
313 register int oparg; /* Current opcode argument, if any */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
314 register object **stack_pointer; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
315 register enum why_code why; /* Reason for block stack unwind */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
316 register int err; /* Error status -- nonzero if error */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
317 register object *x; /* Result object -- NULL if error */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
318 register object *v; /* Temporary objects popped off stack */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
319 register object *w; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
320 register object *u; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
321 register object *t; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
322 register frameobject *f; /* Current frame */ |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
323 register object **fastlocals; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
324 object *retval; /* Return value */ |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
325 int defmode = 0; /* Default access mode for new variables */ |
| 567 | 326 #ifdef LLTRACE |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
327 int lltrace; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
328 #endif |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
329 #if defined(DEBUG) || defined(LLTRACE) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
330 /* Make it easier to find out where we are with a debugger */ |
|
1016
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
331 char *filename = getstringvalue(co->co_filename); |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
332 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
333 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
334 /* Code access macros */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
335 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
336 #define GETCONST(i) Getconst(f, i) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
337 #define GETNAME(i) Getname(f, i) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
338 #define GETNAMEV(i) Getnamev(f, i) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
339 #define FIRST_INSTR() (GETUSTRINGVALUE(f->f_code->co_code)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
340 #define INSTR_OFFSET() (next_instr - FIRST_INSTR()) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
341 #define NEXTOP() (*next_instr++) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
342 #define NEXTARG() (next_instr += 2, (next_instr[-1]<<8) + next_instr[-2]) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
343 #define JUMPTO(x) (next_instr = FIRST_INSTR() + (x)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
344 #define JUMPBY(x) (next_instr += (x)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
345 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
346 /* Stack manipulation macros */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
347 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
348 #define STACK_LEVEL() (stack_pointer - f->f_valuestack) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
349 #define EMPTY() (STACK_LEVEL() == 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
350 #define TOP() (stack_pointer[-1]) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
351 #define BASIC_PUSH(v) (*stack_pointer++ = (v)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
352 #define BASIC_POP() (*--stack_pointer) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
353 |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
354 #define CHECK_STACK(n) (STACK_LEVEL() + (n) < f->f_nvalues || \ |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
355 (stack_pointer = extend_stack(f, STACK_LEVEL(), n))) |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
356 |
| 567 | 357 #ifdef LLTRACE |
| 358 #define PUSH(v) (BASIC_PUSH(v), lltrace && prtrace(TOP(), "push")) | |
| 359 #define POP() (lltrace && prtrace(TOP(), "pop"), BASIC_POP()) | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
360 #else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
361 #define PUSH(v) BASIC_PUSH(v) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
362 #define POP() BASIC_POP() |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
363 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
364 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
365 /* Local variable macros */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
366 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
367 #define GETLOCAL(i) (fastlocals[i]) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
368 #define SETLOCAL(i, value) do { XDECREF(GETLOCAL(i)); \ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
369 GETLOCAL(i) = value; } while (0) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
370 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
371 if (globals == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
372 err_setstr(SystemError, "eval_code2: NULL globals"); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
373 return NULL; |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
374 } |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
375 |
|
1273
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
376 #ifdef LLTRACE |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
377 lltrace = dictlookup(globals, "__lltrace__") != NULL; |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
378 #endif |
|
69a066b6b1ff
(I suggest a recompile after getting this, the ceval.c bugfix may be crucial!)
Guido van Rossum <guido@python.org>
parents:
1271
diff
changeset
|
379 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
380 f = newframeobject( |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
381 current_frame, /*back*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
382 co, /*code*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
383 globals, /*globals*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
384 locals, /*locals*/ |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
385 owner, /*owner*/ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
386 50, /*nvalues*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
387 20); /*nblocks*/ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
388 if (f == NULL) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
389 return NULL; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
390 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
391 current_frame = f; |
| 567 | 392 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
393 if (co->co_nlocals > 0) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
394 fastlocals = ((listobject *)f->f_fastlocals)->ob_item; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
395 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
396 if (co->co_argcount > 0 || |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
397 co->co_flags & (CO_VARARGS | CO_VARKEYWORDS)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
398 int i; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
399 int n = argcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
400 object *kwdict = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
401 if (co->co_flags & CO_VARKEYWORDS) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
402 kwdict = newmappingobject(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
403 if (kwdict == NULL) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
404 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
405 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
406 if (argcount > co->co_argcount) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
407 if (!(co->co_flags & CO_VARARGS)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
408 err_setstr(TypeError, "too many arguments"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
409 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
410 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
411 n = co->co_argcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
412 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
413 for (i = 0; i < n; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
414 x = args[i]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
415 INCREF(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
416 SETLOCAL(i, x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
417 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
418 if (co->co_flags & CO_VARARGS) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
419 u = newtupleobject(argcount - n); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
420 for (i = n; i < argcount; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
421 x = args[i]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
422 INCREF(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
423 SETTUPLEITEM(u, i-n, x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
424 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
425 SETLOCAL(co->co_argcount, u); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
426 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
427 for (i = 0; i < kwcount; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
428 object *keyword = kws[2*i]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
429 object *value = kws[2*i + 1]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
430 int j; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
431 /* XXX slow -- speed up using dictionary? */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
432 for (j = 0; j < co->co_argcount; j++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
433 object *nm = GETTUPLEITEM(co->co_varnames, j); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
434 if (cmpobject(keyword, nm) == 0) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
435 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
436 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
437 if (j >= co->co_argcount) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
438 if (kwdict == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
439 err_setval(KeyError/*XXX*/, keyword); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
440 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
441 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
442 mappinginsert(kwdict, keyword, value); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
443 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
444 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
445 if (GETLOCAL(j) != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
446 err_setstr(TypeError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
447 "keyword parameter redefined"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
448 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
449 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
450 INCREF(value); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
451 SETLOCAL(j, value); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
452 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
453 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
454 if (argcount < co->co_argcount) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
455 int m = co->co_argcount - defcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
456 for (i = argcount; i < m; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
457 if (GETLOCAL(i) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
458 err_setstr(TypeError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
459 "not enough arguments"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
460 goto fail; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
461 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
462 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
463 if (n > m) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
464 i = n - m; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
465 else |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
466 i = 0; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
467 for (; i < defcount; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
468 if (GETLOCAL(m+i) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
469 object *def = defs[i]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
470 INCREF(def); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
471 SETLOCAL(m+i, def); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
472 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
473 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
474 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
475 if (kwdict != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
476 i = co->co_argcount; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
477 if (co->co_flags & CO_VARARGS) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
478 i++; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
479 SETLOCAL(i, kwdict); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
480 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
481 if (0) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
482 fail: |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
483 XDECREF(kwdict); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
484 goto fail2; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
485 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
486 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
487 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
488 if (argcount > 0 || kwcount > 0) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
489 err_setstr(TypeError, "no arguments expected"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
490 fail2: |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
491 current_frame = f->f_back; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
492 DECREF(f); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
493 return NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
494 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
495 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
496 |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
497 if (sys_trace != NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
498 /* sys_trace, if defined, is a function that will |
| 567 | 499 be called on *every* entry to a code block. |
| 500 Its return value, if not None, is a function that | |
| 501 will be called at the start of each executed line | |
| 502 of code. (Actually, the function must return | |
| 503 itself in order to continue tracing.) | |
| 504 The trace functions are called with three arguments: | |
| 505 a pointer to the current frame, a string indicating | |
| 506 why the function is called, and an argument which | |
| 507 depends on the situation. The global trace function | |
| 508 (sys.trace) is also called whenever an exception | |
| 509 is detected. */ | |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
510 if (call_trace(&sys_trace, &f->f_trace, f, "call", |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
511 None/*XXX how to compute arguments now?*/)) { |
| 567 | 512 /* Trace function raised an error */ |
| 513 current_frame = f->f_back; | |
| 514 DECREF(f); | |
| 515 return NULL; | |
| 516 } | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
517 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
518 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
519 if (sys_profile != NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
520 /* Similar for sys_profile, except it needn't return |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
521 itself and isn't called for "line" events */ |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
522 if (call_trace(&sys_profile, (object**)0, f, "call", |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
523 None/*XXX*/)) { |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
524 current_frame = f->f_back; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
525 DECREF(f); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
526 return NULL; |
| 567 | 527 } |
| 528 } | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
529 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
530 next_instr = GETUSTRINGVALUE(f->f_code->co_code); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
531 stack_pointer = f->f_valuestack; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
532 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
533 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
534 err = 0; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
535 x = None; /* Not a reference, just anything non-NULL */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
536 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
537 for (;;) { |
|
237
16f467717d7a
Declare ticker as int; made testbool generic for all numeric types
Guido van Rossum <guido@python.org>
parents:
224
diff
changeset
|
538 static int ticker; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
539 |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
540 /* Do periodic things. |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
541 Doing this every time through the loop would add |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
542 too much overhead (a function call per instruction). |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
543 So we do it only every Nth instruction. */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
544 |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
545 if (pendingfirst != pendinglast) { |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
546 if (Py_MakePendingCalls() < 0) { |
|
1887
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
547 why = WHY_EXCEPTION; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
548 goto on_error; |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
549 } |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
550 } |
|
e7c6a18381d9
* Python/ceval.c (eval_code): added registry of pending functions
Guido van Rossum <guido@python.org>
parents:
1846
diff
changeset
|
551 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
552 if (--ticker < 0) { |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
553 ticker = sys_checkinterval; |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
554 if (sigcheck()) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
555 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
556 goto on_error; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
557 } |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
558 |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
559 #ifdef WITH_THREAD |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
560 if (interpreter_lock) { |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
561 /* Give another thread a chance */ |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
562 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
563 current_frame = NULL; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
564 release_lock(interpreter_lock); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
565 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
566 /* Other threads may run now */ |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
567 |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
568 acquire_lock(interpreter_lock, 1); |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
569 current_frame = f; |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
570 } |
|
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
571 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
572 } |
|
923
72aceed365d4
* Makefile adapted to changes below.
Guido van Rossum <guido@python.org>
parents:
815
diff
changeset
|
573 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
574 /* Extract opcode and argument */ |
|
1016
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
575 |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
576 #ifdef DEBUG |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
577 f->f_lasti = INSTR_OFFSET(); |
|
a41e3ba5b47d
Add some debugging features if DEBUG defined
Guido van Rossum <guido@python.org>
parents:
974
diff
changeset
|
578 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
579 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
580 opcode = NEXTOP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
581 if (HAS_ARG(opcode)) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
582 oparg = NEXTARG(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
583 |
| 567 | 584 #ifdef LLTRACE |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
585 /* Instruction tracing */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
586 |
| 567 | 587 if (lltrace) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
588 if (HAS_ARG(opcode)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
589 printf("%d: %d, %d\n", |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
590 (int) (INSTR_OFFSET() - 3), |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
591 opcode, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
592 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
593 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
594 printf("%d: %d\n", |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
595 (int) (INSTR_OFFSET() - 1), opcode); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
596 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
597 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
598 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
599 |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
600 if (!CHECK_STACK(3)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
601 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
602 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
603 } |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
604 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
605 /* Main switch on opcode */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
606 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
607 switch (opcode) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
608 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
609 /* BEWARE! |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
610 It is essential that any operation that fails sets either |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
611 x to NULL, err to nonzero, or why to anything but WHY_NOT, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
612 and that no operation that succeeds does this! */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
613 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
614 /* case STOP_CODE: this is an error! */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
615 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
616 case POP_TOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
617 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
618 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
619 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
620 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
621 case ROT_TWO: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
622 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
623 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
624 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
625 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
626 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
627 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
628 case ROT_THREE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
629 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
630 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
631 x = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
632 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
633 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
634 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
635 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
636 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
637 case DUP_TOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
638 v = TOP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
639 INCREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
640 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
641 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
642 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
643 case UNARY_POSITIVE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
644 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
645 x = pos(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
646 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
647 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
648 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
649 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
650 case UNARY_NEGATIVE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
651 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
652 x = neg(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
653 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
654 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
655 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
656 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
657 case UNARY_NOT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
658 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
659 x = not(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
660 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
661 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
662 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
663 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
664 case UNARY_CONVERT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
665 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
666 x = reprobject(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
667 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
668 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
669 break; |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
670 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
671 case UNARY_INVERT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
672 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
673 x = invert(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
674 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
675 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
676 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
677 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
678 case BINARY_MULTIPLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
679 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
680 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
681 x = mul(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
682 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
683 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
684 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
685 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
686 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
687 case BINARY_DIVIDE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
688 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
689 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
690 x = divide(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
691 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
692 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
693 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
694 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
695 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
696 case BINARY_MODULO: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
697 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
698 v = POP(); |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
699 x = mod(v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
700 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
701 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
702 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
703 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
704 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
705 case BINARY_ADD: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
706 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
707 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
708 x = add(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
709 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
710 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
711 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
712 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
713 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
714 case BINARY_SUBTRACT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
715 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
716 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
717 x = sub(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
718 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
719 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
720 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
721 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
722 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
723 case BINARY_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
724 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
725 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
726 x = apply_subscript(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
727 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
728 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
729 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
730 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
731 |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
732 case BINARY_LSHIFT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
733 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
734 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
735 x = lshift(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
736 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
737 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
738 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
739 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
740 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
741 case BINARY_RSHIFT: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
742 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
743 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
744 x = rshift(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
745 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
746 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
747 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
748 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
749 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
750 case BINARY_AND: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
751 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
752 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
753 x = and(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
754 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
755 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
756 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
757 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
758 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
759 case BINARY_XOR: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
760 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
761 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
762 x = xor(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
763 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
764 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
765 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
766 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
767 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
768 case BINARY_OR: |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
769 w = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
770 v = POP(); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
771 x = or(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
772 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
773 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
774 PUSH(x); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
775 break; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
776 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
777 case SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
778 case SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
779 case SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
780 case SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
781 if ((opcode-SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
782 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
783 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
784 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
785 if ((opcode-SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
786 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
787 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
788 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
789 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
790 x = apply_slice(u, v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
791 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
792 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
793 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
794 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
795 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
796 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
797 case STORE_SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
798 case STORE_SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
799 case STORE_SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
800 case STORE_SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
801 if ((opcode-STORE_SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
802 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
803 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
804 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
805 if ((opcode-STORE_SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
806 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
807 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
808 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
809 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
810 t = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
811 err = assign_slice(u, v, w, t); /* u[v:w] = t */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
812 DECREF(t); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
813 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
814 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
815 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
816 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
817 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
818 case DELETE_SLICE+0: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
819 case DELETE_SLICE+1: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
820 case DELETE_SLICE+2: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
821 case DELETE_SLICE+3: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
822 if ((opcode-DELETE_SLICE) & 2) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
823 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
824 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
825 w = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
826 if ((opcode-DELETE_SLICE) & 1) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
827 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
828 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
829 v = NULL; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
830 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
831 err = assign_slice(u, v, w, (object *)NULL); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
832 /* del u[v:w] */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
833 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
834 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
835 XDECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
836 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
837 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
838 case STORE_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
839 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
840 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
841 u = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
842 /* v[w] = u */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
843 err = assign_subscript(v, w, u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
844 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
845 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
846 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
847 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
848 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
849 case DELETE_SUBSCR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
850 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
851 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
852 /* del v[w] */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
853 err = assign_subscript(v, w, (object *)NULL); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
854 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
855 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
856 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
857 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
858 case PRINT_EXPR: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
859 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
860 /* Print value except if procedure result */ |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
861 /* Before printing, also assign to '_' */ |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
862 if (v != None && |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
863 (err = dictinsert(f->f_builtins, "_", v)) == 0 && |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
864 !suppress_print) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
865 flushline(); |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
866 x = sysget("stdout"); |
|
2151
5fd8524dd03a
different init for __builtins__
Guido van Rossum <guido@python.org>
parents:
2128
diff
changeset
|
867 err = writeobject(v, x, 0); |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
868 softspace(x, 1); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
869 flushline(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
870 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
871 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
872 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
873 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
874 case PRINT_ITEM: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
875 v = POP(); |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
876 w = sysget("stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
877 if (softspace(w, 1)) |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
878 writestring(" ", w); |
|
1400
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
879 err = writeobject(v, w, PRINT_RAW); |
|
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
880 if (err == 0 && is_stringobject(v)) { |
|
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
881 /* XXX move into writeobject() ? */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
882 char *s = getstringvalue(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
883 int len = getstringsize(v); |
| 2310 | 884 if (len > 0 && |
| 885 isspace(Py_CHARMASK(s[len-1])) && | |
|
1400
aac8231a715c
* mpzmodule.c: removed redundant mpz_print function.
Guido van Rossum <guido@python.org>
parents:
1391
diff
changeset
|
886 s[len-1] != ' ') |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
887 softspace(w, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
888 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
889 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
890 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
891 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
892 case PRINT_NEWLINE: |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
893 x = sysget("stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
894 if (x == NULL) |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
895 err_setstr(RuntimeError, "lost sys.stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
896 else { |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
897 writestring("\n", x); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
898 softspace(x, 0); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
899 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
900 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
901 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
902 case BREAK_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
903 why = WHY_BREAK; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
904 break; |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
905 |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
906 case RAISE_VARARGS: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
907 u = v = w = NULL; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
908 switch (oparg) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
909 case 3: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
910 u = POP(); /* traceback */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
911 if (u == None) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
912 DECREF(u); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
913 u = NULL; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
914 } |
|
3099
d249111d4ccc
spell TraceBack with capital B
Guido van Rossum <guido@python.org>
parents:
2894
diff
changeset
|
915 else if (!PyTraceBack_Check(u)) { |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
916 err_setstr(TypeError, |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
917 "raise 3rd arg must be traceback or None"); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
918 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
919 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
920 /* Fallthrough */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
921 case 2: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
922 v = POP(); /* value */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
923 /* Fallthrough */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
924 case 1: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
925 w = POP(); /* exc */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
926 break; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
927 default: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
928 err_setstr(SystemError, |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
929 "bad RAISE_VARARGS oparg"); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
930 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
931 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
932 if (v == NULL) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
933 v = None; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
934 INCREF(v); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
935 } |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
936 /* A tuple is equivalent to its first element here */ |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
937 while (is_tupleobject(w) && gettuplesize(w) > 0) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
938 t = w; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
939 w = GETTUPLEITEM(w, 0); |
|
2201
8f1daffe799b
add missing INCREF in RAISE_EXCEPTION
Guido van Rossum <guido@python.org>
parents:
2151
diff
changeset
|
940 INCREF(w); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
941 DECREF(t); |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
942 } |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
943 if (is_stringobject(w)) { |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
944 ; |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
945 } else if (is_classobject(w)) { |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
946 if (!is_instanceobject(v) |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
947 || !issubclass((object*)((instanceobject*)v)->in_class, |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
948 w)) { |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
949 err_setstr(TypeError, |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
950 "a class exception must have a value that is an instance of the class"); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
951 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
952 } |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
953 } else if (is_instanceobject(w)) { |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
954 if (v != None) { |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
955 err_setstr(TypeError, |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
956 "an instance exception may not have a separate value"); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
957 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
958 } |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
959 else { |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
960 DECREF(v); |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
961 v = w; |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
962 w = (object*) ((instanceobject*)w)->in_class; |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
963 INCREF(w); |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
964 } |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
965 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
966 else { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
967 err_setstr(TypeError, |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
968 "exceptions must be strings, classes, or instances"); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
969 goto raise_error; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
970 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
971 err_restore(w, v, u); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
972 if (u == NULL) |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
973 why = WHY_EXCEPTION; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
974 else |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
975 why = WHY_RERAISE; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
976 break; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
977 raise_error: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
978 XDECREF(v); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
979 XDECREF(w); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
980 XDECREF(u); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
981 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
982 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
983 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
984 case LOAD_LOCALS: |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
985 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
986 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
987 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
988 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
989 INCREF(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
990 PUSH(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
991 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
992 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
993 case RETURN_VALUE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
994 retval = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
995 why = WHY_RETURN; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
996 break; |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
997 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
998 case EXEC_STMT: |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
999 w = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1000 v = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1001 u = POP(); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1002 err = exec_statement(u, v, w); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1003 DECREF(u); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1004 DECREF(v); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1005 DECREF(w); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
1006 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1007 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1008 case POP_BLOCK: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1009 { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1010 block *b = pop_block(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1011 while (STACK_LEVEL() > b->b_level) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1012 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1013 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1014 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1015 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1016 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1017 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1018 case END_FINALLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1019 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1020 if (is_intobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1021 why = (enum why_code) getintvalue(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1022 if (why == WHY_RETURN) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1023 retval = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1024 } |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
1025 else if (is_stringobject(v) || is_classobject(v)) { |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1026 w = POP(); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1027 u = POP(); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1028 err_restore(v, w, u); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1029 why = WHY_RERAISE; |
|
2872
d3b07ba3e12d
fix bogus DECREF in finally clause
Guido van Rossum <guido@python.org>
parents:
2866
diff
changeset
|
1030 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1031 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1032 else if (v != None) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1033 err_setstr(SystemError, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1034 "'finally' pops bad exception"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1035 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1036 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1037 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1038 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1039 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1040 case BUILD_CLASS: |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1041 u = POP(); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1042 v = POP(); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1043 w = POP(); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1044 x = build_class(u, v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1045 PUSH(x); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1046 DECREF(u); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1047 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1048 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1049 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1050 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1051 case STORE_NAME: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1052 w = GETNAMEV(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1053 v = POP(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1054 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1055 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1056 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1057 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1058 u = dict2lookup(x, w); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1059 if (u == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1060 if (defmode != 0) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1061 if (v != None) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1062 u = (object *)v->ob_type; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1063 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1064 u = NULL; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1065 x = newaccessobject(v, x, |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1066 (typeobject *)u, |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1067 defmode); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1068 DECREF(v); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1069 if (x == NULL) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1070 break; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1071 v = x; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1072 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1073 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1074 else if (is_accessobject(u)) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1075 err = setaccessvalue(u, x, v); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1076 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1077 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1078 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1079 err = dict2insert(x, w, v); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1080 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1081 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1082 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1083 case DELETE_NAME: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1084 w = GETNAMEV(oparg); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1085 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1086 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1087 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1088 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1089 u = dict2lookup(x, w); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1090 if (u != NULL && is_accessobject(u)) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1091 err = setaccessvalue(u, x, |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1092 (object *)NULL); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1093 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1094 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1095 if ((err = dict2remove(x, w)) != 0) |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1096 err_setval(NameError, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1097 break; |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1098 |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1099 #ifdef CASE_TOO_BIG |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1100 default: switch (opcode) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1101 #endif |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1102 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1103 case UNPACK_TUPLE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1104 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1105 if (!is_tupleobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1106 err_setstr(TypeError, "unpack non-tuple"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1107 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1108 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1109 else if (gettuplesize(v) != oparg) { |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1110 err_setstr(ValueError, |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1111 "unpack tuple of wrong size"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1112 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1113 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1114 else { |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1115 if (!CHECK_STACK(oparg)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1116 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1117 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1118 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1119 for (; --oparg >= 0; ) { |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
1120 w = GETTUPLEITEM(v, oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1121 INCREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1122 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1123 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1124 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1125 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1126 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1127 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1128 case UNPACK_LIST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1129 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1130 if (!is_listobject(v)) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1131 err_setstr(TypeError, "unpack non-list"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1132 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1133 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1134 else if (getlistsize(v) != oparg) { |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1135 err_setstr(ValueError, |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1136 "unpack list of wrong size"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1137 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1138 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1139 else { |
|
1079
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1140 if (!CHECK_STACK(oparg)) { |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1141 x = NULL; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1142 break; |
|
e4c6a0dd5c2b
* bltinmodule.c: added built-in function cmp(a, b)
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
1143 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1144 for (; --oparg >= 0; ) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1145 w = getlistitem(v, oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1146 INCREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1147 PUSH(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1148 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1149 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1150 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1151 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1152 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1153 case STORE_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1154 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1155 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1156 u = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1157 err = setattro(v, w, u); /* v.w = u */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1158 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1159 DECREF(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1160 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1161 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1162 case DELETE_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1163 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1164 v = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1165 err = setattro(v, w, (object *)NULL); /* del v.w */ |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1166 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1167 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1168 |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1169 case STORE_GLOBAL: |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1170 w = GETNAMEV(oparg); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1171 v = POP(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1172 if (f->f_locals != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1173 u = dict2lookup(f->f_locals, w); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1174 if (u != NULL && is_accessobject(u)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1175 err = setaccessvalue(u, f->f_globals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1176 v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1177 DECREF(v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1178 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1179 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1180 } |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1181 err = dict2insert(f->f_globals, w, v); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1182 DECREF(v); |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1183 break; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1184 |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1185 case DELETE_GLOBAL: |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1186 w = GETNAMEV(oparg); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1187 if (f->f_locals != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1188 u = dict2lookup(f->f_locals, w); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1189 if (u != NULL && is_accessobject(u)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1190 err = setaccessvalue(u, f->f_globals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1191 (object *)NULL); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1192 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1193 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1194 } |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1195 if ((err = dict2remove(f->f_globals, w)) != 0) |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1196 err_setval(NameError, w); |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1197 break; |
|
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
1198 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1199 case LOAD_CONST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1200 x = GETCONST(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1201 INCREF(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1202 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1203 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1204 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1205 case LOAD_NAME: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1206 w = GETNAMEV(oparg); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1207 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1208 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1209 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1210 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1211 x = dict2lookup(x, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1212 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1213 err_clear(); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1214 x = dict2lookup(f->f_globals, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1215 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1216 err_clear(); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1217 x = dict2lookup(f->f_builtins, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1218 if (x == NULL) { |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1219 err_setval(NameError, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1220 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1221 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1222 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1223 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1224 if (is_accessobject(x)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1225 x = getaccessvalue(x, f->f_globals /* XXX */); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1226 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1227 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1228 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1229 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1230 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1231 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1232 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1233 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1234 case LOAD_GLOBAL: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1235 w = GETNAMEV(oparg); |
|
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1236 x = dict2lookup(f->f_globals, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1237 if (x == NULL) { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1238 err_clear(); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1239 x = dict2lookup(f->f_builtins, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1240 if (x == NULL) { |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1241 err_setval(NameError, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1242 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1243 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1244 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1245 if (is_accessobject(x)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1246 x = getaccessvalue(x, f->f_globals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1247 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1248 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1249 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1250 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1251 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1252 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1253 break; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1254 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1255 #if 0 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1256 case LOAD_LOCAL: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1257 w = GETNAMEV(oparg); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1258 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1259 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1260 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1261 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1262 x = dict2lookup(x, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1263 if (x == NULL) { |
|
1356
043da19302ef
Several optimizations and speed improvements.
Sjoerd Mullender <sjoerd@acm.org>
parents:
1354
diff
changeset
|
1264 err_setval(NameError, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1265 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1266 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1267 if (is_accessobject(x)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1268 x = getaccessvalue(x, f->f_locals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1269 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1270 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1271 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1272 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1273 INCREF(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1274 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1275 break; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1276 #endif |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1277 |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1278 case LOAD_FAST: |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1279 x = GETLOCAL(oparg); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1280 if (x == NULL) { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1281 err_setval(NameError, |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1282 gettupleitem(co->co_varnames, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1283 oparg)); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1284 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1285 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1286 if (is_accessobject(x)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1287 x = getaccessvalue(x, f->f_locals); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1288 if (x == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1289 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1290 } |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1291 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1292 INCREF(x); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1293 PUSH(x); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1294 break; |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1295 |
|
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1296 case STORE_FAST: |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1297 v = POP(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1298 w = GETLOCAL(oparg); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1299 if (w != NULL && is_accessobject(w)) { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1300 err = setaccessvalue(w, f->f_locals, v); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1301 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1302 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1303 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1304 SETLOCAL(oparg, v); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1305 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1306 |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1307 case DELETE_FAST: |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1308 x = GETLOCAL(oparg); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1309 if (x == NULL) { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1310 err_setval(NameError, |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1311 gettupleitem(co->co_varnames, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1312 oparg)); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1313 break; |
|
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1314 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1315 if (is_accessobject(x)) { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1316 err = setaccessvalue(x, f->f_locals, |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1317 (object *)NULL); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1318 break; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1319 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1320 SETLOCAL(oparg, NULL); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1321 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1322 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1323 case BUILD_TUPLE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1324 x = newtupleobject(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1325 if (x != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1326 for (; --oparg >= 0;) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1327 w = POP(); |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
1328 SETTUPLEITEM(x, oparg, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1329 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1330 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1331 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1332 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1333 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1334 case BUILD_LIST: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1335 x = newlistobject(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1336 if (x != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1337 for (; --oparg >= 0;) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1338 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1339 err = setlistitem(x, oparg, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1340 if (err != 0) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1341 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1342 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1343 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1344 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1345 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1346 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1347 case BUILD_MAP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1348 x = newdictobject(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1349 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1350 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1351 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1352 case LOAD_ATTR: |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1353 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1354 v = POP(); |
|
1257
1cabc2b6c970
* Changed all copyright messages to include 1993.
Guido van Rossum <guido@python.org>
parents:
1252
diff
changeset
|
1355 x = getattro(v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1356 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1357 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1358 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1359 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1360 case COMPARE_OP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1361 w = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1362 v = POP(); |
|
802
3d6541a2eca5
Arg of cmp_outcome becomes an int for portability to the Mac
Guido van Rossum <guido@python.org>
parents:
789
diff
changeset
|
1363 x = cmp_outcome(oparg, v, w); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1364 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1365 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1366 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1367 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1368 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1369 case IMPORT_NAME: |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1370 w = GETNAMEV(oparg); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1371 x = dictlookup(f->f_builtins, "__import__"); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1372 if (x == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1373 err_setstr(ImportError, |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1374 "__import__ not found"); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1375 break; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1376 } |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1377 if (is_methodobject(x)) { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1378 u = None; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1379 INCREF(u); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1380 } |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1381 else { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1382 u = find_from_args(f, INSTR_OFFSET()); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1383 if (u == NULL) { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1384 x = u; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1385 break; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1386 } |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1387 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1388 w = mkvalue("(OOOO)", |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1389 w, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1390 f->f_globals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1391 f->f_locals == NULL ? None : f->f_locals, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1392 u); |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1393 DECREF(u); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1394 if (w == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1395 x = NULL; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1396 break; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1397 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1398 x = call_object(x, w); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1399 DECREF(w); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1400 PUSH(x); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1401 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1402 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1403 case IMPORT_FROM: |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
1404 w = GETNAMEV(oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1405 v = TOP(); |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
1406 fast_2_locals(f); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1407 if ((x = f->f_locals) == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1408 err_setstr(SystemError, "no locals"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1409 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1410 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1411 err = import_from(x, v, w); |
|
1262
f820e6917f07
Changes to speed up local variables enormously, by avoiding dictionary
Guido van Rossum <guido@python.org>
parents:
1257
diff
changeset
|
1412 locals_2_fast(f, 0); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1413 break; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1414 |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1415 case ACCESS_MODE: |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1416 v = POP(); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1417 w = GETNAMEV(oparg); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1418 if (getstringvalue(w)[0] == '*') |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1419 defmode = getintvalue(v); |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1420 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
1421 err = access_statement(w, v, f); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1422 DECREF(v); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
1423 break; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1424 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1425 case JUMP_FORWARD: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1426 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1427 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1428 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1429 case JUMP_IF_FALSE: |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1430 err = testbool(TOP()); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1431 if (err > 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1432 err = 0; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1433 else if (err == 0) |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1434 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1435 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1436 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1437 case JUMP_IF_TRUE: |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1438 err = testbool(TOP()); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1439 if (err > 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1440 err = 0; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1441 JUMPBY(oparg); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1442 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1443 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1444 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1445 case JUMP_ABSOLUTE: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1446 JUMPTO(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1447 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1448 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1449 case FOR_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1450 /* for v in s: ... |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1451 On entry: stack contains s, i. |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1452 On exit: stack contains s, i+1, s[i]; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1453 but if loop exhausted: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1454 s, i are popped, and we jump */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1455 w = POP(); /* Loop index */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1456 v = POP(); /* Sequence object */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1457 u = loop_subscript(v, w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1458 if (u != NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1459 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1460 x = newintobject(getintvalue(w)+1); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1461 PUSH(x); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1462 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1463 PUSH(u); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1464 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1465 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1466 DECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1467 DECREF(w); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1468 /* A NULL can mean "s exhausted" |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1469 but also an error: */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1470 if (err_occurred()) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1471 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1472 else |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1473 JUMPBY(oparg); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1474 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1475 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1476 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1477 case SETUP_LOOP: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1478 case SETUP_EXCEPT: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1479 case SETUP_FINALLY: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1480 setup_block(f, opcode, INSTR_OFFSET() + oparg, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1481 STACK_LEVEL()); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1482 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1483 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1484 case SET_LINENO: |
| 567 | 1485 #ifdef LLTRACE |
| 1486 if (lltrace) | |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1487 printf("--- %s:%d \n", filename, oparg); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1488 #endif |
| 567 | 1489 f->f_lineno = oparg; |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1490 if (f->f_trace != NULL) { |
| 567 | 1491 /* Trace each line of code reached */ |
| 1492 f->f_lasti = INSTR_OFFSET(); | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1493 err = call_trace(&f->f_trace, &f->f_trace, |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1494 f, "line", None); |
| 567 | 1495 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1496 break; |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1497 |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1498 case CALL_FUNCTION: |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1499 { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1500 int na = oparg & 0xff; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1501 int nk = (oparg>>8) & 0xff; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1502 int n = na + 2*nk; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1503 object **pfunc = stack_pointer - n - 1; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1504 object *func = *pfunc; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1505 object *self = NULL; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1506 object *class = NULL; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1507 f->f_lasti = INSTR_OFFSET() - 3; /* For tracing */ |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1508 if (is_instancemethodobject(func)) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1509 self = instancemethodgetself(func); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1510 class = instancemethodgetclass(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1511 func = instancemethodgetfunc(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1512 INCREF(func); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1513 if (self != NULL) { |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1514 INCREF(self); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1515 DECREF(*pfunc); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1516 *pfunc = self; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1517 na++; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1518 n++; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1519 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1520 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1521 /* Unbound methods must be |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1522 called with an instance of |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1523 the class (or a derived |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1524 class) as first argument */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1525 if (na > 0 && |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1526 (self = stack_pointer[-n]) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1527 != NULL && |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1528 is_instanceobject(self) && |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1529 issubclass( |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1530 (object *) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1531 (((instanceobject *)self) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1532 ->in_class), |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1533 class)) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1534 /* Handy-dandy */ ; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1535 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1536 err_setstr(TypeError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1537 "unbound method must be called with class instance 1st argument"); |
|
3294
2bddfb3cfcf1
don't return from main loop when error occurs
Guido van Rossum <guido@python.org>
parents:
3099
diff
changeset
|
1538 x = NULL; |
|
2bddfb3cfcf1
don't return from main loop when error occurs
Guido van Rossum <guido@python.org>
parents:
3099
diff
changeset
|
1539 break; |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1540 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1541 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1542 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1543 else |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1544 INCREF(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1545 if (is_funcobject(func)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1546 object *co = getfunccode(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1547 object *globals = getfuncglobals(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1548 object *argdefs = PyFunction_GetDefaults(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1549 object **d; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1550 int nd; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1551 if (argdefs != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1552 d = &GETTUPLEITEM(argdefs, 0); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1553 nd = ((tupleobject *)argdefs)->ob_size; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1554 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1555 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1556 d = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1557 nd = 0; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1558 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1559 x = eval_code2( |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1560 (codeobject *)co, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1561 globals, (object *)NULL, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1562 stack_pointer-n, na, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1563 stack_pointer-2*nk, nk, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1564 d, nd, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1565 class); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1566 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1567 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1568 object *args = newtupleobject(na); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1569 object *kwdict = NULL; |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1570 if (args == NULL) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1571 x = NULL; |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1572 break; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1573 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1574 if (nk > 0) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1575 kwdict = newdictobject(); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1576 if (kwdict == NULL) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1577 x = NULL; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1578 break; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1579 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1580 err = 0; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1581 while (--nk >= 0) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1582 object *value = POP(); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1583 object *key = POP(); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1584 err = mappinginsert( |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1585 kwdict, key, value); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1586 if (err) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1587 DECREF(key); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1588 DECREF(value); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1589 break; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1590 } |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1591 } |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1592 if (err) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1593 DECREF(args); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1594 DECREF(kwdict); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1595 break; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1596 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1597 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1598 while (--na >= 0) { |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1599 w = POP(); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1600 SETTUPLEITEM(args, na, w); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1601 } |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1602 x = PyEval_CallObjectWithKeywords( |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1603 func, args, kwdict); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1604 DECREF(args); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
1605 XDECREF(kwdict); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1606 } |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1607 DECREF(func); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1608 while (stack_pointer > pfunc) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1609 w = POP(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1610 DECREF(w); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1611 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1612 PUSH(x); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1613 break; |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1614 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1615 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1616 case MAKE_FUNCTION: |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1617 v = POP(); /* code object */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1618 x = newfuncobject(v, f->f_globals); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1619 DECREF(v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1620 /* XXX Maybe this should be a separate opcode? */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1621 if (x != NULL && oparg > 0) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1622 v = newtupleobject(oparg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1623 if (v == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1624 DECREF(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1625 x = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1626 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1627 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1628 while (--oparg >= 0) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1629 w = POP(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1630 SETTUPLEITEM(v, oparg, w); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1631 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1632 err = PyFunction_SetDefaults(x, v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1633 DECREF(v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1634 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1635 PUSH(x); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1636 break; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1637 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1638 default: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1639 fprintf(stderr, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1640 "XXX lineno: %d, opcode: %d\n", |
| 567 | 1641 f->f_lineno, opcode); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1642 err_setstr(SystemError, "unknown opcode"); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1643 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1644 break; |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1645 |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1646 #ifdef CASE_TOO_BIG |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1647 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1648 #endif |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
1649 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1650 } /* switch */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1651 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1652 on_error: |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1653 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1654 /* Quickly continue if no error occurred */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1655 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1656 if (why == WHY_NOT) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1657 if (err == 0 && x != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1658 #ifdef CHECKEXC |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1659 if (err_occurred()) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1660 fprintf(stderr, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1661 "XXX undetected error\n"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1662 else |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1663 #endif |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1664 continue; /* Normal, fast path */ |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1665 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1666 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1667 x = None; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1668 err = 0; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1669 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1670 |
|
814
f08d34499269
reverse sense of test for CHECKEXC
Guido van Rossum <guido@python.org>
parents:
802
diff
changeset
|
1671 #ifdef CHECKEXC |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1672 /* Double-check exception status */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1673 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1674 if (why == WHY_EXCEPTION || why == WHY_RERAISE) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1675 if (!err_occurred()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1676 fprintf(stderr, "XXX ghost error\n"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1677 err_setstr(SystemError, "ghost error"); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1678 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1679 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1680 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1681 else { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1682 if (err_occurred()) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1683 fprintf(stderr, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1684 "XXX undetected error (why=%d)\n", |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1685 why); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1686 why = WHY_EXCEPTION; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1687 } |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1688 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1689 #endif |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1690 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1691 /* Log traceback info if this is a real exception */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1692 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1693 if (why == WHY_EXCEPTION) { |
| 567 | 1694 f->f_lasti = INSTR_OFFSET() - 1; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1695 if (HAS_ARG(opcode)) |
| 567 | 1696 f->f_lasti -= 2; |
| 1697 tb_here(f); | |
| 1698 | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1699 if (f->f_trace) |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1700 call_exc_trace(&f->f_trace, &f->f_trace, f); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1701 if (sys_profile) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1702 call_exc_trace(&sys_profile, (object**)0, f); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1703 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1704 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1705 /* For the rest, treat WHY_RERAISE as WHY_EXCEPTION */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1706 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1707 if (why == WHY_RERAISE) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1708 why = WHY_EXCEPTION; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1709 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1710 /* Unwind stacks if a (pseudo) exception occurred */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1711 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1712 while (why != WHY_NOT && f->f_iblock > 0) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1713 block *b = pop_block(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1714 while (STACK_LEVEL() > b->b_level) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1715 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1716 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1717 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1718 if (b->b_type == SETUP_LOOP && why == WHY_BREAK) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1719 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1720 JUMPTO(b->b_handler); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1721 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1722 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1723 if (b->b_type == SETUP_FINALLY || |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1724 b->b_type == SETUP_EXCEPT && |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1725 why == WHY_EXCEPTION) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1726 if (why == WHY_EXCEPTION) { |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1727 object *exc, *val, *tb; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1728 err_fetch(&exc, &val, &tb); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1729 if (val == NULL) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1730 val = None; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1731 INCREF(val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1732 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1733 /* Make the raw exception data |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1734 available to the handler, |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1735 so a program can emulate the |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1736 Python main loop. Don't do |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1737 this for 'finally'. */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1738 if (b->b_type == SETUP_EXCEPT) { |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1739 sysset("exc_traceback", tb); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1740 sysset("exc_value", val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1741 sysset("exc_type", exc); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1742 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1743 PUSH(tb); |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1744 PUSH(val); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1745 PUSH(exc); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1746 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1747 else { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1748 if (why == WHY_RETURN) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1749 PUSH(retval); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1750 v = newintobject((long)why); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1751 PUSH(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1752 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1753 why = WHY_NOT; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1754 JUMPTO(b->b_handler); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1755 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1756 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1757 } /* unwind stack */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1758 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1759 /* End the loop if we still have an error (or return) */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1760 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1761 if (why != WHY_NOT) |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1762 break; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1763 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1764 } /* main loop */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1765 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1766 /* Pop remaining stack entries */ |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1767 |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1768 while (!EMPTY()) { |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1769 v = POP(); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1770 XDECREF(v); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1771 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1772 |
| 567 | 1773 if (why != WHY_RETURN) |
| 1774 retval = NULL; | |
| 1775 | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1776 if (f->f_trace) { |
| 567 | 1777 if (why == WHY_RETURN) { |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1778 if (call_trace(&f->f_trace, &f->f_trace, f, |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1779 "return", retval)) { |
| 567 | 1780 XDECREF(retval); |
| 1781 retval = NULL; | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1782 why = WHY_EXCEPTION; |
| 567 | 1783 } |
| 1784 } | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1785 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1786 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1787 if (sys_profile && why == WHY_RETURN) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1788 if (call_trace(&sys_profile, (object**)0, |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1789 f, "return", retval)) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1790 XDECREF(retval); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1791 retval = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1792 why = WHY_EXCEPTION; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1793 } |
| 567 | 1794 } |
| 1795 | |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1796 /* Restore previous frame and release the current one */ |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
1797 |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1798 current_frame = f->f_back; |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1799 DECREF(f); |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1800 |
| 567 | 1801 return retval; |
|
173
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1802 } |
|
4656452436e1
Moved support functions after main function; added prototypes;
Guido van Rossum <guido@python.org>
parents:
159
diff
changeset
|
1803 |
| 567 | 1804 #ifdef LLTRACE |
| 86 | 1805 static int |
| 1806 prtrace(v, str) | |
| 1807 object *v; | |
| 1808 char *str; | |
| 69 | 1809 { |
| 86 | 1810 printf("%s ", str); |
|
284
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
1811 if (printobject(v, stdout, 0) != 0) |
|
6ac402023cac
printobject now returns an error code
Guido van Rossum <guido@python.org>
parents:
260
diff
changeset
|
1812 err_clear(); /* Don't know what else to do */ |
| 86 | 1813 printf("\n"); |
| 69 | 1814 } |
| 86 | 1815 #endif |
| 69 | 1816 |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1817 static void |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1818 call_exc_trace(p_trace, p_newtrace, f) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1819 object **p_trace, **p_newtrace; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1820 frameobject *f; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1821 { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1822 object *type, *value, *traceback, *arg; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1823 int err; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1824 err_fetch(&type, &value, &traceback); |
|
815
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1825 if (value == NULL) { |
|
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1826 value = None; |
|
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1827 INCREF(value); |
|
6508c93f9472
Test for NULL coming out of err_get() in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
814
diff
changeset
|
1828 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1829 arg = mkvalue("(OOO)", type, value, traceback); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1830 if (arg == NULL) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1831 err_restore(type, value, traceback); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1832 return; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1833 } |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1834 err = call_trace(p_trace, p_newtrace, f, "exception", arg); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1835 DECREF(arg); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1836 if (err == 0) |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1837 err_restore(type, value, traceback); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1838 else { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1839 XDECREF(type); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1840 XDECREF(value); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
1841 XDECREF(traceback); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1842 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1843 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1844 |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1845 static int |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1846 call_trace(p_trace, p_newtrace, f, msg, arg) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1847 object **p_trace; /* in/out; may not be NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1848 may not point to NULL variable initially */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1849 object **p_newtrace; /* in/out; may be NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1850 may point to NULL variable; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1851 may be same variable as p_newtrace */ |
| 567 | 1852 frameobject *f; |
| 1853 char *msg; | |
| 1854 object *arg; | |
| 1855 { | |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1856 object *args, *what; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1857 object *res = NULL; |
| 567 | 1858 static int tracing = 0; |
| 1859 | |
| 1860 if (tracing) { | |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1861 /* Don't do recursive traces */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1862 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1863 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1864 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1865 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1866 return 0; |
| 567 | 1867 } |
| 1868 | |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1869 args = newtupleobject(3); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1870 if (args == NULL) |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1871 goto cleanup; |
| 567 | 1872 what = newstringobject(msg); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1873 if (what == NULL) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1874 goto cleanup; |
| 567 | 1875 INCREF(f); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1876 SETTUPLEITEM(args, 0, (object *)f); |
|
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1877 SETTUPLEITEM(args, 1, what); |
| 567 | 1878 if (arg == NULL) |
| 1879 arg = None; | |
| 1880 INCREF(arg); | |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1881 SETTUPLEITEM(args, 2, arg); |
| 567 | 1882 tracing++; |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1883 fast_2_locals(f); |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1884 res = call_object(*p_trace, args); /* May clear *p_trace! */ |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1885 locals_2_fast(f, 1); |
| 567 | 1886 tracing--; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1887 cleanup: |
|
2813
999b5bdc18ce
3rd arg for raise; INCOMPLETE keyword parameter passing (currently f(kw=value) is seen as f('kw', value))
Guido van Rossum <guido@python.org>
parents:
2612
diff
changeset
|
1888 XDECREF(args); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1889 if (res == NULL) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1890 /* The trace proc raised an exception */ |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1891 tb_here(f); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1892 XDECREF(*p_trace); |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1893 *p_trace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1894 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1895 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1896 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1897 } |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1898 return -1; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1899 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1900 else { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1901 if (p_newtrace) { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1902 XDECREF(*p_newtrace); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1903 if (res == None) |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1904 *p_newtrace = NULL; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1905 else { |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1906 INCREF(res); |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1907 *p_newtrace = res; |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1908 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1909 } |
|
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1910 DECREF(res); |
|
789
f565cf7f9aba
(Hopefully) fix bug in reference count in call_exc_trace()
Guido van Rossum <guido@python.org>
parents:
746
diff
changeset
|
1911 return 0; |
|
708
8bcb50f436fa
New trace implementation; and profile (in a similat vein).
Guido van Rossum <guido@python.org>
parents:
688
diff
changeset
|
1912 } |
| 567 | 1913 } |
| 1914 | |
| 86 | 1915 object * |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1916 getbuiltins() |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1917 { |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1918 if (current_frame == NULL) |
|
2151
5fd8524dd03a
different init for __builtins__
Guido van Rossum <guido@python.org>
parents:
2128
diff
changeset
|
1919 return getbuiltinmod(); |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1920 else |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1921 return current_frame->f_builtins; |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1922 } |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1923 |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1924 object * |
|
1263
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1925 getlocals() |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1926 { |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1927 if (current_frame == NULL) |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1928 return NULL; |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1929 fast_2_locals(current_frame); |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1930 return current_frame->f_locals; |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1931 } |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1932 |
|
65a1e4e9cd54
* Fixed some subtleties with fastlocals. You can no longer access
Guido van Rossum <guido@python.org>
parents:
1262
diff
changeset
|
1933 object * |
| 86 | 1934 getglobals() |
| 69 | 1935 { |
| 86 | 1936 if (current_frame == NULL) |
| 1937 return NULL; | |
| 1938 else | |
| 1939 return current_frame->f_globals; | |
| 69 | 1940 } |
| 1941 | |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1942 object * |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1943 getowner() |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1944 { |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1945 if (current_frame == NULL) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1946 return NULL; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1947 else |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
1948 return current_frame->f_owner; |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1949 } |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
1950 |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1951 object * |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1952 getframe() |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1953 { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1954 return (object *)current_frame; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1955 } |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
1956 |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1957 int |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1958 getrestricted() |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1959 { |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1960 return current_frame == NULL ? 0 : current_frame->f_restricted; |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1961 } |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
1962 |
| 86 | 1963 void |
| 69 | 1964 flushline() |
| 1965 { | |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1966 object *f = sysget("stdout"); |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1967 if (softspace(f, 0)) |
|
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1016
diff
changeset
|
1968 writestring("\n", f); |
| 69 | 1969 } |
| 1970 | |
| 86 | 1971 |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1972 #define BINOP(opname, ropname, thisfunc) \ |
|
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1973 if (!is_instanceobject(v) && !is_instanceobject(w)) \ |
|
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1974 ; \ |
|
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1975 else \ |
|
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1976 return instancebinop(v, w, opname, ropname, thisfunc) |
|
1914
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
1977 |
|
893412101296
* Python/ceval.c, Include/ceval.h: promote MakePendingCalls to
Guido van Rossum <guido@python.org>
parents:
1887
diff
changeset
|
1978 |
| 69 | 1979 static object * |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1980 or(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1981 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1982 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
1983 BINOP("__or__", "__ror__", or); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1984 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1985 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1986 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1987 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1988 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1989 if ((f = v->ob_type->tp_as_number->nb_or) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1990 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1991 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1992 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1993 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1994 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1995 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1996 err_setstr(TypeError, "bad operand type(s) for |"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1997 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1998 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
1999 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2000 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2001 xor(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2002 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2003 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2004 BINOP("__xor__", "__rxor__", xor); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2005 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2006 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2007 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2008 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2009 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2010 if ((f = v->ob_type->tp_as_number->nb_xor) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2011 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2012 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2013 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2014 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2015 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2016 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2017 err_setstr(TypeError, "bad operand type(s) for ^"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2018 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2019 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2020 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2021 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2022 and(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2023 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2024 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2025 BINOP("__and__", "__rand__", and); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2026 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2027 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2028 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2029 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2030 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2031 if ((f = v->ob_type->tp_as_number->nb_and) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2032 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2033 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2034 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2035 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2036 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2037 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2038 err_setstr(TypeError, "bad operand type(s) for &"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2039 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2040 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2041 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2042 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2043 lshift(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2044 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2045 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2046 BINOP("__lshift__", "__rlshift__", lshift); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2047 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2048 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2049 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2050 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2051 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2052 if ((f = v->ob_type->tp_as_number->nb_lshift) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2053 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2054 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2055 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2056 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2057 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2058 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2059 err_setstr(TypeError, "bad operand type(s) for <<"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2060 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2061 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2062 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2063 static object * |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2064 rshift(v, w) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2065 object *v, *w; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2066 { |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2067 BINOP("__rshift__", "__rrshift__", rshift); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2068 if (v->ob_type->tp_as_number != NULL) { |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2069 object *x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2070 object * (*f) FPROTO((object *, object *)); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2071 if (coerce(&v, &w) != 0) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2072 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2073 if ((f = v->ob_type->tp_as_number->nb_rshift) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2074 x = (*f)(v, w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2075 DECREF(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2076 DECREF(w); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2077 if (f != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2078 return x; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2079 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2080 err_setstr(TypeError, "bad operand type(s) for >>"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2081 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2082 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2083 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2084 static object * |
| 86 | 2085 add(v, w) |
| 69 | 2086 object *v, *w; |
| 2087 { | |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2088 BINOP("__add__", "__radd__", add); |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2089 if (v->ob_type->tp_as_sequence != NULL) |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2090 return (*v->ob_type->tp_as_sequence->sq_concat)(v, w); |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2091 else if (v->ob_type->tp_as_number != NULL) { |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2092 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2093 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2094 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2095 x = (*v->ob_type->tp_as_number->nb_add)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2096 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2097 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2098 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2099 } |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
2100 err_setstr(TypeError, "bad operand type(s) for +"); |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1181
diff
changeset
|
2101 return NULL; |
| 69 | 2102 } |
| 2103 | |
| 2104 static object * | |
| 86 | 2105 sub(v, w) |
| 69 | 2106 object *v, *w; |
| 2107 { | |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2108 BINOP("__sub__", "__rsub__", sub); |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2109 if (v->ob_type->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2110 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2111 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2112 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2113 x = (*v->ob_type->tp_as_number->nb_subtract)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2114 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2115 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2116 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2117 } |
| 86 | 2118 err_setstr(TypeError, "bad operand type(s) for -"); |
| 69 | 2119 return NULL; |
| 2120 } | |
| 2121 | |
| 2122 static object * | |
| 86 | 2123 mul(v, w) |
| 69 | 2124 object *v, *w; |
| 2125 { | |
| 2126 typeobject *tp; | |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2127 tp = v->ob_type; |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2128 BINOP("__mul__", "__rmul__", mul); |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2129 if (tp->tp_as_number != NULL && |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2130 w->ob_type->tp_as_sequence != NULL && |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2131 !is_instanceobject(v)) { |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2132 /* number*sequence -- swap v and w */ |
| 69 | 2133 object *tmp = v; |
| 2134 v = w; | |
| 2135 w = tmp; | |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2136 tp = v->ob_type; |
| 69 | 2137 } |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2138 if (tp->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2139 object *x; |
|
955
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2140 if (is_instanceobject(v)) { |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2141 /* Instances of user-defined classes get their |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2142 other argument uncoerced, so they may |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2143 implement sequence*number as well as |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2144 number*number. */ |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2145 INCREF(v); |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2146 INCREF(w); |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2147 } |
|
03de67080c95
* classobject.[ch], {float,long,int}object.c, bltinmodule.c:
Guido van Rossum <guido@python.org>
parents:
944
diff
changeset
|
2148 else if (coerce(&v, &w) != 0) |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2149 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2150 x = (*v->ob_type->tp_as_number->nb_multiply)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2151 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2152 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2153 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2154 } |
| 69 | 2155 if (tp->tp_as_sequence != NULL) { |
| 2156 if (!is_intobject(w)) { | |
| 86 | 2157 err_setstr(TypeError, |
| 2158 "can't multiply sequence with non-int"); | |
| 69 | 2159 return NULL; |
| 2160 } | |
| 86 | 2161 return (*tp->tp_as_sequence->sq_repeat) |
| 2162 (v, (int)getintvalue(w)); | |
| 69 | 2163 } |
| 86 | 2164 err_setstr(TypeError, "bad operand type(s) for *"); |
| 69 | 2165 return NULL; |
| 2166 } | |
| 2167 | |
| 2168 static object * | |
|
88
16e8c5d16493
Change div() into divide(); div() is a Standard C function.
Guido van Rossum <guido@python.org>
parents:
86
diff
changeset
|
2169 divide(v, w) |
| 69 | 2170 object *v, *w; |
| 2171 { | |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2172 BINOP("__div__", "__rdiv__", divide); |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2173 if (v->ob_type->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2174 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2175 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2176 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2177 x = (*v->ob_type->tp_as_number->nb_divide)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2178 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2179 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2180 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2181 } |
| 86 | 2182 err_setstr(TypeError, "bad operand type(s) for /"); |
| 69 | 2183 return NULL; |
| 2184 } | |
| 2185 | |
| 2186 static object * | |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2187 mod(v, w) |
| 86 | 2188 object *v, *w; |
| 69 | 2189 { |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2190 if (is_stringobject(v)) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2191 return formatstring(v, w); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2192 } |
|
2088
1940e1e0cedf
Use new instancebinop interface
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
2193 BINOP("__mod__", "__rmod__", mod); |
|
302
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2194 if (v->ob_type->tp_as_number != NULL) { |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2195 object *x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2196 if (coerce(&v, &w) != 0) |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2197 return NULL; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2198 x = (*v->ob_type->tp_as_number->nb_remainder)(v, w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2199 DECREF(v); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2200 DECREF(w); |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2201 return x; |
|
d19a665904df
Call coerce() in arithmetic operations, to support mixed mode arithmetic
Guido van Rossum <guido@python.org>
parents:
284
diff
changeset
|
2202 } |
| 86 | 2203 err_setstr(TypeError, "bad operand type(s) for %"); |
| 69 | 2204 return NULL; |
| 2205 } | |
| 2206 | |
| 2207 static object * | |
| 86 | 2208 neg(v) |
| 69 | 2209 object *v; |
| 2210 { | |
| 2211 if (v->ob_type->tp_as_number != NULL) | |
| 86 | 2212 return (*v->ob_type->tp_as_number->nb_negative)(v); |
| 2213 err_setstr(TypeError, "bad operand type(s) for unary -"); | |
| 2214 return NULL; | |
| 2215 } | |
| 2216 | |
| 2217 static object * | |
| 2218 pos(v) | |
| 2219 object *v; | |
| 2220 { | |
| 2221 if (v->ob_type->tp_as_number != NULL) | |
| 2222 return (*v->ob_type->tp_as_number->nb_positive)(v); | |
| 2223 err_setstr(TypeError, "bad operand type(s) for unary +"); | |
| 69 | 2224 return NULL; |
| 2225 } | |
| 2226 | |
| 2227 static object * | |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2228 invert(v) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2229 object *v; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2230 { |
|
671
10002e1bc526
Use correct prototype for invert().
Guido van Rossum <guido@python.org>
parents:
661
diff
changeset
|
2231 object * (*f) FPROTO((object *)); |
|
409
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2232 if (v->ob_type->tp_as_number != NULL && |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2233 (f = v->ob_type->tp_as_number->nb_invert) != NULL) |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2234 return (*f)(v); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2235 err_setstr(TypeError, "bad operand type(s) for unary ~"); |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2236 return NULL; |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2237 } |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2238 |
|
b5fe6482072f
Added shift and mask ops.
Guido van Rossum <guido@python.org>
parents:
401
diff
changeset
|
2239 static object * |
| 86 | 2240 not(v) |
| 69 | 2241 object *v; |
| 2242 { | |
| 86 | 2243 int outcome = testbool(v); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2244 object *w; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2245 if (outcome < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2246 return NULL; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2247 if (outcome == 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2248 w = True; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2249 else |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2250 w = False; |
| 86 | 2251 INCREF(w); |
| 2252 return w; | |
| 69 | 2253 } |
|
1313
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1293
diff
changeset
|
2254 |
|
6ee380349c84
* Added gmtime/localtime/mktime and SYSV timezone globals to timemodule.c.
Guido van Rossum <guido@python.org>
parents:
1293
diff
changeset
|
2255 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2256 /* External interface to call any callable object. |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2257 The arg must be a tuple or NULL. */ |
|
314
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2258 |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2259 object * |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2260 call_object(func, arg) |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2261 object *func; |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2262 object *arg; |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2263 { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2264 return PyEval_CallObjectWithKeywords(func, arg, (object *)NULL); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2265 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2266 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2267 object * |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2268 PyEval_CallObjectWithKeywords(func, arg, kw) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2269 object *func; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2270 object *arg; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2271 object *kw; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2272 { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2273 ternaryfunc call; |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2274 object *result; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2275 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2276 if (arg == NULL) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2277 arg = newtupleobject(0); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2278 else if (!is_tupleobject(arg)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2279 err_setstr(TypeError, "argument list must be a tuple"); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2280 return NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2281 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2282 else |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2283 INCREF(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2284 |
|
2894
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2285 if (kw != NULL && !is_dictobject(kw)) { |
|
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2286 err_setstr(TypeError, "keyword list must be a dictionary"); |
|
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2287 return NULL; |
|
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2288 } |
|
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2289 |
|
2589
d5d27dad7fea
remove unused code for tp_call
Guido van Rossum <guido@python.org>
parents:
2503
diff
changeset
|
2290 if (call = func->ob_type->tp_call) |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2291 result = (*call)(func, arg, kw); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2292 else if (is_instancemethodobject(func) || is_funcobject(func)) |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2293 result = call_function(func, arg, kw); |
|
314
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2294 else |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2295 result = call_builtin(func, arg, kw); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2296 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2297 DECREF(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2298 |
|
2006
3aa9184cff8b
replace abort() calls by fatal()
Guido van Rossum <guido@python.org>
parents:
1914
diff
changeset
|
2299 if (result == NULL && !err_occurred()) |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2300 err_setstr(SystemError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2301 "NULL result without error in call_object"); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2302 |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2303 return result; |
|
314
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2304 } |
|
e83852d1a5e2
Add interface to call a Python function (or other callable) object
Guido van Rossum <guido@python.org>
parents:
312
diff
changeset
|
2305 |
| 69 | 2306 static object * |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2307 call_builtin(func, arg, kw) |
| 69 | 2308 object *func; |
| 86 | 2309 object *arg; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2310 object *kw; |
| 69 | 2311 { |
| 2312 if (is_methodobject(func)) { | |
| 2313 method meth = getmethod(func); | |
| 2314 object *self = getself(func); | |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2315 int flags = getflags(func); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2316 if (!(flags & METH_VARARGS)) { |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2317 int size = gettuplesize(arg); |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2318 if (size == 1) |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2319 arg = GETTUPLEITEM(arg, 0); |
|
481
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2320 else if (size == 0) |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2321 arg = NULL; |
|
dc0463453a64
New argument passing mechanism.
Guido van Rossum <guido@python.org>
parents:
464
diff
changeset
|
2322 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2323 if (flags & METH_KEYWORDS) |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2324 return (*(PyCFunctionWithKeywords)meth)(self, arg, kw); |
|
2894
4095782c940e
empty kw dict is ok for builtins
Guido van Rossum <guido@python.org>
parents:
2872
diff
changeset
|
2325 if (kw != NULL && getmappingsize(kw) != 0) { |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2326 err_setstr(TypeError, |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2327 "this function takes no keyword arguments"); |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2328 return NULL; |
|
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2329 } |
| 86 | 2330 return (*meth)(self, arg); |
| 69 | 2331 } |
| 2332 if (is_classobject(func)) { | |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2333 return newinstanceobject(func, arg, kw); |
| 69 | 2334 } |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2335 if (is_instanceobject(func)) { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2336 object *res, *call = getattr(func,"__call__"); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2337 if (call == NULL) { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2338 err_clear(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2339 err_setstr(AttributeError, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2340 "no __call__ method defined"); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2341 return NULL; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2342 } |
|
2866
14111d66577d
changes for keyword args to built-in functions and classes
Guido van Rossum <guido@python.org>
parents:
2844
diff
changeset
|
2343 res = PyEval_CallObjectWithKeywords(call, arg, kw); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2344 DECREF(call); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2345 return res; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2346 } |
| 86 | 2347 err_setstr(TypeError, "call of non-function"); |
| 69 | 2348 return NULL; |
| 2349 } | |
| 2350 | |
| 2351 static object * | |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2352 call_function(func, arg, kw) |
| 69 | 2353 object *func; |
| 86 | 2354 object *arg; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2355 object *kw; |
| 69 | 2356 { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2357 object *class = NULL; /* == owner */ |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2358 object *argdefs; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2359 object **d, **k; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2360 int nk, nd; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2361 object *result; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2362 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2363 if (kw != NULL && !is_dictobject(kw)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2364 err_badcall(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2365 return NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2366 } |
| 69 | 2367 |
|
224
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2368 if (is_instancemethodobject(func)) { |
|
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2369 object *self = instancemethodgetself(func); |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2370 class = instancemethodgetclass(func); |
|
224
e71b6fec86e5
Renamed class methods to instance methods (which they are)
Guido van Rossum <guido@python.org>
parents:
173
diff
changeset
|
2371 func = instancemethodgetfunc(func); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2372 if (self == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2373 /* Unbound methods must be called with an instance of |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2374 the class (or a derived class) as first argument */ |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2375 if (gettuplesize(arg) >= 1) { |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2376 self = GETTUPLEITEM(arg, 0); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2377 if (self != NULL && |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2378 is_instanceobject(self) && |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2379 issubclass((object *) |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2380 (((instanceobject *)self)->in_class), |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2381 class)) |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2382 /* Handy-dandy */ ; |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2383 else |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2384 self = NULL; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2385 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2386 if (self == NULL) { |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2387 err_setstr(TypeError, |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2388 "unbound method must be called with class instance 1st argument"); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2389 return NULL; |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2390 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2391 INCREF(arg); |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2392 } |
|
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2393 else { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2394 int argcount = gettuplesize(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2395 object *newarg = newtupleobject(argcount + 1); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2396 int i; |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2397 if (newarg == NULL) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2398 return NULL; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2399 INCREF(self); |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2400 SETTUPLEITEM(newarg, 0, self); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2401 for (i = 0; i < argcount; i++) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2402 object *v = GETTUPLEITEM(arg, i); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2403 XINCREF(v); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2404 SETTUPLEITEM(newarg, i+1, v); |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2405 } |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2406 arg = newarg; |
| 69 | 2407 } |
| 2408 } | |
| 2409 else { | |
| 2410 if (!is_funcobject(func)) { | |
| 86 | 2411 err_setstr(TypeError, "call of non-function"); |
| 69 | 2412 return NULL; |
| 2413 } | |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2414 INCREF(arg); |
| 69 | 2415 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2416 |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2417 argdefs = PyFunction_GetDefaults(func); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2418 if (argdefs != NULL && is_tupleobject(argdefs)) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2419 d = &GETTUPLEITEM((tupleobject *)argdefs, 0); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2420 nd = gettuplesize(argdefs); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2421 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2422 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2423 d = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2424 nd = 0; |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2425 } |
| 69 | 2426 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2427 if (kw != NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2428 int pos, i; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2429 nk = getmappingsize(kw); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2430 k = NEW(object *, 2*nk); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2431 if (k == NULL) { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2432 err_nomem(); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2433 DECREF(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2434 return NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2435 } |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2436 pos = i = 0; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2437 while (mappinggetnext(kw, &pos, &k[i], &k[i+1])) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2438 i += 2; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2439 nk = i/2; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2440 /* XXX This is broken if the caller deletes dict items! */ |
| 69 | 2441 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2442 else { |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2443 k = NULL; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2444 nk = 0; |
| 69 | 2445 } |
| 2446 | |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2447 result = eval_code2( |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2448 (codeobject *)getfunccode(func), |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2449 getfuncglobals(func), (object *)NULL, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2450 &GETTUPLEITEM(arg, 0), gettuplesize(arg), |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2451 k, nk, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2452 d, nd, |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2453 class); |
| 69 | 2454 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2455 DECREF(arg); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2456 XDEL(k); |
| 69 | 2457 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2458 return result; |
| 69 | 2459 } |
| 2460 | |
| 2461 static object * | |
| 86 | 2462 apply_subscript(v, w) |
| 69 | 2463 object *v, *w; |
| 2464 { | |
| 2465 typeobject *tp = v->ob_type; | |
| 2466 if (tp->tp_as_sequence == NULL && tp->tp_as_mapping == NULL) { | |
| 86 | 2467 err_setstr(TypeError, "unsubscriptable object"); |
| 69 | 2468 return NULL; |
| 2469 } | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2470 if (tp->tp_as_mapping != NULL) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2471 return (*tp->tp_as_mapping->mp_subscript)(v, w); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2472 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2473 else { |
| 69 | 2474 int i; |
| 2475 if (!is_intobject(w)) { | |
| 86 | 2476 err_setstr(TypeError, "sequence subscript not int"); |
| 69 | 2477 return NULL; |
| 2478 } | |
| 2479 i = getintvalue(w); | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2480 if (i < 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2481 int len = (*tp->tp_as_sequence->sq_length)(v); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2482 if (len < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2483 return NULL; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2484 i += len; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2485 } |
| 86 | 2486 return (*tp->tp_as_sequence->sq_item)(v, i); |
| 69 | 2487 } |
| 2488 } | |
| 2489 | |
| 2490 static object * | |
| 86 | 2491 loop_subscript(v, w) |
| 69 | 2492 object *v, *w; |
| 2493 { | |
| 2494 sequence_methods *sq = v->ob_type->tp_as_sequence; | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2495 int i; |
| 69 | 2496 if (sq == NULL) { |
| 86 | 2497 err_setstr(TypeError, "loop over non-sequence"); |
| 69 | 2498 return NULL; |
| 2499 } | |
| 2500 i = getintvalue(w); | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2501 v = (*sq->sq_item)(v, i); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2502 if (v) |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2503 return v; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2504 if (err_occurred() == IndexError) |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2505 err_clear(); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2506 return NULL; |
| 69 | 2507 } |
| 2508 | |
| 2509 static int | |
| 86 | 2510 slice_index(v, isize, pi) |
| 69 | 2511 object *v; |
| 2512 int isize; | |
| 2513 int *pi; | |
| 2514 { | |
| 2515 if (v != NULL) { | |
| 2516 if (!is_intobject(v)) { | |
| 86 | 2517 err_setstr(TypeError, "slice index must be int"); |
| 2518 return -1; | |
| 69 | 2519 } |
| 2520 *pi = getintvalue(v); | |
| 2521 if (*pi < 0) | |
| 2522 *pi += isize; | |
| 2523 } | |
| 86 | 2524 return 0; |
| 69 | 2525 } |
| 2526 | |
| 2527 static object * | |
| 86 | 2528 apply_slice(u, v, w) /* return u[v:w] */ |
| 69 | 2529 object *u, *v, *w; |
| 2530 { | |
| 2531 typeobject *tp = u->ob_type; | |
| 2532 int ilow, ihigh, isize; | |
| 2533 if (tp->tp_as_sequence == NULL) { | |
| 86 | 2534 err_setstr(TypeError, "only sequences can be sliced"); |
| 69 | 2535 return NULL; |
| 2536 } | |
| 2537 ilow = 0; | |
| 2538 isize = ihigh = (*tp->tp_as_sequence->sq_length)(u); | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2539 if (isize < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2540 return NULL; |
| 86 | 2541 if (slice_index(v, isize, &ilow) != 0) |
| 69 | 2542 return NULL; |
| 86 | 2543 if (slice_index(w, isize, &ihigh) != 0) |
| 69 | 2544 return NULL; |
| 86 | 2545 return (*tp->tp_as_sequence->sq_slice)(u, ilow, ihigh); |
| 69 | 2546 } |
| 86 | 2547 |
| 2548 static int | |
| 2549 assign_subscript(w, key, v) /* w[key] = v */ | |
| 69 | 2550 object *w; |
| 2551 object *key; | |
| 2552 object *v; | |
| 2553 { | |
| 2554 typeobject *tp = w->ob_type; | |
| 2555 sequence_methods *sq; | |
| 2556 mapping_methods *mp; | |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2557 int (*func1)(); |
|
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2558 int (*func2)(); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2559 if ((mp = tp->tp_as_mapping) != NULL && |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2560 (func1 = mp->mp_ass_subscript) != NULL) { |
|
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2561 return (*func1)(w, key, v); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2562 } |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2563 else if ((sq = tp->tp_as_sequence) != NULL && |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2564 (func2 = sq->sq_ass_item) != NULL) { |
| 69 | 2565 if (!is_intobject(key)) { |
| 86 | 2566 err_setstr(TypeError, |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2567 "sequence subscript must be integer (assign or del)"); |
| 86 | 2568 return -1; |
| 69 | 2569 } |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2570 else { |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2571 int i = getintvalue(key); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2572 if (i < 0) { |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2573 int len = (*sq->sq_length)(w); |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2574 if (len < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2575 return -1; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2576 i += len; |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2577 } |
|
2366
94bf2f05da31
fix bug in try-finally with class exceptions; declare different func pointers for different uses
Guido van Rossum <guido@python.org>
parents:
2338
diff
changeset
|
2578 return (*func2)(w, i, v); |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2579 } |
| 69 | 2580 } |
| 2581 else { | |
| 86 | 2582 err_setstr(TypeError, |
| 2583 "can't assign to this subscripted object"); | |
| 2584 return -1; | |
| 69 | 2585 } |
| 2586 } | |
| 2587 | |
| 86 | 2588 static int |
| 2589 assign_slice(u, v, w, x) /* u[v:w] = x */ | |
| 69 | 2590 object *u, *v, *w, *x; |
| 2591 { | |
| 86 | 2592 sequence_methods *sq = u->ob_type->tp_as_sequence; |
| 69 | 2593 int ilow, ihigh, isize; |
| 86 | 2594 if (sq == NULL) { |
| 2595 err_setstr(TypeError, "assign to slice of non-sequence"); | |
| 2596 return -1; | |
| 2597 } | |
| 2598 if (sq == NULL || sq->sq_ass_slice == NULL) { | |
| 2599 err_setstr(TypeError, "unassignable slice"); | |
| 2600 return -1; | |
| 69 | 2601 } |
| 2602 ilow = 0; | |
| 86 | 2603 isize = ihigh = (*sq->sq_length)(u); |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2604 if (isize < 0) |
|
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2605 return -1; |
| 86 | 2606 if (slice_index(v, isize, &ilow) != 0) |
| 2607 return -1; | |
| 2608 if (slice_index(w, isize, &ihigh) != 0) | |
| 2609 return -1; | |
| 2610 return (*sq->sq_ass_slice)(u, ilow, ihigh, x); | |
| 69 | 2611 } |
| 2612 | |
| 2613 static int | |
| 2614 cmp_exception(err, v) | |
| 2615 object *err, *v; | |
| 2616 { | |
| 2617 if (is_tupleobject(v)) { | |
| 2618 int i, n; | |
| 2619 n = gettuplesize(v); | |
| 2620 for (i = 0; i < n; i++) { | |
|
464
90300ca21200
Added STORE_GLOBAL and DELETE_GLOBAL.
Guido van Rossum <guido@python.org>
parents:
409
diff
changeset
|
2621 /* Test recursively */ |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2622 if (cmp_exception(err, GETTUPLEITEM(v, i))) |
| 69 | 2623 return 1; |
| 2624 } | |
| 2625 return 0; | |
| 2626 } | |
|
2243
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
2627 if (is_classobject(v) && is_classobject(err)) |
|
283a8eb2e317
allow classes as exceptions
Guido van Rossum <guido@python.org>
parents:
2201
diff
changeset
|
2628 return issubclass(err, v); |
| 69 | 2629 return err == v; |
| 2630 } | |
| 2631 | |
| 86 | 2632 static int |
| 2633 cmp_member(v, w) | |
| 2634 object *v, *w; | |
| 2635 { | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2636 int i, cmp; |
| 86 | 2637 object *x; |
| 2638 sequence_methods *sq; | |
| 2639 /* Special case for char in string */ | |
| 2640 if (is_stringobject(w)) { | |
| 2641 register char *s, *end; | |
| 2642 register char c; | |
| 2643 if (!is_stringobject(v) || getstringsize(v) != 1) { | |
| 2644 err_setstr(TypeError, | |
| 2645 "string member test needs char left operand"); | |
| 2646 return -1; | |
| 2647 } | |
| 2648 c = getstringvalue(v)[0]; | |
| 2649 s = getstringvalue(w); | |
| 2650 end = s + getstringsize(w); | |
| 2651 while (s < end) { | |
| 2652 if (c == *s++) | |
| 2653 return 1; | |
| 2654 } | |
| 2655 return 0; | |
| 2656 } | |
| 2657 sq = w->ob_type->tp_as_sequence; | |
| 2658 if (sq == NULL) { | |
| 2659 err_setstr(TypeError, | |
| 2660 "'in' or 'not in' needs sequence right argument"); | |
| 2661 return -1; | |
| 2662 } | |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2663 for (i = 0; ; i++) { |
| 86 | 2664 x = (*sq->sq_item)(w, i); |
|
1846
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2665 if (x == NULL) { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2666 if (err_occurred() == IndexError) { |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2667 err_clear(); |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2668 break; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2669 } |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2670 return -1; |
|
5243fb187d36
call_object: print message before abort()
Guido van Rossum <guido@python.org>
parents:
1425
diff
changeset
|
2671 } |
| 86 | 2672 cmp = cmpobject(v, x); |
| 2673 XDECREF(x); | |
| 2674 if (cmp == 0) | |
| 2675 return 1; | |
| 2676 } | |
| 2677 return 0; | |
| 2678 } | |
| 2679 | |
| 69 | 2680 static object * |
| 86 | 2681 cmp_outcome(op, v, w) |
|
802
3d6541a2eca5
Arg of cmp_outcome becomes an int for portability to the Mac
Guido van Rossum <guido@python.org>
parents:
789
diff
changeset
|
2682 int op; |
| 69 | 2683 register object *v; |
| 2684 register object *w; | |
| 2685 { | |
| 2686 register int cmp; | |
| 2687 register int res = 0; | |
| 2688 switch (op) { | |
| 86 | 2689 case IS: |
| 2690 case IS_NOT: | |
| 2691 res = (v == w); | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2692 if (op == (int) IS_NOT) |
| 86 | 2693 res = !res; |
| 2694 break; | |
| 69 | 2695 case IN: |
| 2696 case NOT_IN: | |
| 86 | 2697 res = cmp_member(v, w); |
| 2698 if (res < 0) | |
| 2699 return NULL; | |
|
944
222f04f55083
Changes so that user-defined classes can implement operations invoked
Guido van Rossum <guido@python.org>
parents:
926
diff
changeset
|
2700 if (op == (int) NOT_IN) |
| 86 | 2701 res = !res; |
| 69 | 2702 break; |
| 2703 case EXC_MATCH: | |
| 86 | 2704 res = cmp_exception(v, w); |
| 69 | 2705 break; |
| 2706 default: | |
| 86 | 2707 cmp = cmpobject(v, w); |
| 2708 switch (op) { | |
| 2709 case LT: res = cmp < 0; break; | |
| 2710 case LE: res = cmp <= 0; break; | |
| 2711 case EQ: res = cmp == 0; break; | |
| 2712 case NE: res = cmp != 0; break; | |
| 2713 case GT: res = cmp > 0; break; | |
| 2714 case GE: res = cmp >= 0; break; | |
| 2715 /* XXX no default? (res is initialized to 0 though) */ | |
| 2716 } | |
| 69 | 2717 } |
| 2718 v = res ? True : False; | |
| 2719 INCREF(v); | |
| 2720 return v; | |
| 2721 } | |
| 2722 | |
| 86 | 2723 static int |
| 2724 import_from(locals, v, name) | |
| 2725 object *locals; | |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2726 object *v; |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2727 object *name; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2728 { |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2729 object *w, *x; |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2730 if (!is_moduleobject(v)) { |
|
2201
8f1daffe799b
add missing INCREF in RAISE_EXCEPTION
Guido van Rossum <guido@python.org>
parents:
2151
diff
changeset
|
2731 err_setstr(TypeError, "import-from requires module object"); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2732 return -1; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2733 } |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2734 w = getmoduledict(v); |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2735 if (getstringvalue(name)[0] == '*') { |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2736 int pos, err; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2737 object *name, *value; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2738 pos = 0; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2739 while (mappinggetnext(w, &pos, &name, &value)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2740 if (!is_stringobject(name) || |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2741 getstringvalue(name)[0] == '_') |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2742 continue; |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2743 if (is_accessobject(value)) { |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2744 value = getaccessvalue(value, (object *)NULL); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2745 if (value == NULL) { |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2746 err_clear(); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2747 continue; |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2748 } |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2749 } |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2750 else |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2751 INCREF(value); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2752 err = dict2insert(locals, name, value); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2753 DECREF(value); |
|
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2754 if (err != 0) |
| 86 | 2755 return -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2756 } |
| 86 | 2757 return 0; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2758 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2759 else { |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2760 x = dict2lookup(w, name); |
| 86 | 2761 if (x == NULL) { |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2762 char buf[250]; |
|
661
7e5f4d9aee77
Limit length of name passed to sprintf.
Guido van Rossum <guido@python.org>
parents:
607
diff
changeset
|
2763 sprintf(buf, "cannot import name %.230s", |
|
506
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2764 getstringvalue(name)); |
|
9f7161db5669
Negative subscript are now allowed as in slices.
Guido van Rossum <guido@python.org>
parents:
481
diff
changeset
|
2765 err_setstr(ImportError, buf); |
| 86 | 2766 return -1; |
| 2767 } | |
| 2768 else | |
|
334
449f5e5d9af6
Changed many calls to dict stufff to dict2 variants.
Guido van Rossum <guido@python.org>
parents:
314
diff
changeset
|
2769 return dict2insert(locals, name, x); |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2770 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2771 } |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2772 |
|
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2773 static object * |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2774 build_class(methods, bases, name) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2775 object *methods; /* dictionary */ |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2776 object *bases; /* tuple containing classes */ |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2777 object *name; /* string */ |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2778 { |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2779 int i; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2780 if (!is_tupleobject(bases)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2781 err_setstr(SystemError, "build_class with non-tuple bases"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2782 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2783 } |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2784 if (gettuplesize(bases) > 0) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2785 object *base; |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2786 base = GETTUPLEITEM(bases, 0); |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2787 /* Call the base's *type*, if it is callable. |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2788 This code is a hook for Donald Beaudry's type extensions. |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2789 In unexended Python it will never be triggered since its |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2790 types are not callable. */ |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2791 if (base->ob_type->ob_type->tp_call) { |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2792 object *args; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2793 object *class; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2794 args = mkvalue("(OOO)", name, bases, methods); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2795 class = call_object((object *)base->ob_type, args); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2796 DECREF(args); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2797 return class; |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2798 } |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
2006
diff
changeset
|
2799 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2800 if (!is_dictobject(methods)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2801 err_setstr(SystemError, "build_class with non-dictionary"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2802 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2803 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2804 if (!is_stringobject(name)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2805 err_setstr(SystemError, "build_class witn non-string name"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2806 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2807 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2808 for (i = gettuplesize(bases); --i >= 0; ) { |
|
2503
4dd1af0ddef0
various tuple related optimizations; remove unused b/w compat code from ceval.c
Guido van Rossum <guido@python.org>
parents:
2366
diff
changeset
|
2809 object *base = GETTUPLEITEM(bases, i); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2810 if (!is_classobject(base)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2811 err_setstr(TypeError, |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2812 "base is not a class object"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2813 return NULL; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2814 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2815 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2816 return newclassobject(bases, methods, name); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2817 } |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2818 |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2819 static int |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2820 access_statement(name, vmode, f) |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2821 object *name; |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2822 object *vmode; |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2823 frameobject *f; |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2824 { |
|
1290
7971fecbf28e
* Lots of small changes related to access.
Guido van Rossum <guido@python.org>
parents:
1289
diff
changeset
|
2825 int mode = getintvalue(vmode); |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2826 object *value, *ac; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2827 typeobject *type; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2828 int ret; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2829 fast_2_locals(f); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2830 value = dict2lookup(f->f_locals, name); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2831 if (value && is_accessobject(value)) { |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2832 err_setstr(AccessError, "can't override access"); |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2833 return -1; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2834 } |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2835 err_clear(); |
|
1289
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2836 if (value != NULL && value != None) |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2837 type = value->ob_type; |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2838 else |
|
4d292c7857d4
Access checks now work, at least for instance data (not for methods
Guido van Rossum <guido@python.org>
parents:
1288
diff
changeset
|
2839 type = NULL; |
|
1293
ac3c80abbf43
* classobject.c: in instance_getattr, don't make a method out of a
Guido van Rossum <guido@python.org>
parents:
1290
diff
changeset
|
2840 ac = newaccessobject(value, f->f_locals, type, mode); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2841 if (ac == NULL) |
|
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2842 return -1; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2843 ret = mappinginsert(f->f_locals, name, ac); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2844 DECREF(ac); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2845 locals_2_fast(f, 0); |
|
1288
9fed5726a36d
Several changes in one:
Guido van Rossum <guido@python.org>
parents:
1282
diff
changeset
|
2846 return ret; |
|
72
5e8a0b40a4bd
Free parse tree after compiling.
Guido van Rossum <guido@python.org>
parents:
69
diff
changeset
|
2847 } |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2848 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2849 static int |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2850 exec_statement(prog, globals, locals) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2851 object *prog; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2852 object *globals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2853 object *locals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2854 { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2855 char *s; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2856 int n; |
|
2295
3d6c9a47ea44
DECREF result of run_string
Guido van Rossum <guido@python.org>
parents:
2271
diff
changeset
|
2857 object *v; |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2858 int plain = 0; |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2859 |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2860 if (is_tupleobject(prog) && globals == None && locals == None && |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2861 ((n = gettuplesize(prog)) == 2 || n == 3)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2862 /* Backward compatibility hack */ |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2863 globals = gettupleitem(prog, 1); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2864 if (n == 3) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2865 locals = gettupleitem(prog, 2); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2866 prog = gettupleitem(prog, 0); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2867 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2868 if (globals == None) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2869 globals = getglobals(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2870 if (locals == None) { |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2871 locals = getlocals(); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2872 plain = 1; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2873 } |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2874 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2875 else if (locals == None) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2876 locals = globals; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2877 if (!is_stringobject(prog) && |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2878 !is_codeobject(prog) && |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2879 !is_fileobject(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2880 err_setstr(TypeError, |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2881 "exec 1st arg must be string, code or file object"); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2882 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2883 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2884 if (!is_dictobject(globals) || !is_dictobject(locals)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2885 err_setstr(TypeError, |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2886 "exec 2nd/3rd args must be dict or None"); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2887 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2888 } |
|
2098
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
2889 if (dictlookup(globals, "__builtins__") == NULL) |
|
b7be0382f9ee
__builtins__ mods (and sys_checkinterval for ceval.c)
Guido van Rossum <guido@python.org>
parents:
2088
diff
changeset
|
2890 dictinsert(globals, "__builtins__", current_frame->f_builtins); |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2891 if (is_codeobject(prog)) { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2892 if (eval_code((codeobject *) prog, globals, locals) == NULL) |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2893 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2894 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2895 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2896 if (is_fileobject(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2897 FILE *fp = getfilefile(prog); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2898 char *name = getstringvalue(getfilename(prog)); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2899 if (run_file(fp, name, file_input, globals, locals) == NULL) |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2900 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2901 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2902 } |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2903 s = getstringvalue(prog); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2904 if (strlen(s) != getstringsize(prog)) { |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2905 err_setstr(ValueError, "embedded '\\0' in exec string"); |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2906 return -1; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2907 } |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2908 v = run_string(s, file_input, globals, locals); |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2909 if (v == NULL) |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2910 return -1; |
|
2295
3d6c9a47ea44
DECREF result of run_string
Guido van Rossum <guido@python.org>
parents:
2271
diff
changeset
|
2911 DECREF(v); |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2912 if (plain) |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2913 locals_2_fast(current_frame, 0); |
|
1354
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2914 return 0; |
|
fccd415e2eb8
* bltinmodule.c: removed exec() built-in function.
Guido van Rossum <guido@python.org>
parents:
1319
diff
changeset
|
2915 } |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2916 |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2917 /* Hack for newimp.py */ |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2918 static object * |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2919 find_from_args(f, nexti) |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2920 frameobject *f; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2921 int nexti; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2922 { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2923 int opcode; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2924 int oparg; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2925 object *list, *name; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2926 unsigned char *next_instr; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2927 |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2928 next_instr = GETUSTRINGVALUE(f->f_code->co_code) + nexti; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2929 opcode = (*next_instr++); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2930 if (opcode != IMPORT_FROM) { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2931 INCREF(None); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2932 return None; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2933 } |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2934 |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2935 list = newlistobject(0); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2936 if (list == NULL) |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2937 return NULL; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2938 |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2939 do { |
|
2844
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2940 oparg = (next_instr[1]<<8) + next_instr[0]; |
|
0261bf5b3819
keyword arguments and faster calls
Guido van Rossum <guido@python.org>
parents:
2813
diff
changeset
|
2941 next_instr += 2; |
|
2338
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2942 name = Getnamev(f, oparg); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2943 if (addlistitem(list, name) < 0) { |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2944 DECREF(list); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2945 break; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2946 } |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2947 opcode = (*next_instr++); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2948 } while (opcode == IMPORT_FROM); |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2949 |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2950 return list; |
|
4c2f1452125d
call __import__() with 4 args instead of 1
Guido van Rossum <guido@python.org>
parents:
2310
diff
changeset
|
2951 } |
