trio icon indicating copy to clipboard operation
trio copied to clipboard

Make send_eof a standard part of the Stream interface

Open njsmith opened this issue 4 years ago • 6 comments

The only reason HalfCloseableStream existed as a separate interface was because SSLStream couldn't support send_eof. But TLS 1.3 made it possible to support send_eof! So now the static split doesn't make sense. Instead, we move send_eof into the Stream interface (though it can still fail at runtime with NotImplementedError), and get rid of HalfCloseableStream. (Fixes: gh-823.)

This also includes a fix for StapledStream.send_eof, that was revealed by the new enhanced check_two_way_stream. (Fixes: gh-1180).

njsmith avatar Aug 09 '19 02:08 njsmith

This looks great overall. One yapf nit to fix, and one backwards compatibility concern: adding send_eof() as an abstract method of Stream will break any user-provided Stream implementation that doesn't define it. Another approach with better properties there:

  • make it non-abstract and have the default implementation raise NotImplementedError
  • plus use __init_subclass__ to raise a TrioDeprecationWarning when defining a subclass that doesn't override it
  • could use __new__ to warn on construction of such subclasses on 3.5 which doesn't call __init_subclass__, or could decide not to worry about that

I'm also OK leaving this incompatibility in, but it should probably be called out more explicitly in the newsfragments in that case.

oremanj avatar Aug 09 '19 03:08 oremanj

@oremanj okay, fine, you're right :-)

I already figured out how to do this kind of deprecation properly while looking at #636, so might as well do it here too...

njsmith avatar Aug 09 '19 03:08 njsmith

Codecov Report

Merging #1181 into master will increase coverage by <.01%. The diff coverage is 100%.

@@            Coverage Diff             @@
##           master    #1181      +/-   ##
==========================================
+ Coverage   99.57%   99.57%   +<.01%     
==========================================
  Files         106      106              
  Lines       12836    12928      +92     
  Branches      985      996      +11     
==========================================
+ Hits        12781    12873      +92     
  Misses         35       35              
  Partials       20       20
Impacted Files Coverage Δ
trio/abc.py 100% <ø> (ø) :arrow_up:
trio/tests/test_abc.py 100% <100%> (ø) :arrow_up:
trio/_ssl.py 100% <100%> (ø) :arrow_up:
trio/testing/_check_streams.py 99.38% <100%> (+0.04%) :arrow_up:
trio/_highlevel_generic.py 100% <100%> (ø) :arrow_up:
trio/_abc.py 100% <100%> (ø) :arrow_up:
trio/tests/test_highlevel_socket.py 100% <100%> (ø) :arrow_up:
trio/tests/test_ssl.py 100% <100%> (ø) :arrow_up:
trio/_highlevel_socket.py 100% <100%> (ø) :arrow_up:
trio/_unix_pipes.py 100% <100%> (ø) :arrow_up:
... and 2 more

codecov[bot] avatar Aug 09 '19 03:08 codecov[bot]

Still need to fix up some coverage.

njsmith avatar Aug 09 '19 04:08 njsmith

OK, I think everything's been addressed now.

njsmith avatar Aug 09 '19 05:08 njsmith

Sorry for dropping this. I took another look just now and I'm happy with it, except that the version numbers of the deprecations need to be increased from 0.13.0 to 0.15.0.

oremanj avatar May 09 '20 07:05 oremanj