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

Ouverte
#161,952 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

Personne n'a encore pris cette issue.

Évaluation

Difficulté
3/5
Temps estimé
1-2 jours
Accessibilité débutants
48/100
Type d'issue
Bug
Clarté
Plutôt claire
Activité
Active
Stack technique
c, python
Domaine
devtools

Piste de recherche

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.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

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

Langage dominant
Python
Étoiles
78.2k
Forks
36.6k
Merge moyen
19 h 57 min
PR mergées (30 j)
630

Préparer son environnement

Ouvrir dans Codespaces

Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de python/cpython

Toutes les issues de python/cpython

Issues similaires

Plus d'issues Python

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.