Author: Armin Rigo <[email protected]>
Branch:
Changeset: r71328:b79be2085a34
Date: 2014-05-06 13:15 +0200
http://bitbucket.org/pypy/pypy/changeset/b79be2085a34/
Log: Bah, py.path's relto() method is dangerous. It silently returns ''
when it fails. Check with asserts the places where we implicitly
expect to get a correct path.
diff --git a/rpython/translator/c/genc.py b/rpython/translator/c/genc.py
--- a/rpython/translator/c/genc.py
+++ b/rpython/translator/c/genc.py
@@ -537,6 +537,8 @@
pypkgpath = localpath.pypkgpath()
if pypkgpath:
relpypath = localpath.relto(pypkgpath.dirname)
+ assert relpypath, ("%r should be relative to %r" %
+ (localpath, pypkgpath.dirname))
return relpypath.replace('.py', '.c')
return None
if hasattr(node.obj, 'graph'):
diff --git a/rpython/translator/platform/__init__.py
b/rpython/translator/platform/__init__.py
--- a/rpython/translator/platform/__init__.py
+++ b/rpython/translator/platform/__init__.py
@@ -170,6 +170,9 @@
ofile = cfile.new(ext=ext)
if ofile.relto(udir):
return ofile
+ assert ofile.relto(rpythonroot), (
+ "%r should be relative to either %r or %r" % (
+ ofile, rpythonroot, udir))
ofile = udir.join(ofile.relto(rpythonroot))
ofile.dirpath().ensure(dir=True)
return ofile
diff --git a/rpython/translator/platform/posix.py
b/rpython/translator/platform/posix.py
--- a/rpython/translator/platform/posix.py
+++ b/rpython/translator/platform/posix.py
@@ -253,6 +253,9 @@
if fpath.dirpath() == self.makefile_dir:
return fpath.basename
elif fpath.dirpath().dirpath() == self.makefile_dir.dirpath():
+ assert fpath.relto(self.makefile_dir.dirpath()), (
+ "%r should be relative to %r" % (
+ fpath, self.makefile_dir.dirpath()))
path = '../' + fpath.relto(self.makefile_dir.dirpath())
return path.replace('\\', '/')
else:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit