diff options
Diffstat (limited to 'waflib/Utils.py')
-rw-r--r-- | waflib/Utils.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/waflib/Utils.py b/waflib/Utils.py index a62daab..273ebb0 100644 --- a/waflib/Utils.py +++ b/waflib/Utils.py @@ -33,9 +33,14 @@ try: from hashlib import md5 except ImportError: try: - from md5 import md5 + from hashlib import sha1 as md5 except ImportError: pass +else: + try: + md5().digest() + except ValueError: + from hashlib import sha1 as md5 try: import threading except ImportError: @@ -49,7 +54,7 @@ except ImportError: def release(self): pass threading.Lock=threading.Thread=Lock -SIG_NIL='SIG_NIL_SIG_NIL_' +SIG_NIL='SIG_NIL_SIG_NIL_'.encode() O644=420 O755=493 rot_chr=['\\','|','/','-'] @@ -134,7 +139,7 @@ class lazy_generator(object): it=self.it=self.fun(*self.params) return next(it) next=__next__ -is_win32=os.sep=='\\'or sys.platform=='win32' +is_win32=os.sep=='\\'or sys.platform=='win32'or os.name=='nt' def readf(fname,m='r',encoding='latin-1'): if sys.hexversion>0x3000000 and not'b'in m: m+='b' @@ -331,7 +336,7 @@ def check_dir(path): if not os.path.isdir(path): try: os.makedirs(path) - except OSError ,e: + except OSError as e: if not os.path.isdir(path): raise Errors.WafError('Cannot create the folder %r'%path,ex=e) def check_exe(name,env=None): @@ -365,7 +370,7 @@ def shell_escape(cmd): return cmd return' '.join(repr(x)if re_sh.search(x)else x for x in cmd) def h_list(lst): - return md5(repr(lst)).digest() + return md5(repr(lst).encode()).digest() def h_fun(fun): try: return fun.code @@ -521,7 +526,7 @@ def run_prefork_process(cmd,kwargs,cargs): if not proc: return run_regular_process(cmd,kwargs,cargs) proc.stdin.write(obj) - proc.stdin.write('\n') + proc.stdin.write('\n'.encode()) proc.stdin.flush() obj=proc.stdout.readline() if not obj: @@ -575,7 +580,7 @@ def run_regular_process(cmd,kwargs,cargs={}): out,err=(None,None) try: status=proc.wait(**cargs) - except TimeoutExpired ,e: + except TimeoutExpired as e: if kwargs.get('start_new_session')and hasattr(os,'killpg'): os.killpg(proc.pid,signal.SIGKILL) else: |