Skip to content

bpo-28254: _posixsubprocess uses PyGC_Enable/PyGC_Disable - #25693

Merged
vstinner merged 2 commits into
python:masterfrom
vstinner:_posixsubprocess
Apr 28, 2021
Merged

vstinner merged 2 commits into
python:masterfrom
vstinner:_posixsubprocess

Conversation

@vstinner

@vstinner vstinner commented Apr 28, 2021 •

Copy link
Copy Markdown
Member
@vstinner

Copy link
Copy Markdown
Member Author
@pablogsal

Copy link
Copy Markdown
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
Copy Markdown
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

scoder commented Apr 28, 2021

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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 ;-)

@gpshead gpshead left a comment

Copy link
Copy Markdown
Member

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!

preexec_fn=lambda: None)
finally:
gc.disable = orig_gc_disable
gc.isenabled = orig_gc_isenabled

Copy link
Copy Markdown
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
Copy Markdown
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

6 participants