Skip to content

Commit f9b7040

Browse files
committed
Use new names from the PEP.
1 parent d1b3d80 commit f9b7040

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

Include/cpython/pystate.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,11 @@ PyAPI_FUNC(void) _PyInterpreterState_SetEvalFrameFunc(
286286

287287
typedef uintptr_t PyInterpreterRef;
288288

289-
PyAPI_FUNC(int) PyInterpreterRef_Get(PyInterpreterRef *ref);
289+
PyAPI_FUNC(int) PyInterpreterRef_FromCurrent(PyInterpreterRef *ref);
290290
PyAPI_FUNC(PyInterpreterRef) PyInterpreterRef_Dup(PyInterpreterRef ref);
291-
PyAPI_FUNC(int) PyInterpreterRef_Main(PyInterpreterRef *ref);
291+
PyAPI_FUNC(int) PyUnstable_GetDefaultInterpreterRef(PyInterpreterRef *ref);
292292
PyAPI_FUNC(void) PyInterpreterRef_Close(PyInterpreterRef ref);
293-
PyAPI_FUNC(PyInterpreterState *) PyInterpreterRef_AsInterpreter(PyInterpreterRef ref);
293+
PyAPI_FUNC(PyInterpreterState *) PyInterpreterRef_GetInterpreter(PyInterpreterRef ref);
294294

295295
#define PyInterpreterRef_Close(ref) do { \
296296
PyInterpreterRef_Close(ref); \
@@ -306,9 +306,9 @@ typedef struct _PyInterpreterWeakRef {
306306

307307
typedef _PyInterpreterWeakRef *PyInterpreterWeakRef;
308308

309-
PyAPI_FUNC(int) PyInterpreterWeakRef_Get(PyInterpreterWeakRef *ptr);
309+
PyAPI_FUNC(int) PyInterpreterWeakRef_FromCurrent(PyInterpreterWeakRef *ptr);
310310
PyAPI_FUNC(PyInterpreterWeakRef) PyInterpreterWeakRef_Dup(PyInterpreterWeakRef wref);
311-
PyAPI_FUNC(int) PyInterpreterWeakRef_AsStrong(PyInterpreterWeakRef wref, PyInterpreterRef *strong_ptr);
311+
PyAPI_FUNC(int) PyInterpreterWeakRef_Promote(PyInterpreterWeakRef wref, PyInterpreterRef *strong_ptr);
312312
PyAPI_FUNC(void) PyInterpreterWeakRef_Close(PyInterpreterWeakRef wref);
313313

314314
#define PyInterpreterWeakRef_Close(ref) do { \

Modules/_testcapimodule.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2576,7 +2576,7 @@ static PyInterpreterRef
25762576
get_strong_ref(void)
25772577
{
25782578
PyInterpreterRef ref;
2579-
if (PyInterpreterRef_Get(&ref) < 0) {
2579+
if (PyInterpreterRef_FromCurrent(&ref) < 0) {
25802580
Py_FatalError("strong reference should not have failed");
25812581
}
25822582
return ref;
@@ -2587,10 +2587,10 @@ test_interp_ref_common(void)
25872587
{
25882588
PyInterpreterState *interp = PyInterpreterState_Get();
25892589
PyInterpreterRef ref = get_strong_ref();
2590-
assert(PyInterpreterRef_AsInterpreter(ref) == interp);
2590+
assert(PyInterpreterRef_GetInterpreter(ref) == interp);
25912591

25922592
PyInterpreterRef ref_2 = PyInterpreterRef_Dup(ref);
2593-
assert(PyInterpreterRef_AsInterpreter(ref_2) == interp);
2593+
assert(PyInterpreterRef_GetInterpreter(ref_2) == interp);
25942594

25952595
// We can close the references in any order
25962596
PyInterpreterRef_Close(ref);
@@ -2708,7 +2708,7 @@ test_thread_state_ensure_crossinterp(PyObject *self, PyObject *unused)
27082708

27092709
PyThreadState *ensured_tstate = PyThreadState_Get();
27102710
assert(ensured_tstate != save_tstate);
2711-
assert(PyInterpreterState_Get() == PyInterpreterRef_AsInterpreter(ref));
2711+
assert(PyInterpreterState_Get() == PyInterpreterRef_GetInterpreter(ref));
27122712
assert(PyGILState_GetThisThreadState() == ensured_tstate);
27132713

27142714
// Now though, we should reactivate the thread state
@@ -2743,20 +2743,20 @@ test_weak_interpreter_ref_after_shutdown(PyObject *self, PyObject *unused)
27432743
return PyErr_NoMemory();
27442744
}
27452745

2746-
int res = PyInterpreterWeakRef_Get(&wref);
2746+
int res = PyInterpreterWeakRef_FromCurrent(&wref);
27472747
(void)res;
27482748
assert(res == 0);
27492749

27502750
// As a sanity check, ensure that the weakref actually works
27512751
PyInterpreterRef ref;
2752-
res = PyInterpreterWeakRef_AsStrong(wref, &ref);
2752+
res = PyInterpreterWeakRef_Promote(wref, &ref);
27532753
assert(res == 0);
27542754
PyInterpreterRef_Close(ref);
27552755

27562756
// Now, destroy the interpreter and try to acquire a weak reference.
27572757
// It should fail.
27582758
Py_EndInterpreter(interp_tstate);
2759-
res = PyInterpreterWeakRef_AsStrong(wref, &ref);
2759+
res = PyInterpreterWeakRef_Promote(wref, &ref);
27602760
assert(res == -1);
27612761

27622762
PyThreadState_Swap(save_tstate);
@@ -2767,7 +2767,7 @@ static PyObject *
27672767
foo(PyObject *self, PyObject *foo)
27682768
{
27692769
PyInterpreterRef ref;
2770-
PyInterpreterRef_Get(&ref);
2770+
PyInterpreterRef_FromCurrent(&ref);
27712771
PyInterpreterRef_Close(ref);
27722772
Py_RETURN_NONE;
27732773
}

Modules/_testinternalcapi.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,7 +2395,7 @@ test_interp_refcount(PyObject *self, PyObject *unused)
23952395
assert(_PyInterpreterState_Refcount(interp) == 0);
23962396
PyInterpreterRef refs[NUM_REFS];
23972397
for (int i = 0; i < NUM_REFS; ++i) {
2398-
int res = PyInterpreterRef_Get(&refs[i]);
2398+
int res = PyInterpreterRef_FromCurrent(&refs[i]);
23992399
(void)res;
24002400
assert(res == 0);
24012401
assert(_PyInterpreterState_Refcount(interp) == i + 1);
@@ -2414,18 +2414,18 @@ test_interp_weakref_incref(PyObject *self, PyObject *unused)
24142414
{
24152415
PyInterpreterState *interp = PyInterpreterState_Get();
24162416
PyInterpreterWeakRef wref;
2417-
if (PyInterpreterWeakRef_Get(&wref) < 0) {
2417+
if (PyInterpreterWeakRef_FromCurrent(&wref) < 0) {
24182418
return NULL;
24192419
}
24202420
assert(_PyInterpreterState_Refcount(interp) == 0);
24212421

24222422
PyInterpreterRef refs[NUM_REFS];
24232423

24242424
for (int i = 0; i < NUM_REFS; ++i) {
2425-
int res = PyInterpreterWeakRef_AsStrong(wref, &refs[i]);
2425+
int res = PyInterpreterWeakRef_Promote(wref, &refs[i]);
24262426
(void)res;
24272427
assert(res == 0);
2428-
assert(PyInterpreterRef_AsInterpreter(refs[i]) == interp);
2428+
assert(PyInterpreterRef_GetInterpreter(refs[i]) == interp);
24292429
assert(_PyInterpreterState_Refcount(interp) == i + 1);
24302430
}
24312431

Programs/_testembed.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2352,7 +2352,7 @@ test_thread_state_ensure(void)
23522352
PyThread_handle_t handle;
23532353
PyThread_ident_t ident;
23542354
PyInterpreterRef ref;
2355-
if (PyInterpreterRef_Get(&ref) < 0) {
2355+
if (PyInterpreterRef_FromCurrent(&ref) < 0) {
23562356
return -1;
23572357
};
23582358
ThreadData data = { ref };
@@ -2401,22 +2401,22 @@ test_main_interpreter_ref(void)
24012401
{
24022402
// It should not work before the runtime has started.
24032403
PyInterpreterRef ref;
2404-
int res = PyInterpreterRef_Main(&ref);
2404+
int res = PyUnstable_GetDefaultInterpreterRef(&ref);
24052405
(void)res;
24062406
assert(res == -1);
24072407

24082408
_testembed_initialize();
24092409

24102410
// Main interpreter is initialized and ready.
2411-
res = PyInterpreterRef_Main(&ref);
2411+
res = PyUnstable_GetDefaultInterpreterRef(&ref);
24122412
assert(res == 0);
2413-
assert(PyInterpreterRef_AsInterpreter(ref) == PyInterpreterState_Main());
2413+
assert(PyInterpreterRef_GetInterpreter(ref) == PyInterpreterState_Main());
24142414
PyInterpreterRef_Close(ref);
24152415

24162416
Py_Finalize();
24172417

24182418
// Main interpreter is dead, we can no longer acquire references to it.
2419-
res = PyInterpreterRef_Main(&ref);
2419+
res = PyUnstable_GetDefaultInterpreterRef(&ref);
24202420
assert(res == -1);
24212421
return 0;
24222422
}

Python/pystate.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,13 +2783,13 @@ PyGILState_Ensure(void)
27832783
if (tcur == NULL) {
27842784
/* Create a new Python thread state for this thread */
27852785
// XXX Use PyInterpreterState_EnsureThreadState()?
2786-
if (PyInterpreterRef_Main(&ref) < 0) {
2786+
if (PyUnstable_GetDefaultInterpreterRef(&ref) < 0) {
27872787
// The main interpreter has finished, so we don't have
27882788
// any intepreter to make a thread state for. Hang the
27892789
// thread to act as failure.
27902790
PyThread_hang_thread();
27912791
}
2792-
tcur = new_threadstate(PyInterpreterRef_AsInterpreter(ref),
2792+
tcur = new_threadstate(PyInterpreterRef_GetInterpreter(ref),
27932793
_PyThreadState_WHENCE_GILSTATE);
27942794
if (tcur == NULL) {
27952795
Py_FatalError("Couldn't create thread-state for new thread");
@@ -3182,7 +3182,7 @@ ref_as_interp(PyInterpreterRef ref)
31823182
}
31833183

31843184
int
3185-
PyInterpreterRef_Get(PyInterpreterRef *ref)
3185+
PyInterpreterRef_FromCurrent(PyInterpreterRef *ref)
31863186
{
31873187
assert(ref != NULL);
31883188
PyInterpreterState *interp = PyInterpreterState_Get();
@@ -3217,14 +3217,14 @@ PyInterpreterRef_Close(PyInterpreterRef ref)
32173217
}
32183218

32193219
PyInterpreterState *
3220-
PyInterpreterRef_AsInterpreter(PyInterpreterRef ref)
3220+
PyInterpreterRef_GetInterpreter(PyInterpreterRef ref)
32213221
{
32223222
PyInterpreterState *interp = ref_as_interp(ref);
32233223
return interp;
32243224
}
32253225

32263226
int
3227-
PyInterpreterWeakRef_Get(PyInterpreterWeakRef *wref_ptr)
3227+
PyInterpreterWeakRef_FromCurrent(PyInterpreterWeakRef *wref_ptr)
32283228
{
32293229
PyInterpreterState *interp = PyInterpreterState_Get();
32303230
/* PyInterpreterWeakRef_Close() can be called without an attached thread
@@ -3270,7 +3270,7 @@ PyInterpreterWeakRef_Close(PyInterpreterWeakRef wref_handle)
32703270
}
32713271

32723272
int
3273-
PyInterpreterWeakRef_AsStrong(PyInterpreterWeakRef wref_handle, PyInterpreterRef *strong_ptr)
3273+
PyInterpreterWeakRef_Promote(PyInterpreterWeakRef wref_handle, PyInterpreterRef *strong_ptr)
32743274
{
32753275
assert(strong_ptr != NULL);
32763276
_PyInterpreterWeakRef *wref = wref_handle_as_ptr(wref_handle);
@@ -3291,7 +3291,7 @@ PyInterpreterWeakRef_AsStrong(PyInterpreterWeakRef wref_handle, PyInterpreterRef
32913291
}
32923292

32933293
int
3294-
PyInterpreterRef_Main(PyInterpreterRef *strong_ptr)
3294+
PyUnstable_GetDefaultInterpreterRef(PyInterpreterRef *strong_ptr)
32953295
{
32963296
assert(strong_ptr != NULL);
32973297
_PyRuntimeState *runtime = &_PyRuntime;

0 commit comments

Comments
 (0)