From 623a988e892ac22c84a26335829f0b6aa44c7d25 Mon Sep 17 00:00:00 2001 From: Pravin Date: Sun, 17 Feb 2019 14:55:08 +1100 Subject: [PATCH 1/2] Added warning for arguments containing carriage returns. This happens if a shell script was written in Windows but executed in Linux, as may be the case with bash for Windows. --- pythonforandroid/toolchain.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index 153bba1523..ad8e79c2c3 100644 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -229,6 +229,7 @@ class ToolchainCL(object): def __init__(self): argv = sys.argv + self.warn_on_carriage_return_args(argv) # Buildozer used to pass these arguments in a now-invalid order # If that happens, apply this fix # This fix will be removed once a fixed buildozer is released @@ -575,6 +576,12 @@ def add_parser(subparsers, *args, **kwargs): # Each subparser corresponds to a method getattr(self, args.subparser_name.replace('-', '_'))(args) + def warn_on_carriage_return_args(self, args): + for check_arg in args: + if '\r' in check_arg: + warning("Argument '" + str(check_arg.replace('\r', '')) + "' contains a carriage return (\\r).") + warning("Invoking this program via scripts which use CRLF instead of LF line endings will have undefined behaviour.") + def warn_on_deprecated_args(self, args): """ Print warning messages for any deprecated arguments that were passed. From 6d93af114d12fa9da4a2d5fdd46646f5f675f47a Mon Sep 17 00:00:00 2001 From: Pravin Date: Mon, 18 Feb 2019 18:48:58 +1100 Subject: [PATCH 2/2] Changed string concat to format(). Static method. --- pythonforandroid/toolchain.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pythonforandroid/toolchain.py b/pythonforandroid/toolchain.py index ad8e79c2c3..99680d83de 100644 --- a/pythonforandroid/toolchain.py +++ b/pythonforandroid/toolchain.py @@ -576,10 +576,11 @@ def add_parser(subparsers, *args, **kwargs): # Each subparser corresponds to a method getattr(self, args.subparser_name.replace('-', '_'))(args) - def warn_on_carriage_return_args(self, args): + @staticmethod + def warn_on_carriage_return_args(args): for check_arg in args: if '\r' in check_arg: - warning("Argument '" + str(check_arg.replace('\r', '')) + "' contains a carriage return (\\r).") + warning("Argument '{}' contains a carriage return (\\r).".format(str(check_arg.replace('\r', '')))) warning("Invoking this program via scripts which use CRLF instead of LF line endings will have undefined behaviour.") def warn_on_deprecated_args(self, args):