[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-21 Thread Xavier de Gaye
Xavier de Gaye added the comment: In makesockaddr(), the current implementation does not do any decoding of AF_UNIX addresses in the abstract namespace in the struct sockaddr_un to bytes direction, i.e. system to python direction, but does encode a string or bytes object to struct sockaddr_un

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread Xavier de Gaye
Xavier de Gaye added the comment: This patch corrects the non-ascii quote character in the Misc/NEWS diff. -- Added file: http://bugs.python.org/file42543/unix_abstract_namespace_3.patch ___ Python tracker

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread Xavier de Gaye
Xavier de Gaye added the comment: Here is the patch. As a reference, issue #8373 with changeset 1f23bb74f4bc changed the AF_UNIX socket addresses encoding from UTF-8 to the file system encoding and the 'surrogateescape' error handler (PEP 383). -- Added file:

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread Xavier de Gaye
Xavier de Gaye added the comment: I will give it a try. -- ___ Python tracker ___ ___ Python-bugs-list

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread STINNER Victor
STINNER Victor added the comment: > Then it seems that makesockaddr() should be fixed instead of the logging > handler. Yes. That's why I didn't understand the issue at the beginning :-) Would you like to work on fixing the _socket module? It may be worth to keep your syslog unit test. It's

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread Xavier de Gaye
Xavier de Gaye added the comment: Then it seems that makesockaddr() should be fixed instead of the logging handler. -- ___ Python tracker ___

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread Xavier de Gaye
Xavier de Gaye added the comment: makesockaddr() in socketmodule.c calls PyBytes_FromStringAndSize() when the first byte is a null byte. My opinion is not worth much in this matter :). The socket documentation does say that AF_UNIX addresses are "represented as a string, using the file system

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread STINNER Victor
STINNER Victor added the comment: > However it is possible that PyUnicode_DecodeFSDefault() fails for some file system encodings when the encoded address contains null bytes ? No, it's not possible. Undecode bytes are escaped as surrogate characters using the surrogateescape error handler. See

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread STINNER Victor
STINNER Victor added the comment: Xavier de Gaye added the comment: > when self.server_address is a string and contains a null byte, then > getsockname() returns a bytes object. Ah? It sounds strange to me that the type of getsockname() depends on the NULL byte. I would also expect a Unicode

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread Xavier de Gaye
Xavier de Gaye added the comment: The SysLogHandlerTest class instantiates a 'server_class' that eventually calls the server_bind() method of the TCPServer class of the socketserver module. This server_bind() method executes the statements: self.socket.bind(self.server_address)

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread STINNER Victor
STINNER Victor added the comment: Ok. And what is the link between abstract namespace and the fact that the syslog handler gets bytes? Is it tested by your change? -- ___ Python tracker

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-20 Thread Xavier de Gaye
Xavier de Gaye added the comment: A unix abstract socket address is defined here: http://man7.org/linux/man-pages/man7/unix.7.html as: "Traditionally, UNIX domain sockets can be either unnamed, or bound to a filesystem pathname (marked as being of type socket). Linux also supports an

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-19 Thread STINNER Victor
STINNER Victor added the comment: The following change looks good to me: -if isinstance(address, str): +if isinstance(address, (str, bytes)): self.unixsocket = True self._connect_unixsocket(address) But I don't understand the testcase. Is an address

[issue26803] syslog logging handler fails with address in unix abstract namespace

2016-04-19 Thread Xavier de Gaye
New submission from Xavier de Gaye: The traceback: Traceback (most recent call last): File "Lib/logging/handlers.py", line 917, in emit self.socket.sendto(msg, self.address) TypeError: getsockaddrarg: AF_INET address must be tuple, not bytes The attached patch reproduces