Commit 20adbdb6 authored by Laurence Rowe's avatar Laurence Rowe Committed by Julien Muchembled

Avoid DeprecationWarning: 'U' mode is deprecated

Python 3.7 began warning about open's 'U' mode. Universal newline mode (newline=None) is default in Python 3 so avoid specifying it on Python 3.

(cherry picked from commit 978a6af9)
parent e3f11c25
...@@ -1586,6 +1586,11 @@ def _pyscript(path, dest, rsetup, initialization=''): ...@@ -1586,6 +1586,11 @@ def _pyscript(path, dest, rsetup, initialization=''):
generated.append(dest) generated.append(dest)
return generated return generated
if sys.version_info[0] < 3:
universal_newline_option = ", 'U'"
else:
universal_newline_option = ''
py_script_template = script_header + '''\ py_script_template = script_header + '''\
%(relative_paths_setup)s %(relative_paths_setup)s
...@@ -1606,19 +1611,19 @@ if len(sys.argv) > 1: ...@@ -1606,19 +1611,19 @@ if len(sys.argv) > 1:
sys.argv[1:] = _args sys.argv[1:] = _args
_args = [] _args = []
__import__("runpy").run_module( __import__("runpy").run_module(
_val, {}, "__main__", alter_sys=True) _val, {{}}, "__main__", alter_sys=True)
if _args: if _args:
sys.argv[:] = _args sys.argv[:] = _args
__file__ = _args[0] __file__ = _args[0]
del _options, _args del _options, _args
with open(__file__, 'U') as __file__f: with open(__file__{}) as __file__f:
exec(compile(__file__f.read(), __file__, "exec")) exec(compile(__file__f.read(), __file__, "exec"))
if _interactive: if _interactive:
del _interactive del _interactive
__import__("code").interact(banner="", local=globals()) __import__("code").interact(banner="", local=globals())
''' '''.format(universal_newline_option)
runsetup_template = """ runsetup_template = """
import sys import sys
...@@ -1637,9 +1642,9 @@ __file__ = %(__file__)r ...@@ -1637,9 +1642,9 @@ __file__ = %(__file__)r
os.chdir(%(setupdir)r) os.chdir(%(setupdir)r)
sys.argv[0] = %(setup)r sys.argv[0] = %(setup)r
with open(%(setup)r, 'U') as f: with open(%(setup)r{}) as f:
exec(compile(f.read(), %(setup)r, 'exec')) exec(compile(f.read(), %(setup)r, 'exec'))
""" """.format(universal_newline_option)
class VersionConflict(zc.buildout.UserError): class VersionConflict(zc.buildout.UserError):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment