Skip to content

Conversation

@fatelei
Copy link
Contributor

@fatelei fatelei commented Dec 12, 2025

Add RFC 5034 AUTH support to poplib


📚 Documentation preview 📚: https://cpython-previews--142613.org.readthedocs.build/

@diegorusso
Copy link
Contributor

Can you please rebase/merge your branch on top of main please?

@fatelei
Copy link
Contributor Author

fatelei commented Dec 12, 2025

Can you please rebase/merge your branch on top of main please?

done

@diegorusso
Copy link
Contributor

Can you please rebase/merge your branch on top of main please?

done

Thanks! I removed all the reviewers and added only the ones in the original issue.

@picnixz picnixz self-requested a review December 12, 2025 13:12
Copy link
Member

@bitdancer bitdancer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this! I have several suggestions, mostly about mimicing the smtplib API for consistency.

@bedevere-app
Copy link

bedevere-app bot commented Dec 24, 2025

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@aisk
Copy link
Contributor

aisk commented Dec 25, 2025

Hi, please avoid of force push in the future, see: https://devguide.python.org/getting-started/pull-request-lifecycle/#don-t-force-push

@fatelei
Copy link
Contributor Author

fatelei commented Dec 25, 2025

Hi, please avoid of force push in the future, see: https://devguide.python.org/getting-started/pull-request-lifecycle/#don-t-force-push

i rebase, but i can not push, so i force push, sorry

@aisk
Copy link
Contributor

aisk commented Dec 25, 2025

i rebase, but i can not push, so i force push, sorry

You can fetch the remote, then use git merge ... to merge the changes into your local branch, make further changes, and finally git push ... to the remote safely and without -f option.

import re
import socket
import sys
import base64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep the imports alphabetically sorted.

Comment on lines +257 to +258
(``bytes`` or ``str``). Return ``b'*'`` to abort the exchange.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
(``bytes`` or ``str``). Return ``b'*'`` to abort the exchange.
(``bytes`` or ``str``). Return ``b'*'`` to abort the exchange.
.. versionadded:: next

Comment on lines +252 to +253
If *initial_response* is provided (``bytes`` or ``str``), it is
base64-encoded and appended to the command after a single space.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If *initial_response* is provided (``bytes`` or ``str``), it is
base64-encoded and appended to the command after a single space.
If *initial_response* is provided (as :class:`bytes` or :class:`str`),
it is base64-encoded and appended to the command after a single space.

Comment on lines +255 to +257
If *authobject* is provided, it is called with the server’s ``bytes``
challenge (already base64-decoded) and must return the client response
(``bytes`` or ``str``). Return ``b'*'`` to abort the exchange.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
If *authobject* is provided, it is called with the server’s ``bytes``
challenge (already base64-decoded) and must return the client response
(``bytes`` or ``str``). Return ``b'*'`` to abort the exchange.
If *authobject* is provided, it is called with the server’s ``bytes``
challenge (already base64-decoded) and must return the client response
as a :class:`bytes` or :class:`str`. If ``b'*'`` is returned, the exchange
is aborted.

"""
return self._shortcmd('PASS %s' % pswd)


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid changing unrelated code.


auth_challenge_count += 1
if auth_challenge_count > _MAXCHALLENGE:
raise error_proto('Server AUTH mechanism infinite loop')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this the same message as in smtplib?

Comment on lines +489 to +491
resp = authobject(challenge)
if resp is None:
resp = b''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, authobject is allowed to return None. Should it be documented? or is it only kept for parity with legacy implementation of smtplib?

Comment on lines +502 to +506
def auth_plain(self, user, password, authzid=''):
"""Return an authobject suitable for SASL PLAIN.
Result is 'str'.
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def auth_plain(self, user, password, authzid=''):
"""Return an authobject suitable for SASL PLAIN.
Result is 'str'.
"""
def auth_plain(self, user, password, authzid=''):
"""Return an authobject suitable for SASL PLAIN."""

Why was there "result is 'str'"? and before "result is 'response'"? was it LLM-generated?

# Modified by Giampaolo Rodola' to give poplib.POP3 and poplib.POP3_SSL
# a real test suite

import base64
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep a blank line before import base64.

@@ -0,0 +1 @@
Add RFC 5034 AUTH support to poplib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add RFC 5034 AUTH support to poplib
:mod:`poplib`: add :rfc:`5034` ``AUTH`` support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants