void load_global() { IObjectConstructor constructor; string module = pu.readline(); string name = pu.readline(); string key = module + "." + name; if (objectConstructors.ContainsKey(key)) { constructor = objectConstructors[module + "." + name]; } else { // check if it is an exception if (module == "exceptions") { constructor = new AnyClassConstructor(typeof(PythonException)); } else { throw new PickleException("unsupported class: " + module + "." + name); } } stack.add(constructor); }
void load_global() { IObjectConstructor constructor; string module = pu.readline(); string name = pu.readline(); string key = module + "." + name; if (objectConstructors.ContainsKey(key)) { constructor = objectConstructors[module + "." + name]; } else { // check if it is an exception if (module == "exceptions") { // python 2.x constructor = new AnyClassConstructor(typeof(PythonException)); } else if (module == "builtins" || module == "__builtin__") { if (name.EndsWith("Error") || name.EndsWith("Warning") || name.EndsWith("Exception") || name == "GeneratorExit" || name == "KeyboardInterrupt" || name == "StopIteration" || name == "SystemExit") { // it's a python 3.x exception constructor = new AnyClassConstructor(typeof(PythonException)); } else { // return a dictionary with the class's properties constructor = new ClassDictConstructor(module, name); } } else { // return a dictionary with the class's properties constructor = new ClassDictConstructor(module, name); } } stack.add(constructor); }