Skip to content

gh-71199: Name posixmodule types os.<type> on every platform - #161461

Merged
cmaloney merged 3 commits into
python:mainfrom
cmaloney:gh-71199-os-result-names
Nov 6, 2026
Merged

cmaloney merged 3 commits into
python:mainfrom
cmaloney:gh-71199-os-result-names

Conversation

@cmaloney

@cmaloney cmaloney commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

These share code across platforms when present on multiple. Add a pickle test to keep both the platform-specific fully qualified version and the os. name loadable.

cmaloney and others added 2 commits November 5, 2026 21:54
…odule

Pickles name posixmodule types and functions either through os or
through the platform module (posix or nt).  Both spellings must keep
loading.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
times_result, uname_result, waitid_result, sched_param, DirEntry and
ScandirIterator were named after the platform module (posix or nt), so
pickles referenced posix.times_result and could not be loaded on
Windows.  Name them os.<type> like stat_result (pythongh-63408).  Older
pickles keep loading through the platform module.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bedevere-app bedevere-app Bot added awaiting core review type-feature A feature request or enhancement labels Nov 6, 2026
…N4cV.rst

Co-authored-by: Stan Ulbrych <stan@python.org>
@cmaloney
cmaloney merged commit d900c8f into python:main Nov 6, 2026
56 checks passed
@cmaloney
cmaloney deleted the gh-71199-os-result-names branch November 6, 2026 19:05
@vstinner

vstinner commented Nov 6, 2026

Copy link
Copy Markdown
Member

Nice change! I wanted to make it for a few years :-) Good that you did it!

Add a pickle test to keep both the platform-specific fully qualified version and the os. name loadable.

Oh! I didn't make the change since I was worried about breaking pickle. But I tested manually and "it just works"! Types can be get from the old "posix" name or from the new "os" name:

$ ./python
>>> import posix, os
>>> posix.DirEntry
<class 'os.DirEntry'>
>>> os.DirEntry
<class 'os.DirEntry'>

@cmaloney

cmaloney commented Nov 6, 2026

Copy link
Copy Markdown
Contributor Author

Yea, pickle actually still uses the posx. when pickling after this commit which it gets from os.DirEntry.__module__. That changes in the next PR :)

(although currently I'm spending way too much time trying to get a clearing on locale change and not leaking cache dict working)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants