diff options
author | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2014-04-06 17:47:53 +0200 |
---|---|---|
committer | Amaury Forgeot d'Arc <amauryfa@gmail.com> | 2014-04-06 17:47:53 +0200 |
commit | 55adceed7ec313047520f0157e9cf0aed079dd96 (patch) | |
tree | 73932a094b29504db4007cc1469a0e066acc0e08 /lib-python/3/trace.py | |
parent | Branch for Python 3.3 support (diff) | |
parent | Drop stdlib from Python-3.3.5 tarball (diff) | |
download | pypy-55adceed7ec313047520f0157e9cf0aed079dd96.tar.gz pypy-55adceed7ec313047520f0157e9cf0aed079dd96.tar.bz2 pypy-55adceed7ec313047520f0157e9cf0aed079dd96.zip |
Merge stdlib from vendor/stdlib-3.3.5
Diffstat (limited to 'lib-python/3/trace.py')
-rwxr-xr-x[-rw-r--r--] | lib-python/3/trace.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib-python/3/trace.py b/lib-python/3/trace.py index 3f618cdf6c..db04dda68e 100644..100755 --- a/lib-python/3/trace.py +++ b/lib-python/3/trace.py @@ -39,8 +39,8 @@ Sample use, programmatically # create a Trace object, telling it what to ignore, and whether to # do tracing or line-counting or both. - tracer = trace.Trace(ignoredirs=[sys.prefix, sys.exec_prefix,], trace=0, - count=1) + tracer = trace.Trace(ignoredirs=[sys.base_prefix, sys.base_exec_prefix,], + trace=0, count=1) # run the new command using the given tracer tracer.run('main()') # make a report, placing output in /tmp @@ -48,12 +48,10 @@ Sample use, programmatically r.write_results(show_missing=True, coverdir="/tmp") """ __all__ = ['Trace', 'CoverageResults'] -import io import linecache import os import re import sys -import time import token import tokenize import inspect @@ -61,6 +59,10 @@ import gc import dis import pickle from warnings import warn as _warn +try: + from time import monotonic as _time +except ImportError: + from time import time as _time try: import threading @@ -244,8 +246,7 @@ class CoverageResults: """Return True if the filename does not refer to a file we want to have reported. """ - return (filename == "<string>" or - filename.startswith("<doctest ")) + return filename.startswith('<') and filename.endswith('>') def update(self, other): """Merge in the data from another CoverageResults""" @@ -477,7 +478,7 @@ class Trace: self._caller_cache = {} self.start_time = None if timing: - self.start_time = time.time() + self.start_time = _time() if countcallers: self.globaltrace = self.globaltrace_trackcallers elif countfuncs: @@ -619,7 +620,7 @@ class Trace: self.counts[key] = self.counts.get(key, 0) + 1 if self.start_time: - print('%.2f' % (time.time() - self.start_time), end=' ') + print('%.2f' % (_time() - self.start_time), end=' ') bname = os.path.basename(filename) print("%s(%d): %s" % (bname, lineno, linecache.getline(filename, lineno)), end='') @@ -632,7 +633,7 @@ class Trace: lineno = frame.f_lineno if self.start_time: - print('%.2f' % (time.time() - self.start_time), end=' ') + print('%.2f' % (_time() - self.start_time), end=' ') bname = os.path.basename(filename) print("%s(%d): %s" % (bname, lineno, linecache.getline(filename, lineno)), end='') @@ -754,10 +755,10 @@ def main(argv=None): # should I also call expanduser? (after all, could use $HOME) s = s.replace("$prefix", - os.path.join(sys.prefix, "lib", + os.path.join(sys.base_prefix, "lib", "python" + sys.version[:3])) s = s.replace("$exec_prefix", - os.path.join(sys.exec_prefix, "lib", + os.path.join(sys.base_exec_prefix, "lib", "python" + sys.version[:3])) s = os.path.normpath(s) ignore_dirs.append(s) |