Skip to content

Commit 2438c5f

Browse files
committed
Avoid usage of the name 'thread' in examples.
For whatever reason, the rendered highlighter treats these as keywords.
1 parent 01f8422 commit 2438c5f

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

peps/pep-0788.rst

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ With this PEP, you'd implement it like this:
653653
return -1;
654654
}
655655
656-
PyThreadRef thread;
657-
if (PyThreadState_Ensure(ref, &thread) < 0) {
656+
PyThreadRef thread_ref;
657+
if (PyThreadState_Ensure(ref, &thread_ref) < 0) {
658658
PyInterpreterRef_Close(ref);
659659
puts("Out of memory.\n", stderr);
660660
return -1;
@@ -665,7 +665,7 @@ With this PEP, you'd implement it like this:
665665
free(to_write);
666666
PyErr_Print();
667667
668-
PyThreadState_Release(thread);
668+
PyThreadState_Release(thread_ref);
669669
PyInterpreterRef_Close(ref);
670670
return res < 0;
671671
}
@@ -756,15 +756,15 @@ This is the same code, rewritten to use the new functions:
756756
thread_func(void *arg)
757757
{
758758
PyInterpreterRef interp = (PyInterpreterRef)arg;
759-
PyThreadRef thread;
760-
if (PyThreadState_Ensure(interp, &thread) < 0) {
759+
PyThreadRef thread_ref;
760+
if (PyThreadState_Ensure(interp, &thread_ref) < 0) {
761761
PyInterpreterRef_Close(interp);
762762
return -1;
763763
}
764764
if (PyRun_SimpleString("print(42)") < 0) {
765765
PyErr_Print();
766766
}
767-
PyThreadState_Release(&thread);
767+
PyThreadState_Release(thread_ref);
768768
PyInterpreterRef_Close(interp);
769769
return 0;
770770
}
@@ -804,8 +804,8 @@ release the interpreter reference, allowing the interpreter to shut down.
804804
thread_func(void *arg)
805805
{
806806
PyInterpreterRef ref = (PyInterpreterRef)arg;
807-
PyThreadRef thread;
808-
if (PyThreadState_Ensure(ref, &thread) < 0) {
807+
PyThreadRef thread_ref;
808+
if (PyThreadState_Ensure(ref, &thread_ref) < 0) {
809809
PyInterpreterRef_Close(ref);
810810
return -1;
811811
}
@@ -815,7 +815,7 @@ release the interpreter reference, allowing the interpreter to shut down.
815815
if (PyRun_SimpleString("print(42)") < 0) {
816816
PyErr_Print();
817817
}
818-
PyThreadState_Release(thread);
818+
PyThreadState_Release(thread_ref);
819819
return 0;
820820
}
821821
@@ -861,15 +861,15 @@ deadlock the interpreter if it's not released.
861861
return -1;
862862
}
863863
864-
PyThreadRef thread;
865-
if (PyThreadState_Ensure(ref, &thread) < 0) {
864+
PyThreadRef thread_ref;
865+
if (PyThreadState_Ensure(ref, &thread_ref) < 0) {
866866
PyInterpreterRef_Close(ref);
867867
return -1;
868868
}
869869
if (PyRun_SimpleString("print(42)") < 0) {
870870
PyErr_Print();
871871
}
872-
PyThreadState_Release(thread);
872+
PyThreadState_Release(thread_ref);
873873
PyInterpreterRef_Close(ref);
874874
return 0;
875875
}
@@ -920,15 +920,15 @@ interpreter here.
920920
return;
921921
}
922922
923-
PyThreadRef thread;
924-
if (PyThreadState_Ensure(ref, &thread) < 0) {
923+
PyThreadRef thread_ref;
924+
if (PyThreadState_Ensure(ref, &thread_ref) < 0) {
925925
PyInterpreterRef_Close(ref);
926926
return -1;
927927
}
928928
if (PyRun_SimpleString("print(42)") < 0) {
929929
PyErr_Print();
930930
}
931-
PyThreadState_Release(thread);
931+
PyThreadState_Release(thread_ref);
932932
PyInterpreterRef_Close(ref);
933933
return 0;
934934
}

0 commit comments

Comments
 (0)