فهرست منبع

fix other issue for isinstance

lyon1998 1 سال پیش
والد
کامیت
bd4205681e

+ 14 - 0
examples/_thread/thread_issue1.py

@@ -0,0 +1,14 @@
+import time
+import _thread
+
+
+def task2():
+    while True:
+        print("123")
+        time.sleep_ms(2001)
+
+
+_thread.start_new_thread(task2, ())
+
+while True:
+    time.sleep_ms(2000)

+ 0 - 1
package/_thread/_thread.c

@@ -155,7 +155,6 @@ void _thread_start_new_thread(PikaObj* self, Arg* function, Arg* args_) {
         obj_setSysOut(self, "thread create failed");
         return;
     }
-    pika_platform_thread_startup(info->thread);
 #if !PIKA_THREAD_MALLOC_STACK_ENABLE
     g_PikaMemInfo.heapUsed += info->stack_size;
 #endif

+ 3 - 1
port/linux/.vscode/launch.json

@@ -34,7 +34,9 @@
                 // "--gtest_filter=jrpc.cmd"
                 // "--gtest_filter=jrpc.exec_get_val"
                 // "--gtest_filter=jrpc.exec_get_val"
-                "--gtest_filter=builtin.issue_isinstance"
+                // "--gtest_filter=thread.issue1"
+                // "--gtest_filter=except.isinstance"
+                "--gtest_filter=builtin.isinstance"
             ],
             "stopAtEntry": false,
             "cwd": "${workspaceFolder}",

+ 3 - 0
port/linux/test/py-test.cpp

@@ -109,6 +109,9 @@ TEST_RUN_SINGLE_FILE_EXCEPT_OUTPUT(socket,
                                    "test/python/socket/socket_download.py",
                                    "PASS\r\n")
 
+TEST_RUN_SINGLE_FILE_PASS(builtin,
+                          issue_isinstance,
+                          "test/python/builtins/issue_isinstance.py");
 #endif
 
 TEST_END

+ 14 - 0
port/linux/test/python/_thread/thread_issue1.py

@@ -0,0 +1,14 @@
+import time
+import _thread
+
+
+def task2():
+    while True:
+        print("123")
+        time.sleep_ms(2001)
+
+
+_thread.start_new_thread(task2, ())
+
+while True:
+    time.sleep_ms(2000)

+ 1 - 1
src/PikaObj.c

@@ -4010,7 +4010,7 @@ pika_bool _isinstance(Arg* aObj, Arg* classinfo) {
             goto __exit;
         }
         Arg* aObjSuper = methodArg_super(aObjType, &objProp);
-        if (NULL == aObjSuper) {
+        if ((NULL == aObjSuper) && (NULL == objProp)) {
             res = pika_false;
             goto __exit;
         }

+ 4 - 2
src/PikaPlatform.c

@@ -612,8 +612,10 @@ PIKA_WEAK void pika_platform_thread_yield(void) {
     pika_thread_idle_hook();
 #if PIKA_FREERTOS_ENABLE
     vTaskDelay(1);
-#elif defined(__linux) || defined(_WIN32)
-    return;
+#elif defined(_WIN32)
+    SwitchToThread();
+#elif defined(__linux)
+    sched_yield();
 #elif PIKA_RTTHREAD_ENABLE
     rt_thread_yield();
 #elif PIKA_ZEUSOS_ENABLE

+ 1 - 0
src/PikaPlatform.h

@@ -261,6 +261,7 @@ uint8_t pika_is_locked_pikaMemory(void);
 /* Thread Platform */
 #ifdef __linux
 #include <pthread.h>
+#include <sched.h>
 typedef struct pika_platform_thread {
     pthread_t thread;
     pthread_mutex_t mutex;

+ 1 - 1
src/PikaVersion.h

@@ -2,4 +2,4 @@
 #define PIKA_VERSION_MINOR 13
 #define PIKA_VERSION_MICRO 3
 
-#define PIKA_EDIT_TIME "2024/08/02 18:06:51"
+#define PIKA_EDIT_TIME "2024/08/03 17:05:07"