`python -m asyncio ps` and `python -m asyncio pstree` fail for task names that are str subclasses

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, python
領域
devtools

調査の方向性

The failure comes from read_py_str() in the remote debugger, which rejects non-compact Unicode objects, so start there and see how it reads the string layout. Run the repro with a str subclass task name, then check that python -m asyncio ps and pstree both list the task. Done means both commands succeed on that case and the existing asyncio debugging tests still pass.

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

説明

type-bug
Bug report

The remote debugger cannot read the non-compact string layout used by str subclasses, so a valid task name can break both ps and pstree

Repro:

import asyncio
import os

class TaskName(str):
    def __str__(self):
        return self

async def main():
    asyncio.current_task().set_name(TaskName("worker"))
    print(os.getpid())
    await asyncio.Event().wait()

asyncio.run(main())

Run:

sudo ./python.exe -m asyncio ps <PID> --retries 0
sudo ./python.exe -m asyncio pstree <PID> --retries 0

Output:

Error retrieving tasks: Cannot read non-compact Unicode object at 0x101c625d0

asyncio docs say:

      The *value* argument can be any object, which is then
      converted to a string.

Proposed fix: add support for non-compact strings in read_py_str()

I'll work on this

CPython versions tested on:

CPython main branch

Operating systems tested on:

macOS

主要言語
Python
スター
78.2k
フォーク
36.6k
平均マージ
19時間 57分
マージ済み PR(30日)
630

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

はじめの一歩

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

python/cpython のほかの issue

python/cpython の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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