diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 573ca0f015..0a6500d98e 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -17,6 +17,7 @@ Redis 8.6 Fixed ~~~~~ * Fix ``TypeError`` when displaying help for actions whose parameters have no ``description`` key. #6375 +* Fix utf-8 encode before checking paramter max size #6352 Changed ~~~~~~~ diff --git a/contrib/runners/python_runner/python_runner/python_runner.py b/contrib/runners/python_runner/python_runner/python_runner.py index a8200e0bb3..9bba07985f 100644 --- a/contrib/runners/python_runner/python_runner/python_runner.py +++ b/contrib/runners/python_runner/python_runner/python_runner.py @@ -188,7 +188,10 @@ def run(self, action_parameters): # failure to fork the wrapper process when using large parameters. stdin = None stdin_params = None - if len(serialized_parameters) >= MAX_PARAM_LENGTH: + if ( + len(serialized_parameters.encode(sys.getdefaultencoding(), errors="ignore")) + >= MAX_PARAM_LENGTH + ): stdin = subprocess.PIPE LOG.debug("Parameters are too big...changing to stdin") stdin_params = '{"parameters": %s}\n' % (serialized_parameters) diff --git a/contrib/runners/python_runner/tests/unit/test_output_schema.py b/contrib/runners/python_runner/tests/unit/test_output_schema.py index c5fd0d00e2..fe09df162d 100644 --- a/contrib/runners/python_runner/tests/unit/test_output_schema.py +++ b/contrib/runners/python_runner/tests/unit/test_output_schema.py @@ -40,6 +40,7 @@ MOCK_SYS = mock.Mock() MOCK_SYS.argv = [] MOCK_SYS.executable = sys.executable +MOCK_SYS.getdefaultencoding.return_value = sys.getdefaultencoding() MOCK_EXECUTION = mock.Mock() MOCK_EXECUTION.id = "598dbf0c0640fd54bffc688b" diff --git a/contrib/runners/python_runner/tests/unit/test_pythonrunner.py b/contrib/runners/python_runner/tests/unit/test_pythonrunner.py index 22d9e14b36..f66d6f8f50 100644 --- a/contrib/runners/python_runner/tests/unit/test_pythonrunner.py +++ b/contrib/runners/python_runner/tests/unit/test_pythonrunner.py @@ -97,6 +97,7 @@ mock_sys = mock.Mock() mock_sys.argv = [] mock_sys.executable = sys.executable +mock_sys.getdefaultencoding.return_value = sys.getdefaultencoding() MOCK_EXECUTION = mock.Mock() MOCK_EXECUTION.id = "598dbf0c0640fd54bffc688b"