Python pickle.GLOBAL Examples
The following are 4
code examples of pickle.GLOBAL().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pickle
, or try the search function
.
Example #1
Source File: test_cpickle_jy.py From medicare-demo with Apache License 2.0 | 6 votes |
def testWithUserDefinedImport(self): """test cPickle calling a user defined import function.""" # This tests the fix for http://bugs.jython.org/issue1665 # setup original_import = __builtin__.__import__ def import_hook(name, _globals=None, locals=None, fromlist=None, level= -1): return original_import(name, _globals, locals, fromlist, level) # test __builtin__.__import__ = import_hook try: if "no_such_module" in sys.modules: del sys.modules["no_such_module"] # force cPickle to call __import__ self.assertRaises(ImportError, cPickle.loads, pickle.GLOBAL + "no_such_module\n" + "no_such_class\n") finally: __builtin__.__import__ = original_import
Example #2
Source File: test_cpickle_jy.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 6 votes |
def testWithUserDefinedImport(self): """test cPickle calling a user defined import function.""" # This tests the fix for http://bugs.jython.org/issue1665 # setup original_import = __builtin__.__import__ def import_hook(name, _globals=None, locals=None, fromlist=None, level= -1): return original_import(name, _globals, locals, fromlist, level) # test __builtin__.__import__ = import_hook try: if "no_such_module" in sys.modules: del sys.modules["no_such_module"] # force cPickle to call __import__ self.assertRaises(ImportError, cPickle.loads, pickle.GLOBAL + "no_such_module\n" + "no_such_class\n") finally: __builtin__.__import__ = original_import
Example #3
Source File: test_cpickle_jy.py From CTFCrackTools with GNU General Public License v3.0 | 6 votes |
def testWithUserDefinedImport(self): """test cPickle calling a user defined import function.""" # This tests the fix for http://bugs.jython.org/issue1665 # setup original_import = __builtin__.__import__ def import_hook(name, _globals=None, locals=None, fromlist=None, level= -1): return original_import(name, _globals, locals, fromlist, level) # test __builtin__.__import__ = import_hook try: if "no_such_module" in sys.modules: del sys.modules["no_such_module"] # force cPickle to call __import__ self.assertRaises(ImportError, cPickle.loads, pickle.GLOBAL + "no_such_module\n" + "no_such_class\n") finally: __builtin__.__import__ = original_import
Example #4
Source File: recipe-572213.py From code with MIT License | 5 votes |
def save_global_byname(self, obj, modname, objname): """ Save obj as a global reference. Used for objects that pickle does not find correctly. """ self.write('%s%s\n%s\n' % (pickle.GLOBAL, modname, objname)) self.memoize(obj)