[Python-Dev] python hangs when parsing a bad-formed email

Amaury Forgeot d'Arc amauryfa at gmail.com
Wed Apr 23 01:18:30 CEST 2008


Alberto Casado Martín wrote:
> Hi all,
>  First of all, sorry if this isn't the list where I have to post this.
>  And sorry for my english.
>  As the subject says, I'm having problems with the attached email, when
>  I try to get a email object  reading the attached file, the python
>  process gets hang and gets all cpu.
>  I have debuged my code to find where it happens, and I found that is
>  _parsegen method of the FeedParser class. I know that the email format
>  is wrong but  I don't know why python hangs.
>  following paste the code showing where hangs.
>  bash-3.00$ python
>  Python 2.5.1 (r251:54863, Feb 28 2008, 07:48:25)
>  [GCC 3.4.6] on sunos5
>  Type "help", "copyright", "credits" or "license" for more information.
>  >>> import email
>  >>> fp = open('raro.txt')
>  >>> mail = email.message_from_file(fp)
>  never return............

When you think you found a problem with python, please submit an issue
in the python issue tracker:

In your case, I suspect some regular expression trying to match all
the empty lines of the message, one character at a time.

Amaury Forgeot d'Arc

More information about the Python-Dev mailing list