Skip to content

Commit f3aea4b

Browse files
committed
feat: avoid to fail on DecodeErrors when logging
1 parent 0998b8e commit f3aea4b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

slapd/__init__.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ def _test_config(self):
342342
]
343343
p = subprocess.run(popen_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
344344
if p.returncode != 0:
345-
self.logger.error(p.stdout.decode("utf-8"))
345+
self.logger.error(p.stdout.decode("utf-8", errors="replace"))
346346
raise RuntimeError("configuration test failed")
347347
self.logger.info("config ok: %s", self._slapd_conf)
348348

@@ -479,14 +479,14 @@ def _cli_popen(
479479
self.logger.debug("Run command: %r", " ".join(args))
480480
proc = subprocess.run(args, input=stdin_data, capture_output=True)
481481
self.logger.debug(
482-
"stdin_data=%s", stdin_data.decode("utf-8") if stdin_data else stdin_data
482+
"stdin_data=%s", stdin_data.decode("utf-8", errors="replace") if stdin_data else stdin_data
483483
)
484484

485485
if proc.stdout is not None:
486-
self.logger.debug("stdout=%s", proc.stdout.decode("utf-8"))
486+
self.logger.debug("stdout=%s", proc.stdout.decode("utf-8", errors="replace"))
487487

488488
if proc.stderr is not None:
489-
self.logger.debug("stderr=%s", proc.stderr.decode("utf-8"))
489+
self.logger.debug("stderr=%s", proc.stderr.decode("utf-8", errors="replace"))
490490

491491
if proc.returncode not in expected:
492492
raise RuntimeError(

0 commit comments

Comments
 (0)