special-case _pytest.__init__ in genscript to avoid a python3 bug

This commit is contained in:
Ronny Pfannschmidt 2015-07-27 11:33:27 +02:00
parent 5098e5fc47
commit 235f9da432
1 changed files with 6 additions and 1 deletions

View File

@ -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)