summaryrefslogtreecommitdiffstats
path: root/Lib/bdb.py
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>1999-09-09 23:24:33 (GMT)
committerBarry Warsaw <barry@python.org>1999-09-09 23:24:33 (GMT)
commit148ffbc886a35751ca65447de5c22387ce7ca6f0 (patch)
treea8792f826d6acf9312f9fa2220cdd86f6fde05f7 /Lib/bdb.py
parent2bee8feac614599d172ea4483a17294b81063fdc (diff)
downloadcpython-148ffbc886a35751ca65447de5c22387ce7ca6f0.zip
cpython-148ffbc886a35751ca65447de5c22387ce7ca6f0.tar.gz
cpython-148ffbc886a35751ca65447de5c22387ce7ca6f0.tar.bz2
canonic(): This used to be equivalent to str() but that caused too
much breakage (esp. in JPython which holds absolute path names in co_filename already). This implementation uses os.path.abspath() as a slightly better way to canonicalize path names. It implements a cache.
Diffstat (limited to 'Lib/bdb.py')
-rw-r--r--Lib/bdb.py15
1 files changed, 9 insertions, 6 deletions
diff --git a/Lib/bdb.py b/Lib/bdb.py
index abfb7de..89908fc 100644
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -1,6 +1,7 @@
# Debugger basics
import sys
+import os
import types
BdbQuit = 'bdb.BdbQuit' # Exception to give up completely
@@ -17,12 +18,14 @@ class Bdb:
def __init__(self):
self.breaks = {}
- # We want to have a method self.canonic() which
- # canonicalizes filenames before comparing them
- # but we want the default to be a very fast no-op.
- # Solution: the built-in str function.
- if not hasattr(self, "canonic"):
- self.canonic = str
+ self.fncache = {}
+
+ def canonic(self, filename):
+ canonic = self.fncache.get(filename)
+ if not canonic:
+ canonic = os.path.abspath(filename)
+ self.fncache[filename] = canonic
+ return canonic
def reset(self):
import linecache