Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bpo-28254: _posixsubprocess uses PyGC_Enable/PyGC_Disable #25693

Merged
merged 2 commits into from
Apr 28, 2021
Merged

bpo-28254: _posixsubprocess uses PyGC_Enable/PyGC_Disable #25693

merged 2 commits into from
Apr 28, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Apr 28, 2021

@vstinner
Copy link
Member Author

cc @pablogsal @scoder

@pablogsal
Copy link
Member

 ======================================================================
FAIL: test_preexec_gc_module_failure (test.test_subprocess.POSIXProcessTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/runner/work/cpython/cpython/Lib/test/test_subprocess.py", line 2170, in test_preexec_gc_module_failure
    self.assertRaises(RuntimeError, subprocess.Popen,
AssertionError: RuntimeError not raised by Popen

👀

@vstinner
Copy link
Member Author

Thanks. I fixed test_subprocess.

@vstinner vstinner merged commit 103d5e4 into python:master Apr 28, 2021
@vstinner vstinner deleted the _posixsubprocess branch April 28, 2021 17:09
@scoder
Copy link
Contributor

scoder commented Apr 28, 2021

Actually, I think much of this could already have been saved before by using the ID-string API. But still, this is just so much better.

@vstinner
Copy link
Member Author

Actually, I think much of this could already have been saved before by using the ID-string API. But still, this is just so much better.

I don't think that using cached interned strings is really relevant here, spawning a subprocess takes a few milliseconds, we are far from nanoseconds avoided thanks to the cache. Anyway, it's now gone ;-)

Copy link
Member

@gpshead gpshead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yay, thanks for the cleanup!

del gc.isenabled # force an AttributeError
self.assertRaises(AttributeError, subprocess.Popen,
[sys.executable, '-c', ''],
preexec_fn=lambda: None)
finally:
gc.disable = orig_gc_disable
gc.isenabled = orig_gc_isenabled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saving and restoring these two with the try: finally: seems no longer necessary now that they're not being monkeypatched out to cause errors. (harmless, but anyone reading this will wonder why...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're right: I created #25709

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants