8000 compact MethodType between 2 and 3 (#403) · foolishantcat/client_python@ae86f1c · GitHub
[go: up one dir, main page]

Skip to content

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ae86f1c

Browse files
Hanaasagibrian-brazil
authored andcommitted
compact MethodType between 2 and 3 (prometheus#403)
Signed-off-by: Hanaasagi <ambiguous404@gmail.com>
1 parent 04c112a commit ae86f1c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

prometheus_client/metrics.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
if sys.version_info > (3,):
1616
unicode = str
17+
create_bound_method = types.MethodType
18+
else:
19+
def create_bound_method(func, obj):
20+
return types.MethodType(func, obj, obj.__class__)
1721

1822

1923
def _build_full_name(metric_type, name, namespace, subsystem, unit):
@@ -369,7 +373,7 @@ def set_function(self, f):
369373
def samples(self):
370374
return (('', {}, float(f())),)
371375

372-
self._child_samples = types.MethodType(samples, self)
376+
self._child_samples = create_bound_method(samples, self)
373377

374378
def _child_samples(self):
375379
return (('', {}, self._value.get()),)

0 commit comments

Comments
 (0)
0