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

Lines changed: 4 additions & 4 deletions
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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy