Terry J. Reedy <tjre...@udel.edu> added the comment:

I am not familiar with either smtp or email, but I can make some general 
comments.

1. "AttributeError: 'NoneType' object has no attribute 'get_all'" seems pretty 
straightforward to me.  Hard to debug?  Depends on knowledge and experience. 
When coming from library code, it nearly always means that one called a library 
function with an invalid argument.  None, with only standard dunder attributes, 
is perhaps the most common bad argument.  Look in the traceback to find the bad 
call in one's own code, where one must have passed None, even if not by that 
name.  In this case, if one does not know that 'get_all' is a method of the two 
email message classes, this can be discovered in the document index.

2. It is not a bug for a function to expect users to know the above and in 
effect say "Don't do that!" when an attribute reference fails.  So I see this 
as an enhancement request, not a bugfix report.  But why add a check for None 
to this particular function?

3. Python functions often use duck-typing, allowing arguments that act 
sufficiently well like the documented requirement.  While 
https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.send_message  says 
that msg should be a Message object, this may not be an exact requirement.  
Indeed, 
https://docs.python.org/3/library/smtplib.html#smtplib.SMTP.send_message starts 
with "The Message class is very similar to the EmailMessage class ...".  So I 
wonder, "Is EmailMessage is also allowed?"  Or, "Do  any users pass instances 
of custom message classes?"

If so, perhaps the doc should be augmented.  But checking only for Message 
would be wrong, and would break code passing non-Message instances.

----------
nosy: +barry, maxking, r.david.murray, terry.reedy
stage:  -> test needed
type: behavior -> enhancement

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue42807>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to