[issue42892] AttributeError in email.message.get_body()

2021-07-30 Thread Łukasz Langa

Change by Łukasz Langa :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-07-30 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 0f42b726c87f72d522893f927b4cb592b8875641 by Miss Islington (bot) 
in branch '3.9':
bpo-42892: fix email multipart attribute error (GH-26903) (GH-27493)
https://github.com/python/cpython/commit/0f42b726c87f72d522893f927b4cb592b8875641


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-07-30 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 6f950023c6a2168b229363d75f59a24ecdd66d19 by Miss Islington (bot) 
in branch '3.10':
bpo-42892: fix email multipart attribute error (GH-26903) (GH-27492)
https://github.com/python/cpython/commit/6f950023c6a2168b229363d75f59a24ecdd66d19


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-07-30 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26009
pull_request: https://github.com/python/cpython/pull/27493

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-07-30 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset e3f877c32d7cccb734f45310f26beeec793364ce by andrei kulakov in 
branch 'main':
bpo-42892: fix email multipart attribute error (GH-26903)
https://github.com/python/cpython/commit/e3f877c32d7cccb734f45310f26beeec793364ce


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-07-30 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 7.0 -> 8.0
pull_requests: +26008
pull_request: https://github.com/python/cpython/pull/27492

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-06-28 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.10, Python 3.11

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-06-24 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Put up the PR here: https://github.com/python/cpython/pull/26903

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-06-24 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
pull_requests: +25479
pull_request: https://github.com/python/cpython/pull/26903

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-06-24 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I'll try to fix the unit test today.

--
nosy: +andrei.avk

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-05-19 Thread R. David Murray


R. David Murray  added the comment:

Actually, I'm wrong.  The body of a part can be a string, and that's what's 
going to happen with a malformed body of something claiming to be a multipart. 
The problem is that there is code that doesn't guard against this possibility.  
The following patch against master fixes the bug listed here, as well as 
iter_parts().  But it causes one test suite failure so it isn't a correct patch 
as it stands:

diff --git a/Lib/email/message.py b/Lib/email/message.py
index 3701b30553..d5d4a2385a 100644
--- a/Lib/email/message.py
+++ b/Lib/email/message.py
@@ -982,7 +982,7 @@ def _find_body(self, part, preferencelist):
 if subtype in preferencelist:
 yield (preferencelist.index(subtype), part)
 return
-if maintype != 'multipart':
+if maintype != 'multipart' or not self.is_multipart():
 return
 if subtype != 'related':
 for subpart in part.iter_parts():
@@ -1087,7 +1087,7 @@ def iter_parts(self):
 
 Return an empty iterator for a non-multipart.
 """
-if self.get_content_maintype() == 'multipart':
+if self.is_multipart():
 yield from self.get_payload()
 
 def get_content(self, *args, content_manager=None, **kw):

Maybe someone can take this and finish it (with tests)...I may or may not have 
time to get back to this.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-05-19 Thread R. David Murray


R. David Murray  added the comment:

Yes, that's the real question.  That's what needs to be fixed, otherwise we'll 
just keep finding new bugs.  For example, try calling iter_parts() on that 
message.  It isn't pretty :)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-05-19 Thread Irit Katriel


Irit Katriel  added the comment:

Can you see how it happened that part is a str?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-01-11 Thread Xavier Hausherr


Xavier Hausherr  added the comment:

Attached PR fix the issue.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-01-11 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
nosy: +python-dev
nosy_count: 4.0 -> 5.0
pull_requests: +23019
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24192

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue42892] AttributeError in email.message.get_body()

2021-01-11 Thread Xavier Hausherr


New submission from Xavier Hausherr :

Following this issue: https://bugs.python.org/issue33972

Same bug apply to email.message.get_body() with attached email example and the 
following code: 

from email.policy import default
import email

with open('email_bad_formatted.eml', 'rb') as fp:
msg = email.message_from_binary_file(fp, policy=default)
body = msg.get_body()

> Result:
E   AttributeError: 'str' object has no attribute 'is_attachment'

/usr/local/lib/python3.9/email/message.py:978: AttributeError

--
components: email
files: email_bad_formatted.eml
messages: 384847
nosy: barry, iritkatriel, r.david.murray, xavier2
priority: normal
severity: normal
status: open
title: AttributeError in email.message.get_body()
versions: Python 3.9
Added file: https://bugs.python.org/file49734/email_bad_formatted.eml

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com