Proposal: Fix `NTDebugHandler` and Deprecate `setup_logging` in `logutil.py`.
维护者通常 1 天内回复
评估
调研方向
从 comtypes/logutil.py 开始,重点查看 NTDebugHandler 和 setup_logging,然后检查它们在 server/inprocserver.py 中的使用情况。查看 issue 671 和已合并的 pull request 921 以了解背景。完成的标准是:handler 不再存在所报告的 Python 3 不兼容问题,并且 setup_logging 被明确标记为 deprecated,同时不再保留不必要的 logging 职责。
由索引模型根据 Issue 内容生成。
描述
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
- In Python 2,
strrepresented byte sequences, and Unicode strings were handled by a separateunicodetype.
In Python 3,strrepresents Unicode text, andbytesis used explicitly for byte sequences. - In Python 3,
logging.Formatter.format, which is invoked bylogging.Logger.format, always returns a Unicode string (str). - The
NTDebugHandler.emitmethod has a type check (isinstance(text, str)) and passing thisstrdirectly to_OutputDebugStringA(which expectsLPCSTR(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_loggingis a justloggingutility, unrelated to COM or Windows. - Such
loggingconfiguration 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.
NTDebugHandleris used inserver/inprocserver.py, but as discussed in https://github.com/enthought/comtypes/issues/671, the use case forinprocserverhas not been confirmed for years.
This suggests either that its breakage has gone unnoticed, or developers are using forks/custom patches.- The
setup_loggingfunction is not called anywhere withinserver/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).
- 主要语言
- Python
- 星标
- 347
- 派生
- 107
- 平均合并
- 19 小时 36 分钟
- 30 天内合并 PR
- 17
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
enthought/comtypes 的其他 Issue
-
good first issue
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
typing
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
question
难度 3/5 1-2 天 新手友好度 58/100
enthought/comtypes#935 · 10 条评论 ·
维护者通常 1 天内回复
-
ci tests
难度 3/5 1-2 天 新手友好度 62/100
enthought/comtypes#925 · 11 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
enthought/comtypes#873 · 4 条评论 ·
维护者通常 1 天内回复
查看 enthought/comtypes 的全部 Issue
相似的 Issue
-
难度 1/5 1 小时以内 新手友好度 88/100
-
难度 2/5 1-3 小时 新手友好度 72/100
aws-samples/sample-per-model-bedrock#261 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 65/100
pwncollege/dojo#1188 ·
维护者通常 1 天内回复
-
bug launcher packaging
难度 1/5 1 小时以内 新手友好度 88/100
tenstorrent/tt-studio#1426 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
python-attrs/cattrs#796 ·
维护者通常 1 天内回复