File tree Expand file tree Collapse file tree 4 files changed +13
-17
lines changed Expand file tree Collapse file tree 4 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -254,10 +254,10 @@ _get_current_module_state(void)
254
254
{
255
255
PyObject * mod = _get_current_module ();
256
256
if (mod == NULL ) {
257
- // XXX import it?
258
- PyErr_SetString ( PyExc_RuntimeError ,
259
- MODULE_NAME_STR " module not imported yet" ) ;
260
- return NULL ;
257
+ mod = PyImport_ImportModule ( MODULE_NAME_STR );
258
+ if ( mod == NULL ) {
259
+ return NULL ;
260
+ }
261
261
}
262
262
module_state * state = get_module_state (mod );
263
263
Py_DECREF (mod );
Original file line number Diff line number Diff line change @@ -1356,10 +1356,10 @@ _queueobj_from_xid(_PyXIData_t *data)
1356
1356
1357
1357
PyObject * mod = _get_current_module ();
1358
1358
if (mod == NULL ) {
1359
- // XXX import it?
1360
- PyErr_SetString ( PyExc_RuntimeError ,
1361
- MODULE_NAME_STR " module not imported yet" ) ;
1362
- return NULL ;
1359
+ mod = PyImport_ImportModule ( MODULE_NAME_STR );
1360
+ if ( mod == NULL ) {
1361
+ return NULL ;
1362
+ }
1363
1363
}
1364
1364
1365
1365
PyTypeObject * cls = get_external_queue_type (mod );
Original file line number Diff line number Diff line change @@ -316,15 +316,10 @@ get_module_state(PyObject *mod)
316
316
}
317
317
318
318
static module_state *
319
- _get_current_module_state (int force )
319
+ _get_current_module_state (void )
320
320
{
321
321
PyObject * mod = _get_current_module ();
322
322
if (mod == NULL ) {
323
- if (!force ) {
324
- PyErr_SetString (PyExc_RuntimeError ,
325
- MODULE_NAME_STR " module not imported yet" );
326
- return NULL ;
327
- }
328
323
mod = PyImport_ImportModule (MODULE_NAME_STR );
329
324
if (mod == NULL ) {
330
325
return NULL ;
@@ -357,8 +352,7 @@ clear_module_state(module_state *state)
357
352
static PyTypeObject *
358
353
_get_current_xibufferview_type (void )
359
354
{
360
- int force = 1 ;
361
- module_state * state = _get_current_module_state (force );
355
+ module_state * state = _get_current_module_state ();
362
356
if (state == NULL ) {
363
357
return NULL ;
364
358
}
Original file line number Diff line number Diff line change @@ -3964,8 +3964,10 @@ PyImport_Import(PyObject *module_name)
3964
3964
if (globals != NULL ) {
3965
3965
Py_INCREF (globals );
3966
3966
builtins = PyObject_GetItem (globals , & _Py_ID (__builtins__ ));
3967
- if (builtins == NULL )
3967
+ if (builtins == NULL ) {
3968
+ // XXX Fall back to interp->builtins or sys.modules['builtins']?
3968
3969
goto err ;
3970
+ }
3969
3971
}
3970
3972
else {
3971
3973
/* No globals -- use standard builtins, and fake globals */
You can’t perform that action at this time.
0 commit comments