From f59515e452a522fb3b4989aada18eb84234bacc0 Mon Sep 17 00:00:00 2001 From: cookedm Date: Tue, 31 Jan 2006 22:49:15 +0000 Subject: Misc cleanups + replace `a` with %r or repr(a) Also replace some type checks with misc_util.is_sequence or misc_util.is_string or appropiate isinstance(). --- numpy/distutils/exec_command.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'numpy/distutils/exec_command.py') diff --git a/numpy/distutils/exec_command.py b/numpy/distutils/exec_command.py index 6c5554bba..a44fd9abf 100644 --- a/numpy/distutils/exec_command.py +++ b/numpy/distutils/exec_command.py @@ -65,7 +65,7 @@ def get_pythonexe(): fdir,fn = os.path.split(pythonexe) fn = fn.upper().replace('PYTHONW','PYTHON') pythonexe = os.path.join(fdir,fn) - assert os.path.isfile(pythonexe),`pythonexe`+' is not a file' + assert os.path.isfile(pythonexe), '%r is not a file' % (pythonexe,) return pythonexe ############################################################ @@ -104,19 +104,19 @@ def splitcmdline(line): def test_splitcmdline(): l = splitcmdline('a b cc') - assert l==['a','b','cc'],`l` + assert l==['a','b','cc'], repr(l) l = splitcmdline('a') - assert l==['a'],`l` + assert l==['a'], repr(l) l = splitcmdline('a " b cc"') - assert l==['a','" b cc"'],`l` + assert l==['a','" b cc"'], repr(l) l = splitcmdline('"a bcc" -h') - assert l==['"a bcc"','-h'],`l` + assert l==['"a bcc"','-h'], repr(l) l = splitcmdline(r'"\"a \" bcc" -h') - assert l==[r'"\"a \" bcc"','-h'],`l` + assert l==[r'"\"a \" bcc"','-h'], repr(l) l = splitcmdline(" 'a bcc' -h") - assert l==["'a bcc'",'-h'],`l` + assert l==["'a bcc'",'-h'], repr(l) l = splitcmdline(r"'\'a \' bcc' -h") - assert l==[r"'\'a \' bcc'",'-h'],`l` + assert l==[r"'\'a \' bcc'",'-h'], repr(l) ############################################################ @@ -340,7 +340,8 @@ def _exec_command_python(command, cmd = '%s %s' % (python_exe, cmdfile) status = os.system(cmd) - assert not status,`cmd`+' failed' + if status: + raise RuntimeError("%r failed" % (cmd,)) os.remove(cmdfile) f = open(stsfile,'r') -- cgit v1.2.1