-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
bpo-29808: SyslogHandler: fix initial connect to syslog #663
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept your contribution by verifying you have signed the PSF contributor agreement (CLA). Unfortunately we couldn't find an account corresponding to your GitHub username on bugs.python.org (b.p.o) to verify you have signed the CLA. This is necessary for legal reasons before we can look at your contribution. Please follow these steps to help rectify the issue:
Thanks again to your contribution and we look forward to looking at it! |
@socketpair, thanks for your PR! By analyzing the history of the files in this pull request, we identified @vsajip, @benjaminp, @nnorwitz, @Yhg1s and @birkenfeld to be potential reviewers. |
@the-knights-who-say-ni I have signed what you wanted me to sign. |
Lib/logging/handlers.py
Outdated
if socktype == socket.SOCK_STREAM: | ||
self.socket.connect(address) | ||
self.socktype = socktype | ||
self.socket.connect(address) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This actually works for UDP sockets too. This simplify send()
later since we should not specify address every time.
Lib/logging/handlers.py
Outdated
self._connect_unixsocket(address) | ||
self._unix_socktype = socktype | ||
try: | ||
self._connect_unixsocket() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Syslog server may not work at the time of the constructor call.
Thank you for your contribution but please first open an issue for the problem on https://bugs.python.org and then add the issue number (bpo-nnnnnn) to the title of this pull request. |
@socketpair Did you add your GitHub username to the account in b.p.o? |
@Mariatta I don't know what is b.p.o. I have an account at bugs.python.org. And also have just signed something @the-knights-who-say-ni said to sign. |
Lib/logging/handlers.py
Outdated
@@ -800,52 +800,54 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT), | |||
Initialize a handler. | |||
|
|||
If address is specified as a string, a UNIX socket is used. To log to a | |||
local syslogd, "SysLogHandler(address="/dev/log")" can be used. | |||
local syslogd, `SysLogHandler(address="/dev/log")` can be used. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make random stylistic changes.
Lib/logging/handlers.py
Outdated
If facility is not specified, LOG_USER is used. If socktype is | ||
specified as socket.SOCK_DGRAM or socket.SOCK_STREAM, that specific | ||
socket type will be used. For Unix sockets, you can also specify a | ||
socktype of None, in which case socket.SOCK_DGRAM will be used, falling | ||
back to socket.SOCK_STREAM. | ||
""" | ||
logging.Handler.__init__(self) | ||
super().__init__() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make changes to "tidy up the code base". Address only specific things which cause the issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, should I make another PR, that fixes such things?
@socketpair in your account at https://bugs.python.org, you'll need to put your GitHub username (socketpair) into your user details page. Thanks :) |
|
ahh.. b.p.o is "bugs.python.org". google gets https://en.wikipedia.org/wiki/Business_process_outsourcing |
Lib/logging/handlers.py
Outdated
try: | ||
self._connect_unixsocket(address) | ||
except OSError: | ||
pass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is pretty surprising to read—it makes more sense with the comment from the associated bug report.
Would you be averse to adding a comment in here to explain why it's safe to suppress this error?
Lib/logging/handlers.py
Outdated
@@ -815,7 +815,10 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT), | |||
|
|||
if isinstance(address, str): | |||
self.unixsocket = True | |||
self._connect_unixsocket(address) | |||
try: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's contextlib.suppress
which you may enjoy if you like context managers :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like. Is it required here in order patch to be accepted ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No.
Quite busy at the moment. Will get to it when I have time. Please be patient. |
Does this need backport to 3.5 and 3.6? The ticket says this applies to those versions too. |
Actually this bug happens with Python 3.5.2. So, yes, it will be nice if you apply this patch to these Python versions. |
No description provided.