This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: syslog: Default "ident" in syslog.openlog() shouldn't contain slash
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: brandtbucher, miss-islington, vaclavbartos
Priority: normal Keywords:

Created on 2019-10-03 11:38 by vaclavbartos, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 16557 merged vaclavbartos, 2019-10-03 11:38
Messages (2)
msg353839 - (view) Author: Vaclav Bartos (vaclavbartos) * Date: 2019-10-03 11:38
When `syslog.openlog()` is called without parameters (or `syslog.syslog()` is called directly), the `ident` parameter should be set to "sys.argv[0] with leading path components stripped" (citation from docs).

I suppose this means that when sys.argv[0] is "/some/path/to/script", the ident should be set to "script" (this is the behavior in Python 2.7)

However, in Python 3.x, it gets set to "/script", i.e. the last slash is included in the string. I suppose this is not intended, it is just a "one-off" error in parsing the string.

The fix is trivial, see the linked GitHub PR.


To reproduce the bug:

$ python3
>>> import sys
>>> import syslog
>>> sys.argv[0] = "/some/path/to/script"
>>> syslog.syslog("TEST MESSAGE")
>>> 
$ tail -n 1 /var/log/messages
Oct  3 11:11:46 localhost /script: TEST MESSAGE
msg359984 - (view) Author: miss-islington (miss-islington) Date: 2020-01-14 17:57
New changeset f04750bb7af45cb6efab8d92d1ff063f0bf2833d by Miss Islington (bot) (Václav Bartoš) in branch 'master':
bpo-38361: syslog: fixed making default "ident" from sys.argv[0] (GH-16557)
https://github.com/python/cpython/commit/f04750bb7af45cb6efab8d92d1ff063f0bf2833d
History
Date User Action Args
2022-04-11 14:59:21adminsetgithub: 82542
2021-07-09 18:54:59ned.deilylinkissue27875 superseder
2020-01-15 17:46:37brandtbuchersetstatus: open -> closed

nosy: + brandtbucher
versions: - Python 3.5, Python 3.6, Python 3.7, Python 3.8
components: + Library (Lib), - Extension Modules
resolution: fixed
stage: resolved
2020-01-14 17:57:08miss-islingtonsetnosy: + miss-islington
messages: + msg359984
2019-10-03 11:38:58vaclavbartoscreate