From 235f9da432310c7084af08c2fddefd9a3a0bf223 Mon Sep 17 00:00:00 2001 From: Ronny Pfannschmidt Date: Mon, 27 Jul 2015 11:33:27 +0200 Subject: [PATCH] special-case _pytest.__init__ in genscript to avoid a python3 bug --- _pytest/genscript.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/_pytest/genscript.py b/_pytest/genscript.py index d6f452370..fbaef4c2d 100755 --- a/_pytest/genscript.py +++ b/_pytest/genscript.py @@ -31,7 +31,12 @@ def pkg_to_mapping(name): else: # package for pyfile in toplevel.visit('*.py'): pkg = pkgname(name, toplevel, pyfile) - name2src[pkg] = pyfile.read() + if pkg == '_pytest.__init__': + # remove the coding comment line to avoid python bug + lines = pyfile.read().splitlines(True) + name2src[pkg] = ''.join(lines[1:]) + else: + name2src[pkg] = pyfile.read() # with wheels py source code might be not be installed # and the resulting genscript is useless, just bail out. assert name2src, "no source code found for %r at %r" %(name, toplevel)