Yury Selivanov added the comment:
This issue is resolved in 3.7: https://bugs.python.org/issue32331
--
nosy: +yselivanov
resolution: -> out of date
stage: -> resolved
status: open -> closed
superseder: -> Fix socket.type on OSes with SOCK_NONBLOCK
type: -> behavior
Changes by Ethan Furman et...@stoneleaf.us:
--
nosy: -ethan.furman
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
___
___
Python-bugs-list
R. David Murray added the comment:
I added some review comments.
Something I don't understand: if settimeout sets NONBLOCK, and CLOEXEC is
always set now, why does s=socket.socket() yield something whose type is
SOCK_STREAM, while settimeout causes type to change? I don't understand the
R. David Murray added the comment:
The behavior of s.type has changed in 3.5: it now behaves like the proposed new
method behaves. Looking at the source I can't figure out why this is so. It
doesn't seem as though it should be, but this needs to be sorted out before we
can proceed.
R. David Murray added the comment:
Wait, I take it back. I must have run the test incorrectly.
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
___
Raúl Cumplido added the comment:
ping, any comment on the patch that was provided during the PyCon 2015 sprints?
--
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
___
Raúl Cumplido added the comment:
Added new patch as per review comments.
--
Added file: http://bugs.python.org/file39069/21327.2.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
___
Changes by Jean-Paul Calderone jean-p...@clusterhq.com:
--
nosy: -exarkun
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
___
___
Raúl Cumplido added the comment:
Forget my previous comment. Done with Linux and had the initial behavior again:
s = socket.socket()
s.type
SocketType.SOCK_STREAM: 1
s.settimeout(2)
s.type
2049
--
___
Python tracker rep...@bugs.python.org
Raúl Cumplido added the comment:
While reproducing it I've seen that this has been already solved:
sock = socket.socket(type=socket.SOCK_STREAM)
sock.type
SocketKind.SOCK_STREAM: 1
sock.settimeout(2)
sock.type
SocketKind.SOCK_STREAM: 1
But the next is still not correct:
sock =
Raúl Cumplido added the comment:
after conversation with @r.david.murray I understand that we only want to
return the type, not all the flags, so the function will return just the
socket.SOCK_STREAM or socket.SOCK_DGRAM ...
--
___
Python tracker
Raúl Cumplido added the comment:
@haypo Would you expect the new function to return a tuple?
i.e:
socket.get_socket_type(sock)
(socket.SOCK_STREAM, socket.SOCK_NONBLOCK)
socket.get_socket_type(sock2)
(socket.SOCK_STREAM,)
--
nosy: +raulcd
___
Raúl Cumplido added the comment:
Added docs and test in the patch.
--
keywords: +patch
Added file: http://bugs.python.org/file39009/issue21327.patch
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
Raúl Cumplido added the comment:
Added patch that solves issue, but I am not sure this is what you expect. If
you think this is the expected behavior I will add docs and tests:
sock = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK)
sock.type
2049
socket.get_socket_type(sock)
R. David Murray added the comment:
If we were designing from scratch, that would be true. But we are stuck with
the behavior that we have, and cannot change it because we need to preserve
backward compatibility. This is why we need to make it a new method.
--
Nina Zakharenko added the comment:
Maybe it would be better if the type property on socket had this behavior,
rather than creating a new method.
--
nosy: +nnja
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
Changes by Mark Lawrence breamore...@yahoo.co.uk:
--
nosy: -BreamoreBoy
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
___
___
New submission from Giampaolo Rodola':
s = socket.socket()
s.type
SocketType.SOCK_STREAM: 1
s.settimeout(2)
s.type
2049
I can reproduce this with Python 3.5, 3.4 and 3.3.
2.7 is not affected.
--
messages: 216999
nosy: giampaolo.rodola
priority: normal
severity: normal
status:
Giampaolo Rodola' added the comment:
It seems this was introduced in issue 7523 / revision 12442ac3f7dd.
--
nosy: +pitrou
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
___
Changes by Giampaolo Rodola' g.rod...@gmail.com:
--
Removed message: http://bugs.python.org/msg217001
___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue21327
___
Giampaolo Rodola' added the comment:
Generally speaking I think it's fine to have this behavior only if the socket
object is instantiated like this:
s = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK)
s.type
2049
...but when it comes to using setblocking() I would not expect
Giampaolo Rodola' added the comment:
Generally speaking I think it's fine to have this behavior only if the socket
object is instantiated like this:
s = socket.socket(type=socket.SOCK_STREAM | socket.SOCK_NONBLOCK)
s.type
2049
...but when it comes to using settimeout() I would not expect
Antoine Pitrou added the comment:
I think distinguishing between the two situations would make the code yet more
complicated (and fragile). It's a bit unfortunate that the `type` attribute has
become a kitchen sink for disparate pieces of configuration.
The fact that you are the first to
STINNER Victor added the comment:
I would prefer to add something to get the type without SOCK_NONBLOCK nor
SOCK_CLOEXEC. So new feature can only be added to Python 3.5. For older
Python versions, you can to filter manually, which is difficult because you
have yo check if SOCK_NONBLOCK and/or
24 matches
Mail list logo