Discussion:
[bug-mailutils] Guile 2.2 bindings: error when printing message object.
Ricardo Wurmus
2018-08-24 19:00:42 UTC
Permalink
Hello!

I’m the author of GNU Guile Debbugs, a Guile interface to the SOAP
service of the Debbugs bug tracker. I’m trying to use the Guile
bindings of Mailutils to simplify the task of dealing with emails from
Debbugs (e.g. to parse multipart messages or to decode Quoted Printable
strings).

I used the latest version of Mailutils from Savannah because unlike the
latest release it provides working bindings for Guile 2.2.
Unfortunately, I cannot get it to read a message in mbox format from a
file. Here’s what I tried:

--8<---------------cut here---------------start------------->8---
wget https://debbugs.gnu.org/cgi/bugreport.cgi?bug=32514;msg=8;mbox=yes
guile
GNU Guile 2.2.4
Copyright (C) 1995-2017 Free Software Foundation, Inc.

Guile comes with ABSOLUTELY NO WARRANTY; for details type `,show w'.
This program is free software, and you are welcome to redistribute it
under certain conditions; type `,show c' for details.

Enter `,help' for help.
scheme@(guile-user)> ,use (mailutils mailutils)
scheme@(guile-user)> (call-with-input-file "bug_32514_message_8.mbox" mu-message-from-port)
$1 = #<message "debbugs-submit-***@debbugs.gnu.org" "Fri Aug 24 06:39" ERROR: In procedure write:
Wrong type (expecting exact integer): #<closed: file 14ef0e0>

Entering a new prompt. Type `,bt' for a backtrace or `,q' to continue.
scheme@(guile-user) [1]> ,bt
In ice-9/boot-9.scm:
829:9 3 (catch quit #<procedure 119f560 at system/repl/repl.scm:191:18 ()> #<procedure 7fc1e1f559f8 at system/repl/repl.scm:210:18 (k . args)> _)
260:13 2 While executing meta-command:
Wrong type (expecting exact integer): #<closed: file 14ef0e0>
scheme@(guile-user) [1]>
--8<---------------cut here---------------end--------------->8---

This also happens for other messages that don’t come from Debbugs. The
problem only seems to happen when the message object is printed – I can
assign the parsed to a variable, but I cannot print it.

--
Ricardo
Sergey Poznyakoff
2018-08-24 21:25:43 UTC
Permalink
Hi Ricardo,
I'm the author of GNU Guile Debbugs, a Guile interface to the SOAP
service of the Debbugs bug tracker.
I'm pleased to meet you.
I'm trying to use the Guile
bindings of Mailutils to simplify the task of dealing with emails from
Debbugs (e.g. to parse multipart messages or to decode Quoted Printable
strings).
It's a very interesting and promising usage.
Wrong type (expecting exact integer): #<closed: file 14ef0e0>
It appears that the port opened by call-with-input-file got closed prior
to being used by mu-message-from-port. That function protects its argument
port by being collected by gc, but that doesn't help when the port is
closed explicitly after calling the function. I will fix it. In the
meantime, please use this workaround:

(call-with-input-file "bug_32514_message_8.mbox"
(lambda (port)
(mu-message-from-port (duplicate-port port "r"))))

Regards,
Sergey
Ricardo Wurmus
2018-08-25 08:15:05 UTC
Permalink
Hi Sergey,
Post by Sergey Poznyakoff
Post by Ricardo Wurmus
mu-message-from-port)
Wrong type (expecting exact integer): #<closed: file 14ef0e0>
It appears that the port opened by call-with-input-file got closed prior
to being used by mu-message-from-port. That function protects its argument
port by being collected by gc, but that doesn't help when the port is
closed explicitly after calling the function. I will fix it. In the
(call-with-input-file "bug_32514_message_8.mbox"
(lambda (port)
(mu-message-from-port (duplicate-port port "r"))))
This works for now. Thank you for the suggestion and for working on a
fix!

--
Ricardo

Loading...