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

オープン
#122,874 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

tests topic-email type-bug
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Lib/test/test_smtplib.py の SMTPSimTests.test_with_statement と test_with_statement_QUIT_failure から始め、SMTP の構築方法を test_quit_resets_greeting と比較します。提案されている localhost 引数を確認してから、これらのテストまたは make test を実行します。完了とは、報告されている両方の失敗が Python 3.12.5 で成功することです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
testing-qa
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
58/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。