Skip to content

Commit bd42056

Browse files
committed
fix other issue for isinstance
1 parent 2bd5059 commit bd42056

9 files changed

Lines changed: 41 additions & 6 deletions

File tree

examples/_thread/thread_issue1.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import time
2+
import _thread
3+
4+
5+
def task2():
6+
while True:
7+
print("123")
8+
time.sleep_ms(2001)
9+
10+
11+
_thread.start_new_thread(task2, ())
12+
13+
while True:
14+
time.sleep_ms(2000)

package/_thread/_thread.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,6 @@ void _thread_start_new_thread(PikaObj* self, Arg* function, Arg* args_) {
155155
obj_setSysOut(self, "thread create failed");
156156
return;
157157
}
158-
pika_platform_thread_startup(info->thread);
159158
#if !PIKA_THREAD_MALLOC_STACK_ENABLE
160159
g_PikaMemInfo.heapUsed += info->stack_size;
161160
#endif

port/linux/.vscode/launch.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@
3434
// "--gtest_filter=jrpc.cmd"
3535
// "--gtest_filter=jrpc.exec_get_val"
3636
// "--gtest_filter=jrpc.exec_get_val"
37-
"--gtest_filter=builtin.issue_isinstance"
37+
// "--gtest_filter=thread.issue1"
38+
// "--gtest_filter=except.isinstance"
39+
"--gtest_filter=builtin.isinstance"
3840
],
3941
"stopAtEntry": false,
4042
"cwd": "${workspaceFolder}",

port/linux/test/py-test.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,9 @@ TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(socket,
109109
"test/python/socket/socket_download.py",
110110
"PASS\r\n")
111111

112+
TEST_RUN_SINGLE_FILE_PASS(builtin,
113+
issue_isinstance,
114+
"test/python/builtins/issue_isinstance.py");
112115
#endif
113116

114117
TEST_END
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import time
2+
import _thread
3+
4+
5+
def task2():
6+
while True:
7+
print("123")
8+
time.sleep_ms(2001)
9+
10+
11+
_thread.start_new_thread(task2, ())
12+
13+
while True:
14+
time.sleep_ms(2000)

src/PikaObj.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4010,7 +4010,7 @@ pika_bool _isinstance(Arg* aObj, Arg* classinfo) {
40104010
goto __exit;
40114011
}
40124012
Arg* aObjSuper = methodArg_super(aObjType, &objProp);
4013-
if (NULL == aObjSuper) {
4013+
if ((NULL == aObjSuper) && (NULL == objProp)) {
40144014
res = pika_false;
40154015
goto __exit;
40164016
}

src/PikaPlatform.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,10 @@ PIKA_WEAK void pika_platform_thread_yield(void) {
612612
pika_thread_idle_hook();
613613
#if PIKA_FREERTOS_ENABLE
614614
vTaskDelay(1);
615-
#elif defined(__linux) || defined(_WIN32)
616-
return;
615+
#elif defined(_WIN32)
616+
SwitchToThread();
617+
#elif defined(__linux)
618+
sched_yield();
617619
#elif PIKA_RTTHREAD_ENABLE
618620
rt_thread_yield();
619621
#elif PIKA_ZEUSOS_ENABLE

src/PikaPlatform.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ uint8_t pika_is_locked_pikaMemory(void);
261261
/* Thread Platform */
262262
#ifdef __linux
263263
#include <pthread.h>
264+
#include <sched.h>
264265
typedef struct pika_platform_thread {
265266
pthread_t thread;
266267
pthread_mutex_t mutex;

src/PikaVersion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
#define PIKA_VERSION_MINOR 13
33
#define PIKA_VERSION_MICRO 3
44

5-
#define PIKA_EDIT_TIME "2024/08/02 18:06:51"
5+
#define PIKA_EDIT_TIME "2024/08/03 17:05:07"

0 commit comments

Comments
 (0)