Skip to content

Commit e612619

Browse files
Merge pull request #2106 from nicoddemus/sys-modules-none
Remove support code for earlier Python 3 version in Source.compile
2 parents 8208a77 + 30f0152 commit e612619

File tree

2 files changed

+5
-10
lines changed

2 files changed

+5
-10
lines changed

CHANGELOG.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
* Fix error message using ``approx`` with complex numbers (`#2082`_).
1919
Thanks `@adler-j`_ for the report and `@nicoddemus`_ for the PR.
2020

21-
*
21+
* Remove internal code meant to support earlier Python 3 versions that produced the side effect
22+
of leaving ``None`` in ``sys.modules`` when expressions were evaluated by pytest (for example passing a condition
23+
as a string to ``pytest.mark.skipif``)(`#2103`_).
24+
Thanks `@jaraco`_ for the report and `@nicoddemus`_ for the PR.
2225

2326
* Cope gracefully with a .pyc file with no matching .py file (`#2038`_). Thanks
2427
`@nedbat`_.
@@ -41,6 +44,7 @@
4144
.. _#2038: https://github.com/pytest-dev/pytest/issues/2038
4245
.. _#2078: https://github.com/pytest-dev/pytest/issues/2078
4346
.. _#2082: https://github.com/pytest-dev/pytest/issues/2082
47+
.. _#2103: https://github.com/pytest-dev/pytest/issues/2103
4448

4549

4650
3.0.4

_pytest/_code/source.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import sys
55
import inspect, tokenize
66
import py
7-
from types import ModuleType
87
cpy_compile = compile
98

109
try:
@@ -192,14 +191,6 @@ def compile(self, filename=None, mode='exec',
192191
if flag & _AST_FLAG:
193192
return co
194193
lines = [(x + "\n") for x in self.lines]
195-
if sys.version_info[0] >= 3:
196-
# XXX py3's inspect.getsourcefile() checks for a module
197-
# and a pep302 __loader__ ... we don't have a module
198-
# at code compile-time so we need to fake it here
199-
m = ModuleType("_pycodecompile_pseudo_module")
200-
py.std.inspect.modulesbyfile[filename] = None
201-
py.std.sys.modules[None] = m
202-
m.__loader__ = 1
203194
py.std.linecache.cache[filename] = (1, None, lines, filename)
204195
return co
205196

0 commit comments

Comments
 (0)