On 8/7/20 4:17 PM, Flavio Leitner wrote:
> On Fri, Jun 19, 2020 at 03:53:51PM +0200, Timothy Redaelli wrote:
>> On Python3 buffering can only be disabled on files opened in binary mode.
>>
>> Signed-off-by: Timothy Redaelli <[email protected]>
>> ---
>> v2:
>> - Added missing Signed-off-by
>>
>> utilities/ovs-dpctl-top.in | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/utilities/ovs-dpctl-top.in b/utilities/ovs-dpctl-top.in
>> index fbe6e4f56..97dc12f27 100755
>> --- a/utilities/ovs-dpctl-top.in
>> +++ b/utilities/ovs-dpctl-top.in
>> @@ -1236,7 +1236,7 @@ def flows_script(args):
>>
>> if (args.flowFiles is None):
>> logging.info("reading flows from stdin")
>> - ihdl = os.fdopen(sys.stdin.fileno(), 'r', 0)
>> + ihdl = os.fdopen(sys.stdin.fileno(), 'rb', 0)
>
>
> Although this patch solves the issue, the binary seems to be not
> intended to use with text. The flows_read() will call readline()
> which deals with text (newlines, encoding/decoding, ...).
I agree that opening in binary is not a good thing to do.
IIUC, this code was intended to avoid buffering issues with python2
where it was possible to have block-buffering behavior even if
line-buffering is a default cause for text files.
For python3 we should not need any of these tricks.
>
> Perhaps we could stop using buffering?
> @@ -1234,7 +1236,7 @@ def flows_script(args):
>
> if (args.flowFiles is None):
> logging.info("reading flows from stdin")
> - ihdl = os.fdopen(sys.stdin.fileno(), 'r', 0)
> + ihdl = os.fdopen(sys.stdin.fileno(), 'r')
There is no point in re-opening stdin, we should be able to just
pass sys.stdin to flows_read() without any issues.
> try:
> flow_db = flows_read(ihdl, flow_db)
> finally:
>
>
> Thanks!
> fbl
>
>> try:
>> flow_db = flows_read(ihdl, flow_db)
>> finally:
>> --
>> 2.26.2
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev