[issue40060] socket.TCP_NOTSENT_LOWAT is missing in official macOS builds

Dima Tisnek report at bugs.python.org
Tue Apr 7 04:41:21 EDT 2020


Dima Tisnek <dimaqq at gmail.com> added the comment:

Wow, very curious.

Yes, it's very much like `socket.TCP_KEEPCNT` in that respect, though, admittedly I don't have a very old Mac to test this right now. I think there were VMs for that maybe? 🤔



I wonder, what failure would be best for a naive code below, a NameError or OSError(errno=42)?

sock.setsockopt(socket.SOL_TCP, socket.TCP_NOTSENT_LOWAT, 42)

I guess the question is, at what level should the users catch exceptions...
After all, we don't delete this constant on Linux, and surely someone somewhere runs a very old kernel...



Oddly according to https://github.com/search?l=Python&q=%22socket.TCP_NOTSENT_LOWAT%22&type=Code none (in the OSS community) appears to be using this feature yet?

The search without `socket.` prefix yields a bunch of vendored mypy pyi's, but no actual code either.

And some even work around the constant being optional: https://github.com/python-trio/trio/blob/5b91edb2a860d024ab057e2be55fb34f311bf8ed/trio/socket.py#L170-L178



So, would this be a "not a regression" if none appears to use this constant yet?

Or do we take "don't break existing code" so seriously, that in this case too, we ought to assume that there's someone out there who has private code like below which we must not break?:

if code := getattr(socket, "TCP_NOTSENT_LOWAT", None):
    sock.setsockopt(socket.SOL_TCP, code, 42)



P.S.
If someone wants to take https://github.com/python/cpython/pull/19402 forward, by all means :)
Or I can try to hack up delete-at-runtime...

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue40060>
_______________________________________


More information about the Python-bugs-list mailing list