Two places in this code Python 3 changed from raising ValueError
to TypeError. So catch the addition exceptions.
IMO this code might be better off performing type sniffing. But
I'm not sure the implications of changing that.
pulkit | |
durin42 |
hg-reviewers |
Two places in this code Python 3 changed from raising ValueError
to TypeError. So catch the addition exceptions.
IMO this code might be better off performing type sniffing. But
I'm not sure the implications of changing that.
Lint Skipped |
Unit Tests Skipped |
Path | Packages | |||
---|---|---|---|---|
M | mercurial/templatekw.py (8 lines) |
Status | Author | Revision | |
---|---|---|---|
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Needs Revision | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg | ||
Closed | indygreg |
return | return | ||||
startname = 'start_' + plural | startname = 'start_' + plural | ||||
if startname in templ: | if startname in templ: | ||||
yield templ(startname, **strmapping) | yield templ(startname, **strmapping) | ||||
vmapping = mapping.copy() | vmapping = mapping.copy() | ||||
def one(v, tag=name): | def one(v, tag=name): | ||||
try: | try: | ||||
vmapping.update(v) | vmapping.update(v) | ||||
except (AttributeError, ValueError): | # Python 2 raises ValueError if the type of v is wrong. Python | ||||
# 3 raises TypeError. | |||||
except (AttributeError, TypeError, ValueError): | |||||
try: | try: | ||||
# Python 2 raises ValueError trying to destructure an e.g. | |||||
# bytes. Python 3 raises TypeError. | |||||
for a, b in v: | for a, b in v: | ||||
vmapping[a] = b | vmapping[a] = b | ||||
except ValueError: | except (TypeError, ValueError): | ||||
vmapping[name] = v | vmapping[name] = v | ||||
return templ(tag, **pycompat.strkwargs(vmapping)) | return templ(tag, **pycompat.strkwargs(vmapping)) | ||||
lastname = 'last_' + name | lastname = 'last_' + name | ||||
if lastname in templ: | if lastname in templ: | ||||
last = values.pop() | last = values.pop() | ||||
else: | else: | ||||
last = None | last = None | ||||
for v in values: | for v in values: |