File tree 1 file changed +16
-0
lines changed
1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,12 @@ internal PyScope(string name)
41
41
variables , "__builtins__" ,
42
42
Runtime . PyEval_GetBuiltins ( )
43
43
) ;
44
+ InitVariables ( ) ;
45
+ }
46
+
47
+ //To compitable with the python module
48
+ private void InitVariables ( )
49
+ {
44
50
SetVariable ( "locals" , ( Func < PyDict > ) Variables ) ;
45
51
SetVariable ( "globals" , ( Func < PyDict > ) Variables ) ;
46
52
}
@@ -50,10 +56,19 @@ internal PyScope(string name)
50
56
/// </summary>
51
57
internal IntPtr variables { get ; private set ; }
52
58
59
+ public long Refcount
60
+ {
61
+ get
62
+ {
63
+ return Runtime . Refcount ( variables ) ;
64
+ }
65
+ }
66
+
53
67
public event Action < PyScope > OnDispose ;
54
68
55
69
public PyDict Variables ( )
56
70
{
71
+ Runtime . XIncref ( variables ) ;
57
72
return new PyDict ( variables ) ;
58
73
}
59
74
@@ -77,6 +92,7 @@ public void ImportScope(PyScope scope)
77
92
{
78
93
throw new PythonException ( ) ;
79
94
}
95
+ InitVariables ( ) ;
80
96
}
81
97
82
98
/// <summary>
You can’t perform that action at this time.
0 commit comments