python 3.12.5 source install make test test_smtplib FAIL test_with_statement AND test_with_statement_QUIT_failure Connection unexpectedly closed
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 77.2k
- Forks
- 35.9k
- Métriques de merge des PR
- Métriques de PR en attente
Description
Bug report
Bug description:
Update: This describes the problem, analysis and suggested fix. Can someone modify the source test code as indicated?
Rocky 9 LINUX
make test
ERROR
======================================================================
ERROR: test_with_statement (test.test_smtplib.SMTPSimTests.test_with_statement)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/defuser/Downloads/Python-3.12.5/Lib/test/test_smtplib.py", line 1231, in test_with_statement
code, message = smtp.noop()
^^^^^^^^^^^
...
======================================================================
ERROR: test_with_statement_QUIT_failure (test.test_smtplib.SMTPSimTests.test_with_statement_QUIT_failure)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/defuser/Downloads/Python-3.12.5/Lib/test/test_smtplib.py", line 1241, in test_with_statement_QUIT_failure
smtp.noop()
cd /home/defuser/Downloads/Python-3.12.5/Lib/test
vi test_smtplib.py
search for (one is right before the other)
test_with_statement
test_with_statement_QUIT_failure
note
with smtplib.SMTP(HOST, self.port, 'localhost') as smtp:
python with explanation, see https://www.geeksforgeeks.org/with-statement-in-python/
IN ANOTHER TERMINAL
cd ~/Downloads/Python-3.12.5
find . -name "smtplib*"
./Doc/library/smtplib.rst
./Lib/smtplib.py
./Lib/__pycache__/smtplib.cpython-312.pyc
view ./Lib/smtplib.py
search for
class SMTP
note this class meets "with" requirements in https://www.geeksforgeeks.org/with-statement-in-python/
def __init__(self, host='', port=0, local_hostname=None,
timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
source_address=None):
RETURN to TERMINAL "vi test_smtplib.py"
SMTP class instantiations (see test_quit_resets_greeting) use
smtp = smtplib.SMTP(HOST, self.port,
local_hostname='localhost' ...)
It is PROBABLY improper to use 'local_hostname=None' in "with" statement.
SOLUTION
In methods test_with_statement and test_with_statement_QUIT_failure
change
with smtplib.SMTP(HOST, self.port) as smtp:
to
with smtplib.SMTP(HOST, self.port, 'localhost') as smtp:
make test will now work
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez dans Lib/test/test_smtplib.py avec SMTPSimTests.test_with_statement et test_with_statement_QUIT_failure, en comparant leur construction SMTP avec test_quit_resets_greeting. Exécutez ces tests ou make test après avoir vérifié l’argument localhost proposé ; c’est terminé lorsque les deux échecs signalés réussissent sur Python 3.12.5.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- testing-qa
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- À l'abandon
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 58/100