syslog: Handle ValueError raised while sending logs to syslog (#82225)

* ValueError exception is raised when Null Character is sent
  to syslog.syslog with Python 3.12.
* Handle this error gracefully instead of stacktrace

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
pull/82218/head
Abhijeet Kasurde 6 months ago committed by GitHub
parent 1a759659fe
commit 8fd1aa0d2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,3 @@
---
bugfixes:
- syslog - Handle ValueError exception raised when sending Null Characters to syslog with Python 3.12.

@ -1269,7 +1269,7 @@ class AnsibleModule(object):
facility = getattr(syslog, self._syslog_facility, syslog.LOG_USER)
syslog.openlog(str(module), 0, facility)
syslog.syslog(syslog.LOG_INFO, msg)
except TypeError as e:
except (TypeError, ValueError) as e:
self.fail_json(
msg='Failed to log to syslog (%s). To proceed anyway, '
'disable syslog logging by setting no_target_syslog '

Loading…
Cancel
Save