upgrade to python3

This commit is contained in:
2026-02-08 11:23:34 +08:00
parent 487c041148
commit 9b20887cc2
9 changed files with 139 additions and 195 deletions

View File

@@ -80,10 +80,11 @@ class ExternalJudge:
self.comparecmd = tester.comparecmd
self.codefile = os.path.abspath(os.path.join(datadir, tester.source))
with open(self.codefile, 'w') as f:
f.write(string.replace(vcode, '\r\n', '\n'))
f.write(vcode.replace('\r\n', '\n'))
if len(vcode) > 0 and vcode[-1] != '\n':
f.write('\n')
self.logger.debug("Save validator code as %s" % self.codefile)
def judge(self, sid, tid, tin, tout, result, errfile, rundir = None):
@@ -116,9 +117,10 @@ class ExternalJudge:
pid = os.fork()
if pid == 0:
os.close(1)
os.open(rfile, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0666)
os.open(rfile, os.O_WRONLY | os.O_CREAT | os.O_TRUNC, 0o666)
os.close(2)
os.open(errfile, os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0666)
os.open(errfile, os.O_WRONLY | os.O_CREAT | os.O_APPEND, 0o666)
if rundir: os.chdir(rundir)
os.execv(cmd[0], cmd)