File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 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)
4141 variables , "__builtins__" ,
4242 Runtime . PyEval_GetBuiltins ( )
4343 ) ;
44+ InitVariables ( ) ;
45+ }
46+
47+ //To compitable with the python module
48+ private void InitVariables ( )
49+ {
4450 SetVariable ( "locals" , ( Func < PyDict > ) Variables ) ;
4551 SetVariable ( "globals" , ( Func < PyDict > ) Variables ) ;
4652 }
@@ -50,10 +56,19 @@ internal PyScope(string name)
5056 /// </summary>
5157 internal IntPtr variables { get ; private set ; }
5258
59+ public long Refcount
60+ {
61+ get
62+ {
63+ return Runtime . Refcount ( variables ) ;
64+ }
65+ }
66+
5367 public event Action < PyScope > OnDispose ;
5468
5569 public PyDict Variables ( )
5670 {
71+ Runtime . XIncref ( variables ) ;
5772 return new PyDict ( variables ) ;
5873 }
5974
@@ -77,6 +92,7 @@ public void ImportScope(PyScope scope)
7792 {
7893 throw new PythonException ( ) ;
7994 }
95+ InitVariables ( ) ;
8096 }
8197
8298 /// <summary>
You can’t perform that action at this time.
0 commit comments