Skip to content

Amend string-escaping helper dq() to escape \r #436

Description

@benjikj-cera

Applies To

  • Notebooks (.deepnote files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

I had errors when executing SQL cells with the extension saying SyntaxError: unterminated string literal (detected at line 7), which was a python error, with line 7 being the first line of the SQL cell. I debugged this with Claude code and it told me:

Its string-escaping helper (dq() in the extension bundle) escapes \, ', and \n (line-feed) — but forgets \r (carriage return). Your testing.deepnote file stored the SQL with CRLF line endings, so the \ns got escaped away (collapsing to one line) while the raw \r bytes stayed inside the single-quoted string. Python's tokenizer treats a bare \r as a line ending → SyntaxError: unterminated string literal.

SELECT 1 worked only because it's a single line with no line breaks (0 CRs). Every real, multi-line query had CRs (28, 8, 3 respectively) and failed.

I proved it by porting dq() to Python: CRLF input → your exact error; LF input → compiles fine.

VS Code Version

1.127.0

Deepnote Extension Version

1.5.0

Deepnote logs

Coding Language and Runtime Version

Python 3.12.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions