@@ -13,7 +13,8 @@ pub fn init(context: &PyContext) {
13
13
let ref frame_type = context. frame_type ;
14
14
frame_type. set_attr ( "__new__" , context. new_rustfunc ( frame_new) ) ;
15
15
frame_type. set_attr ( "__repr__" , context. new_rustfunc ( frame_repr) ) ;
16
- frame_type. set_attr ( "f_locals" , context. new_property ( frame_locals) ) ;
16
+ frame_type. set_attr ( "f_locals" , context. new_property ( frame_flocals) ) ;
17
+ frame_type. set_attr ( "f_code" , context. new_property ( frame_fcode) ) ;
17
18
}
18
19
19
20
fn frame_new ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
@@ -27,7 +28,7 @@ fn frame_repr(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
27
28
Ok ( vm. new_str ( repr) )
28
29
}
29
30
30
- fn frame_locals ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
31
+ fn frame_flocals ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
31
32
arg_check ! ( vm, args, required = [ ( frame, Some ( vm. ctx. frame_type( ) ) ) ] ) ;
32
33
let frame = get_value ( frame) ;
33
34
let py_scope = frame. locals . clone ( ) ;
@@ -40,6 +41,11 @@ fn frame_locals(vm: &mut VirtualMachine, args: PyFuncArgs) -> PyResult {
40
41
}
41
42
}
42
43
44
+ fn frame_fcode ( vm : & mut VirtualMachine , args : PyFuncArgs ) -> PyResult {
45
+ arg_check ! ( vm, args, required = [ ( frame, Some ( vm. ctx. frame_type( ) ) ) ] ) ;
46
+ Ok ( vm. ctx . new_code_object ( get_value ( frame) . code ) )
47
+ }
48
+
43
49
pub fn get_value ( obj : & PyObjectRef ) -> Frame {
44
50
if let PyObjectKind :: Frame { frame } = & obj. borrow ( ) . kind {
45
51
frame. clone ( )
0 commit comments