Skip to content

Commit 2029854

Browse files
committed
Added escaping of - in literal to prevent processing of ->
1 parent 56cab0b commit 2029854

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/pybind11/pybind11.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ class cpp_function : public function {
500500
}
501501
} else if (c == '!'
502502
&& (*(pc + 1) == '!' || *(pc + 1) == '@' || *(pc + 1) == '%'
503-
|| *(pc + 1) == '{' || *(pc + 1) == '}')) {
503+
|| *(pc + 1) == '{' || *(pc + 1) == '}' || *(pc + 1) == '-')) {
504504
// typing::Literal escapes special characters with !
505505
signature += *++pc;
506506
} else if (c == '@') {

include/pybind11/typing.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ consteval auto sanitize_string_literal() {
264264
+ std::ranges::count(v, '}') + 1];
265265
size_t i = 0;
266266
for (auto c : StrLit.name) {
267-
if (c == '!' || c == '@' || c == '%' || c == '{' || c == '}') {
267+
if (c == '!' || c == '@' || c == '%' || c == '{' || c == '}' || c == '-') {
268268
result[i++] = '!';
269269
}
270270
result[i++] = c;

0 commit comments

Comments
 (0)