diff config.py @ 83:37c4ad87583c

Several small fixes Bug fix: testconf.py bytecode is written on Python 2.5. It is not written on newer versions of Python, but Python 2.5 lacks the facility to disable writing it; before this fix, the code just raised an unhandled exception. Bug fix: callable validators no longer require the outfile configuration variable to be set. Bug fix: the pause configuration variable (if not callable) is run in a shell just like it did in test.py v1; in particular, auto-detected values of the pause configuration variable now work again. Extras: *.{class,orig} added to .hgignore; Sublime Text 1 project file removed as I am using Sublime Text 2 now.
author Oleg Oshmyan <chortos@inbox.lv>
date Thu, 24 Feb 2011 00:10:19 +0000
parents 06356af50bf9
children cd347cfca272
line wrap: on
line diff
--- a/config.py	Wed Feb 23 23:35:27 2011 +0000
+++ b/config.py	Thu Feb 24 00:10:19 2011 +0000
@@ -90,8 +90,11 @@
 
 def load_problem(problem_name):
 	global builtins
-	dwb = sys.dont_write_bytecode
-	sys.dont_write_bytecode = True
+	try:
+		dwb = sys.dont_write_bytecode
+		sys.dont_write_bytecode = True
+	except AttributeError:
+		pass
 	metafile = files.File('/'.join((problem_name, 'testconf.py')), True, 'configuration')
 	module = None
 	with CompatBuiltins() as builtins:
@@ -157,7 +160,10 @@
 			setattr(module, name, newmap)
 	if options.no_maxtime:
 		module.maxcputime = module.maxwalltime = 0
-	sys.dont_write_bytecode = dwb
+	try:
+		sys.dont_write_bytecode = dwb
+	except NameError:
+		pass
 	for name in patterns:
 		if hasattr(module, name):
 			setattr(module, name, getattr(module, name).replace('%', problem_name))
@@ -165,8 +171,11 @@
 
 def load_global():
 	global builtins
-	dwb = sys.dont_write_bytecode
-	sys.dont_write_bytecode = True
+	try:
+		dwb = sys.dont_write_bytecode
+		sys.dont_write_bytecode = True
+	except AttributeError:
+		pass
 	metafile = files.File('testconf.py', True, 'configuration')
 	module = None
 	with CompatBuiltins() as builtins:
@@ -199,5 +208,8 @@
 		module.problems = module.tasknames
 	global globalconf
 	globalconf = module
-	sys.dont_write_bytecode = dwb
+	try:
+		sys.dont_write_bytecode = dwb
+	except NameError:
+		pass
 	return module
\ No newline at end of file