GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — gh-134587: Suggest fix for tempfile.mkdtemp() in Windows AppContainer by vedant713 · Pull Request #134607 · python/cpython

Conversation

@vedant713

@vedant713 vedant713 commented May 24, 2025 •
edited by bedevere-app Bot
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown

Proposed Solution

  • Detect whether the process is running inside an AppContainer.
  • Retrieve the AppContainer SID using whoami /user.
  • Use icacls to grant Full Control access to that SID for the created directory.

Suggested Helper Functions

if _os.name == 'nt':
    import ctypes as _ctypes
    import ctypes.wintypes as _wintypes
    import subprocess as _subprocess

    def _is_appcontainer():
        TOKEN_QUERY = 0x0008
        TokenIsAppContainer = 29
        h_token = _wintypes.HANDLE()
        if not _ctypes.windll.advapi32.OpenProcessToken(
            _ctypes.windll.kernel32.GetCurrentProcess(),
            TOKEN_QUERY,
            _ctypes.byref(h_token)
        ):
            return False

        is_container = _wintypes.BOOL()
        return_length = _wintypes.DWORD()
        if not _ctypes.windll.advapi32.GetTokenInformation(
            h_token,
            TokenIsAppContainer,
            _ctypes.byref(is_container),
            _ctypes.sizeof(is_container),
            _ctypes.byref(return_length)
        ):
            return False

        return bool(is_container.value)

    def _grant_appcontainer_access(path):
        try:
            sid = _subprocess.check_output("whoami /user", shell=True)
            sid_str = sid.decode().splitlines()[1].split()[1]
            _subprocess.run(f'icacls \"{path}\" /grant *{sid_str}:(OI)(CI)F', shell=True, check=True)
        except Exception:
            pass
  • Issue: mkdtemp() created directories no longer allows for writing files when running under a Windows AppContainer in 3.12.4 (but works under 3.12.3) #134587

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
vedant713 added 10 commits May 17, 2025 16:01
@vedant713
Add files via upload
63af523
@vedant713
Merge branch 'python:main' into main
01bb6a8
@vedant713
Delete Misc/NEWS.d/next/Core_and_Builtins/2025-05-17-16-45-00.gh-issu…
660e3fa
…e-134070.vdhoke.rst
@vedant713
pythongh-134070: Fix mi_clz32/mi_ctz32 to prevent out-of-bounds read (p…
960e266
…ythonGH-134149)
@vedant713
2025-05-17-16-45-00.gh-issue-134070.vdhoke.rst
e127bd4
@vedant713
2025-05-17-16-45-00.gh-issue-134070.vdhoke.rst
f52a881
@vedant713
pythongh-134070: Add news entry for mi_clz32/mi_ctz32 out-of-bounds fix
eb1f908
@vedant713
2025-05-17-16-45-00.gh-issue-134070.vdhoke.rst
cbdb9b5
@vedant713
2025-05-17-16-45-00.gh-issue-134070.vdhoke.rst
31ae4fa
@vedant713
Create placeholder for mkdtemp AppContainer fix
0d2b415
@bedevere-app bedevere-app Bot mentioned this pull request May 24, 2025
mkdtemp() created directories no longer allows for writing files when running under a Windows AppContainer in 3.12.4 (but works under 3.12.3) #134587
Open
@github-actions

github-actions Bot commented Apr 25, 2026

Copy link
Copy Markdown

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot added the stale Stale PR or inactive for long period of time. label Apr 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

No reviews

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

stale Stale PR or inactive for long period of time.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

1 participant

@vedant713
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.