diff config.py @ 70:b9d5857f7b9a

Better emulation of built-ins for testconf Bug fix: next is now in compat.__all__. Members of compat that do not correspond to built-ins or members of itertools are no longer added to built-ins while loading testconf. xrange is now added to built-ins only while loading testconf and only in legacy mode. testconf can now access the original built-ins through the CompatBuiltins context manager which is now exposed as config.builtins. Bug fix: the default string encoding is no longer relied upon.
author Oleg Oshmyan <chortos@inbox.lv>
date Mon, 03 Jan 2011 01:27:56 +0200
parents 7c6dba0b84f2
children b071ef77377c
line wrap: on
line diff
--- a/config.py	Mon Jan 03 01:07:02 2011 +0200
+++ b/config.py	Mon Jan 03 01:27:56 2011 +0200
@@ -86,11 +86,12 @@
 		os.remove(self.name)
 
 def load_problem(problem_name):
+	global builtins
 	dwb = sys.dont_write_bytecode
 	sys.dont_write_bytecode = True
 	metafile = files.File('/'.join((problem_name, 'testconf.py')), True, 'configuration')
 	module = None
-	with CompatBuiltins():
+	with CompatBuiltins() as builtins:
 		if zipimport and isinstance(metafile.archive, files.ZipArchive):
 			try:
 				module = zipimport.zipimporter(os.path.dirname(metafile.full_real_path)).load_module('testconf')
@@ -154,11 +155,12 @@
 	return module
 
 def load_global():
+	global builtins
 	dwb = sys.dont_write_bytecode
 	sys.dont_write_bytecode = True
 	metafile = files.File('testconf.py', True, 'configuration')
 	module = None
-	with CompatBuiltins():
+	with CompatBuiltins() as builtins:
 		if zipimport and isinstance(metafile.archive, files.ZipArchive):
 			try:
 				module = zipimport.zipimporter(os.path.dirname(metafile.full_real_path)).load_module('testconf')