Comments (6)
I don't think such meta codecs are a good idea, since their meaning depends on the local configuration of the app running the code and can thus behave in undefined ways. The "mbcs" codec we have is similar and has issues, since you don't know what the actual encoding will be. The codec is needed because the Windows C API uses this meta encoding, but it's not ideal.
In the above use case, it's better to use a fixed default encoding such as "utf-8".
You can see that the io sub-system also doesn't use "locale" as encoding, but instead seems to go out to the os.environ
to figure out what the locale settings are and then uses whatever this returns for the actual encoding ("utf-8" in case of the example).
PS: In the early days of Python 2 we experimented with using a locale based default encoding and quickly dropped that idea. Explicit is better than implicit...
from cpython.
Confirmed in main branch. I'm not sure we need to keep the same behavior for the encoding field in open
and codecs.open
API. CC @Eclips4
from cpython.
3.11 is already in security-only mode. Bug fixes can only be applied for 3.12+.
from cpython.
io.text_encoding()
was added in 3.10, and the behavior was the same as in 3.11.
So this is rather a new feature request.
from cpython.
@serhiy-storchaka May I take handle of this feature request if we confirm this is necessary?
from cpython.
@malemburg, what do you think about support of encoding='locale'
in codecs
streams?
from cpython.
Related Issues (20)
- `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 5
- `__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
- Inconsistent behavior of `asyncio.Server.wait_closed` in Python 3.12 versus earlier releases HOT 1
- How does Python's Binascii.a2b_base64 (base64.b64decode) work? HOT 1
- 3.12.4 breaks`logging.config.DictConfig` with `logging.handlers.QueueHandler` on read-only file systems
- Add tests for new Tk widget options
- [RFE] `fields` and `time_*` properties must not be used on UUIDs that are time-agnostic. HOT 6
- [C API] Add PyObject_VectorcallDict() to the limited C API HOT 1
- shutil's move function fails to handle files opened by another process
- Texto HOT 4
- Intel vPro® Platform TEI Study by Forrester
- Bump the bundled pip version to 24.1.x
- Git for Administrators - MoodleDocs HOT 2
- V20.14.0 HOT 1
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.