fix(Python): pass UTF-8 byte length for log dir option#1310
Open
Windsland52 wants to merge 2 commits into
Open
fix(Python): pass UTF-8 byte length for log dir option#1310Windsland52 wants to merge 2 commits into
Windsland52 wants to merge 2 commits into
Conversation
Tasker.set_log_dir encoded the path as UTF-8 but passed the character count to MaaGlobalSetOption. Non-ASCII paths were truncated before native path conversion on Windows, which could surface as an uncaught C++ filesystem exception. Use the encoded byte length and cover set_log_dir with a non-ASCII path in the binding test.
Contributor
There was a problem hiding this comment.
Hey - 我在这里提供了一些整体性的反馈:
- 在
set_log_dir中,建议显式使用'utf-8'进行编码(例如str(path).encode('utf-8')),并将变量命名为encoded_path_bytes或类似名称,以明确传递给MaaGlobalSetOption的长度是字节长度,而不是字符数量。
给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- 在 `set_log_dir` 中,建议显式使用 `'utf-8'` 进行编码(例如 `str(path).encode('utf-8')`),并将变量命名为 `encoded_path_bytes` 或类似名称,以明确传递给 `MaaGlobalSetOption` 的长度是字节长度,而不是字符数量。帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- In
set_log_dir, consider explicitly encoding with'utf-8'(e.g.,str(path).encode('utf-8')) and naming the variableencoded_path_bytesor similar to make it clear the length passed toMaaGlobalSetOptionis a byte length and not a character count.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `set_log_dir`, consider explicitly encoding with `'utf-8'` (e.g., `str(path).encode('utf-8')`) and naming the variable `encoded_path_bytes` or similar to make it clear the length passed to `MaaGlobalSetOption` is a byte length and not a character count.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Member
Author
|
@MistEO review |
Member
Author
|
等 MaaXYZ/MaaUtils#16 合并 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Tasker.set_log_dir encoded the path as UTF-8 but passed the character count to MaaGlobalSetOption. Non-ASCII paths were truncated before native path conversion on Windows, which could surface as an uncaught C++ filesystem exception.
Use the encoded byte length and cover set_log_dir with a non-ASCII path in the binding test.
Summary by Sourcery
修复 Python Tasker 日志目录配置,以正确处理 UTF-8 路径,并在测试中为包含非 ASCII 字符的日志目录路径补充覆盖。
Bug 修复:
MaaGlobalSetOption的日志目录选项长度,避免非 ASCII 路径被截断。测试:
Tasker.set_log_dir在 Windows 风格路径中使用包含非 ASCII 字符的日志目录路径时能够正常工作。Original summary in English
Summary by Sourcery
Fix Python Tasker log directory configuration to correctly handle UTF-8 paths and add coverage for non-ASCII log directory paths in tests.
Bug Fixes:
Tests: