# HG changeset patch # User Oleg Oshmyan # Date 1298506219 0 # Node ID 37c4ad87583c668fb13c8b17618aa4ea31db2213 # Parent 06356af50bf9b935356f5a4d933afadf43f7769e 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. diff -r 06356af50bf9 -r 37c4ad87583c .hgignore --- a/.hgignore Wed Feb 23 23:35:27 2011 +0000 +++ b/.hgignore Thu Feb 24 00:10:19 2011 +0000 @@ -1,2 +1,2 @@ -\.pyc$ +\.(pyc|pyo|class|orig)$ (/|^)suite$ \ No newline at end of file diff -r 06356af50bf9 -r 37c4ad87583c config.py --- 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 diff -r 06356af50bf9 -r 37c4ad87583c problem.py --- a/problem.py Wed Feb 23 23:35:27 2011 +0000 +++ b/problem.py Thu Feb 24 00:10:19 2011 +0000 @@ -207,7 +207,8 @@ sys.stdout.flush() return weighted, prob.config.taskweight finally: - if options.erase and (not prob.config.stdio or case and case.validator): + if options.erase and (not prob.config.stdio or case and + (case.validator and not callable(case.validator))): for var in 'in', 'out': name = getattr(prob.config, var + 'name') if name: diff -r 06356af50bf9 -r 37c4ad87583c testcases.py --- a/testcases.py Wed Feb 23 23:35:27 2011 +0000 +++ b/testcases.py Thu Feb 24 00:10:19 2011 +0000 @@ -279,7 +279,7 @@ contextmgr = Copying(case.infile, inputdatafname) with contextmgr: with open(inputdatafname) as infile: - with tempfile.TemporaryFile('w+') if options.erase and not case.validator else open(case.problem.config.outname, 'w+') as outfile: + with tempfile.TemporaryFile('w+') if options.erase and (not case.validator or callable(case.validator)) else open(case.problem.config.outname, 'w+') as outfile: call(case.problem.config.path, case=case, stdin=infile, stdout=outfile, stderr=devnull, universal_newlines=True, bufsize=-1) if config.globalconf.force_zero_exitcode and case.process.returncode or case.process.returncode < 0: raise NonZeroExitCode(case.process.returncode) diff -r 06356af50bf9 -r 37c4ad87583c upreckon-vcs --- a/upreckon-vcs Wed Feb 23 23:35:27 2011 +0000 +++ b/upreckon-vcs Thu Feb 24 00:10:19 2011 +0000 @@ -161,4 +161,4 @@ globalconf.pause() else: with open(os.devnull, 'w') as devnull: - subprocess.call(globalconf.pause, stdout=devnull, stderr=subprocess.STDOUT) \ No newline at end of file + subprocess.call(globalconf.pause, shell=True, stdout=devnull, stderr=subprocess.STDOUT) \ No newline at end of file diff -r 06356af50bf9 -r 37c4ad87583c upreckon.sublime-project --- a/upreckon.sublime-project Wed Feb 23 23:35:27 2011 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,10 +0,0 @@ - - - - - - - -