Skip to content

Commit 0613717

Browse files
[3.14] gh-142836: Avoid /proc fd pipes on Solaris (GH-142853) (#142854)
gh-142836: Avoid /proc fd pipes on Solaris (GH-142853) (cherry picked from commit c35b812) Co-authored-by: Jason R. Coombs <[email protected]>
1 parent eb1284e commit 0613717

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

Lib/test/test_pdb.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3563,10 +3563,22 @@ def _assert_find_function(self, file_content, func_name, expected):
35633563

35643564
def _fd_dir_for_pipe_targets(self):
35653565
"""Return a directory exposing live file descriptors, if any."""
3566+
return self._proc_fd_dir() or self._dev_fd_dir()
3567+
3568+
def _proc_fd_dir(self):
3569+
"""Return /proc-backed fd dir when it can be used for pipes."""
3570+
# GH-142836: Opening /proc/self/fd entries for pipes raises EACCES on
3571+
# Solaris, so prefer other mechanisms there.
3572+
if sys.platform.startswith("sunos"):
3573+
return None
3574+
35663575
proc_fd = "/proc/self/fd"
35673576
if os.path.isdir(proc_fd) and os.path.exists(os.path.join(proc_fd, '0')):
35683577
return proc_fd
3578+
return None
35693579

3580+
def _dev_fd_dir(self):
3581+
"""Return /dev-backed fd dir when usable."""
35703582
dev_fd = "/dev/fd"
35713583
if os.path.isdir(dev_fd) and os.path.exists(os.path.join(dev_fd, '0')):
35723584
if sys.platform.startswith("freebsd"):
@@ -3576,7 +3588,6 @@ def _fd_dir_for_pipe_targets(self):
35763588
except FileNotFoundError:
35773589
return None
35783590
return dev_fd
3579-
35803591
return None
35813592

35823593
def test_find_function_empty_file(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Accommodated Solaris in ``test_pdb.test_script_target_anonymous_pipe``.

0 commit comments

Comments
 (0)