Title: `math.tanpi` is untested at its poles and no test-file flag fits · Issue #155966 · python/cpython · GitHub
Open Graph Title: `math.tanpi` is untested at its poles and no test-file flag fits · Issue #155966 · python/cpython
X Title: `math.tanpi` is untested at its poles and no test-file flag fits · Issue #155966 · python/cpython
Description: Bug description: math.tanpi is singular at every odd half-integer, and m_tanpi in Modules/mathmodule.c has an explicit branch for that case, but nothing exercises it. None of the 279 tanpi rows in Lib/test/mathdata/math_testcases.txt has...
Open Graph Description: Bug description: math.tanpi is singular at every odd half-integer, and m_tanpi in Modules/mathmodule.c has an explicit branch for that case, but nothing exercises it. None of the 279 tanpi rows in ...
X Description: Bug description: math.tanpi is singular at every odd half-integer, and m_tanpi in Modules/mathmodule.c has an explicit branch for that case, but nothing exercises it. None of the 279 tanpi rows in ...
Opengraph URL: https://github.com/python/cpython/issues/155966
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`math.tanpi` is untested at its poles and no test-file flag fits","articleBody":"### Bug description:\n\n`math.tanpi` is singular at every odd half-integer, and `m_tanpi` in `Modules/mathmodule.c` has an explicit branch for that case, but nothing exercises it. None of the 279 `tanpi` rows in `Lib/test/mathdata/math_testcases.txt` has a half-integer argument, and `Lib/test/test_math.py` never names `tanpi`.\n\nAdding a row for it does not work as written, because the flag that describes this case makes `test_mtestfile` fail:\n\n```\n$ echo 'tanpi20004 tanpi 0.5 -> inf divide-by-zero' >> Lib/test/mathdata/math_testcases.txt\n$ ./python -m test test_math -m test_mtestfile\n...\nAssertionError: Failures in test_mtestfile:\n tanpi20004: tanpi[0.5]: expected 'ValueError', got 'OverflowError' (not equal)\n...\nResult: FAILURE\n```\n\nThe header of `math_testcases.txt` defines `divide-by-zero` as \"raised when a finite input gives a mathematically infinite result\", which is what happens at the pole, and `test_mtestfile` maps that flag to `ValueError`, while `math.tanpi(0.5)` raises `OverflowError`. The other flag, `overflow`, passes, but the same header defines it as \"raised when a finite input gives a finite result that is too large to fit in the usual range of an IEEE 754 double\", so the row would record something the file says is false.\n\n`Doc/library/math.rst` does not mention the poles either.\n\nExpected: `math.tanpi` at an odd half-integer is covered by a test, with a flag that matches the file's own definitions.\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-155980\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/fedonman","@type":"Person","name":"fedonman"},"datePublished":"2026-08-17T19:13:06Z","url":"https://github.com/python/cpython/issues/155966"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6ffde4aa-126c-3f93-e9cb-d40b9201581d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BEB8:33444D:3262A6C:4300C42:6B01F258 |
| html-safe-nonce | c73353221c8c8d057058c5485668e1e58c87131088b56243e86ef036360070f6 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRUI4OjMzNDQ0RDozMjYyQTZDOjQzMDBDNDI6NkIwMUYyNTgiLCJ2aXNpdG9yX2lkIjoiNzkzMzE5NDg4NTQ4MDQ0NDUwNCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 08f7b817a18d70064b9383beaa236210a13b0a0bba3f68cee1f872c8dd83eeaa |
| hovercard-subject-tag | issue:5174587211 |
| github-keyboard-shortcuts | repository,issues,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/_view_fragments/issues/show/python/cpython/155966/issue_layout |
| twitter:image | https://opengraph.githubassets.com/60beeec8c92292b55a53e005b52eb5d8e0523c57f31187727e8dc9c0a5216bf4/python/cpython/issues/155966 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/60beeec8c92292b55a53e005b52eb5d8e0523c57f31187727e8dc9c0a5216bf4/python/cpython/issues/155966 |
| og:image:alt | Bug description: math.tanpi is singular at every odd half-integer, and m_tanpi in Modules/mathmodule.c has an explicit branch for that case, but nothing exercises it. None of the 279 tanpi rows in ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | fedonman |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width