Skip to content

Commit dc426bb

Browse files
committed
Added Py27 support for validation script
1 parent b669112 commit dc426bb

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

scripts/validate_docstrings.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
def _load_obj(obj_name):
4747
for maxsplit in range(1, obj_name.count('.') + 1):
4848
# TODO when py3 only replace by: module, *func_parts = ...
49-
func_name_split = obj_name.rsplit('.', maxsplit=maxsplit)
49+
func_name_split = obj_name.rsplit('.', maxsplit)
5050
module = func_name_split[0]
5151
func_parts = func_name_split[1:]
5252
try:
@@ -186,12 +186,11 @@ def signature_parameters(self):
186186
# accessor classes have a signature, but don't want to show this
187187
return tuple()
188188
try:
189-
signature = inspect.signature(self.method_obj)
189+
params = self.method_obj.__code__.co_varnames
190190
except (TypeError, ValueError):
191191
# Some objects, mainly in C extensions do not support introspection
192192
# of the signature
193193
return tuple()
194-
params = tuple(signature.parameters.keys())
195194
if params and params[0] in ('self', 'cls'):
196195
return params[1:]
197196
return params
@@ -264,8 +263,7 @@ def examples_errors(self):
264263
error_msgs = ''
265264
for test in finder.find(self.raw_doc, self.method_name, globs=context):
266265
f = StringIO()
267-
with contextlib.redirect_stdout(f):
268-
runner.run(test)
266+
runner.run(test, out=f)
269267
error_msgs += f.getvalue()
270268
return error_msgs
271269

0 commit comments

Comments
 (0)