[issue45299] SMTP.send_message() does from mangling when it should not

2021-11-25 Thread Andrei Kulakov
Andrei Kulakov added the comment: Grant: sounds good! I can do the initial PR review. Note that the PR will need a test and a news entry. See the link below on authoring PRs: https://devguide.python.org/pullrequest/ -- ___ Python tracker

[issue45299] SMTP.send_message() does from mangling when it should not

2021-11-25 Thread Grant Edwards
Grant Edwards added the comment: Yes, passing the mangle_from value to BytesGenerator seems like the safest fix. It's unfortunate that BytesGenerator defaults to doing "the wrong thing" in the absence of a policy argument, but there might be code that depends on it. I've never done a PR

[issue45299] SMTP.send_message() does from mangling when it should not

2021-11-25 Thread Andrei Kulakov
Andrei Kulakov added the comment: R. David: `mangle_from_` is the only exception; I agree it seems likely it was done this way for backwards compatibility. Grant: do you agree with the fix to logic? Also do you agree that mangle_from_ is the only setting that's not being applied to msg

[issue45299] SMTP.send_message() does from mangling when it should not

2021-11-24 Thread R. David Murray
R. David Murray added the comment: Your backward compatibility argument is persuasive. As you say, that means the BytesGenerate docs would need to be updated to note that that parameter is the exception to the rule for backward compatibility reasons. (If it is the only exception I have to

[issue45299] SMTP.send_message() does from mangling when it should not

2021-11-23 Thread Andrei Kulakov
Andrei Kulakov added the comment: There are 3 policy settings that are also being passed as parameters to Generator/BytesGenerator: - mangle_from_ - linesep - maxheaderlen Both linesep and maxheaderlen are being inserted into policy after self.policy (if there is one) overrides message

[issue45299] SMTP.send_message() does from mangling when it should not

2021-11-23 Thread R. David Murray
R. David Murray added the comment: In this case the docs are correct and the code has a bug. The intent was that if the message passed in to BytesGenerator has a policy, that policy should be followed. If it is not being followed, that's a bug in BytesGenerator. The tricky part of course

[issue45299] SMTP.send_message() does from mangling when it should not

2021-11-23 Thread Andrei Kulakov
Andrei Kulakov added the comment: Seems like a reasonable request to me. I can make the PR+test. To minimize backwards-incompatible change, we can pass `_mangle_from=policy._mangle_from` argument instead of passing the entire policy. Is that a good idea or passing the policy argument

[issue45299] SMTP.send_message() does from mangling when it should not

2021-09-26 Thread Grant Edwards
New submission from Grant Edwards : SMTP.send_message() does from mangling even when the message's policy has that disabled. The problem is in the send_messsage() function shown below: 912 def send_message(self, msg, from_addr=None, to_addrs=None, 913