Title: Fix crash on prime after single-character superscript by jameslin9968 · Pull Request #32066 · matplotlib/matplotlib · GitHub
Open Graph Title: Fix crash on prime after single-character superscript by jameslin9968 · Pull Request #32066 · matplotlib/matplotlib
X Title: Fix crash on prime after single-character superscript by jameslin9968 · Pull Request #32066 · matplotlib/matplotlib
Description: A prime (apostrophe) following a single-character superscript such as $x^2'$ raised AttributeError: 'Char' object has no attribute 'children'. A single-character superscript is parsed as a bare Char, whereas the apostrophe handling in Parser.subsuper assumed the superscript was an Hlist and called super.children.extend(...). The braced form $x^{2}'$ already produced an Hlist and worked. The fix wraps a non-Hlist superscript in an Hlist before appending the prime glyphs, matching the braced case. PR summary Minimal reproduction (crashes on current main / released matplotlib): import matplotlib.pyplot as plt fig = plt.figure() fig.text(0.1, 0.5, r"$x^2'$") # prime after single-char superscript fig.savefig("out.png") # -> AttributeError: 'Char' object has no attribute 'children' With this PR the expression renders correctly, matching the already-working braced form $x^{2}'$. AI Disclosure This PR was authored with substantial AI assistance (Claude). AI was used to localize the bug in Parser.subsuper, write the fix, and generate the parametrized regression tests in test_mathtext.py. All changes were run and verified locally: the new tests fail without the fix and pass with it, and the full test_mathtext.py suite passes (732 passed / 0 failed). PR checklist [N/A] "closes #0000" — no pre-existing issue was filed for this crash new and changed code is tested (4 parametrized cases in test_mathtext.py) [N/A] Plotting related features are demonstrated in an example — bugfix, no new feature [N/A] New Features and API Changes are noted in a release note — behavior-only bugfix, none needed Documentation complies with guidelines — no doc changes needed
Open Graph Description: A prime (apostrophe) following a single-character superscript such as $x^2'$ raised AttributeError: 'Char' object has no attribute 'children'. A single-character superscript is ...
X Description: A prime (apostrophe) following a single-character superscript such as $x^2'$ raised AttributeError: 'Char' object has no attribute 'children'. A single-chara...
Opengraph URL: https://github.com/matplotlib/matplotlib/pull/32066
X: @github
Domain: github.com
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:a4e5e070-55b2-aee2-2d62-4b324008c49d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | E38A:3BB26F:23C1DE8:30ED0EE:6A631098 |
| html-safe-nonce | 9da5ff6edf86a24653854bff2368a09d1e3159335210ec42d7dbed5d6e2395a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMzhBOjNCQjI2RjoyM0MxREU4OjMwRUQwRUU6NkE2MzEwOTgiLCJ2aXNpdG9yX2lkIjoiNDkzNDA4MjkyODgwNzE1OTI4IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 4f2b1c96be1d46e1f7b43bbf629f3237bec805b6e5791fb06da714460d34413b |
| hovercard-subject-tag | pull_request:4083375395 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/matplotlib/matplotlib/pull/32066/files |
| twitter:image | https://avatars.githubusercontent.com/u/22108779?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/22108779?s=400&v=4 |
| og:image:alt | A prime (apostrophe) following a single-character superscript such as $x^2'$ raised AttributeError: 'Char' object has no attribute 'children'. A single-character superscript is ... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 1a6c056e02f174fffc096c521ec0ff6fb83e40a2ec8cb8875466ec1524872dd6 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/matplotlib/matplotlib git https://github.com/matplotlib/matplotlib.git |
| octolytics-dimension-user_id | 215947 |
| octolytics-dimension-user_login | matplotlib |
| octolytics-dimension-repository_id | 1385122 |
| octolytics-dimension-repository_nwo | matplotlib/matplotlib |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 1385122 |
| octolytics-dimension-repository_network_root_nwo | matplotlib/matplotlib |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 6a93e25585f487ddff9e3996c06d5b869d6e1828 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width