bpo-31904: Fix site and sysconfig modules for VxWorks RTOS by pxinwr · Pull Request #21821 · python/cpython (original) (raw)

What does os.path.expanduser('~') return on VxWorks?

It depends on whether user management feature is enabled or not on VxWorks. By default this feature is disabled. And expanduser() will encounter KeyError then returning the unchanged path. If user management feature is enabled, the pw_dir attribute will be None so that expanduser() will raise exception. So I created PR 23530 to fix this.

Instead of changing sysconfig and site, maybe posixpath.expanduser() could get a special case to return sys.prefix?

Looks sys.prefix is for system-wide settings whereas the return value of posixpath.expanduser() is used for user specific settings. If we return sys.prefix from posixpath.expanduser(), any chance things get mixed up to mess? Now I get stuck on which one, None or sys.prefix should be returned for user base and user site. What is your idea? If determined to None, ENABLE_USER_SITE should also be set to False. Since sys.prefix has been added to sys.path, so setting user base to None has no impact on sys.path.