Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3d613796
Commit
3d613796
authored
Apr 25, 2010
by
Brett Cannon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert an accidental commit from r80492.
parent
1994969c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
36 deletions
+17
-36
Lib/subprocess.py
Lib/subprocess.py
+17
-36
No files found.
Lib/subprocess.py
View file @
3d613796
...
@@ -413,6 +413,7 @@ class CalledProcessError(Exception):
...
@@ -413,6 +413,7 @@ class CalledProcessError(Exception):
if
mswindows
:
if
mswindows
:
from
_subprocess
import
CREATE_NEW_CONSOLE
,
CREATE_NEW_PROCESS_GROUP
import
threading
import
threading
import
msvcrt
import
msvcrt
import
_subprocess
import
_subprocess
...
@@ -441,7 +442,6 @@ __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call",
...
@@ -441,7 +442,6 @@ __all__ = ["Popen", "PIPE", "STDOUT", "call", "check_call",
"check_output"
,
"CalledProcessError"
]
"check_output"
,
"CalledProcessError"
]
if
mswindows
:
if
mswindows
:
from
_subprocess
import
CREATE_NEW_CONSOLE
,
CREATE_NEW_PROCESS_GROUP
__all__
.
extend
([
"CREATE_NEW_CONSOLE"
,
"CREATE_NEW_PROCESS_GROUP"
])
__all__
.
extend
([
"CREATE_NEW_CONSOLE"
,
"CREATE_NEW_PROCESS_GROUP"
])
try
:
try
:
MAXFD
=
os
.
sysconf
(
"SC_OPEN_MAX"
)
MAXFD
=
os
.
sysconf
(
"SC_OPEN_MAX"
)
...
@@ -699,12 +699,12 @@ class Popen(object):
...
@@ -699,12 +699,12 @@ class Popen(object):
return
data
return
data
def
__del__
(
self
,
_maxint
=
sys
.
maxint
):
def
__del__
(
self
,
sys
=
sys
):
if
not
self
.
_child_created
:
if
not
self
.
_child_created
:
# We didn't get to successfully create a child process.
# We didn't get to successfully create a child process.
return
return
# In case the child hasn't been waited on, check if it's done.
# In case the child hasn't been waited on, check if it's done.
self
.
_internal_poll
(
_deadstate
=
_
maxint
)
self
.
_internal_poll
(
_deadstate
=
sys
.
maxint
)
if
self
.
returncode
is
None
and
_active
is
not
None
:
if
self
.
returncode
is
None
and
_active
is
not
None
:
# Child is still running, keep us alive until we can wait on it.
# Child is still running, keep us alive until we can wait on it.
_active
.
append
(
self
)
_active
.
append
(
self
)
...
@@ -907,20 +907,13 @@ class Popen(object):
...
@@ -907,20 +907,13 @@ class Popen(object):
errwrite
.
Close
()
errwrite
.
Close
()
def
_internal_poll
(
self
,
_deadstate
=
None
,
def
_internal_poll
(
self
,
_deadstate
=
None
):
_WaitForSingleObject
=
WaitForSingleObject
,
_WAIT_OBJECT_0
=
WAIT_OBJECT_0
,
_GetExitCodeProcess
=
GetExitCodeProcess
):
"""Check if child process has terminated. Returns returncode
"""Check if child process has terminated. Returns returncode
attribute.
attribute."""
This method is called by __del__, so it can only refer to objects
in its local scope.
"""
if
self
.
returncode
is
None
:
if
self
.
returncode
is
None
:
if
_WaitForSingleObject
(
self
.
_handle
,
0
)
==
_WAIT_OBJECT_0
:
if
(
_subprocess
.
WaitForSingleObject
(
self
.
_handle
,
0
)
==
self
.
returncode
=
_GetExitCodeProcess
(
self
.
_handle
)
_subprocess
.
WAIT_OBJECT_0
):
self
.
returncode
=
_subprocess
.
GetExitCodeProcess
(
self
.
_handle
)
return
self
.
returncode
return
self
.
returncode
...
@@ -1201,37 +1194,25 @@ class Popen(object):
...
@@ -1201,37 +1194,25 @@ class Popen(object):
raise
child_exception
raise
child_exception
def
_handle_exitstatus
(
self
,
sts
,
_WIFSIGNALED
=
os
.
WIFSIGNALED
,
def
_handle_exitstatus
(
self
,
sts
):
_WTERMSIG
=
os
.
WTERMSIG
,
_WIFEXITED
=
os
.
WIFEXITED
,
if
os
.
WIFSIGNALED
(
sts
):
_WEXITSTATUS
=
os
.
WEXITSTATUS
):
self
.
returncode
=
-
os
.
WTERMSIG
(
sts
)
"""
elif
os
.
WIFEXITED
(
sts
):
self
.
returncode
=
os
.
WEXITSTATUS
(
sts
)
This method is called (indirectly) by __del__, so it cannot
refer to anything outside of its local scope."""
if
_WIFSIGNALED
(
sts
):
self
.
returncode
=
-
_WTERMSIG
(
sts
)
elif
_WIFEXITED
(
sts
):
self
.
returncode
=
_WEXITSTATUS
(
sts
)
else
:
else
:
# Should never happen
# Should never happen
raise
RuntimeError
(
"Unknown child exit status!"
)
raise
RuntimeError
(
"Unknown child exit status!"
)
def
_internal_poll
(
self
,
_deadstate
=
None
,
_waitpid
=
os
.
waitpid
,
def
_internal_poll
(
self
,
_deadstate
=
None
):
_WNOHANG
=
os
.
WNOHANG
,
_os_error
=
os
.
error
):
"""Check if child process has terminated. Returns returncode
"""Check if child process has terminated. Returns returncode
attribute.
attribute."""
This method is called by __del__, so it cannot reference anything
outside of the local scope (nor can any methods it calls).
"""
if
self
.
returncode
is
None
:
if
self
.
returncode
is
None
:
try
:
try
:
pid
,
sts
=
_waitpid
(
self
.
pid
,
_
WNOHANG
)
pid
,
sts
=
os
.
waitpid
(
self
.
pid
,
os
.
WNOHANG
)
if
pid
==
self
.
pid
:
if
pid
==
self
.
pid
:
self
.
_handle_exitstatus
(
sts
)
self
.
_handle_exitstatus
(
sts
)
except
_os_
error
:
except
os
.
error
:
if
_deadstate
is
not
None
:
if
_deadstate
is
not
None
:
self
.
returncode
=
_deadstate
self
.
returncode
=
_deadstate
return
self
.
returncode
return
self
.
returncode
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment