Mercurial > hg
comparison mercurial/templater.py @ 24886:10a13da8840d stable
templater: fail more gracefully for blank strings to word
author | Ryan McElroy <rmcelroy@fb.com> |
---|---|
date | Thu, 30 Apr 2015 12:33:36 -0700 |
parents | d80819f67d59 |
children | 09124cce913f |
comparison
equal
deleted
inserted
replaced
24885:eea3977e6fca | 24886:10a13da8840d |
---|---|
537 if not (2 <= len(args) <= 3): | 537 if not (2 <= len(args) <= 3): |
538 # i18n: "word" is a keyword | 538 # i18n: "word" is a keyword |
539 raise error.ParseError(_("word expects two or three arguments, got %d") | 539 raise error.ParseError(_("word expects two or three arguments, got %d") |
540 % len(args)) | 540 % len(args)) |
541 | 541 |
542 num = int(stringify(args[0][0](context, mapping, args[0][1]))) | 542 try: |
543 num = int(stringify(args[0][0](context, mapping, args[0][1]))) | |
544 except ValueError: | |
545 # i18n: "word" is a keyword | |
546 raise error.ParseError( | |
547 _("Use strings like '3' for numbers passed to word function")) | |
543 text = stringify(args[1][0](context, mapping, args[1][1])) | 548 text = stringify(args[1][0](context, mapping, args[1][1])) |
544 if len(args) == 3: | 549 if len(args) == 3: |
545 splitter = stringify(args[2][0](context, mapping, args[2][1])) | 550 splitter = stringify(args[2][0](context, mapping, args[2][1])) |
546 else: | 551 else: |
547 splitter = None | 552 splitter = None |