Change os.getuid() guard in tmpdir.py

This matches the guard used by typeshed and avoid mypy errors on Windows:

48a346920b/stdlib/os/__init__.pyi (L388)
This commit is contained in:
Bruno Oliveira 2021-06-12 12:10:34 -03:00
parent c85b21eaa0
commit 16685dc279
1 changed files with 3 additions and 2 deletions

View File

@ -1,6 +1,7 @@
"""Support for providing temporary directories to test functions.""" """Support for providing temporary directories to test functions."""
import os import os
import re import re
import sys
import tempfile import tempfile
from pathlib import Path from pathlib import Path
from typing import Optional from typing import Optional
@ -130,9 +131,9 @@ class TempPathFactory:
# Also, to keep things private, fixup any world-readable temp # Also, to keep things private, fixup any world-readable temp
# rootdir's permissions. Historically 0o755 was used, so we can't # rootdir's permissions. Historically 0o755 was used, so we can't
# just error out on this, at least for a while. # just error out on this, at least for a while.
if hasattr(os, "getuid"): if sys.platform != "win32":
rootdir_stat = rootdir.stat()
uid = os.getuid() uid = os.getuid()
rootdir_stat = rootdir.stat()
# getuid shouldn't fail, but cpython defines such a case. # getuid shouldn't fail, but cpython defines such a case.
# Let's hope for the best. # Let's hope for the best.
if uid != -1: if uid != -1: