annotate Python/modsupport.c @ 13884:8eeaff96b4c2 legacy-trunk

When returning an error from jcompile() (which is passed through by PyNode_Compile()), make sure that an exception is actually set -- otherwise someone stomped on our error. [2.0 checkin of this fix.]
author Guido van Rossum <guido@python.org>
date Mon, 07 Aug 2000 19:22:43 +0000
parents 94f6ec87930a
children 6f6f965c5e2d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
1 /***********************************************************
13255
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 13096
diff changeset
2 Copyright (c) 2000, BeOpen.com.
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 13096
diff changeset
3 Copyright (c) 1995-2000, Corporation for National Research Initiatives.
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 13096
diff changeset
4 Copyright (c) 1990-1995, Stichting Mathematisch Centrum.
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 13096
diff changeset
5 All rights reserved.
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
6
13255
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 13096
diff changeset
7 See the file "Misc/COPYRIGHT" for information on usage and
916fb024ce94 Change copyright notice.
Guido van Rossum <guido@python.org>
parents: 13096
diff changeset
8 redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
145
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
9 ******************************************************************/
853b736a6a9e Added copyright notice.
Guido van Rossum <guido@python.org>
parents: 86
diff changeset
10
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
11 /* Module support implementation */
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
12
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
13 #include "Python.h"
13330
63d2887baf11 Include limits.h if we have it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13256
diff changeset
14 #ifdef HAVE_LIMITS_H
63d2887baf11 Include limits.h if we have it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13256
diff changeset
15 #include <limits.h>
63d2887baf11 Include limits.h if we have it.
Jack Jansen <jack.jansen@cwi.nl>
parents: 13256
diff changeset
16 #endif
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
17
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
18 #ifdef MPW /* MPW pushes 'extended' for float and double types with varargs */
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
19 typedef extended va_double;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
20 #else
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
21 typedef double va_double;
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
22 #endif
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
23
6602
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
24 /* Package context -- the full module name for package imports */
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
25 char *_Py_PackageContext = NULL;
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
26
5925
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
27 /* Py_InitModule4() parameters:
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
28 - name is the module name
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
29 - methods is the list of top-level functions
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
30 - doc is the documentation string
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
31 - passthrough is passed as self to functions defined in the module
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
32 - api_version is the value of PYTHON_API_VERSION at the time the
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
33 module was compiled
5925
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
34
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
35 Return value is a borrowed reference to the module object; or NULL
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
36 if an error occurred (in Python 1.4 and before, errors were fatal).
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
37 Errors may still leak memory.
2090
f78b387b54e0 New newmethodobject() interface takes struct methodlist pointer
Guido van Rossum <guido@python.org>
parents: 2062
diff changeset
38 */
1848
b724599401ff Merge back to main trunk
Guido van Rossum <guido@python.org>
parents: 1319
diff changeset
39
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
40 static char api_version_warning[] =
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
41 "WARNING: Python C API version mismatch for module %s:\n\
3347
faa21ce1ff01 Corrected format string in api_version_warning.
Sjoerd Mullender <sjoerd@acm.org>
parents: 2501
diff changeset
42 This Python has API version %d, module %s has version %d.\n";
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
43
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
44 PyObject *
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
45 Py_InitModule4(char *name, PyMethodDef *methods, char *doc,
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
46 PyObject *passthrough, int module_api_version)
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
47 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
48 PyObject *m, *d, *v;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
49 PyMethodDef *ml;
13859
94f6ec87930a Add a test that Py_IsInitialized() in Py_InitModule4(). See
Guido van Rossum <guido@python.org>
parents: 13658
diff changeset
50 if (!Py_IsInitialized())
94f6ec87930a Add a test that Py_IsInitialized() in Py_InitModule4(). See
Guido van Rossum <guido@python.org>
parents: 13658
diff changeset
51 Py_FatalError("Interpreter not initialized (version mismatch?)");
2095
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
52 if (module_api_version != PYTHON_API_VERSION)
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
53 fprintf(stderr, api_version_warning,
0d7e4aa595f7 api version checking
Guido van Rossum <guido@python.org>
parents: 2090
diff changeset
54 name, PYTHON_API_VERSION, name, module_api_version);
6602
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
55 if (_Py_PackageContext != NULL) {
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
56 char *p = strrchr(_Py_PackageContext, '.');
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
57 if (p != NULL && strcmp(name, p+1) == 0) {
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
58 name = _Py_PackageContext;
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
59 _Py_PackageContext = NULL;
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
60 }
4514a5ea3ec4 Fix importing of shared libraries from inside packages.
Guido van Rossum <guido@python.org>
parents: 5925
diff changeset
61 }
5925
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
62 if ((m = PyImport_AddModule(name)) == NULL)
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
63 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
64 d = PyModule_GetDict(m);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
65 for (ml = methods; ml->ml_name != NULL; ml++) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
66 v = PyCFunction_New(ml, passthrough);
5925
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
67 if (v == NULL)
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
68 return NULL;
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
69 if (PyDict_SetItemString(d, ml->ml_name, v) != 0)
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
70 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
71 Py_DECREF(v);
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
72 }
2090
f78b387b54e0 New newmethodobject() interface takes struct methodlist pointer
Guido van Rossum <guido@python.org>
parents: 2062
diff changeset
73 if (doc != NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
74 v = PyString_FromString(doc);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
75 if (v == NULL || PyDict_SetItemString(d, "__doc__", v) != 0)
5925
93304b2e14cb Removed fatal errors from Py_Initmodule4() (and thus from
Guido van Rossum <guido@python.org>
parents: 5373
diff changeset
76 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
77 Py_DECREF(v);
2090
f78b387b54e0 New newmethodobject() interface takes struct methodlist pointer
Guido van Rossum <guido@python.org>
parents: 2062
diff changeset
78 }
86
a6934380c6e7 "Compiling" version
Guido van Rossum <guido@python.org>
parents: 12
diff changeset
79 return m;
6
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
80 }
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
81
fc6fcd7df4f7 Initial revision
Guido van Rossum <guido@python.org>
parents:
diff changeset
82
1211
406860dfaac7 * stdwinmodule.c: various new commands: setwin{pos,size},
Guido van Rossum <guido@python.org>
parents: 1198
diff changeset
83 /* Helper for mkvalue() to scan the length of a format */
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
84
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
85 static int countformat(char *format, int endchar)
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
86 {
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
87 int count = 0;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
88 int level = 0;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
89 while (level > 0 || *format != endchar) {
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
90 switch (*format) {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
91 case '\0':
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
92 /* Premature end */
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
93 PyErr_SetString(PyExc_SystemError,
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
94 "unmatched paren in format");
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
95 return -1;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
96 case '(':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
97 case '[':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
98 case '{':
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
99 if (level == 0)
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
100 count++;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
101 level++;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
102 break;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
103 case ')':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
104 case ']':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
105 case '}':
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
106 level--;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
107 break;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
108 case '#':
2202
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
109 case '&':
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
110 case ',':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
111 case ':':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
112 case ' ':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
113 case '\t':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
114 break;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
115 default:
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
116 if (level == 0)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
117 count++;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
118 }
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
119 format++;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
120 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
121 return count;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
122 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
123
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
124
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
125 /* Generic function to create a value -- the inverse of getargs() */
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
126 /* After an original idea and first implementation by Steven Miale */
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
127
13447
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 13378
diff changeset
128 static PyObject *do_mktuple(char**, va_list *, int, int);
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 13378
diff changeset
129 static PyObject *do_mklist(char**, va_list *, int, int);
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 13378
diff changeset
130 static PyObject *do_mkdict(char**, va_list *, int, int);
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 13378
diff changeset
131 static PyObject *do_mkvalue(char**, va_list *);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
132
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
133
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
134 static PyObject *
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
135 do_mkdict(char **p_format, va_list *p_va, int endchar, int n)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
136 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
137 PyObject *d;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
138 int i;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
139 if (n < 0)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
140 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
141 if ((d = PyDict_New()) == NULL)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
142 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
143 for (i = 0; i < n; i+= 2) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
144 PyObject *k, *v;
6613
2e874a5a912f Plug memory leak in Py_BuildValue when using {...} to construct dictionaries.
Guido van Rossum <guido@python.org>
parents: 6602
diff changeset
145 int err;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
146 k = do_mkvalue(p_format, p_va);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
147 if (k == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
148 Py_DECREF(d);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
149 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
150 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
151 v = do_mkvalue(p_format, p_va);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
152 if (v == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
153 Py_DECREF(k);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
154 Py_DECREF(d);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
155 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
156 }
6613
2e874a5a912f Plug memory leak in Py_BuildValue when using {...} to construct dictionaries.
Guido van Rossum <guido@python.org>
parents: 6602
diff changeset
157 err = PyDict_SetItem(d, k, v);
2e874a5a912f Plug memory leak in Py_BuildValue when using {...} to construct dictionaries.
Guido van Rossum <guido@python.org>
parents: 6602
diff changeset
158 Py_DECREF(k);
2e874a5a912f Plug memory leak in Py_BuildValue when using {...} to construct dictionaries.
Guido van Rossum <guido@python.org>
parents: 6602
diff changeset
159 Py_DECREF(v);
2e874a5a912f Plug memory leak in Py_BuildValue when using {...} to construct dictionaries.
Guido van Rossum <guido@python.org>
parents: 6602
diff changeset
160 if (err < 0) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
161 Py_DECREF(d);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
162 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
163 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
164 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
165 if (d != NULL && **p_format != endchar) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
166 Py_DECREF(d);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
167 d = NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
168 PyErr_SetString(PyExc_SystemError,
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
169 "Unmatched paren in format");
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
170 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
171 else if (endchar)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
172 ++*p_format;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
173 return d;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
174 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
175
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
176 static PyObject *
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
177 do_mklist(char **p_format, va_list *p_va, int endchar, int n)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
178 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
179 PyObject *v;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
180 int i;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
181 if (n < 0)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
182 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
183 if ((v = PyList_New(n)) == NULL)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
184 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
185 for (i = 0; i < n; i++) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
186 PyObject *w = do_mkvalue(p_format, p_va);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
187 if (w == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
188 Py_DECREF(v);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
189 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
190 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
191 PyList_SetItem(v, i, w);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
192 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
193 if (v != NULL && **p_format != endchar) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
194 Py_DECREF(v);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
195 v = NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
196 PyErr_SetString(PyExc_SystemError,
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
197 "Unmatched paren in format");
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
198 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
199 else if (endchar)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
200 ++*p_format;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
201 return v;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
202 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
203
12520
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
204 static int
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
205 _ustrlen(Py_UNICODE *u)
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
206 {
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
207 int i = 0;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
208 Py_UNICODE *v = u;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
209 while (*v != 0) { i++; v++; }
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
210 return i;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
211 }
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
212
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
213 static PyObject *
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
214 do_mktuple(char **p_format, va_list *p_va, int endchar, int n)
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
215 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
216 PyObject *v;
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
217 int i;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
218 if (n < 0)
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
219 return NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
220 if ((v = PyTuple_New(n)) == NULL)
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
221 return NULL;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
222 for (i = 0; i < n; i++) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
223 PyObject *w = do_mkvalue(p_format, p_va);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
224 if (w == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
225 Py_DECREF(v);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
226 return NULL;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
227 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
228 PyTuple_SetItem(v, i, w);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
229 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
230 if (v != NULL && **p_format != endchar) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
231 Py_DECREF(v);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
232 v = NULL;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
233 PyErr_SetString(PyExc_SystemError,
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
234 "Unmatched paren in format");
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
235 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
236 else if (endchar)
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
237 ++*p_format;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
238 return v;
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
239 }
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
240
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
241 static PyObject *
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
242 do_mkvalue(char **p_format, va_list *p_va)
860
39134c99c923 Added parameter decls to do_mkvalue for non-template machines
Guido van Rossum <guido@python.org>
parents: 817
diff changeset
243 {
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
244 for (;;) {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
245 switch (*(*p_format)++) {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
246 case '(':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
247 return do_mktuple(p_format, p_va, ')',
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
248 countformat(*p_format, ')'));
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
249
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
250 case '[':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
251 return do_mklist(p_format, p_va, ']',
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
252 countformat(*p_format, ']'));
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
253
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
254 case '{':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
255 return do_mkdict(p_format, p_va, '}',
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
256 countformat(*p_format, '}'));
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
257
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
258 case 'b':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
259 case 'h':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
260 case 'i':
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
261 return PyInt_FromLong((long)va_arg(*p_va, int));
13378
113d833eea7e Added support for H (unsigned short) specifier in PyArg_ParseTuple and
Jack Jansen <jack.jansen@cwi.nl>
parents: 13330
diff changeset
262
113d833eea7e Added support for H (unsigned short) specifier in PyArg_ParseTuple and
Jack Jansen <jack.jansen@cwi.nl>
parents: 13330
diff changeset
263 case 'H':
113d833eea7e Added support for H (unsigned short) specifier in PyArg_ParseTuple and
Jack Jansen <jack.jansen@cwi.nl>
parents: 13330
diff changeset
264 return PyInt_FromLong((long)va_arg(*p_va, unsigned int));
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
265
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
266 case 'l':
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
267 return PyInt_FromLong((long)va_arg(*p_va, long));
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
268
9949
98e37347378b Change rare occurrences of #if HAVE_LONG_LONG to #ifdef.
Guido van Rossum <guido@python.org>
parents: 9722
diff changeset
269 #ifdef HAVE_LONG_LONG
8822
bd47ee068b83 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8640
diff changeset
270 case 'L':
9044
d437b6683e24 Patch by Mark Hammond to support 64-bit ints on MS platforms.
Guido van Rossum <guido@python.org>
parents: 8898
diff changeset
271 return PyLong_FromLongLong((LONG_LONG)va_arg(*p_va, LONG_LONG));
8822
bd47ee068b83 Changes for BeOS, QNX and long long, by Chris Herborth.
Guido van Rossum <guido@python.org>
parents: 8640
diff changeset
272 #endif
12520
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
273 case 'u':
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
274 {
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
275 PyObject *v;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
276 Py_UNICODE *u = va_arg(*p_va, Py_UNICODE *);
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
277 int n;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
278 if (**p_format == '#') {
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
279 ++*p_format;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
280 n = va_arg(*p_va, int);
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
281 }
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
282 else
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
283 n = -1;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
284 if (u == NULL) {
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
285 v = Py_None;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
286 Py_INCREF(v);
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
287 }
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
288 else {
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
289 if (n < 0)
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
290 n = _ustrlen(u);
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
291 v = PyUnicode_FromUnicode(u, n);
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
292 }
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
293 return v;
b6b7bd20c845 Brian Hooper <brian_takashi@hotmail.com>:
Fred Drake <fdrake@acm.org>
parents: 9949
diff changeset
294 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
295 case 'f':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
296 case 'd':
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
297 return PyFloat_FromDouble(
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
298 (double)va_arg(*p_va, va_double));
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
299
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
300 case 'c':
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
301 {
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
302 char p[1];
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
303 p[0] = va_arg(*p_va, int);
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
304 return PyString_FromStringAndSize(p, 1);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
305 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
306
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
307 case 's':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
308 case 'z':
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
309 {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
310 PyObject *v;
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
311 char *str = va_arg(*p_va, char *);
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
312 int n;
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
313 if (**p_format == '#') {
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
314 ++*p_format;
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
315 n = va_arg(*p_va, int);
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
316 }
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
317 else
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
318 n = -1;
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
319 if (str == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
320 v = Py_None;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
321 Py_INCREF(v);
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
322 }
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
323 else {
13096
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
324 if (n < 0) {
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
325 size_t m = strlen(str);
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
326 if (m > INT_MAX) {
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
327 PyErr_SetString(PyExc_OverflowError,
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
328 "string too long for Python string");
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
329 return NULL;
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
330 }
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
331 n = (int)m;
8c8de5b736dc Trent Mick's Win64 changes: size_t vs. int or long; also some overflow
Guido van Rossum <guido@python.org>
parents: 12520
diff changeset
332 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
333 v = PyString_FromStringAndSize(str, n);
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
334 }
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
335 return v;
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
336 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
337
9720
24ca64134594 Add 'N' format character to Py_BuildValue -- like 'O' but doesn't INCREF.
Guido van Rossum <guido@python.org>
parents: 9044
diff changeset
338 case 'N':
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
339 case 'S':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
340 case 'O':
2202
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
341 if (**p_format == '&') {
13447
a89f7f268de4 Nuke all remaining occurrences of Py_PROTO and Py_FPROTO.
Tim Peters <tim.peters@gmail.com>
parents: 13378
diff changeset
342 typedef PyObject *(*converter)(void *);
2202
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
343 converter func = va_arg(*p_va, converter);
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
344 void *arg = va_arg(*p_va, void *);
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
345 ++*p_format;
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
346 return (*func)(arg);
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
347 }
9894e55468ec support "O&" taking an object constructor a void*
Guido van Rossum <guido@python.org>
parents: 2154
diff changeset
348 else {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
349 PyObject *v;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
350 v = va_arg(*p_va, PyObject *);
9722
3955f787e9a1 Oops, forgot a pair of {}'s. (Greg Couch)
Guido van Rossum <guido@python.org>
parents: 9720
diff changeset
351 if (v != NULL) {
9720
24ca64134594 Add 'N' format character to Py_BuildValue -- like 'O' but doesn't INCREF.
Guido van Rossum <guido@python.org>
parents: 9044
diff changeset
352 if (*(*p_format - 1) != 'N')
24ca64134594 Add 'N' format character to Py_BuildValue -- like 'O' but doesn't INCREF.
Guido van Rossum <guido@python.org>
parents: 9044
diff changeset
353 Py_INCREF(v);
9722
3955f787e9a1 Oops, forgot a pair of {}'s. (Greg Couch)
Guido van Rossum <guido@python.org>
parents: 9720
diff changeset
354 }
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
355 else if (!PyErr_Occurred())
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
356 /* If a NULL was passed
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
357 * because a call that should
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
358 * have constructed a value
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
359 * failed, that's OK, and we
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
360 * pass the error on; but if
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
361 * no error occurred it's not
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
362 * clear that the caller knew
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
363 * what she was doing. */
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
364 PyErr_SetString(PyExc_SystemError,
8640
8e86a797e596 Two error messages still used the old name of the functio mkvalue() --
Guido van Rossum <guido@python.org>
parents: 6613
diff changeset
365 "NULL object passed to Py_BuildValue");
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
366 return v;
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
367 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
368
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
369 case ':':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
370 case ',':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
371 case ' ':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
372 case '\t':
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
373 break;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
374
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
375 default:
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
376 PyErr_SetString(PyExc_SystemError,
8640
8e86a797e596 Two error messages still used the old name of the functio mkvalue() --
Guido van Rossum <guido@python.org>
parents: 6613
diff changeset
377 "bad format char passed to Py_BuildValue");
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
378 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
379
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
380 }
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
381 }
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
382 }
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
383
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
384
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
385 PyObject *Py_BuildValue(char *format, ...)
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
386 {
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
387 va_list va;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
388 PyObject* retval;
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
389 va_start(va, format);
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
390 retval = Py_VaBuildValue(format, va);
817
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
391 va_end(va);
aa633f0defa6 Merged with Steve Miale's version
Guido van Rossum <guido@python.org>
parents: 816
diff changeset
392 return retval;
816
e4a27d84ea36 Added mkvalue() function
Guido van Rossum <guido@python.org>
parents: 795
diff changeset
393 }
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
394
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
395 PyObject *
13658
f79434ee41fa Mass ANSIfication of function definitions. Doesn't cover all 'extern'
Thomas Wouters <thomas@python.org>
parents: 13447
diff changeset
396 Py_VaBuildValue(char *format, va_list va)
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
397 {
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
398 char *f = format;
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
399 int n = countformat(f, '\0');
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
400 va_list lva;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
401
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
402 #ifdef VA_LIST_IS_ARRAY
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
403 memcpy(lva, va, sizeof(va_list));
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
404 #else
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
405 lva = va;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
406 #endif
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
407
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
408 if (n < 0)
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
409 return NULL;
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
410 if (n == 0) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
411 Py_INCREF(Py_None);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
412 return Py_None;
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
413 }
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
414 if (n == 1)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
415 return do_mkvalue(&f, &lva);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
416 return do_mktuple(&f, &lva, '\0', n);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
417 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
418
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
419
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
420 PyObject *
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
421 PyEval_CallFunction(PyObject *obj, char *format, ...)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
422 {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
423 va_list vargs;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
424 PyObject *args;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
425 PyObject *res;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
426
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
427 va_start(vargs, format);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
428
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
429 args = Py_VaBuildValue(format, vargs);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
430 va_end(vargs);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
431
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
432 if (args == NULL)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
433 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
434
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
435 res = PyEval_CallObject(obj, args);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
436 Py_DECREF(args);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
437
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
438 return res;
1252
c4cd0d9d8281 * Changed many files to use mkvalue() instead of newtupleobject().
Guido van Rossum <guido@python.org>
parents: 1211
diff changeset
439 }
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
440
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
441
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
442 PyObject *
8898
492363d6bc94 # Fix strange type (methonname instead of methodname).
Guido van Rossum <guido@python.org>
parents: 8822
diff changeset
443 PyEval_CallMethod(PyObject *obj, char *methodname, char *format, ...)
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
444 {
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
445 va_list vargs;
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
446 PyObject *meth;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
447 PyObject *args;
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
448 PyObject *res;
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
449
8898
492363d6bc94 # Fix strange type (methonname instead of methodname).
Guido van Rossum <guido@python.org>
parents: 8822
diff changeset
450 meth = PyObject_GetAttrString(obj, methodname);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
451 if (meth == NULL)
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
452 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
453
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
454 va_start(vargs, format);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
455
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
456 args = Py_VaBuildValue(format, vargs);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
457 va_end(vargs);
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
458
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
459 if (args == NULL) {
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
460 Py_DECREF(meth);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
461 return NULL;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
462 }
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
463
5373
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
464 res = PyEval_CallObject(meth, args);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
465 Py_DECREF(meth);
5880384d7c71 Quickly renamed the remaining files -- this directory is done.
Guido van Rossum <guido@python.org>
parents: 4503
diff changeset
466 Py_DECREF(args);
2052
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
467
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
468 return res;
d7e91437f0a2 Lots of changes, most minor (fatal() instead of abort(), use of
Guido van Rossum <guido@python.org>
parents: 1913
diff changeset
469 }