* [PATCH b4] Avoid type error when local mbox lacks specified message ID
@ 2021-05-23 2:58 Kyle Meyer
2021-05-25 11:59 ` Konstantin Ryabitsev
0 siblings, 1 reply; 2+ messages in thread
From: Kyle Meyer @ 2021-05-23 2:58 UTC (permalink / raw)
To: tools
Calling b4-am with --use-local=MBOX is supposed to abort with "Could
not find MID in MBOX" if the mbox doesn't contain the specified
message ID. As of 4950093c0 (Don't use mboxo for anything,
2021-05-18), a type error is signaled because get_strict_thread()
returns None when there are no matches, and get_msgs() feeds this
result to len().
Update get_msgs() to instead check whether the returned value
evaluates to false.
Signed-off-by: Kyle Meyer <kyle@kyleam.com>
---
b4/mbox.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/b4/mbox.py b/b4/mbox.py
index a4b005f..bf1a586 100644
--- a/b4/mbox.py
+++ b/b4/mbox.py
@@ -572,7 +572,7 @@ def get_msgs(cmdargs) -> Tuple[Optional[str], Optional[list]]:
if msgid:
msgs = b4.get_strict_thread(in_mbx, msgid)
- if not len(msgs):
+ if not msgs:
logger.critical('Could not find %s in %s', msgid, cmdargs.localmbox)
sys.exit(1)
else:
base-commit: 7ed8a3cafd5f3ba5b4e914b495bb3035428e2d45
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH b4] Avoid type error when local mbox lacks specified message ID
2021-05-23 2:58 [PATCH b4] Avoid type error when local mbox lacks specified message ID Kyle Meyer
@ 2021-05-25 11:59 ` Konstantin Ryabitsev
0 siblings, 0 replies; 2+ messages in thread
From: Konstantin Ryabitsev @ 2021-05-25 11:59 UTC (permalink / raw)
To: tools, Kyle Meyer; +Cc: Konstantin Ryabitsev
On Sat, 22 May 2021 22:58:12 -0400, Kyle Meyer wrote:
> Calling b4-am with --use-local=MBOX is supposed to abort with "Could
> not find MID in MBOX" if the mbox doesn't contain the specified
> message ID. As of 4950093c0 (Don't use mboxo for anything,
> 2021-05-18), a type error is signaled because get_strict_thread()
> returns None when there are no matches, and get_msgs() feeds this
> result to len().
>
> [...]
Applied, thanks!
[1/1] Avoid type error when local mbox lacks specified message ID
commit: 5d6e3d8e47af6c787ca2cc32e873478fb5c3ba55
I should really refactor that part of the code to properly throw exceptions
instead of returning None. My head is a bit of a mishmash of "Python best
practices from 2003," back when throwing exceptions was considered "too slow."
I'm getting better, though -- who knows, I may even finally add a test suite.
:)
Best regards,
--
Konstantin Ryabitsev <konstantin@linuxfoundation.org>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-05-25 11:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-23 2:58 [PATCH b4] Avoid type error when local mbox lacks specified message ID Kyle Meyer
2021-05-25 11:59 ` Konstantin Ryabitsev
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).