Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Space in windows username creates UnicodeDecodeError #1467

Open
pw-simon opened this issue Apr 6, 2023 · 1 comment
Open

Space in windows username creates UnicodeDecodeError #1467

pw-simon opened this issue Apr 6, 2023 · 1 comment
Labels
bug os:windows Windows-specific shell Shell related issues

Comments

@pw-simon
Copy link

pw-simon commented Apr 6, 2023

I freshly installed rez 2.112.0 with also fresh python 3.10.11.
When I run rez-env in the command line I get the following errors:

Exception in thread Thread-3 (_readerthread):
Traceback (most recent call last):
  File "C:\Python310\lib\threading.py", line 1016, in _bootstrap_inner
    self.run()
  File "C:\Python310\lib\threading.py", line 953, in run
    self._target(*self._args, **self._kwargs)
  File "C:\Python310\lib\subprocess.py", line 1515, in _readerthread
    buffer.append(fh.read())
  File "C:\Python310\lib\codecs.py", line 322, in decode
    (result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xa0 in position 124: invalid start byte
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\opt\rez\Scripts\rez\rez-env.exe\__main__.py", line 7, in <module>
  File "c:\opt\rez\lib\site-packages\rez\cli\_entry_points.py", line 148, in run_rez_env
    return run("env")
  File "c:\opt\rez\lib\site-packages\rez\cli\_main.py", line 191, in run
    returncode = run_cmd()
  File "c:\opt\rez\lib\site-packages\rez\cli\_main.py", line 183, in run_cmd
    return func(opts, opts.parser, extra_arg_groups)
  File "c:\opt\rez\lib\site-packages\rez\cli\env.py", line 251, in command
    returncode, _, _ = context.execute_shell(
  File "c:\opt\rez\lib\site-packages\rez\resolved_context.py", line 1045, in _check
    return fn(self, *nargs, **kwargs)
  File "c:\opt\rez\lib\site-packages\rez\resolved_context.py", line 1431, in execute_shell
    self._execute(executor)
  File "c:\opt\rez\lib\site-packages\rez\utils\memcached.py", line 271, in wrapper
    return func(*nargs, **kwargs)
  File "c:\opt\rez\lib\site-packages\rez\resolved_context.py", line 2121, in _execute
    executor.append_system_paths()
  File "c:\opt\rez\lib\site-packages\rez\rex.py", line 1341, in append_system_paths
    for path in sh.get_syspaths():
  File "c:\opt\rez\lib\site-packages\rezplugins\shell\cmd.py", line 87, in get_syspaths
    cls.syspaths = get_syspaths_from_registry()
  File "c:\opt\rez\lib\site-packages\rezplugins\shell\_utils\windows.py", line 103, in get_syspaths_from_registry
    out_ = out_.strip()
AttributeError: 'NoneType' object has no attribute 'strip'

Printing out the entry variable I get this:
{'cmd': ['REG', 'QUERY', 'HKCU\\Environment', '/v', 'PATH'], 'expected': 'HKEY_CURRENT_USER\\\\Environment[\\s]+PATH[\\s]+REG_(EXPAND_)?SZ[\\s]+(.*)'}
If I'm not mistaken, the error comes from the fact, that my Windows username (HKEY_CURRENT_USER) contains a space character (0xa0, NBSP), which then generates the UnicodeDecodeError, which then goes on and creates the AttributeError.

I might also add, that this is not a custom made or renamed folder. This was made by Windows by default, so I think this issue might affect more people.

Environment

  • OS: Windows 10
  • Rez version: 2.112.0
  • Rez python version: 3.10.11

To Reproduce

  1. Have a space character in the current windows user's name
  2. Start a cmd
  3. Run rez-env

Expected behavior
Starting a new rez-env.

Actual behavior
Error as seen above.

@pw-simon pw-simon added the bug label Apr 6, 2023
@JeanChristopheMorinPerso JeanChristopheMorinPerso added os:windows Windows-specific shell Shell related issues labels Apr 6, 2023
@JeanChristopheMorinPerso
Copy link
Member

To me the error says it all. That type of space is not supported. Of I'm not mistaken, 0xa0 is a non standard space right? @instinct-vfx any opinion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug os:windows Windows-specific shell Shell related issues
Projects
None yet
Development

No branches or pull requests

2 participants