Skip to content

_raw() wraps all outputs in double quotes #377

@ivanharvard

Description

@ivanharvard

In _raw(), all objects (except for lists, EOF, and TIMEOUT) go through this process:

  • The object is converted to a string
  • Then the object is converted to its escaped representation (using repr)
  • This new escaped representation adds quotes around the object, which we remove using [1:-1]
  • Finally, we wrap the entire thing in double quotes.

There's a few concerns I have with this:

  • Why double quotes? Why not single quotes in cases where single quotes weren't in the string? And why remove quotes just to add them back in?
  • Since Mismatch and Missing call the _raw function, even if you enter a non-string input, the error message will spit out what looks to be a string. Take a look at this code:
from check50 import Mismatch

raise Mismatch(1, "1")

which outputs

expected: "1"
actual:   "1"

Or this code:

from check50 import Missing

raise Missing("1", [1,2,3])

which outputs

Did not find "1" in ""1"\n"2"\n"3""

Metadata

Metadata

Assignees

No one assigned

    Labels

    4.xIssues relating to check50 4.xquestion

    Type

    No type
    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