Closed peace-maker closed 2 months ago
While discussing this on the CTF discord the wish for a configuration option to control the recvline behavior as well as printing of the new warning came up. Keeping it here for reference.
[PB] theKidOfArcrania: it might make sense to have some sort of configuration option for the user to explicitly state what behavior they want. that way there's a way to squelch the warning or this: https://xkcd.com/1172/ [RedRocket] Peace-Maker: Hm, some context.eof_isnewline defaulting to True? [PB] theKidOfArcrania_: so the idea im thinking is you have a tristate value either of a argument to recvline, or a context.throw_eof_on_incomplete_line where you have three settings (None where you implement default sane behavior but emit warning, False, if you want to explicitly state that you want new behavior, or True if you want old behavior and suppress the warning).
When there is still data available in the tube buffer when an EOFError occurs in
tube.recvline()
, return that data even though it doesn't contain a newline. The next timetube.recvline()
is called afterwards will raise EOFError normally.This behavior is in line with the GNU readline implementation and avoids loss of data. It allows
tube.stream()
to print everything that's received before the receiving end terminates.A new warning is logged when data is returned due to an EOF informing about the lack of the trailing newline character.
Fixes #2366