Commit 2b11d166 authored by Tom Niget's avatar Tom Niget

Introduce _ps custom literal for PyStr

parent 825661d3
......@@ -35,6 +35,10 @@ public:
}
};
inline constexpr PyStr operator""_ps(const char *s, size_t len) noexcept {
return PyStr(s, len);
}
PyStr PyBytes::decode(const std::string &encoding) const {
return PyStr(this->begin(), this->end());
}
......
......@@ -61,7 +61,7 @@ class ExpressionVisitor(NodeVisitor):
def visit_Constant(self, node: ast.Constant) -> Iterable[str]:
if isinstance(node.value, str):
# TODO: escape sequences
yield f"\"{repr(node.value)[1:-1]}\"s"
yield f"\"{repr(node.value)[1:-1]}\"_ps"
elif isinstance(node.value, bool):
yield str(node.value).lower()
elif isinstance(node.value, int):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment