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

Document that os.environ forcibly upper-cases keys on case-insensitive OSs #101754

Closed
brettcannon opened this issue Feb 9, 2023 · 4 comments · Fixed by #101840
Closed

Document that os.environ forcibly upper-cases keys on case-insensitive OSs #101754

brettcannon opened this issue Feb 9, 2023 · 4 comments · Fixed by #101840
Labels
docs Documentation in the Doc dir

Comments

@brettcannon
Copy link
Member

brettcannon commented Feb 9, 2023

Documentation

os.environ docs don't mention that the keys get upper-cased automatically on e.g. Windows.

Linked PRs

@brettcannon brettcannon added the docs Documentation in the Doc dir label Feb 9, 2023
@brettcannon
Copy link
Member Author

This came up when using Python to read the environment then trying to merge the results with Node's environment variable APIs which do not normalize.

@karrtikr
Copy link

karrtikr commented Feb 9, 2023

Source code:

return encode(key).upper()

@eryksun
Copy link
Contributor

eryksun commented Feb 9, 2023

Note that it wouldn't be hard to make os.environ case insensitive but case preserving, starting with Python 3.12 or 3.13. I discussed a possible implementation in issue #73010.

@OTheDev
Copy link
Contributor

OTheDev commented Feb 11, 2023

Thoughts on the following (third note) suggested fix?

fix

EDIT: on second thought, I think I prefer

fix3

miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 3, 2023
…to uppercase (pythonGH-101840)

(cherry picked from commit 4e7c0cb)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this issue Mar 3, 2023
…to uppercase (pythonGH-101840)

(cherry picked from commit 4e7c0cb)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
miss-islington added a commit that referenced this issue Mar 3, 2023
…ercase (GH-101840)

(cherry picked from commit 4e7c0cb)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
miss-islington added a commit that referenced this issue Mar 3, 2023
…ercase (GH-101840)

(cherry picked from commit 4e7c0cb)

Co-authored-by: Owain Davies <116417456+OTheDev@users.noreply.github.com>
carljm added a commit to carljm/cpython that referenced this issue Mar 4, 2023
* main:
  pythongh-102021 : Allow multiple input files for interpreter loop generator (python#102022)
  Add import of `unittest.mock.Mock` in documentation (python#102346)
  pythongh-102383: [docs] Arguments of `PyObject_CopyData` are `PyObject *` (python#102390)
  pythongh-101754: Document that Windows converts keys in `os.environ` to uppercase (pythonGH-101840)
  pythongh-102324: Improve tests of `typing.override` (python#102325)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants