WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
229824
[webkitpy] WrappedPopen breaks process returncode
https://bugs.webkit.org/show_bug.cgi?id=229824
Summary
[webkitpy] WrappedPopen breaks process returncode
Carlos Alberto Lopez Perez
Reported
2021-09-02 12:42:43 PDT
The class WrappedPopen() was added in
r250375
to wrap the subprocess.Popen() for making the python2 subprocess.Popen() objects more similar to the ones from python3. But the way this class wraps the objects makes breaks the process returncode if the process doesn't return immediately. This is because WrappedPopen() defines a new class the sets functions with the same name than subprocess.Popen() setting the value returned to the one that returns subprocess.Popen(). But in the case of subprocess.Popen().returncode that is not a function, but a string that will change of value when the process ends. If we evaluate this function before we call subprocess.Popen().communicate() or subprocess.Popen().wait() then the value of returncode will be None This can be checked with this following test program:
http://sprunge.us/aoxZ0j
If you run it with python2 you get "The call return code is None" instead of getting "The call return code is 2" which is what it should be (what happens when you run it with python3 which don't triggers the call to use WrappedPopen()) I have observed this when working on
bug 229758
.. with python2 the call from host.executive.popen() always returned a returncode of None This is not an issue for subprocess.Popen().stdout and subprocess.Popen().stderr because if you look at what prints the debug function on that example for this cases it sets the value to a descriptor rather than reading from the descriptor. So when the call to read from the descriptor is done it will work. Example, you see this: setting attribute .. stdout to <open file '<fdopen>', mode 'rb' at 0x7fe12cc1d540> setting attribute .. returncode to None
Attachments
Patch
(1.67 KB, patch)
2021-09-02 12:55 PDT
,
Jonathan Bedard
no flags
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
Jonathan Bedard
Comment 1
2021-09-02 12:55:48 PDT
Created
attachment 437186
[details]
Patch
Jonathan Bedard
Comment 2
2021-09-02 12:56:37 PDT
(In reply to Jonathan Bedard from
comment #1
)
> Created
attachment 437186
[details]
> Patch
I suspect this will fix the problem, although I'm a bit unclear which script can cause this.
Carlos Alberto Lopez Perez
Comment 3
2021-09-02 13:25:20 PDT
This fixes it indeed, thanks. I was trying here to instead of wrapping the object to add the __exit__ and __enter__ methods to the Popen class directly, but for some unknown reason then when you try to use the usual "with popen_object:" it doesn't like this methods added via setattr() and complains about missing __exit__
EWS
Comment 4
2021-09-02 14:09:22 PDT
Committed
r281952
(
241259@main
): <
https://commits.webkit.org/241259@main
> All reviewed patches have been landed. Closing bug and clearing flags on
attachment 437186
[details]
.
Radar WebKit Bug Importer
Comment 5
2021-09-02 14:10:31 PDT
<
rdar://problem/82692759
>
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug