[Python-checkins] cpython (merge 3.4 -> default): The webbrowser module now uses subprocess's start_new_session=True rather

gregory.p.smith python-checkins at python.org
Wed Aug 27 18:41:21 CEST 2014


http://hg.python.org/cpython/rev/fb3aee1cff59
changeset: 92254:fb3aee1cff59
parent: 92252:f5f5553f219e
parent: 92253:a48ef19911ea
user: Gregory P. Smith <greg at krypto.org>
date: Wed Aug 27 09:41:05 2014 -0700
summary:
 The webbrowser module now uses subprocess's start_new_session=True rather
than a potentially risky preexec_fn=os.setsid call.
files:
 Lib/webbrowser.py | 15 ++++-----------
 Misc/NEWS | 3 +++
 2 files changed, 7 insertions(+), 11 deletions(-)
diff --git a/Lib/webbrowser.py b/Lib/webbrowser.py
--- a/Lib/webbrowser.py
+++ b/Lib/webbrowser.py
@@ -159,10 +159,8 @@
 if sys.platform[:3] == 'win':
 p = subprocess.Popen(cmdline)
 else:
- setsid = getattr(os, 'setsid', None)
- if not setsid:
- setsid = getattr(os, 'setpgrp', None)
- p = subprocess.Popen(cmdline, close_fds=True, preexec_fn=setsid)
+ p = subprocess.Popen(cmdline, close_fds=True,
+ start_new_session=True)
 return (p.poll() is None)
 except OSError:
 return False
@@ -321,11 +319,6 @@
 action = "openURL"
 
 devnull = subprocess.DEVNULL
- # if possible, put browser in separate process group, so
- # keyboard interrupts don't affect browser as well as Python
- setsid = getattr(os, 'setsid', None)
- if not setsid:
- setsid = getattr(os, 'setpgrp', None)
 
 try:
 p = subprocess.Popen(["kfmclient", action, url],
@@ -343,7 +336,7 @@
 p = subprocess.Popen(["konqueror", "--silent", url],
 close_fds=True, stdin=devnull,
 stdout=devnull, stderr=devnull,
- preexec_fn=setsid)
+ start_new_session=True)
 except OSError:
 # fall through to next variant
 pass
@@ -356,7 +349,7 @@
 p = subprocess.Popen(["kfm", "-d", url],
 close_fds=True, stdin=devnull,
 stdout=devnull, stderr=devnull,
- preexec_fn=setsid)
+ start_new_session=True)
 except OSError:
 return False
 else:
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -124,6 +124,9 @@
 Library
 -------
 
+- The webbrowser module now uses subprocess's start_new_session=True rather
+ than a potentially risky preexec_fn=os.setsid call.
+
 - Issue #22042: signal.set_wakeup_fd(fd) now raises an exception if the file
 descriptor is in blocking mode.
 
-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /