Skip to content

Commit 8b70bb6

Browse files
[8.0.x] Catch OSError from getpass.getuser() (#11876)
Co-authored-by: Russell Martin <[email protected]>
1 parent 169d775 commit 8b70bb6

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,7 @@ Ronny Pfannschmidt
338338
Ross Lawley
339339
Ruaridh Williamson
340340
Russel Winder
341+
Russell Martin
341342
Ryan Puddephatt
342343
Ryan Wooden
343344
Sadra Barikbin

changelog/11875.bugfix.rst

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Correctly handle errors from :func:`getpass.getuser` in Python 3.13.

src/_pytest/tmpdir.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ def get_user() -> Optional[str]:
203203
import getpass
204204

205205
return getpass.getuser()
206-
except (ImportError, KeyError):
206+
except (ImportError, OSError, KeyError):
207207
return None
208208

209209

0 commit comments

Comments
 (0)