Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

PyConfig.stdlib_dir does not affectsys._stdlib_dir #106718

Closed
Assignees
ncoghlanzooba
Labels
3.11only security fixes3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error
@Yhg1s

Description

@Yhg1s

In Python 3.11, PyConfig gained astdlib_dir attribute which is, as far as I can tell, supposed to overridesys._stdlib_dir (which is used by importlib). No matter what I set it to or what else I set, however, it seems to be ignored. For example:

#include<Python.h>#include<stdio.h>externwchar_t*_Py_GetStdlibDir(void);intmain(intargc,char**argv){PyStatusstatus;PyConfigconfig;PyConfig_InitPythonConfig(&config);PyConfig_SetString(&config,&config.stdlib_dir,L"/my/stdlib/dir");Py_InitializeFromConfig(&config);if (PyStatus_Exception(status)) {Py_ExitStatusException(status);    }PyConfig_Clear(&config);fprintf(stderr,"stdlib_dir = '%ls'\n",_Py_GetStdlibDir());Py_Finalize();}
% gcc -Wall$(/python/3.12-opt/bin/python3-config --cflags) -o testprogram testprogram.c$(/python/3.12-opt/bin/python3-config --ldflags) -lpython3.12# Look ma, no warnings.% ./testprogramstdlib_dir ='/python/3.12-opt/lib/python3.12'

It doesn't seem to matter whetherPyConfig.stdlib_dir is set to an existing directory either (although for my use-case, it must be a non-existant one; we're getting the stdlib from embedded data, and the incorrect setting ofsys._stdlib_dir means importlib'sFrozenImporter sets the wrong__file__ attribute on frozen/deepfrozen modules, likeos.)

Linked PRs

Metadata

Metadata

Assignees

Labels

3.11only security fixes3.12only security fixes3.13bugs and security fixestype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp