Removed the hard-coded python3 syntax to raise meaningful exceptions

This commit is contained in:
Thomas Nagy 2012-10-02 03:46:52 +02:00
parent 85d863bd52
commit c575dc1392
1 changed files with 7 additions and 2 deletions

View File

@ -51,6 +51,11 @@ def sub_file(fname, lst):
finally: finally:
f.close() f.close()
def to_bytes(x):
if sys.hexversion>0x300000f:
return x.encode()
return x
print("------> Executing code from the top-level wscript <-----") print("------> Executing code from the top-level wscript <-----")
def init(ctx): def init(ctx):
if Options.options.setver: # maintainer only (ita) if Options.options.setver: # maintainer only (ita)
@ -333,9 +338,9 @@ def create_waf(*k, **kw):
f = open('waf', 'wb') f = open('waf', 'wb')
try: try:
f.write(ccc.encode()) f.write(ccc.encode())
f.write(b'#==>\n#') f.write(to_bytes('#==>\n#'))
f.write(cnt) f.write(cnt)
f.write(b'\n#<==\n') f.write(to_bytes('\n#<==\n'))
finally: finally:
f.close() f.close()