Roundup Tracker - Issues

Message6909

Author tekberg
Recipients rouilj, tekberg
Date 2020-05-14.14:50:38
Message-id <1589467839.07.0.917750020348.issue2551084@roundup.psfhosted.org>
In-reply-to
I'm using the roundup admin code to create messages, files and issues. Some of the files are rather large. Looking at the roundup/admin.py code at line 104 a split is done to separate a property name from its value. Here are the few lines that matter.

l = arg.split('=')
if len(l) < 2:
    raise UsageError(_('argument "%(arg)s" not propname=value'
        )%locals())
key, value = l[0], '='.join(l[1:])

As you can see, a split is done on '=' and then a length check is done. After that, the variables key and value are assigned. The value part does a join on '=' to reconstitute it. A better approach is to use the maxsplit argument for split:

l = arg.split('=', 1)
if len(l) < 2:
    raise UsageError(_('argument "%(arg)s" not propname=value'
        )%locals())
key, value = l

Here, the arg is split into at most 2 pieces (1 split), the length check is done, and the key and value are assigned.

While this may not be important for small propname/value pairs in roundup-admin, it is important when the value is large, like files. In addition, the code is simpler. If you would like a diff and/or a test case for this, please let me know.
History
Date User Action Args
2020-05-14 14:50:39tekbergsetrecipients: + tekberg, rouilj
2020-05-14 14:50:39tekbergsetmessageid: <1589467839.07.0.917750020348.issue2551084@roundup.psfhosted.org>
2020-05-14 14:50:38tekberglinkissue2551084 messages
2020-05-14 14:50:38tekbergcreate