Commits

Philip Jenvey  committed 024efa6

fix test_syslog

  • Participants
  • Parent commits 9b0d6cf
  • Branches py3k

Comments (0)

Files changed (1)

File lib_pypy/syslog.py

     global _S_ident_o, _S_log_open
     if ident is None:
         ident = _get_argv()
+    if ident is not None:
+        if not isinstance(ident, str):
+            msg = "openlog() argument 1 must be a str, not {!r}"
+            raise TypeError(msg.format(type(ident).__name__))
+        ident = ident.encode(sys.getdefaultencoding())
     _S_ident_o = c_char_p(ident)    # keepalive
     _openlog(_S_ident_o, logoption, facility)
     _S_log_open = True
     # if log is not opened, open it now
     if not _S_log_open:
         openlog()
-    _syslog(priority, "%s", message)
+    if not isinstance(message, str):
+        raise TypeError("syslog() message must be a str, not {!r}".format(
+                type(message).__name__))
+    message = message.encode(sys.getdefaultencoding())
+    _syslog(priority, b"%s", message)
 
 @builtinify
 def closelog():