Skip to content

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

Merged
merged 1 commit into from
Mar 17, 2017
Merged

bpo-29808: SyslogHandler: fix initial connect to syslog #663

merged 1 commit into from
Mar 17, 2017

Conversation

socketpair
Copy link
Contributor

No description provided.

@the-knights-who-say-ni
Copy link

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:

  1. If you don't have an account on b.p.o, please create one
  2. Make sure your GitHub username is listed in "Your Details" at b.p.o
  3. If you have not already done so, please sign the PSF contributor agreement. The "bugs.python.org username " requested by the form is the "Login name" field under "Your Details".
  4. If you just signed the CLA, please wait at least one US business day and then check "Your Details" on bugs.python.org to see if your account has been marked as having signed the CLA (the delay is due to a person having to manually check your signed CLA)
  5. Reply here saying you have completed the above steps

Thanks again to your contribution and we look forward to looking at it!

@mention-bot
Copy link

@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.

@socketpair
Copy link
Contributor Author

@the-knights-who-say-ni I have signed what you wanted me to sign.

if socktype == socket.SOCK_STREAM:
self.socket.connect(address)
self.socktype = socktype
self.socket.connect(address)
Copy link
Contributor Author

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.

self._connect_unixsocket(address)
self._unix_socktype = socktype
try:
self._connect_unixsocket()
Copy link
Contributor Author

@socketpair socketpair Mar 14, 2017

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.

@ned-deily
Copy link
Member

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 socketpair changed the title SyslogHandler: fix initial connect to syslog + code simplification. SyslogHandler: fix initial connect to syslog + code simplification (bpo-29808) Mar 14, 2017
@Mariatta Mariatta changed the title SyslogHandler: fix initial connect to syslog + code simplification (bpo-29808) bpo-29808: SyslogHandler: fix initial connect to syslog + code simplification Mar 14, 2017
@Mariatta
Copy link
Member

@socketpair Did you add your GitHub username to the account in b.p.o?

@socketpair
Copy link
Contributor Author

@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.

@@ -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.
Copy link
Member

@vsajip vsajip Mar 14, 2017

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.

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__()
Copy link
Member

@vsajip vsajip Mar 14, 2017

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.

Copy link
Contributor Author

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?

@Mariatta
Copy link
Member

@socketpair in your account at https://bugs.python.org, you'll need to put your GitHub username (socketpair) into your user details page.
Please read the message from the-knights-who-say-ni above, and click on "Your Details" at b.p.o in number 2, to see where the username should be entered.

Thanks :)

@socketpair
Copy link
Contributor Author

socketpair commented Mar 14, 2017

@Mariatta

  1. I set socketpair as github username
  2. I changed bugs.python.org's username from mmarkk to socketpair
  3. Please note, I signed CLA as username socketpair

@socketpair
Copy link
Contributor Author

ahh.. b.p.o is "bugs.python.org". google gets https://en.wikipedia.org/wiki/Business_process_outsourcing

@socketpair
Copy link
Contributor Author

socketpair commented Mar 14, 2017

@vsajip
@prophile
@Mariatta
What happens with code coverage check? I did not touch files that this tool mentions.

@socketpair socketpair changed the title bpo-29808: SyslogHandler: fix initial connect to syslog + code simplification bpo-29808: SyslogHandler: fix initial connect to syslog Mar 14, 2017
try:
self._connect_unixsocket(address)
except OSError:
pass

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?

@@ -815,7 +815,10 @@ def __init__(self, address=('localhost', SYSLOG_UDP_PORT),

if isinstance(address, str):
self.unixsocket = True
self._connect_unixsocket(address)
try:

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 :)

Copy link
Contributor Author

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 ?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No.

@socketpair
Copy link
Contributor Author

socketpair commented Mar 17, 2017

@vsajip
@prophile
@Mariatta

I have fixed everything you asked to fix. Ping.

@vsajip
Copy link
Member

vsajip commented Mar 17, 2017

Quite busy at the moment. Will get to it when I have time. Please be patient.

@vsajip vsajip merged commit 1b038e0 into python:master Mar 17, 2017
@Mariatta
Copy link
Member

Does this need backport to 3.5 and 3.6? The ticket says this applies to those versions too.

@socketpair
Copy link
Contributor Author

Actually this bug happens with Python 3.5.2. So, yes, it will be nice if you apply this patch to these Python versions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants