syslog.syslog('msg') logs message with ident "python". #52698
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee = None closed_at = <Date 2010-04-23.08:35:59.026> created_at = <Date 2010-04-19.05:26:38.039> labels = ['easy', 'type-bug', 'library'] title = 'syslog.syslog(\'msg\') logs message with ident "python".' updated_at = <Date 2010-04-23.18:45:59.727> user = 'https://bugs.python.org/jafo'
activity = <Date 2010-04-23.18:45:59.727> actor = 'r.david.murray' assignee = 'none' closed = True closed_date = <Date 2010-04-23.08:35:59.026> closer = 'jafo' components = ['Library (Lib)'] creation = <Date 2010-04-19.05:26:38.039> creator = 'jafo' dependencies =  files = ['16982', '16983', '17004', '17018'] hgrepos =  issue_num = 8451 keywords = ['patch', 'easy', 'needs review'] message_count = 12.0 messages = ['103555', '103573', '103668', '103706', '103724', '103798', '103822', '103856', '103994', '103995', '104036', '104037'] nosy_count = 4.0 nosy_names = ['jafo', 'pitrou', 'eric.smith', 'r.david.murray'] pr_nums =  priority = 'normal' resolution = 'accepted' stage = 'patch review' status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue8451' versions = ['Python 2.7', 'Python 3.2']
The text was updated successfully, but these errors were encountered:
As discussed in this thread:
The syslog module is using the C argv as the program name, not the python sys.argv. So, in most cases this means that unless you explicitly set a ident, you get "python" as the ident. Not entirely helpful.
"make test" with this succeeds.
I think this is ready to go into the trunk, but would like a review. I'll check with the release maintainer about if this is appropriate for 2.7b.
Some notes about the patch:
Antoine: I believe I have everything you mentioned addressed with the new patch. That was an awesome review, thank you so much.
The only things I didn't do were parts of the last two items you bring up:
If PyTuple_New(0) fails, bail out.
syslog(3) can continue even if the openlog() fails. It won't have the expected "ident" string, but it *WILL* log.
I believe this is the desired behavior.
NOTE: I puled the code out that does all the sys.argv handling, which I think made that whole section of code much easier to read, particularly with the new changes. The down side is that the code to be reviewed is quite different now.
I also found a leak in the call to syslog_openlog() where I wasn't DECREFing the return.
Can you please review these changes?
A couple of points:
Didn't we decide that instead of using:
You should add some comments to syslog_get_argv explaining why you're handling errors the way you are. That is, why you're swallowing exceptions and continuing. Similarly with the call to PyTuple_New(0).
I also think it would be clearer if using the string "python" were inside syslog_get_argv, but that's a style thing.
Should the fallback be "python", or derived from C's argv?
Is it possible that sys.argv would be unicode?
Is SEP correct, or should it really be using os.path.sep and/or os.path.altsep? This is probably a nit, but I could see it being a problem under cygwin (which I haven't tested yet).
Your "if" statements shouldn't all be on one line. The single-line style with braces isn't used anywhere else in this module, and it's not in the Python code base that I could see (except for the occasional macro).
The example code has some extra spaces around the equal signs. It should be:
Thanks for doing this!
Ok, so I left the argument style in the docs as it was.
*** NOTE ***: Sean: Change this for the 3 trunk commit.
Setting the "python" string is outside of the argv function because we want to use "python" on any of the many places where the return is done.
As far as using the C argv, I decided to specifically use "python" as a fallback. We could easily just let openlog pick it, which is what the old behavior was, but in that case it's dependent on the implementation.
I can't answer about sys.argv being unicode.
From my looking at the code, SEP will vary depending on the platform, and is just what os.path.sep is -- I was going to use os.path.sep, but found it just returns SEP.
Thanks for the great review, I've attached a new version.
One argument in favor of letting openlog pick it (assuming it uses argv) is that for a while at least we will have many systems running both python2 and python3, and it might be useful to have that distinction show up in the log if the fallback is used. I'm not sure this is a strong argument :)