/// <summary> /// Constructor /// </summary> /// <remarks> /// Create a scope based on a Python Module. /// </remarks> internal PyScope(IntPtr ptr, PyScopeManager manager) { if (!Runtime.PyType_IsSubtype(Runtime.PyObject_TYPE(ptr), Runtime.PyModuleType)) { throw new PyScopeException("object is not a module"); } Manager = manager ?? PyScopeManager.Global; obj = ptr; //Refcount of the variables not increase variables = Runtime.PyModule_GetDict(obj); Runtime.CheckExceptionOccurred(); Runtime.PyDict_SetItemString( variables, "__builtins__", Runtime.PyEval_GetBuiltins() ); this.Name = this.Get <string>("__name__"); }
internal static void Reset() { Global = new PyScopeManager(); }