Skip to content

Commit ef744d8

Browse files
bondarevtssigmavirus24
authored andcommitted
Improve RepresenterError creation
1 parent 2c55eb6 commit ef744d8

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/yaml/representer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ def represent_yaml_object(self, tag, data, cls, flow_style=None):
246246
return self.represent_mapping(tag, state, flow_style=flow_style)
247247

248248
def represent_undefined(self, data):
249-
raise RepresenterError("cannot represent an object: %s" % data)
249+
raise RepresenterError("cannot represent an object", data)
250250

251251
SafeRepresenter.add_representer(type(None),
252252
SafeRepresenter.represent_none)
@@ -411,7 +411,7 @@ def represent_object(self, data):
411411
elif hasattr(data, '__reduce__'):
412412
reduce = data.__reduce__()
413413
else:
414-
raise RepresenterError("cannot represent object: %r" % data)
414+
raise RepresenterError("cannot represent an object", data)
415415
reduce = (list(reduce)+[None]*5)[:5]
416416
function, args, state, listitems, dictitems = reduce
417417
args = list(args)

lib3/yaml/representer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ def represent_yaml_object(self, tag, data, cls, flow_style=None):
226226
return self.represent_mapping(tag, state, flow_style=flow_style)
227227

228228
def represent_undefined(self, data):
229-
raise RepresenterError("cannot represent an object: %s" % data)
229+
raise RepresenterError("cannot represent an object", data)
230230

231231
SafeRepresenter.add_representer(type(None),
232232
SafeRepresenter.represent_none)
@@ -316,7 +316,7 @@ def represent_object(self, data):
316316
elif hasattr(data, '__reduce__'):
317317
reduce = data.__reduce__()
318318
else:
319-
raise RepresenterError("cannot represent object: %r" % data)
319+
raise RepresenterError("cannot represent an object", data)
320320
reduce = (list(reduce)+[None]*5)[:5]
321321
function, args, state, listitems, dictitems = reduce
322322
args = list(args)

0 commit comments

Comments
 (0)