Skip to content

global_post_fixes() fails on Windows due to missing encoding parameter #7

@pushkarev-alexandr

Description

@pushkarev-alexandr

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

  1. Run nukestubsgen() on Windows with a non-UTF-8 system locale (e.g. cp1251 or cp1252)
  2. global_post_fixes() crashes with:
    UnicodeDecodeError: 'charmap' codec can't decode byte 0x98 in position XXXX: character maps to <undefined>
    
  3. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions