mirror of
https://github.com/cool-RR/PySnooper.git
synced 2026-01-23 10:15:11 +00:00
parent
e2aa42bd6d
commit
bd05c1686f
2 changed files with 18 additions and 1 deletions
|
|
@ -6,6 +6,7 @@ import abc
|
|||
import os
|
||||
import inspect
|
||||
import sys
|
||||
import datetime as datetime_module
|
||||
|
||||
PY3 = (sys.version_info[0] == 3)
|
||||
PY2 = not PY3
|
||||
|
|
@ -64,3 +65,18 @@ try:
|
|||
from collections import abc as collections_abc
|
||||
except ImportError: # Python 2.7
|
||||
import collections as collections_abc
|
||||
|
||||
if sys.version_info[:2] >= (3, 6):
|
||||
time_isoformat = datetime_module.time.isoformat
|
||||
else:
|
||||
def time_isoformat(time, timespec='microseconds'):
|
||||
assert isinstance(time, datetime_module.time)
|
||||
if timespec != 'microseconds':
|
||||
raise NotImplementedError
|
||||
result = '{:02d}:{:02d}:{:02d}.{:06d}'.format(
|
||||
time.hour, time.minute, time.second, time.microsecond
|
||||
)
|
||||
assert len(result) == 15
|
||||
return result
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -346,7 +346,8 @@ class Tracer:
|
|||
# #
|
||||
### Finished checking whether we should trace this line. ##############
|
||||
|
||||
now_string = datetime_module.datetime.now().time().isoformat()
|
||||
now = datetime_module.datetime.now().time()
|
||||
now_string = pycompat.time_isoformat(now, timespec='microseconds')
|
||||
line_no = frame.f_lineno
|
||||
source_path, source = get_path_and_source_from_frame(frame)
|
||||
if self.last_source_path != source_path:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue