Fix code_to_line when called with empty code

Previously, it was referring to line before it was assigned. Noticed
when testing the R kernel.
Merge pull request #6657 from takluyver/adapt-no-code-to-line

Fix code_to_line when called with empty code