Comments (4)
The more important bug (perhaps already filed separately?) is import site in a ._pth file also including user site packages. The only reasonable workaround is to add sys.path.append(site.getusersitepackages()) but it seems fairly reasonable given the context.
I haven't raised a separate issue for this but sounds like I should. I'll also send a patch alongside.
Edit. Raised #120037
from cpython.
The most relevant part of the discussion that relates to this bug:
It seems you uncovered a bug in “Modules/getpath.py”. It’s not supposed to add the default module search path from the “PythonPath” registry key if the standard library was found already. However, the code is only checking the variables home and stdlib_dir, which aren’t set if the standard library was found in a zip file such as “python311.zip”. A variable needs to be defined when the standard library was found as a zip file, which can be included in the check that determines whether to fetch the default search path from the registry.
from cpython.
It looks like your entire workaround is to add the path you do want into sys.path
(i.e. keep the ._pth
file), rather than trying to remove the ones you don't want.
Personally, I really dislike the reliance on registry keys for finding the install. Unfortunately, it broke too many people to turn it off (i.e. don't install the default keys). I seem to recall that we also broke people when we accidentally turned it off in an earlier version of 3.11.
In any case, getpath.py
is much easier to change than before. Anyone is welcome to submit a PR. If the detection is clear enough, we can probably backport the fix to maintenance releases.
The more important bug (perhaps already filed separately?) is import site
in a ._pth
file also including user site packages. The only reasonable workaround is to add sys.path.append(site.getusersitepackages())
but it seems fairly reasonable given the context.
from cpython.
I'll also send a patch alongside.
I don't think you've contributed before? The basic idea is to send a PR against main
and then we'll worry about backporting it to earlier releases. There's more info at devguide.python.org.
The changes for this one should be entirely in Modules/getpath.py
. The other is probably a bit more complex - I don't remember whether the flag for no user site packages can be set from getpath.py.
from cpython.
Related Issues (20)
- Security branches: Consider fixing the documentation or adding a notice banner HOT 1
- New REPL omits local variables when running ./python -i script.py HOT 2
- importlib.metadata test fixtures should prefer test.support fixtures
- Lacking description of how to correctly implement indexing syntax support.
- Rewrite asyncio subprocesses without child watchers
- Unpickling Exceptions with keyword arguments in multiprocessing throws an error HOT 12
- Reference leak in `_contextvars.Context.run()`
- Allow one to use build.bat to skip building test project files entirely. HOT 4
- CANT FIND THE FUCKING DOWNLOAD BUTTON HOT 2
- Typo in the documentation of the `cmd` parameter of `ftplib.FTP.retrbinary()` HOT 1
- ios buildbot failure: `enclose 'sqlite3_create_window_function' in a __builtin_available check to silence this warning` HOT 1
- generator frame type should not be PyObject*[]
- `subprocess.run` docs should recommend copying `os.environ` on Windows HOT 3
- `faulthandler` itself crashes in free-threading build (in `_Py_DumpExtensionModules`)
- Some Runtime Finalization Constraints Are Not Enforced Nor Documented
- asyncio REPL fails to run with TERM=dumb or PYTHON_BASIC_REPL in 3.13.0b2 HOT 1
- `__module__` is not defined, seeming to contradict the Python Data Model. HOT 13
- `PyDict_Next` should not lock the dict
- `type_setattro` error return paths contain bugs
- Simplify chained comparison HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cpython.