File tree 1 file changed +11
-3
lines changed 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -395,18 +395,26 @@ optionally followed by an import of the module::
395
395
}
396
396
397
397
/* Add a built-in module, before Py_Initialize */
398
- PyImport_AppendInittab("spam", PyInit_spam);
398
+ if (PyImport_AppendInittab("spam", PyInit_spam) == -1) {
399
+ fprintf(stderr, "Error: could not extend in-built modules table\n");
400
+ exit(1);
401
+ }
399
402
400
403
/* Pass argv[0] to the Python interpreter */
401
404
Py_SetProgramName(program);
402
405
403
- /* Initialize the Python interpreter. Required. */
406
+ /* Initialize the Python interpreter. Required.
407
+ If this step fails, it will be a fatal error. */
404
408
Py_Initialize();
405
409
406
410
/* Optionally import the module; alternatively,
407
411
import can be deferred until the embedded script
408
412
imports it. */
409
- PyImport_ImportModule("spam");
413
+ pmodule = PyImport_ImportModule("spam");
414
+ if (!pmodule) {
415
+ PyErr_Print();
416
+ fprintf(stderr, "Error: could not import module 'spam'\n");
417
+ }
410
418
411
419
...
412
420
You can’t perform that action at this time.
0 commit comments