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

Đang mở
#161,952 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c, python
Lĩnh vực
devtools

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
78.2k
Fork
36.6k
Merge trung bình
19 giờ 57 phút
Pull request đã merge (30 ngày)
630

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của python/cpython

Tất cả issue của python/cpython

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.