Skip to content

Commit cff22e0

Browse files
committed
Partial fix for Matplotlib 3.9's test suite.
1 parent 4a940ee commit cff22e0

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

Diff for: ext/_mplcairo.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -1588,10 +1588,12 @@ void GraphicsContextRenderer::draw_text(
15881588
next_glyphs_pos = glyphs_pos + cluster.num_glyphs;
15891589
for (auto j = glyphs_pos; j < next_glyphs_pos; ++j) {
15901590
if (!gac.glyphs[j].index) {
1591-
auto missing =
1592-
py::cast(s.substr(bytes_pos, cluster.num_bytes))
1593-
.attr("encode")("ascii", "namereplace");
1594-
warn_on_missing_glyph(missing.cast<std::string>());
1591+
auto missing = py::cast(s.substr(bytes_pos, cluster.num_bytes));
1592+
warn_on_missing_glyph( // Format forced by test_mathtext_ticks.
1593+
"{} ({})"_format(
1594+
py::module::import("builtins").attr("ord")(missing),
1595+
missing.attr("encode")("ascii", "namereplace").attr("decode")())
1596+
.cast<std::string>());
15951597
}
15961598
}
15971599
bytes_pos = next_bytes_pos;

Diff for: ext/_util.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -903,8 +903,8 @@ void warn_on_missing_glyph(std::string s)
903903
{
904904
PY_CHECK(
905905
PyErr_WarnEx,
906-
nullptr,
907-
"Requested glyph ({}) missing from current font."_format(s)
906+
PyExc_UserWarning,
907+
"Glyph {} missing from current font."_format(s)
908908
.cast<std::string>().c_str(),
909909
1);
910910
}

0 commit comments

Comments
 (0)