On 4/10/20 12:03 AM, William Tu wrote: > On Wed, Mar 25, 2020 at 05:33:51PM -0700, William Tu wrote: >> On Thu, Mar 19, 2020 at 12:20:19PM -0700, William Tu wrote: >>> On Thu, Mar 19, 2020 at 12:05 PM Timothy Redaelli <[email protected]> >>> wrote: >>>> >>>> Currently ovs-bugtool tool doesn't start on Python 3. >>>> This commit fixes ovs-bugtool to make it works on Python 3. >>>> >>>> Replaced StringIO.StringIO with io.BytesIO since the script is >>>> processing binary data. >>>> >>>> Reported-at: https://bugzilla.redhat.com/1809241 >>>> Reported-by: Flavio Leitner <[email protected]> >>>> Signed-off-by: Timothy Redaelli <[email protected]> >>>> --- >>>> Changes since v1: >>>> * Converted StringIO to BytesIO >>>> * Fix some other string/bytes conversion >>>> --- >>> >>> Thanks for sending out v2. Hit an error below: >>> ~/ovs# python3 >>> Python 3.5.2 (default, Oct 8 2019, 13:06:37) >>> >>> ~/ovs# ./utilities/bugtool/ovs-bugtool -y -s --output=tar.gz >>> --outfile=/tmp/t.tgz >>> Traceback (most recent call last): >>> File "./utilities/bugtool/ovs-bugtool", line 1405, in <module> >>> sys.exit(main()) >>> File "./utilities/bugtool/ovs-bugtool", line 717, in main >>> collect_data() >>> File "./utilities/bugtool/ovs-bugtool", line 388, in collect_data >>> v['output'] = BytesIOmtime(s) >>> File "./utilities/bugtool/ovs-bugtool", line 1395, in __init__ >>> BytesIO.__init__(self, buf) >>> TypeError: a bytes-like object is required, not 'str' >>> >>> I think sometimes 's' is bytes type, sometimes 's' is a str type... >>> William >> >> Hi Timothy, >> >> How about adding this to your patch? >> I tested it and works ok. >> >> diff --git a/utilities/bugtool/ovs-bugtool.in >> b/utilities/bugtool/ovs-bugtool.in >> index c26c2be7a4eb..47f3c4629f70 100755 >> --- a/utilities/bugtool/ovs-bugtool.in >> +++ b/utilities/bugtool/ovs-bugtool.in >> @@ -385,7 +385,10 @@ def collect_data(): >> except Exception as e: >> s = str(e).encode() >> if check_space(cap, k, len(s)): >> - v['output'] = BytesIOmtime(s) >> + if isinstance(s, str): >> + v['output'] = BytesIOmtime(s.encode()) >> + else: >> + v['output'] = BytesIOmtime(s) >> >> >> def main(argv=None): >> > I applied to master with the diff above. > Thanks! > William
Looks like this patch didn't make it to branch-2.13, but it needed there since we do not support python2 staring from 2.13. I'll backport it. Best regards, Ilya Maximets. _______________________________________________ dev mailing list [email protected] https://mail.openvswitch.org/mailman/listinfo/ovs-dev
