Mercurial > cpython-lru_cache-weakref
annotate Python/sysmodule.c @ 4256:e225e70fd657 legacy-trunk
Changes to setpythonpath():
Test for / as well as for SEP for MS filenames.
Drop trailing separator from sys.path[0] for MS and Unix filenames.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Tue, 10 Sep 1996 14:44:21 +0000 |
| parents | c80c515999b9 |
| children | 1427d61f1307 |
| rev | line source |
|---|---|
| 145 | 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 | 4 |
| 5 All Rights Reserved | |
| 6 | |
| 7 Permission to use, copy, modify, and distribute this software and its | |
| 8 documentation for any purpose and without fee is hereby granted, | |
| 9 provided that the above copyright notice appear in all copies and that | |
| 10 both that copyright notice and this permission notice appear in | |
| 11 supporting documentation, and that the names of Stichting Mathematisch | |
| 12 Centrum or CWI not be used in advertising or publicity pertaining to | |
| 13 distribution of the software without specific, written prior permission. | |
| 14 | |
| 15 STICHTING MATHEMATISCH CENTRUM DISCLAIMS ALL WARRANTIES WITH REGARD TO | |
| 16 THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
| 17 FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH CENTRUM BE LIABLE | |
| 18 FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
| 19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
| 20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT | |
| 21 OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
| 22 | |
| 23 ******************************************************************/ | |
| 24 | |
| 6 | 25 /* System module */ |
| 26 | |
| 27 /* | |
| 28 Various bits of information used by the interpreter are collected in | |
| 29 module 'sys'. | |
| 86 | 30 Function member: |
|
2586
ae131b8b4e31
fix comment about exit()
Guido van Rossum <guido@python.org>
parents:
2421
diff
changeset
|
31 - exit(sts): raise SystemExit |
| 6 | 32 Data members: |
| 33 - stdin, stdout, stderr: standard file objects | |
| 86 | 34 - modules: the table of modules (dictionary) |
| 6 | 35 - path: module search path (list of strings) |
| 86 | 36 - argv: script arguments (list of strings) |
| 37 - ps1, ps2: optional primary and secondary prompts (strings) | |
| 6 | 38 */ |
| 39 | |
| 86 | 40 #include "allobjects.h" |
| 41 | |
| 42 #include "sysmodule.h" | |
| 43 #include "import.h" | |
| 44 #include "modsupport.h" | |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
45 #include "osdefs.h" |
| 86 | 46 |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
47 object *sys_trace, *sys_profile; |
|
2618
6cc637c60ce6
init sys_checkinterval to 10
Guido van Rossum <guido@python.org>
parents:
2586
diff
changeset
|
48 int sys_checkinterval = 10; |
| 6 | 49 |
| 50 static object *sysdict; | |
| 51 | |
|
3490
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
52 #ifdef NT |
|
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
53 extern void *PyWin_DLLhModule; |
|
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
54 #endif |
|
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
55 |
| 6 | 56 object * |
| 57 sysget(name) | |
| 58 char *name; | |
| 59 { | |
| 60 return dictlookup(sysdict, name); | |
| 61 } | |
| 62 | |
| 63 FILE * | |
| 64 sysgetfile(name, def) | |
| 65 char *name; | |
| 66 FILE *def; | |
| 67 { | |
| 68 FILE *fp = NULL; | |
| 69 object *v = sysget(name); | |
|
1073
2c0432fcc270
Modified most (but not yet all) I/O to always go through sys.stdout or
Guido van Rossum <guido@python.org>
parents:
1013
diff
changeset
|
70 if (v != NULL && is_fileobject(v)) |
| 6 | 71 fp = getfilefile(v); |
| 72 if (fp == NULL) | |
| 73 fp = def; | |
| 74 return fp; | |
| 75 } | |
| 76 | |
| 77 int | |
| 78 sysset(name, v) | |
| 79 char *name; | |
| 80 object *v; | |
| 81 { | |
|
631
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
82 if (v == NULL) { |
|
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
83 if (dictlookup(sysdict, name) == NULL) |
|
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
84 return 0; |
|
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
85 else |
|
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
86 return dictremove(sysdict, name); |
|
f5a2bc39e10e
sysset(name, NULL) does nothing if sys.name is undefined
Guido van Rossum <guido@python.org>
parents:
596
diff
changeset
|
87 } |
| 6 | 88 else |
| 89 return dictinsert(sysdict, name, v); | |
| 90 } | |
| 91 | |
| 92 static object * | |
| 93 sys_exit(self, args) | |
| 94 object *self; | |
| 95 object *args; | |
| 96 { | |
|
549
4efff6cea90f
Raise SystemExit instead of calling goaway().
Guido van Rossum <guido@python.org>
parents:
476
diff
changeset
|
97 /* Raise SystemExit so callers may catch it or clean up. */ |
|
4efff6cea90f
Raise SystemExit instead of calling goaway().
Guido van Rossum <guido@python.org>
parents:
476
diff
changeset
|
98 err_setval(SystemExit, args); |
|
4efff6cea90f
Raise SystemExit instead of calling goaway().
Guido van Rossum <guido@python.org>
parents:
476
diff
changeset
|
99 return NULL; |
| 6 | 100 } |
| 101 | |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
102 static object * |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
103 sys_settrace(self, args) |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
104 object *self; |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
105 object *args; |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
106 { |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
107 if (args == None) |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
108 args = NULL; |
|
788
ba4ec13c0f9f
Fix reference counts of sys_trace and sys_profile
Guido van Rossum <guido@python.org>
parents:
710
diff
changeset
|
109 else |
|
901
fea3f594df77
sysmodule.c: calling sys.settrace() or sys.setprofile() without
Guido van Rossum <guido@python.org>
parents:
788
diff
changeset
|
110 XINCREF(args); |
|
788
ba4ec13c0f9f
Fix reference counts of sys_trace and sys_profile
Guido van Rossum <guido@python.org>
parents:
710
diff
changeset
|
111 XDECREF(sys_trace); |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
112 sys_trace = args; |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
113 INCREF(None); |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
114 return None; |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
115 } |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
116 |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
117 static object * |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
118 sys_setprofile(self, args) |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
119 object *self; |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
120 object *args; |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
121 { |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
122 if (args == None) |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
123 args = NULL; |
|
788
ba4ec13c0f9f
Fix reference counts of sys_trace and sys_profile
Guido van Rossum <guido@python.org>
parents:
710
diff
changeset
|
124 else |
|
901
fea3f594df77
sysmodule.c: calling sys.settrace() or sys.setprofile() without
Guido van Rossum <guido@python.org>
parents:
788
diff
changeset
|
125 XINCREF(args); |
|
788
ba4ec13c0f9f
Fix reference counts of sys_trace and sys_profile
Guido van Rossum <guido@python.org>
parents:
710
diff
changeset
|
126 XDECREF(sys_profile); |
|
710
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
127 sys_profile = args; |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
128 INCREF(None); |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
129 return None; |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
130 } |
|
bc5c77fa8006
Added settrace() and setprofile().
Guido van Rossum <guido@python.org>
parents:
631
diff
changeset
|
131 |
|
2093
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
132 static object * |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
133 sys_setcheckinterval(self, args) |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
134 object *self; |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
135 object *args; |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
136 { |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
137 if (!newgetargs(args, "i", &sys_checkinterval)) |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
138 return NULL; |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
139 INCREF(None); |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
140 return None; |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
141 } |
|
e8cafb2b743a
sys.check_interval=x -> sys.setcheckinterval(x)
Guido van Rossum <guido@python.org>
parents:
2062
diff
changeset
|
142 |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
143 #ifdef USE_MALLOPT |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
144 /* Link with -lmalloc (or -lmpc) on an SGI */ |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
145 #include <malloc.h> |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
146 |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
147 static object * |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
148 sys_mdebug(self, args) |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
149 object *self; |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
150 object *args; |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
151 { |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
152 int flag; |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
153 if (!getargs(args, "i", &flag)) |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
154 return NULL; |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
155 mallopt(M_DEBUG, flag); |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
156 INCREF(None); |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
157 return None; |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
158 } |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
159 #endif /* USE_MALLOPT */ |
|
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
160 |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
161 static object * |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
162 sys_getrefcount(self, args) |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
163 object *self; |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
164 object *args; |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
165 { |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
166 object *arg; |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
167 if (!getargs(args, "O", &arg)) |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
168 return NULL; |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
169 return newintobject((long) arg->ob_refcnt); |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
170 } |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
171 |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
172 #ifdef COUNT_ALLOCS |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
173 static PyObject * |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
174 sys_getcounts(self, args) |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
175 PyObject *self, *args; |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
176 { |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
177 extern PyObject *get_counts Py_PROTO((void)); |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
178 |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
179 if (!PyArg_Parse(args, "")) |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
180 return NULL; |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
181 return get_counts(); |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
182 } |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
183 #endif |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
184 |
|
3585
4ed09a3c3201
TRACE_REFS -> Py_TRACE_REFS
Guido van Rossum <guido@python.org>
parents:
3490
diff
changeset
|
185 #ifdef Py_TRACE_REFS |
|
3609
0b0c4ed1936a
rename printrefs, getobjects to _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
3585
diff
changeset
|
186 /* Defined in objects.c because it uses static globals if that file */ |
|
0b0c4ed1936a
rename printrefs, getobjects to _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
3585
diff
changeset
|
187 extern PyObject *_Py_GetObjects Py_PROTO((PyObject *, PyObject *)); |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
188 #endif |
|
3609
0b0c4ed1936a
rename printrefs, getobjects to _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
3585
diff
changeset
|
189 |
| 86 | 190 static struct methodlist sys_methods[] = { |
|
2421
6eda642f19d0
add explicit 0 flags for methodlist
Guido van Rossum <guido@python.org>
parents:
2093
diff
changeset
|
191 {"exit", sys_exit, 0}, |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
192 {"getrefcount", sys_getrefcount, 0}, |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
193 #ifdef COUNT_ALLOCS |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
194 {"getcounts", sys_getcounts, 0}, |
|
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
195 #endif |
|
3585
4ed09a3c3201
TRACE_REFS -> Py_TRACE_REFS
Guido van Rossum <guido@python.org>
parents:
3490
diff
changeset
|
196 #ifdef Py_TRACE_REFS |
|
3609
0b0c4ed1936a
rename printrefs, getobjects to _Py_ prefix
Guido van Rossum <guido@python.org>
parents:
3585
diff
changeset
|
197 {"getobjects", _Py_GetObjects, 1}, |
|
3024
54aa87b1ccee
Implemented two new functions in sys:
Sjoerd Mullender <sjoerd@acm.org>
parents:
2810
diff
changeset
|
198 #endif |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
199 #ifdef USE_MALLOPT |
|
2421
6eda642f19d0
add explicit 0 flags for methodlist
Guido van Rossum <guido@python.org>
parents:
2093
diff
changeset
|
200 {"mdebug", sys_mdebug, 0}, |
|
1013
a1ce5a949828
Add an optional interface to turn malloc debugging on and off.
Guido van Rossum <guido@python.org>
parents:
901
diff
changeset
|
201 #endif |
|
2421
6eda642f19d0
add explicit 0 flags for methodlist
Guido van Rossum <guido@python.org>
parents:
2093
diff
changeset
|
202 {"setprofile", sys_setprofile, 0}, |
|
6eda642f19d0
add explicit 0 flags for methodlist
Guido van Rossum <guido@python.org>
parents:
2093
diff
changeset
|
203 {"settrace", sys_settrace, 0}, |
|
3326
1eab8495462f
fix args options for setcheckinterval
Guido van Rossum <guido@python.org>
parents:
3024
diff
changeset
|
204 {"setcheckinterval", sys_setcheckinterval, 1}, |
| 86 | 205 {NULL, NULL} /* sentinel */ |
| 206 }; | |
| 207 | |
| 6 | 208 static object *sysin, *sysout, *syserr; |
| 209 | |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
210 static object * |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
211 list_builtin_module_names() |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
212 { |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
213 object *list = newlistobject(0); |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
214 int i; |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
215 if (list == NULL) |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
216 return NULL; |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
217 for (i = 0; inittab[i].name != NULL; i++) { |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
218 object *name = newstringobject(inittab[i].name); |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
219 if (name == NULL) |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
220 break; |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
221 addlistitem(list, name); |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
222 DECREF(name); |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
223 } |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
224 if (sortlist(list) != 0) { |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
225 DECREF(list); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
226 list = NULL; |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
227 } |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
228 return list; |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
229 } |
|
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
230 |
| 6 | 231 void |
| 86 | 232 initsys() |
| 6 | 233 { |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
234 extern long getmaxint PROTO((void)); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
235 extern char *getversion PROTO((void)); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
236 extern char *getcopyright PROTO((void)); |
| 2810 | 237 extern char *getplatform PROTO((void)); |
|
3680
8721fafdb67a
Define sys.prefix and sys.exec_prefix (see Modules/getpath.c; from Makefile).
Guido van Rossum <guido@python.org>
parents:
3609
diff
changeset
|
238 extern char *Py_GetPrefix PROTO((void)); |
|
8721fafdb67a
Define sys.prefix and sys.exec_prefix (see Modules/getpath.c; from Makefile).
Guido van Rossum <guido@python.org>
parents:
3609
diff
changeset
|
239 extern char *Py_GetExecPrefix PROTO((void)); |
|
265
187ba1733b17
Added fclose to newopenfileobject() calls.
Guido van Rossum <guido@python.org>
parents:
234
diff
changeset
|
240 extern int fclose PROTO((FILE *)); |
| 86 | 241 object *m = initmodule("sys", sys_methods); |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
242 object *v; |
| 86 | 243 sysdict = getmoduledict(m); |
| 244 INCREF(sysdict); | |
| 6 | 245 /* NB keep an extra ref to the std files to avoid closing them |
| 246 when the user deletes them */ | |
|
265
187ba1733b17
Added fclose to newopenfileobject() calls.
Guido van Rossum <guido@python.org>
parents:
234
diff
changeset
|
247 sysin = newopenfileobject(stdin, "<stdin>", "r", fclose); |
|
187ba1733b17
Added fclose to newopenfileobject() calls.
Guido van Rossum <guido@python.org>
parents:
234
diff
changeset
|
248 sysout = newopenfileobject(stdout, "<stdout>", "w", fclose); |
|
187ba1733b17
Added fclose to newopenfileobject() calls.
Guido van Rossum <guido@python.org>
parents:
234
diff
changeset
|
249 syserr = newopenfileobject(stderr, "<stderr>", "w", fclose); |
| 6 | 250 if (err_occurred()) |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
251 fatal("can't initialize sys.std{in,out,err}"); |
| 6 | 252 dictinsert(sysdict, "stdin", sysin); |
| 253 dictinsert(sysdict, "stdout", sysout); | |
| 254 dictinsert(sysdict, "stderr", syserr); | |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
255 dictinsert(sysdict, "version", v = newstringobject(getversion())); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
256 XDECREF(v); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
257 dictinsert(sysdict, "copyright", v = newstringobject(getcopyright())); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
258 XDECREF(v); |
| 2810 | 259 dictinsert(sysdict, "platform", v = newstringobject(getplatform())); |
| 260 XDECREF(v); | |
|
3680
8721fafdb67a
Define sys.prefix and sys.exec_prefix (see Modules/getpath.c; from Makefile).
Guido van Rossum <guido@python.org>
parents:
3609
diff
changeset
|
261 dictinsert(sysdict, "prefix", v = newstringobject(Py_GetPrefix())); |
|
8721fafdb67a
Define sys.prefix and sys.exec_prefix (see Modules/getpath.c; from Makefile).
Guido van Rossum <guido@python.org>
parents:
3609
diff
changeset
|
262 XDECREF(v); |
|
8721fafdb67a
Define sys.prefix and sys.exec_prefix (see Modules/getpath.c; from Makefile).
Guido van Rossum <guido@python.org>
parents:
3609
diff
changeset
|
263 dictinsert(sysdict, "exec_prefix", |
|
8721fafdb67a
Define sys.prefix and sys.exec_prefix (see Modules/getpath.c; from Makefile).
Guido van Rossum <guido@python.org>
parents:
3609
diff
changeset
|
264 v = newstringobject(Py_GetExecPrefix())); |
|
8721fafdb67a
Define sys.prefix and sys.exec_prefix (see Modules/getpath.c; from Makefile).
Guido van Rossum <guido@python.org>
parents:
3609
diff
changeset
|
265 XDECREF(v); |
|
1848
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
266 dictinsert(sysdict, "maxint", v = newintobject(getmaxint())); |
|
b724599401ff
Merge back to main trunk
Guido van Rossum <guido@python.org>
parents:
1198
diff
changeset
|
267 XDECREF(v); |
| 86 | 268 dictinsert(sysdict, "modules", get_modules()); |
|
1198
2937897a7d8b
* Added Fixcprt.py: script to fix copyright message.
Guido van Rossum <guido@python.org>
parents:
1073
diff
changeset
|
269 dictinsert(sysdict, "builtin_module_names", |
|
2052
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
1848
diff
changeset
|
270 v = list_builtin_module_names()); |
|
d7e91437f0a2
Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents:
1848
diff
changeset
|
271 XDECREF(v); |
|
4126
c80c515999b9
Use MS_DLL_ID as sys.winver
Guido van Rossum <guido@python.org>
parents:
3877
diff
changeset
|
272 #ifdef MS_COREDLL |
|
3490
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
273 dictinsert(sysdict, "dllhandle", v = newintobject((int)PyWin_DLLhModule)); |
|
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
274 XDECREF(v); |
|
4126
c80c515999b9
Use MS_DLL_ID as sys.winver
Guido van Rossum <guido@python.org>
parents:
3877
diff
changeset
|
275 dictinsert(sysdict, "winver", v = newstringobject(MS_DLL_ID)); |
|
3490
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
276 XDECREF(v); |
|
1dfc519ea3cb
Under NT, define sys.dllhandle and sys.winver (Mark H.).
Guido van Rossum <guido@python.org>
parents:
3326
diff
changeset
|
277 #endif |
| 6 | 278 if (err_occurred()) |
| 279 fatal("can't insert sys.* objects in sys dict"); | |
| 86 | 280 } |
| 281 | |
| 282 static object * | |
| 283 makepathobject(path, delim) | |
| 284 char *path; | |
| 285 int delim; | |
| 286 { | |
| 287 int i, n; | |
| 288 char *p; | |
| 289 object *v, *w; | |
| 6 | 290 |
| 86 | 291 n = 1; |
| 292 p = path; | |
| 293 while ((p = strchr(p, delim)) != NULL) { | |
| 294 n++; | |
| 295 p++; | |
| 296 } | |
| 297 v = newlistobject(n); | |
| 298 if (v == NULL) | |
| 299 return NULL; | |
| 300 for (i = 0; ; i++) { | |
| 301 p = strchr(path, delim); | |
| 302 if (p == NULL) | |
| 303 p = strchr(path, '\0'); /* End of string */ | |
| 304 w = newsizedstringobject(path, (int) (p - path)); | |
| 305 if (w == NULL) { | |
| 306 DECREF(v); | |
| 307 return NULL; | |
| 308 } | |
| 309 setlistitem(v, i, w); | |
| 310 if (*p == '\0') | |
| 311 break; | |
| 312 path = p+1; | |
| 313 } | |
| 314 return v; | |
| 315 } | |
| 316 | |
| 317 void | |
| 318 setpythonpath(path) | |
| 319 char *path; | |
| 320 { | |
| 321 object *v; | |
| 322 if ((v = makepathobject(path, DELIM)) == NULL) | |
| 323 fatal("can't create sys.path"); | |
| 324 if (sysset("path", v) != 0) | |
| 325 fatal("can't assign sys.path"); | |
|
83
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
326 DECREF(v); |
|
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
327 } |
|
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
328 |
| 86 | 329 static object * |
| 330 makeargvobject(argc, argv) | |
| 331 int argc; | |
| 332 char **argv; | |
|
83
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
333 { |
| 86 | 334 object *av; |
|
596
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
335 if (argc <= 0 || argv == NULL) { |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
336 /* Ensure at least one (empty) argument is seen */ |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
337 static char *empty_argv[1] = {""}; |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
338 argv = empty_argv; |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
339 argc = 1; |
|
e18f1fa398a3
Ensure that sys.argv[0] always exists (maybe as empty string).
Guido van Rossum <guido@python.org>
parents:
549
diff
changeset
|
340 } |
| 86 | 341 av = newlistobject(argc); |
| 342 if (av != NULL) { | |
| 343 int i; | |
| 344 for (i = 0; i < argc; i++) { | |
| 345 object *v = newstringobject(argv[i]); | |
| 346 if (v == NULL) { | |
| 347 DECREF(av); | |
| 348 av = NULL; | |
| 349 break; | |
| 350 } | |
| 351 setlistitem(av, i, v); | |
|
83
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
352 } |
|
f6bcf3c1d714
Empty all modules' symbol tables, so most circular references are
Guido van Rossum <guido@python.org>
parents:
6
diff
changeset
|
353 } |
| 86 | 354 return av; |
| 6 | 355 } |
| 356 | |
| 357 void | |
| 86 | 358 setpythonargv(argc, argv) |
| 359 int argc; | |
| 360 char **argv; | |
| 6 | 361 { |
| 86 | 362 object *av = makeargvobject(argc, argv); |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
363 object *path = sysget("path"); |
| 86 | 364 if (av == NULL) |
| 365 fatal("no mem for sys.argv"); | |
| 366 if (sysset("argv", av) != 0) | |
| 367 fatal("can't assign sys.argv"); | |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
368 if (path != NULL) { |
|
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
369 char *p = NULL; |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
370 int n = 0; |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
371 object *a; |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
372 #if SEP == '\\' /* Special case for MS filename syntax */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
373 if (argc > 0 && argv[0] != NULL) { |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
374 char *q; |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
375 p = strrchr(argv[0], SEP); |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
376 /* Test for alternate separator */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
377 q = strrchr(p ? p : argv[0], '/'); |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
378 if (q != NULL) |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
379 p = q; |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
380 if (p != NULL) { |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
381 n = p + 1 - argv[0]; |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
382 if (n > 1 && p[-1] != ':') |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
383 n--; /* Drop trailing separator */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
384 } |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
385 } |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
386 #else /* All other filename syntaxes */ |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
387 if (argc > 0 && argv[0] != NULL) |
|
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
388 p = strrchr(argv[0], SEP); |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
389 if (p != NULL) { |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
390 n = p + 1 - argv[0]; |
|
4256
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
391 #if SEP == '/' /* Special case for Unix filename syntax */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
392 if (n > 1) |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
393 n--; /* Drop trailing separator */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
394 #endif /* Unix */ |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
395 } |
|
e225e70fd657
Changes to setpythonpath():
Guido van Rossum <guido@python.org>
parents:
4126
diff
changeset
|
396 #endif /* All others */ |
|
3877
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
397 a = newsizedstringobject(argv[0], n); |
|
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
398 if (a == NULL) |
|
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
399 fatal("no mem for sys.path insertion"); |
|
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
400 if (inslistitem(path, 0, a) < 0) |
|
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
401 fatal("sys.path.insert(0) failed"); |
|
408e374934e5
Always insert script directory in front of sys.path -- if there's no
Guido van Rossum <guido@python.org>
parents:
3806
diff
changeset
|
402 DECREF(a); |
|
3806
93868c7a15c9
As a side effect of calling PySys_SetArgv (setpythonargv), the
Guido van Rossum <guido@python.org>
parents:
3738
diff
changeset
|
403 } |
| 86 | 404 DECREF(av); |
| 6 | 405 } |
