8
8
9
9
#include <Python.h>
10
10
11
- /** This should be the name of your executable.
12
- * It is just used for error messages. */
13
- #define EXECUTABLE_NAME "pyxcode"
14
-
15
11
/** Takes a path and adds it to sys.paths by calling PyRun_SimpleString.
16
12
* This does rather laborious C string concatenation so that it will work in
17
13
* a primitive C environment.
@@ -68,7 +64,7 @@ int import_call_execute(int argc, const char *argv[]) {
68
64
if (argc != 4 ) {
69
65
fprintf (stderr ,
70
66
"Wrong arguments!"
71
- " Usage: " EXECUTABLE_NAME " package_path module function\n" );
67
+ " Usage: %s package_path module function\n" , argv [ 0 ] );
72
68
return_value = -1 ;
73
69
goto except ;
74
70
}
@@ -81,31 +77,31 @@ int import_call_execute(int argc, const char *argv[]) {
81
77
pModule = PyImport_ImportModule (argv [2 ]);
82
78
if (! pModule ) {
83
79
fprintf (stderr ,
84
- EXECUTABLE_NAME " : Failed to load module \"%s\"\n" , argv [2 ]);
80
+ "%s : Failed to load module \"%s\"\n", argv [ 0 ] , argv [2 ]);
85
81
return_value = -3 ;
86
82
goto except ;
87
83
}
88
84
pFunc = PyObject_GetAttrString (pModule , argv [3 ]);
89
85
if (! pFunc ) {
90
86
fprintf (stderr ,
91
- EXECUTABLE_NAME " : Can not find function \"%s\"\n" , argv [3 ]);
87
+ "%s : Can not find function \"%s\"\n", argv [ 0 ] , argv [3 ]);
92
88
return_value = -4 ;
93
89
goto except ;
94
90
}
95
91
if (! PyCallable_Check (pFunc )) {
96
92
fprintf (stderr ,
97
- EXECUTABLE_NAME " : Function \"%s\" is not callable\n" , argv [3 ]);
93
+ "%s : Function \"%s\" is not callable\n", argv [ 0 ] , argv [3 ]);
98
94
return_value = -5 ;
99
95
goto except ;
100
96
}
101
97
pResult = PyObject_CallObject (pFunc , NULL );
102
98
if (! pResult ) {
103
- fprintf (stderr , EXECUTABLE_NAME " : Function call failed\n" );
99
+ fprintf (stderr , "%s : Function call failed\n", argv [ 0 ] );
104
100
return_value = -6 ;
105
101
goto except ;
106
102
}
107
103
#ifdef DEBUG
108
- printf (EXECUTABLE_NAME " : PyObject_CallObject() succeeded\n" );
104
+ printf ("%s : PyObject_CallObject() succeeded\n", argv [ 0 ] );
109
105
#endif
110
106
assert (! PyErr_Occurred ());
111
107
goto finally ;
0 commit comments