Skip to content

Commit

Permalink
Backport pybind11 bugfix (kpeeters#293)
Browse files Browse the repository at this point in the history
The last time pybind11 was copied over, it had a small bug which was fixed upstream a month later. This caused cadabra2 to fail with a runtime error when built with -D_GLIBCXX_ASSERTIONS which is the default on some distros.
  • Loading branch information
cbehan authored Jan 28, 2024
1 parent 2b53a4c commit cb9e61c
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libs/pybind11/include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,13 @@ inline std::string replace_newlines_and_squash(const char *text) {
std::string result(text);
bool previous_is_whitespace = false;

// Do not modify string representations
char first_char = result[0];
char last_char = result[result.size() - 1];
if (first_char == last_char && first_char == '\'') {
return result;
if (result.size() >= 2) {
// Do not modify string representations
char first_char = result[0];
char last_char = result[result.size() - 1];
if (first_char == last_char && first_char == '\'') {
return result;
}
}
result.clear();

Expand Down

0 comments on commit cb9e61c

Please sign in to comment.