Fix SF#1516184 (again) and add a test to prevent regression.
(There was a problem with empty filenames still causing recursion)
diff --git a/Lib/inspect.py b/Lib/inspect.py
index 311fe7e..dc2fa08 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -364,8 +364,9 @@
 
     The idea is for each object to have a unique origin, so this routine
     normalizes the result as much as possible."""
-    return os.path.normcase(
-        os.path.abspath(_filename or getsourcefile(object) or getfile(object)))
+    if _filename is None:
+        _filename = getsourcefile(object) or getfile(object)
+    return os.path.normcase(os.path.abspath(_filename))
 
 modulesbyfile = {}