Skip to content

Commit

Permalink
Added escaping of - in literal to prevent processing of ->
Browse files Browse the repository at this point in the history
  • Loading branch information
timohl committed Jan 10, 2025
1 parent 56cab0b commit 2029854
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class cpp_function : public function {
}
} else if (c == '!'
&& (*(pc + 1) == '!' || *(pc + 1) == '@' || *(pc + 1) == '%'
|| *(pc + 1) == '{' || *(pc + 1) == '}')) {
|| *(pc + 1) == '{' || *(pc + 1) == '}' || *(pc + 1) == '-')) {
// typing::Literal escapes special characters with !
signature += *++pc;
} else if (c == '@') {
Expand Down
2 changes: 1 addition & 1 deletion include/pybind11/typing.h
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ consteval auto sanitize_string_literal() {
+ std::ranges::count(v, '}') + 1];
size_t i = 0;
for (auto c : StrLit.name) {
if (c == '!' || c == '@' || c == '%' || c == '{' || c == '}') {
if (c == '!' || c == '@' || c == '%' || c == '{' || c == '}' || c == '-') {
result[i++] = '!';
}
result[i++] = c;
Expand Down

0 comments on commit 2029854

Please sign in to comment.