Description
global_post_fixes() in nukestubsgen.py opens files without specifying an encoding, which causes UnicodeDecodeError on Windows when stub files contain non-ASCII characters in docstrings.
Steps to reproduce
- Run
nukestubsgen() on Windows with a non-UTF-8 system locale (e.g. cp1251 or cp1252)
global_post_fixes() crashes with:
UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position XXXX: character maps to <undefined>
- The stubs are generated but the global post-fixes (removing
(Object):, prefixing hiero. to core./ui. types) are never applied
Root cause
def global_post_fixes():
for file in STUBS_PATH.glob('**/*.py'):
with open(file, 'r') as f # no encoding, falls back to system locale
content = f.read()
...
with open(file, 'w') as f: # same issue on write
f.write(content)
Without an explicit encoding, Python uses the Windows system locale (cp1251/cp1252), which cannot decode UTF-8 multi-byte sequences present in some Nuke/Hiero docstrings.
Fix
def global_post_fixes():
for file in STUBS_PATH.glob('**/*.py'):
with open(file, 'r', encoding='utf-8') as f:
content = f.read()
...
with open(file, 'w', encoding='utf-8') as f:
f.write(content)
Environment
- OS: Windows 11
- System locale: cp1252
- NukeStudio: 15.1v10
- Python: Nuke's internal interpreter
Description
global_post_fixes()innukestubsgen.pyopens files without specifying an encoding, which causesUnicodeDecodeErroron Windows when stub files contain non-ASCII characters in docstrings.Steps to reproduce
nukestubsgen()on Windows with a non-UTF-8 system locale (e.g. cp1251 or cp1252)global_post_fixes()crashes with:(Object):, prefixinghiero.tocore./ui.types) are never appliedRoot cause
Without an explicit
encoding, Python uses the Windows system locale (cp1251/cp1252), which cannot decode UTF-8 multi-byte sequences present in some Nuke/Hiero docstrings.Fix
Environment