New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NNTP: add post_message wrapper to post Email Message objects #63969
Comments
post method fails because string methods have bytesrting arguments ie. |
Can you show an example of the failure, including the traceback? I would think that nttplib would be mostly operating on byte objects, and I'm sure Antoine tested posting. |
Traceback (most recent call last):
File "./nntp_test.py", line 23, in <module>
s.post(msg)
File "/usr/lib/python3.3/nntplib.py", line 909, in post
return self._post('POST', data)
File "/usr/lib/python3.3/nntplib.py", line 895, in _post
if not line.endswith(_CRLF):
TypeError: endswith first arg must be str or a tuple of str, not bytes |
This won't work. The post() method needs a bytes object, or something which when iterating yields bytes data. Perhaps you can try to call as_bytes() on your MIMEText object: |
as_bytes was added in 3.4. For earlier python versions, you'll have to create a BytesGenerator object and flatten the message using it to get a bytes object you can past to post. |
It might be worth adding a post_message method, analogous to the send_message method I added to smtplib. |
Ok I found this out too on my own. It might be better to add examples using the MIME* classes to nntplib documentation. |
Hi David, You wrote:
Do you still think this would be worthwhile to add? If so, do you think this would be a good task for someone to work on at the PyCon sprints? Thanks! |
I do, and sure. I won't be able to review it, though :( |
Thanks David! If someone is looking for an issue to work on, I'll keep this one in mind with the caveat that it won't be reviewed during the sprints. And if no one works on it at that time, then it might be a good first issue afterwards. I'm updating the title to reflect the request. |
I think we can close this old issue because the nntplib module is deprecated in 3.11 and set for removal in 3.13. See PEP 594 – Removing dead batteries from the standard library and #91217. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: