The existing test only tried to test the except branch, but without insuring that the AttributeError occurs. PR 4070 fixes that and adds a test of the try branch, that sys.ps1 is respected and left alone (and later used as it) when present. Ditto for test_ps2.
On the PR, Serhiy asks "Wouldn't be better to restore sys.ps1 in test_idle if it is changed here?"
Aside from the fact that, as far as I know, it is not sanely possible to do so, I think it a bug for a test to be unnecessarily fragile. Both ps1 and ps2 are set when Python is in interactive mode. IDLE is only (partially) imitating Python's shell when it sets sys.ps1.
The premise of python/cpython#69774 is that tests should accommodate sys.stdout and sys.stderr being None to the extent possible. I think the same applies to sys.ps1/2 being set. Indeed, as I reported on python/cpython#75942, in msg304298, 9 days ago, test_code_module tests test_ps1 and test_ps2 failed when I ran '>>> import test.autotest' in a *Python* shell. I did not understand the reason for the failures then, but if I had investigated, I should hope that I would have submitted the same PR, which fixes this autotest failure.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
The text was updated successfully, but these errors were encountered: