예제 #1
0
        /// <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__");
        }
예제 #2
0
 internal static void Reset()
 {
     Global = new PyScopeManager();
 }