[issue39100] email.policy.SMTP throws AttributeError on invalid header

2022-01-30 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I confirmed I get the same error as Anton on 3.9 and 3.11 .

--

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2022-01-30 Thread Anton Khirnov


Anton Khirnov  added the comment:

Ping yet again. Can anyone please look at this?

--

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2021-07-07 Thread Anton Khirnov


Anton Khirnov  added the comment:

Quoting Andrei Kulakov (2021-07-03 16:03:34)
> Anton: thanks for the report! In the message you say you are not sure
> of the solution, and because of that not sending a patch, but then you
> created the PR; - please clarify.

I didn't send a patch when originally submitting the bugreport in 2019.
I did write a patch about a year later, since there was no response to
the bugreport.

--

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2021-07-07 Thread Anton Khirnov


Anton Khirnov  added the comment:

Quoting R. David Murray (2021-07-06 18:59:56)
> How are you encountering this error?  The following program runs without 
> exception for me on master:
> 
> from email import message_from_binary_file
> from email.policy import SMTP
> 
> msg = message_from_binary_file(open('mail.eml', 'rb'), policy=SMTP)
> print(msg)

The exception is thrown on accessing the 'to' header, so make that
print(msg['to'])

--

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2021-07-06 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I should have been more exact - I've used python3.7.7 .

--

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2021-07-06 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Running R.David's test script on python3.7, it also works, there's no exception.

--

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2021-07-06 Thread R. David Murray


R. David Murray  added the comment:

How are you encountering this error?  The following program runs without 
exception for me on master:

from email import message_from_binary_file
from email.policy import SMTP

msg = message_from_binary_file(open('mail.eml', 'rb'), policy=SMTP)
print(msg)

--

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2021-07-03 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Anton: thanks for the report! In the message you say you are not sure of the 
solution, and because of that not sending a patch, but then you created the PR; 
- please clarify.

--
nosy: +andrei.avk

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2021-03-15 Thread Anton Khirnov


Change by Anton Khirnov :


--
keywords: +patch
pull_requests: +23633
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24872

___
Python tracker 

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



[issue39100] email.policy.SMTP throws AttributeError on invalid header

2019-12-19 Thread Anton Khirnov


New submission from Anton Khirnov :

When parsing a (broken) mail from linux-me...@vger.kernel.org (message-id 
20190212181908.horde.peighvv2khy9ekuy8ta8...@webmail.your-server.de, headers 
attached) with email.policy.SMTP, I get an AttributeError on trying to read the 
'to' header:

/usr/lib/python3.7/email/headerregistry.py in (.0)
345  mb.local_part or '',
346  mb.domain or '')
--> 347  for mb in addr.all_mailboxes]))
348 defects = list(address_list.all_defects)
349 else:

AttributeError: 'Group' object has no attribute 'local_part'

The header in question is:
To: unlisted-recipients:; (no To-header on input)

The problem seems to be that mb is a Group and not an Address, gets token_type 
of 'invalid-mailbox', but does not have the attributes local_part/domain that 
are expected in mailboxes. Copying the line

local_part = domain = route = addr_spec = display_name

from InvalidMailbox to Group fixes this, but it is not clear to me this is the 
right solution, so not sending a patch.

--
components: email
files: mail.eml
messages: 358689
nosy: barry, elenril, r.david.murray
priority: normal
severity: normal
status: open
title: email.policy.SMTP throws AttributeError on invalid header
type: behavior
Added file: https://bugs.python.org/file48792/mail.eml

___
Python tracker 

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