bpo-28254: _posixsubprocess uses PyGC_Enable/PyGC_Disable by vstinner · Pull Request #25693 · python/cpython (original) (raw)

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 andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation8 Commits2 Checks0 Files changed

Conversation

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})

vstinner

@vstinner

@vstinner

@pablogsal

 ======================================================================
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

@vstinner

Thanks. I fixed test_subprocess.

@scoder

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

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

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

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...)

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