[Python-bugs-list] [ python-Bugs-824977 ] Memory error on AIX in email.Utils._qdecode

SourceForge.net noreply at sourceforge.net
Thu Oct 16 16:00:17 EDT 2003


Bugs item #824977, was opened at 2003-10-16 13:40
Message generated for change (Comment added) made by customdesigned
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=824977&group_id=5470

Category: Extension Modules
Group: Python 2.2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Stuart D. Gathman (customdesigned)
>Assigned to: Nobody/Anonymous (nobody)
Summary: Memory error on AIX in email.Utils._qdecode

Initial Comment:
The following scriptlet works correctly on RedHat
python2-2.2.3, but gets a MemoryError on AIX
python-2.2.3.  This is the only anomoly for AIX python
I have seen.

import email

fp = open('analfail')
msg = email.message_from_file(fp)
for part in msg.walk():
  if part.get_main_type() == 'text':
    txt = part.get_payload(decode=True)
    #del msg["content-transfer-encoding"]
    msg.set_payload(txt)
fp.close()
print msg.as_string()

It doesn't matter whether the 'del' is there.

----------------------------------------------------------------------

>Comment By: Stuart D. Gathman (customdesigned)
Date: 2003-10-16 16:00

Message:
Logged In: YES 
user_id=142072

Fixed binascii as follows:
--- ./Modules/binascii.c.bms    Mon Mar 17 06:34:43 2003
+++ ./Modules/binascii.c        Thu Oct 16 15:55:34 2003
@@ -1036,7 +1036,7 @@
        /* We allocate the output same size as input, this
is overkill */
        odata = (unsigned char *) calloc(1, datalen);
 
-       if (odata == NULL) {
+       if (odata == NULL && datalen > 0) {
                PyErr_NoMemory();
                return NULL;
        }

This bug will manifest not just on AIX, but any system which
returns NULL from malloc or calloc when allocated size is 0.

----------------------------------------------------------------------

Comment By: Stuart D. Gathman (customdesigned)
Date: 2003-10-16 13:47

Message:
Logged In: YES 
user_id=142072

It looks like the problem is with a2b_qp in the binascii
extension module.  So I am changing the Category.

----------------------------------------------------------------------

Comment By: Stuart D. Gathman (customdesigned)
Date: 2003-10-16 13:43

Message:
Logged In: YES 
user_id=142072

I forgot to include the traceback.

$ python t.py
Traceback (most recent call last):
  File "t.py", line 8, in ?
    txt = part.get_payload(decode=True)
  File "/usr/local/lib/python2.2/email/Message.py", line
197, in get_payload
    return Utils._qdecode(payload)
  File "/usr/local/lib/python2.2/quopri.py", line 161, in
decodestring
    return a2b_qp(s, header = header)
MemoryError


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=824977&group_id=5470



More information about the Python-bugs-list mailing list