python / python/cpython

Cannot round-trip UCS-2 with unpaired surrogates using UTF-16 and surrogateescape

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

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

docs topic-unicode
主要言語
Python
スター
77.2k
フォーク
36k
PR マージ指標
PR 指標を取得中

説明

Bug report

The following Python code throws a UnicodeEncodeError:

b'\xdc\xff'.decode('UTF-16BE', 'surrogateescape').encode('UTF-16', 'surrogateescape')

I would expect that it would return b'\xdc\xff' instead.

Your environment

  • CPython versions tested on: 3.10.4 from Fedora 35 repository
  • Operating system and architecture: Fedora 35 on x86-64

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

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

はじめの一歩

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

調査の方向性

まず、報告された UTF-16BE デコードおよび UTF-16 エンコードの snippet を、指定された CPython バージョンで実行し、その後、関連するエンコーディングと surrogateescape の挙動を追跡します。完了の条件は、バイト列 b'\xdc\xff' が UnicodeEncodeError なしでラウンドトリップし、報告された期待値に照らして挙動が確認されていることです。

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

評価

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

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

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