Description: fix self-exclusion of open-file detection under fakeroot
 get_files_open_for_writing() compared os.getuid() (goes through libc,
 faked by e.g. fakeroot's LD_PRELOAD) against psutil's per-process uid
 (read from /proc/<pid>/status, kernel-truth, unaffected by fakeroot).
 Under fakeroot this mismatches for every process, including our own, so
 the filter silently discarded everything and the function always
 returned {}. Get "my own uid" the same way psutil reports other
 processes' uids.
Bug-Debian: seen building 1.6.4-1 with `fakeroot debian/rules binary`
Forwarded: https://github.com/datalad/datalad/pull/7941 (more elaborate)
Last-Update: 2026-09-26
--- a/datalad/support/openfiles.py
+++ b/datalad/support/openfiles.py
@@ -90,7 +90,8 @@ def get_files_open_for_writing(
     # On Windows os.getuid() and psutil's 'uids' attr are unavailable,
     # so UID-based filtering is skipped and all processes are scanned.
     _have_uids = hasattr(os, 'getuid')
-    my_uid = os.getuid() if _have_uids else None
+    my_uid = (psutil.Process().uids().real if psutil else os.getuid()) \
+        if _have_uids else None
     n_procs = 0
     n_skipped_uid = 0
     # Cache lsof results per-pid so we call it at most once per process
