python / python/cpython

python 3.12.5 source install make test test_smtplib FAIL test_with_statement AND test_with_statement_QUIT_failure Connection unexpectedly closed

Offen
#122,874 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

tests topic-email type-bug
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne in Lib/test/test_smtplib.py bei SMTPSimTests.test_with_statement und test_with_statement_QUIT_failure und vergleiche ihre SMTP-Konstruktion mit test_quit_resets_greeting. Führe diese Tests oder make test aus, nachdem du das vorgeschlagene localhost-Argument überprüft hast; erledigt bedeutet, dass beide gemeldeten Fehlschläge unter Python 3.12.5 erfolgreich sind.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
testing-qa
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
58/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.