I need some help interpreting this error
2QdxY4RzWzUUiLuE at potatochowder.com
2QdxY4RzWzUUiLuE at potatochowder.com
Wed Feb 17 13:29:33 EST 2021
On 2021-02-17 at 17:36:48 +0000,
Chris Green <cl at isbd.net> wrote:
> Stefan Ram <ram at zedat.fu-berlin.de> wrote:
> > Chris Green <cl at isbd.net> writes:
> > > chris at cheddar$ tail mail.err
> > > Traceback (most recent call last):
> > > File "/home/chris/.mutt/bin/filter.py", line 95, in <module>
> > > if sbstrip in msghdr["subject"]:
> > > TypeError: argument of type 'Header' is not iterable
> > >But msghdr["subject"] is surely just a string isn't it? Why is it
> > >complaining about something of type 'Header'?
> >
> > I presume that the error message has been edited (abbreviated).
> >
> > In "if sbstrip in msghdr["subject"]:", there is no argument.
> >
> > But the error message says "argument of ...".
> >
> > When something that is not iterable is presented to a for loop,
> > the error message does not mention "argument":
> >
> I have output everything that appears, I've not changed it at all.
> It's the whole content of the file ~/tmp/mail.err as it's the only
> error that has occurred for the last day or so. The error log is
> created by the line:-
>
> sys.stderr = open("/home/chris/tmp/mail.err", 'a')
>
> So that's everything that was output to stderr.
>
> I think you are puzzled in the same way that I was, the error message
> doesn't make a lot of sense.
At some point, the internal code for the "in" operator is likely
iterating over the elements of msghdr["subject"].
That error message doesn't make a lot of sense if msghdr["subject"] is a
sub-class of str. It makes more sense if msghdr["subject"] is something
else.
IMO, you need more information in the log, a try/except block to prevent
the code from crashing, and, yes, perhaps some patience to wait for it
to happen again.
Sometimes, developing software isn't all fortune, fame, and glory. ;-)
More information about the Python-list
mailing list