-
Christoph Reiter authored
For making warnings point to the code doing the import, the stack frames of the import system need to be skipped. The frame count number varries between CPython versions and in 3.5 all frames of the import system are skipped for warnings (https://bugs.python.org/issue24305). This hardcodes the frame counts for all supported CPython versions which fixes the import warning output for CPython 3.3 and 3.5. This also fixes/works around a bug in CPython 3 where if a too large stacklevel value was passed to warn(), CPython would try to interpret a file called "sys" in the same directory of the executed script (https://bugs.python.org/issue25493 and https://bugzilla.gnome.org/show_bug.cgi?id=757184). https://bugzilla.gnome.org/show_bug.cgi?id=757184
12022437