python / python/cpython

ftplib storbinary

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

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

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

説明

Bug report

Bug description:

There's a problem with SSL and the storbinary method. I get this error:

Error uploading yourfile.mp3: [SSL: UNEXPECTED_EOF_WHILE_READING] EOF occurred in violation of protocol (_ssl.c:2685)

A YouTuber posted a fix which creates your own storbinary function and eliminates some code in the original that solves the problem. I attached the fix below. You use this function in place of the method that comes with the library.

def storbinary(self, cmd, fp, blocksize=8192, callback=None, rest=None):
    self.voidcmd('TYPE I')
    with self.transfercmd(cmd, rest) as conn:
        while 1:
            buf = fp.read(blocksize)
            if not buf: break
            conn.sendall(buf)
            if callback: callback(buf)
    return self.voidresp()
    
    ----
    ftps = FTP_TLS()
    ftps.set_pasv(True)

      ....
    for upload in uploads:
        print(upload)
        with open(upload, 'rb') as file:  # Use 'with' to ensure the file is closed properly
            remote_filename = os.path.basename(upload)  # Get the base filename for uploading
            try:
                storbinary(ftps, f'STOR {remote_filename}', file)
            #    ftps.storbinary(f'STOR {remote_filename}', file) 

                print(f'Successfully uploaded: {remote_filename}')
            except all_errors as e:
                print(f'Error uploading {remote_filename}: {e}')
    # Connect to the server
    ftps.connect(ftps_host)
    ftps.login(user=ftps_user, passwd=ftps_password)
    ftps.prot_p()  # Switch to secure data connection

    
CPython versions tested on:

3.12

Operating systems tested on:

macOS

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

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

はじめの一歩

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

調査の方向性

ftplib.FTP_TLS.storbinary から始め、macOS 上の Python 3.12 について報告されている SSL アップロード失敗を、添付された置換関数と比較しながら再現します。リポジトリのファイルもテストも指定されていません。完了条件は、storbinary を置き換えずに報告されたアップロードが動作し、その挙動に回帰テストのカバレッジがあることです。

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

評価

技術スタック
python
領域
networking
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

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

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