Skip to content

Commit 0ea695c

Browse files
committed
remove doulbe lines for enable, and make disable similar
1 parent 5738bac commit 0ea695c

1 file changed

Lines changed: 0 additions & 42 deletions

File tree

scorep/instrumenter.py

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -82,15 +82,12 @@ def __init__(self, region_name=""):
8282
else:
8383
self.user_region_name = True
8484
self.module_name = ""
85-
self.func = None
8685

8786
def _recreate_cm(self):
8887
return self
8988

9089
def __call__(self, func):
9190
with disable():
92-
self.func = func
93-
9491
@functools.wraps(func)
9592
def inner(*args, **kwds):
9693
with self._recreate_cm():
@@ -114,22 +111,6 @@ def __enter__(self):
114111
self.module_name, self.region_name, full_file_name,
115112
line_number)
116113

117-
elif callable(self.func):
118-
# The user did not specify a region name, and it's a callable, so it's a semi instrumented region
119-
self.region_name = self.func.__name__
120-
self.module_name = self.func.__module__
121-
self.code_obj = self.func.__code__
122-
file_name = self.func.__code__.co_filename
123-
line_number = self.func.__code__.co_firstlineno
124-
125-
if file_name is not None:
126-
full_file_name = os.path.abspath(file_name)
127-
else:
128-
full_file_name = "None"
129-
130-
get_instrumenter().region_begin(
131-
self.module_name, self.region_name, full_file_name, line_number, self.code_obj)
132-
133114
get_instrumenter().register()
134115

135116
def __exit__(self, exc_type=None, exc_value=None, traceback=None):
@@ -139,9 +120,6 @@ def __exit__(self, exc_type=None, exc_value=None, traceback=None):
139120
if self.user_region_name:
140121
get_instrumenter().region_end(
141122
self.module_name, self.region_name)
142-
elif callable(self.func):
143-
get_instrumenter().region_end(
144-
self.module_name, self.region_name, self.code_obj)
145123

146124

147125
class disable():
@@ -170,8 +148,6 @@ def _recreate_cm(self):
170148
def __call__(self, func):
171149
self.__enter__()
172150
try:
173-
self.func = func
174-
175151
@functools.wraps(func)
176152
def inner(*args, **kwds):
177153
with self._recreate_cm():
@@ -198,29 +174,11 @@ def __enter__(self):
198174
get_instrumenter().region_begin(
199175
self.module_name, self.region_name, full_file_name,
200176
line_number)
201-
elif callable(self.func):
202-
# The user did not specify a region name, and it's a callable, so it's a semi instrumented region
203-
self.region_name = self.func.__name__
204-
self.module_name = self.func.__module__
205-
self.code_obj = self.func.__code__
206-
file_name = self.func.__code__.co_filename
207-
line_number = self.func.__code__.co_firstlineno
208-
209-
if file_name is not None:
210-
full_file_name = os.path.abspath(file_name)
211-
else:
212-
full_file_name = "None"
213-
214-
get_instrumenter().region_begin(
215-
self.module_name, self.region_name, full_file_name, line_number, self.code_obj)
216177

217178
def __exit__(self, exc_type=None, exc_value=None, traceback=None):
218179
if self.tracer_registered:
219180
if self.user_region_name:
220181
get_instrumenter().region_end(
221182
self.module_name, self.region_name)
222-
elif callable(self.func):
223-
get_instrumenter().region_end(
224-
self.module_name, self.region_name, self.code_obj)
225183

226184
get_instrumenter().register()

0 commit comments

Comments
 (0)