Skip to content

chore: add encoding= to open() calls and raw regex in src/agent/session.py and src/repl/core.py#11

Open
mangodxd wants to merge 1 commit intoGPT-AGI:mainfrom
mangodxd:cleanup/encoding-08791998
Open

chore: add encoding= to open() calls and raw regex in src/agent/session.py and src/repl/core.py#11
mangodxd wants to merge 1 commit intoGPT-AGI:mainfrom
mangodxd:cleanup/encoding-08791998

Conversation

@mangodxd
Copy link
Copy Markdown

@mangodxd mangodxd commented Apr 5, 2026

Hello,

I noticed a few areas where the code could be slightly improved. This PR focuses on minor housekeeping tasks and does not change any of the existing runtime logic:

Explicit encoding for file operations

  • src/agent/session.py: added encoding="utf-8" to 2 open() call(s)

I added explicit encoding here because Python's default behavior depends on the OS. This change ensures consistent cross-platform behavior.

Regex syntax cleanup

  • src/repl/core.py: converted 2 regex string(s) to raw strings

Using standard strings for regex patterns with backslashes triggers a SyntaxWarning in Python 3.12+. Converted to raw strings (r"...") to follow modern best practices.

Examples of changes

Example change in src/agent/session.py:

-        with open(session_file, 'w') as f:
+        with open(session_file, 'w', encoding="utf-8") as f:
-        with open(session_file, 'r') as f:
+        with open(session_file, 'r', encoding="utf-8") as f:

Example change in src/repl/core.py:

-            if "/.clawd/skills/" in p or "\\.clawd\\skills\\" in p or "/.claude/skills/" in p or "\\.claude\\skills\\" in p:
+            if "/.clawd/skills/" in p or r"\\.clawd\\skills\\" in p or "/.claude/skills/" in p or r"\\.claude\\skills\\" in p:

Verification

  • I verified these changes using ast.parse() to ensure no syntax errors were introduced.
  • I did not modify any __init__.py files.

If anything looks incorrect, please feel free to adjust it or close the PR entirely. Thank you for maintaining this project!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant