Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Proposal: Fix `NTDebugHandler` and Deprecate `setup_logging` in `logutil.py`.

Aperta
#920 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@junkmd ci sta già lavorando.

Dal 21/9/2026.

  • #921 di @junkmd — integrata
  • #945 di @junkmd — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
python
Ambito
tooling

Direzione di ricerca

Inizia da comtypes/logutil.py, in particolare da NTDebugHandler e setup_logging, quindi esamina il loro utilizzo in server/inprocserver.py. Esamina l’issue 671 e la pull request 921 integrata per il contesto. Il lavoro è completato quando l’handler non presenta più l’incompatibilità segnalata con Python 3 e setup_logging è chiaramente deprecato, senza che rimanga alcuna responsabilità di logging non necessaria.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug tests

Summary

The logutil module contains components that are either broken, or overly broad in this project responsibilities, and have not been properly maintained or tested for a long time.
I propose to fix the NTDebugHandler class and deprecate the setup_logging function.

Problems

1. NTDebugHandler is broken due to Python 2/3 str vs bytes incompatibility

https://github.com/enthought/comtypes/blob/06879ab77bd71d86ca2601ce0af01c3e3f85de26/comtypes/logutil.py#L17-L28

  • In Python 2, str represented byte sequences, and Unicode strings were handled by a separate unicode type.
    In Python 3, str represents Unicode text, and bytes is used explicitly for byte sequences.
  • In Python 3, logging.Formatter.format, which is invoked by logging.Logger.format, always returns a Unicode string (str).
  • The NTDebugHandler.emit method has a type check (isinstance(text, str)) and passing this str directly to _OutputDebugStringA (which expects LPCSTR(bytes)) inevitably leads to errors.
  • So _OutputDebugStringW (for wide character strings) is sufficient. The existing type branching is now a source of malfunction.
2. setup_logging has excessive responsibility
  • The setup_logging is a just logging utility, unrelated to COM or Windows.
  • Such logging configuration responsibilities should ideally rest with the application developer.
3. Lack of usage and redundancy
  • These components are likely unused or used in very limited circumstances for a long time.
  • NTDebugHandler is used in server/inprocserver.py, but as discussed in https://github.com/enthought/comtypes/issues/671, the use case for inprocserver has not been confirmed for years.
    This suggests either that its breakage has gone unnoticed, or developers are using forks/custom patches.
  • The setup_logging function is not called anywhere within server/inprocserver.py, indicating its non-essential nature for the project and a weak justification for its existence.

Proposal

For the reasons outlined above, we propose to fix NTDebugHandler and deprecate the setup_logging function from this library.
This will simplify the codebase, resolve potential Python version incompatibility issues, and clarify the scope of this project responsibilities.

I plan to fix NTDebugHandler by the next release and deprecate setup_logging, with a view to removing it in a future version (likely 1.5.0).

Lingua principale
Python
Stelle
346
Fork
107
Merge medio
22h 5m
PR unite (30g)
15

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di enthought/comtypes

Tutte le issue di enthought/comtypes

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.