This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Make pwd module optional for wasm32-emscripten and wasi
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: christian.heimes Nosy List: christian.heimes, erlendaasland
Priority: normal Keywords: patch

Created on 2022-03-05 20:50 by christian.heimes, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 31700 merged christian.heimes, 2022-03-05 20:58
PR 31737 merged erlendaasland, 2022-03-07 21:38
Messages (3)
msg414595 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-03-05 20:50
WebAssembly platforms like wasm32-emscripten and wasm32-wasi don't have a typical user and group database.

WASI platform does not provide necessary API functions at all. Emscripten provides dummy stubs. On Emscripten the pwd module compiles, but is non-functional:

Python 3.11.0a4+ (heads/main-dirty:b1a3446, Jan 25 2022, 10:19:07) [Clang 14.0.0 ( f142c45f1e494f8dbdcc1bcf1412 on emscripten
Type "help", "copyright", "credits" or "license" for more information.
>>> import pwd, os
>>> os.getuid()
>>> pwd.getpwall()
>>> pwd.getpwuid(os.getuid())
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'getpwuid(): uid not found: 0'

I propose to make the pwd optional and catch import error in few places where the pwd module is used to look up user home directory.
msg414662 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-03-07 12:36
New changeset ca9689f8dac01d27e041e1dbbdae146746d48ab3 by Christian Heimes in branch 'main':
bpo-46933: Make pwd module optional (GH-31700)
msg414704 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2022-03-07 22:18
New changeset 47cca0492b3c379823d4bdb600be56a633e5bb88 by Erlend Egeberg Aasland in branch 'main':
bpo-46933: Fix make distclean regression (GH-31737)
Date User Action Args
2022-04-11 14:59:57adminsetgithub: 91089
2022-03-07 22:18:58christian.heimessetmessages: + msg414704
2022-03-07 21:38:46erlendaaslandsetnosy: + erlendaasland

pull_requests: + pull_request29854
2022-03-07 12:40:22christian.heimessetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2022-03-07 12:36:50christian.heimessetmessages: + msg414662
2022-03-05 20:58:28christian.heimessetkeywords: + patch
stage: patch review
pull_requests: + pull_request29820
2022-03-05 20:50:25christian.heimescreate