tqchen commented on code in PR #19940:
URL: https://github.com/apache/tvm/pull/19940#discussion_r3523830453
##########
src/script/printer/doc_printer/python_doc_printer.cc:
##########
@@ -394,6 +396,19 @@ void PythonDocPrinter::PrintTypedDoc(const LiteralDoc&
doc) {
}
}
+void PythonDocPrinter::PrintTypedDoc(const ExprStringDoc& doc) {
+ this->output_ << '"';
+ size_t start_pos = this->output_.tellp();
+ this->PrintDoc(doc->value);
+ std::string output = this->output_.str();
+ std::string value = output.substr(start_pos);
+ TVM_FFI_ICHECK(value.find('\n') == std::string::npos)
+ << "An expression rendered inside a Python string literal must be one
line";
+ this->output_.str(output.substr(0, start_pos));
+ this->output_.seekp(start_pos);
+ this->output_ << support::StrEscape(value) << '"';
+}
Review Comment:
Follow-up `fe7571044c` adds the requested reviewer-facing documentation at
`ScopedExprStringEscapeBuf`: why the active printer must transform writes into
the final buffer for precise source spans, plus buffer ownership/lifetime,
byte-wise escaping, absolute `tellp()`, newline/write failures, and
exception-safe restoration. Behavior is unchanged. The incremental build and
focused Relax/Python-doc/underlining/invisible-path suite passed (286 passed, 1
expected failure); private and public heads both match this commit, with fresh
CI running.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]