joerick/pyinstrument — pull request #13 by codelol (2014-06-06 04:17:02+00:00)
Title: Fix for "relative path" on Windows

First of all, I think this is a really useful tool.

I normally use Windows, so I tried it on my system and found a few minor bugs specifically on Windows:

(1) When you run it on a non-system drive (any drive other than "c:"), function "file_path_short" will fail at calling "os.path.relpath", because it's not possible to compute a relative path between two paths for different drives. Windows does not have a root ('/') directory.

(2) Paths in Windows are like '\', so need to split with '\\'.

(3) When splitting line number and path, we are handling a string like this 'c:\...\module.py:12', which has two colons, so it's a little tricky.