diff --git a/readthedocs/doc_builder/environments.py b/readthedocs/doc_builder/environments.py index f0118164c2f..d142f897a7d 100644 --- a/readthedocs/doc_builder/environments.py +++ b/readthedocs/doc_builder/environments.py @@ -194,7 +194,7 @@ def sanitize_output(self, output): # https://code.djangoproject.com/ticket/28201 sanitized = sanitized.replace('\x00', '') except (TypeError, AttributeError): - sanitized = None + sanitized = "" # Chunk the output data to be less than ``DATA_UPLOAD_MAX_MEMORY_SIZE`` output_length = len(output) if output else 0 @@ -315,10 +315,8 @@ def run(self): cmd_stdout, cmd_stderr = out else: cmd_stdout = out - # Docker returns None when there's no stderr/stdout - # so we need to convert that to a string. - self.output = self.sanitize_output(cmd_stdout or "") - self.error = self.sanitize_output(cmd_stderr or "") + self.output = self.sanitize_output(cmd_stdout) + self.error = self.sanitize_output(cmd_stderr) cmd_ret = client.exec_inspect(exec_id=exec_cmd['Id']) self.exit_code = cmd_ret['ExitCode'] diff --git a/readthedocs/rtd_tests/tests/test_doc_building.py b/readthedocs/rtd_tests/tests/test_doc_building.py index 0004d5bc0ea..f1b2d570bad 100644 --- a/readthedocs/rtd_tests/tests/test_doc_building.py +++ b/readthedocs/rtd_tests/tests/test_doc_building.py @@ -255,7 +255,7 @@ def test_error_output(self): cmd = BuildCommand(['/bin/bash', '-c', 'echo -n FOOBAR 1>&2']) cmd.run() self.assertEqual(cmd.output, 'FOOBAR') - self.assertIsNone(cmd.error) + self.assertEqual(cmd.error, "") def test_sanitize_output(self): cmd = BuildCommand(['/bin/bash', '-c', 'echo'])