@@ -335,71 +335,29 @@ typedef struct _sharedexception {
335
335
PyAPI_FUNC (PyObject * ) _PyXI_ApplyError (_PyXI_error * err );
336
336
337
337
338
- typedef struct xi_session _PyXI_session ;
339
- typedef struct _sharedns _PyXI_namespace ;
340
-
341
- PyAPI_FUNC (void ) _PyXI_FreeNamespace (_PyXI_namespace * ns );
342
- PyAPI_FUNC (_PyXI_namespace * ) _PyXI_NamespaceFromNames (PyObject * names );
343
- PyAPI_FUNC (int ) _PyXI_FillNamespaceFromDict (
344
- _PyXI_namespace * ns ,
345
- PyObject * nsobj ,
346
- _PyXI_session * session );
347
- PyAPI_FUNC (int ) _PyXI_ApplyNamespace (
348
- _PyXI_namespace * ns ,
349
- PyObject * nsobj ,
350
- PyObject * dflt );
351
-
352
-
353
338
// A cross-interpreter session involves entering an interpreter
354
- // ( _PyXI_Enter() ), doing some work with it, and finally exiting
355
- // that interpreter ( _PyXI_Exit() ).
339
+ // with _PyXI_Enter(), doing some work with it, and finally exiting
340
+ // that interpreter with _PyXI_Exit().
356
341
//
357
342
// At the boundaries of the session, both entering and exiting,
358
343
// data may be exchanged between the previous interpreter and the
359
344
// target one in a thread-safe way that does not violate the
360
345
// isolation between interpreters. This includes setting objects
361
346
// in the target's __main__ module on the way in, and capturing
362
347
// uncaught exceptions on the way out.
363
- struct xi_session {
364
- // Once a session has been entered, this is the tstate that was
365
- // current before the session. If it is different from cur_tstate
366
- // then we must have switched interpreters. Either way, this will
367
- // be the current tstate once we exit the session.
368
- PyThreadState * prev_tstate ;
369
- // Once a session has been entered, this is the current tstate.
370
- // It must be current when the session exits.
371
- PyThreadState * init_tstate ;
372
- // This is true if init_tstate needs cleanup during exit.
373
- int own_init_tstate ;
374
-
375
- // This is true if, while entering the session, init_thread took
376
- // "ownership" of the interpreter's __main__ module. This means
377
- // it is the only thread that is allowed to run code there.
378
- // (Caveat: for now, users may still run exec() against the
379
- // __main__ module's dict, though that isn't advisable.)
380
- int running ;
381
- // This is a cached reference to the __dict__ of the entered
382
- // interpreter's __main__ module. It is looked up when at the
383
- // beginning of the session as a convenience.
384
- PyObject * main_ns ;
385
-
386
- // This is set if the interpreter is entered and raised an exception
387
- // that needs to be handled in some special way during exit.
388
- _PyXI_errcode * error_override ;
389
- // This is set if exit captured an exception to propagate.
390
- _PyXI_error * error ;
391
-
392
- // -- pre-allocated memory --
393
- _PyXI_error _error ;
394
- _PyXI_errcode _error_override ;
395
- };
348
+ typedef struct xi_session _PyXI_session ;
349
+
350
+ PyAPI_FUNC (_PyXI_session * ) _PyXI_NewSession (void );
351
+ PyAPI_FUNC (void ) _PyXI_FreeSession (_PyXI_session * );
396
352
397
353
PyAPI_FUNC (int ) _PyXI_Enter (
398
354
_PyXI_session * session ,
399
355
PyInterpreterState * interp ,
400
356
PyObject * nsupdates );
401
357
PyAPI_FUNC (void ) _PyXI_Exit (_PyXI_session * session );
402
358
359
+ PyAPI_FUNC (PyObject * ) _PyXI_GetMainNamespace (_PyXI_session * );
360
+
403
361
PyAPI_FUNC (PyObject * ) _PyXI_ApplyCapturedException (_PyXI_session * session );
404
362
PyAPI_FUNC (int ) _PyXI_HasCapturedException (_PyXI_session * session );
405
363
0 commit comments