summaryrefslogtreecommitdiff
path: root/third_party/waf/waflib/fixpy2.py
diff options
context:
space:
mode:
authorAlexander Bokovoy <ab@samba.org>2018-01-31 11:48:43 +0200
committerAndrew Bartlett <abartlet@samba.org>2018-09-05 06:37:22 +0200
commit4e65b33c1d40bb2c243f775f388056aed31d8671 (patch)
tree5a41b6ddef7ce1c0b6a93bcc16ef89da10f080e8 /third_party/waf/waflib/fixpy2.py
parentfaef27506977db01cc4619140a71652463914378 (diff)
downloadsamba-4e65b33c1d40bb2c243f775f388056aed31d8671.tar.gz
third_party:waf: update to upstream 2.0.4 release
Update third_party/waf/ to 2.0.4 to bring us closer to Python 3 This change requires a number of changes in buildtools/ too. Signed-off-by: Alexander Bokovoy <ab@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Diffstat (limited to 'third_party/waf/waflib/fixpy2.py')
-rw-r--r--third_party/waf/waflib/fixpy2.py23
1 files changed, 9 insertions, 14 deletions
diff --git a/third_party/waf/waflib/fixpy2.py b/third_party/waf/waflib/fixpy2.py
index a7bcef525d1..83df79cbeda 100644
--- a/third_party/waf/waflib/fixpy2.py
+++ b/third_party/waf/waflib/fixpy2.py
@@ -4,7 +4,9 @@
#!/usr/bin/env python
# encoding: utf-8
-# Thomas Nagy, 2010-2016 (ita)
+# Thomas Nagy, 2010-2018 (ita)
+
+from __future__ import with_statement
import os
@@ -12,7 +14,6 @@ all_modifs = {}
def fixdir(dir):
"""Call all substitution functions on Waf folders"""
- global all_modifs
for k in all_modifs:
for v in all_modifs[k]:
modif(os.path.join(dir, 'waflib'), k, v)
@@ -30,24 +31,17 @@ def modif(dir, name, fun):
return
filename = os.path.join(dir, name)
- f = open(filename, 'r')
- try:
+ with open(filename, 'r') as f:
txt = f.read()
- finally:
- f.close()
txt = fun(txt)
- f = open(filename, 'w')
- try:
+ with open(filename, 'w') as f:
f.write(txt)
- finally:
- f.close()
def subst(*k):
"""register a substitution function"""
def do_subst(fun):
- global all_modifs
for x in k:
try:
all_modifs[x].append(fun)
@@ -59,9 +53,9 @@ def subst(*k):
@subst('*')
def r1(code):
"utf-8 fixes for python < 2.6"
- code = code.replace(',e:', ',e:')
- code = code.replace("", '')
- return code.replace('', '')
+ code = code.replace('as e:', ',e:')
+ code = code.replace(".decode(sys.stdout.encoding or'latin-1',errors='replace')", '')
+ return code.replace('.encode()', '')
@subst('Runner.py')
def r4(code):
@@ -71,3 +65,4 @@ def r4(code):
@subst('Context.py')
def r5(code):
return code.replace("('Execution failure: %s'%str(e),ex=e)", "('Execution failure: %s'%str(e),ex=e),None,sys.exc_info()[2]")
+