Skip to content

gh-87595: mmap.size() now returns the size on Unix for anonymous memory#24781

Merged
serhiy-storchaka merged 8 commits into
python:mainfrom
ZackerySpytz:bpo-43429-mmap-size-platforms
Sep 2, 2025
Merged

gh-87595: mmap.size() now returns the size on Unix for anonymous memory#24781
serhiy-storchaka merged 8 commits into
python:mainfrom
ZackerySpytz:bpo-43429-mmap-size-platforms

Conversation

@ZackerySpytz

@ZackerySpytz ZackerySpytz commented Mar 7, 2021

Copy link
Copy Markdown
Contributor

Previously, the size would be returned on Windows and an OSError would
be raised on Unix.

https://bugs.python.org/issue43429

Previously, the size would be returned on Windows and an OSError would
be raised on Unix.
@github-actions

github-actions Bot commented Apr 7, 2021

Copy link
Copy Markdown

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 7, 2021
@github-actions github-actions Bot removed the stale Stale PR or inactive for long period of time. label Aug 5, 2022

@furkanonder furkanonder left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. @ZackerySpytz Could you resolve the conflicts?

@arhadthedev arhadthedev changed the title bpo-43429: mmap.size() now returns the size on Unix for anonymous memory gh-87595: mmap.size() now returns the size on Unix for anonymous memory May 12, 2023
@arhadthedev

Copy link
Copy Markdown
Member

Marking as needs backport to 3.11 because the parent issue is marked as type-bug An unexpected behavior, bug, or error .

@arhadthedev arhadthedev added the needs backport to 3.11 only security fixes label May 12, 2023
Comment thread Doc/library/mmap.rst
@serhiy-storchaka

serhiy-storchaka commented Aug 29, 2025

Copy link
Copy Markdown
Member

@ZackerySpytz, could you please update your PR to 3.15? It should take into account trackfd, like in #138198.

@vstinner

vstinner commented Sep 2, 2025

Copy link
Copy Markdown
Member

I'm not sure that @ZackerySpytz is still active. Maybe a new PR should be written?

@serhiy-storchaka serhiy-storchaka merged commit 32032ee into python:main Sep 2, 2025
45 checks passed
@miss-islington-app

Copy link
Copy Markdown

Thanks @ZackerySpytz for the PR, and @serhiy-storchaka for merging it 🌮🎉.. I'm working now to backport this PR to: 3.13, 3.14.
🐍🍒⛏🤖

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 2, 2025
…thonGH-24781)

Previously, the size would be returned on Windows and an OSError would
be raised on Unix.

Also, raise ValueError instead of OSError for trackfd=False.
(cherry picked from commit 32032ee)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Sep 2, 2025
…thonGH-24781)

Previously, the size would be returned on Windows and an OSError would
be raised on Unix.

Also, raise ValueError instead of OSError for trackfd=False.
(cherry picked from commit 32032ee)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
@bedevere-app

bedevere-app Bot commented Sep 2, 2025

Copy link
Copy Markdown

GH-138404 is a backport of this pull request to the 3.14 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.14 bugs and security fixes label Sep 2, 2025
@bedevere-app

bedevere-app Bot commented Sep 2, 2025

Copy link
Copy Markdown

GH-138405 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app Bot removed the needs backport to 3.13 bugs and security fixes label Sep 2, 2025

@ZackerySpytz ZackerySpytz left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello, @serhiy-storchaka. We must modify some of the changes you have made to this PR.

Comment thread Doc/library/mmap.rst

Return the length of the file, which can be larger than the size of the
memory-mapped area.
For anonymous mapping, return its size.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For anonymous mapping, return its size.
For an anonymous mapping, return its size.

Comment thread Doc/library/mmap.rst
For anonymous mapping, return its size.

.. versionchanged:: next
Supports anonymous mapping on Unix.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Supports anonymous mapping on Unix.
Anonymous mappings are now supported on Unix.

Comment on lines +4 to +5
would be raised on Unix.
Raise :exc:`ValueError` instead of :exc:`OSError` with ``trackfd=False``.

@ZackerySpytz ZackerySpytz Sep 2, 2025

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
would be raised on Unix.
Raise :exc:`ValueError` instead of :exc:`OSError` with ``trackfd=False``.
would be raised on Unix. :exc:`ValueError` is now raised instead of
:exc:`OSError` when ``trackfd=False``.

@AA-Turner

Copy link
Copy Markdown
Member

@ZackerySpytz this has been merged, please would you open a new PR?

@ZackerySpytz

Copy link
Copy Markdown
Contributor Author

I'm well aware that this PR has been merged, thank you very much.

@ZackerySpytz

Copy link
Copy Markdown
Contributor Author

@serhiy-storchaka I have created GH-138494.

lkollar pushed a commit to lkollar/cpython that referenced this pull request Sep 9, 2025
…thonGH-24781)

Previously, the size would be returned on Windows and an OSError would
be raised on Unix.

Also, raise ValueError instead of OSError for trackfd=False.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.