Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3765cd8

Browse files
committed
Add special case handling for __get__(None, NoneType)
1 parent7bf8378 commit3765cd8

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

‎vm/src/obj/objfunction.rs‎

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
usesuper::super::pyobject::{
2-
AttributeProtocol,PyContext,PyFuncArgs,PyObject,PyObjectKind,PyObjectRef,PyResult,
3-
TypeProtocol,
2+
AttributeProtocol,IdProtocol,PyContext,PyFuncArgs,PyObject,PyObjectKind,PyObjectRef,
3+
PyResult,TypeProtocol,
44
};
55
usesuper::super::vm::VirtualMachine;
66
usesuper::objtype;
@@ -22,7 +22,17 @@ pub fn init(context: &PyContext) {
2222
}
2323

2424
fnbind_method(vm:&mutVirtualMachine,args:PyFuncArgs) ->PyResult{
25-
Ok(vm.new_bound_method(args.args[0].clone(), args.args[1].clone()))
25+
arg_check!(
26+
vm,
27+
args,
28+
required =[(function,None),(obj,None),(cls,None)]
29+
);
30+
31+
if obj.is(&vm.get_none()) && !cls.is(&obj.typ()){
32+
Ok(function.clone())
33+
}else{
34+
Ok(vm.ctx.new_bound_method(function.clone(), obj.clone()))
35+
}
2636
}
2737

2838
fnmember_get(vm:&mutVirtualMachine,mutargs:PyFuncArgs) ->PyResult{

‎vm/src/vm.rs‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ use super::obj::objsequence;
1717
usesuper::obj::objstr;
1818
usesuper::obj::objtype;
1919
usesuper::pyobject::{
20-
AttributeProtocol,DictProtocol,IdProtocol,PyContext,PyFuncArgs,PyObjectKind,PyObjectRef,
21-
PyResult,TypeProtocol,
20+
AttributeProtocol,DictProtocol,PyContext,PyFuncArgs,PyObjectKind,PyObjectRef,PyResult,
21+
TypeProtocol,
2222
};
2323
usesuper::stdlib;
2424
usesuper::sysmodule;
@@ -92,14 +92,6 @@ impl VirtualMachine {
9292
self.ctx.none()
9393
}
9494

95-
pubfnnew_bound_method(&self,function:PyObjectRef,object:PyObjectRef) ->PyObjectRef{
96-
if object.is(&self.get_none()){
97-
function
98-
}else{
99-
self.ctx.new_bound_method(function, object)
100-
}
101-
}
102-
10395
pubfnget_type(&self) ->PyObjectRef{
10496
self.ctx.type_type()
10597
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp