Skip to content


Subversion checkout URL

You can clone with
Download ZIP


sprintf error should be more awesome #759

Benabik opened this Issue · 3 comments

2 participants


Currently, sprintf str, "%;", [] throws the following exception: ';' is not a valid sprintf format. It would be more clear if it displayed the entire format there, including the %.

First thought on implementation: keep an index for the % character and then substr between there and the current position before throwing the exception.

@Whiteknight Whiteknight was assigned

I've started a new branch, whiteknight/sprintf_cleanup, to work on several issues related to the sprintf code, including this ticket. I will post updates as the work progresses.

@Whiteknight Whiteknight referenced this issue from a commit
@Whiteknight Whiteknight A few small code cleanups. Fix t/op/sprintf.t, since it is wonderfull…
…y matching on the exact text of the exception message, which is changing for GH #759

@benabik The error message has been updated to say:

"'%c' is not valid in sprintf format sequence '%Ss'"

Where the second parameter is the text of the format sequence so far. Once the state machine finds one incorrect character it can't keep going to find the complete intended format, so this is the best we can do. If this is acceptable to you, I'll merge my branch to master and close this ticket.


I have just merged this branch to master. The error message is improved as best as I can make it. I'm closing this ticket.

@Whiteknight Whiteknight removed their assignment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.