Kaydet (Commit) 148ffbc8 authored tarafından Barry Warsaw's avatar Barry Warsaw

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.
üst 2bee8fea
# Debugger basics # Debugger basics
import sys import sys
import os
import types import types
BdbQuit = 'bdb.BdbQuit' # Exception to give up completely BdbQuit = 'bdb.BdbQuit' # Exception to give up completely
...@@ -17,12 +18,14 @@ class Bdb: ...@@ -17,12 +18,14 @@ class Bdb:
def __init__(self): def __init__(self):
self.breaks = {} self.breaks = {}
# We want to have a method self.canonic() which self.fncache = {}
# canonicalizes filenames before comparing them
# but we want the default to be a very fast no-op. def canonic(self, filename):
# Solution: the built-in str function. canonic = self.fncache.get(filename)
if not hasattr(self, "canonic"): if not canonic:
self.canonic = str canonic = os.path.abspath(filename)
self.fncache[filename] = canonic
return canonic
def reset(self): def reset(self):
import linecache import linecache
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment