[New-bugs-announce] [issue31404] undefined behavior and crashes in case of a bad sys.modules
Oren Milman
report at bugs.python.org
Sat Sep 9 13:36:26 EDT 2017
New submission from Oren Milman:
at least on my Windows, the following code:
import sys
sys.modules = []
- when run interactively, causes weird behavior, e.g. exit() doesn't exit the
interpreter, and print() doesn't print.
then, pressing Ctrl+C causes 'Assertion failed: !PyErr_Occurred(), file ..\Objects\call.c, line 803'
- when run as a script, causes PyImport_Cleanup() to raise a negative ref count
Fatal Python error.
(this is because PyImport_Cleanup() (in Python/import.c) assumes that
PyImport_GetModuleDict() returned a dict.)
IIUC, this bug was introduced in https://github.com/python/cpython/pull/1638
(which resolved #28411).
----------
components: Interpreter Core
messages: 301783
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: undefined behavior and crashes in case of a bad sys.modules
type: crash
versions: Python 3.7
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31404>
_______________________________________
More information about the New-bugs-announce
mailing list