Skip to content

Commit

Permalink
fix mam lack for is instance
Browse files Browse the repository at this point in the history
  • Loading branch information
pikasTech committed Aug 2, 2024
1 parent 08342ae commit 2bd5059
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 3 deletions.
1 change: 1 addition & 0 deletions examples/builtins/isinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
assert isinstance({"key": "value"}, dict) == True
assert isinstance(3.14, float) == True
assert isinstance(object(), object) == True
assert isinstance(10, str) == False

class MyClass:
pass
Expand Down
20 changes: 20 additions & 0 deletions examples/builtins/issue_isinstance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class scr_Text:
def cus_print(self, data, end='\n'):
str_buf = ""

if isinstance(data, str):
str_buf = str_buf + data
elif isinstance(data, int):
str_buf = str_buf + str(data)
else:
str_buf = "The type is not recognized"
str_buf = str_buf + end


screen = scr_Text()
screen.cus_print(12)
screen.cus_print(12)
screen.cus_print(12)
screen.cus_print(12)

print('PASS')
3 changes: 2 additions & 1 deletion port/linux/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
// "--gtest_filter=jrpc.BlockingRequestBetweenTwoJRPC"
// "--gtest_filter=jrpc.cmd"
// "--gtest_filter=jrpc.exec_get_val"
"--gtest_filter=jrpc.exec_get_val"
// "--gtest_filter=jrpc.exec_get_val"
"--gtest_filter=builtin.issue_isinstance"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
Expand Down
1 change: 1 addition & 0 deletions port/linux/test/python/builtins/isinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
assert isinstance({"key": "value"}, dict) == True
assert isinstance(3.14, float) == True
assert isinstance(object(), object) == True
assert isinstance(10, str) == False

class MyClass:
pass
Expand Down
20 changes: 20 additions & 0 deletions port/linux/test/python/builtins/issue_isinstance.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
class scr_Text:
def cus_print(self, data, end='\n'):
str_buf = ""

if isinstance(data, str):
str_buf = str_buf + data
elif isinstance(data, int):
str_buf = str_buf + str(data)
else:
str_buf = "The type is not recognized"
str_buf = str_buf + end


screen = scr_Text()
screen.cus_print(12)
screen.cus_print(12)
screen.cus_print(12)
screen.cus_print(12)

print('PASS')
7 changes: 6 additions & 1 deletion src/PikaObj.c
Original file line number Diff line number Diff line change
Expand Up @@ -4009,7 +4009,12 @@ pika_bool _isinstance(Arg* aObj, Arg* classinfo) {
res = pika_true;
goto __exit;
}
aObjType = methodArg_super(aObjType, &objProp);
Arg* aObjSuper = methodArg_super(aObjType, &objProp);
if (NULL == aObjSuper) {
res = pika_false;
goto __exit;
}
aObjType = aObjSuper;
if (NULL != objProp) {
if (!(arg_getType(classinfo) ==
ARG_TYPE_METHOD_NATIVE_CONSTRUCTOR)) {
Expand Down
2 changes: 1 addition & 1 deletion src/PikaVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
#define PIKA_VERSION_MINOR 13
#define PIKA_VERSION_MICRO 3

#define PIKA_EDIT_TIME "2024/08/02 16:00:32"
#define PIKA_EDIT_TIME "2024/08/02 18:06:51"

0 comments on commit 2bd5059

Please sign in to comment.