Open
Conversation
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.
Problem
Renaming objects would intermittently crash with:
re.error: bad escape \T at position 13
This happened because re.sub() treats its replacement string as a template where backslashes carry special meaning (\1 = group 1, \n = newline, etc.). If any replacement value contained a backslash followed by a letter — e.g. a Windows file path from @f, or a user-defined string variable — Python's regex engine would raise an error rather than insert the text literally. This only affected certain objects/scenes because the crash depended on what the variable values resolved to at runtime.
Changes
variable_replacer/variable_replacer.py
All re.sub() calls in replaceInputString now pass the replacement as a lambda callable instead of a bare string. When re.sub receives a callable, it calls it with the match object and uses the return value verbatim — no template processing, no backslash interpretation. This is the root cause fix.
operators/search_replace.py
Non-regex, case-insensitive path: same lambda fix applied to replaceSearch.sub(...).
Regex mode path: replaced the bare re.sub(searchReplaced, replaceReplaced, ...) call with explicit re.compile + pattern.sub, wrapped in try/except re.error blocks. Invalid regex patterns or replacement strings now surface a proper error popup instead of a raw traceback. The regex mode replacement is intentionally kept as a string (not a lambda) so users can still use backreferences like \1 in their regex replacements.
operators/search_select.py
The case-insensitive re.search call is now wrapped in try/except re.error, so an invalid search expression shows an error popup instead of crashing.