René's URL Explorer Experiment


Title: _CustomTextWrap produces lines wider than `width` after the #399 fix (032dc0d) · Issue #478 · astanin/python-tabulate · GitHub

Open Graph Title: _CustomTextWrap produces lines wider than `width` after the #399 fix (032dc0d) · Issue #478 · astanin/python-tabulate

X Title: _CustomTextWrap produces lines wider than `width` after the #399 fix (032dc0d) · Issue #478 · astanin/python-tabulate

Description: The fix for #399 (032dc0d, on master, not in a release yet) stops the infinite loop, but it also makes some lines wider than the requested width. Before that commit, the same inputs wrapped correctly. Minimal repro >>> import tabulate, w...

Open Graph Description: The fix for #399 (032dc0d, on master, not in a release yet) stops the infinite loop, but it also makes some lines wider than the requested width. Before that commit, the same inputs wrapped correct...

X Description: The fix for #399 (032dc0d, on master, not in a release yet) stops the infinite loop, but it also makes some lines wider than the requested width. Before that commit, the same inputs wrapped correct...

Opengraph URL: https://github.com/astanin/python-tabulate/issues/478

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"_CustomTextWrap produces lines wider than `width` after the #399 fix (032dc0d)","articleBody":"The fix for #399 (032dc0d, on `master`, not in a release yet) stops the infinite loop, but it also makes some lines wider than the requested width. Before that commit, the same inputs wrapped correctly.\n\n### Minimal repro\n\n```python\n>>> import tabulate, wcwidth\n>>> out = tabulate._CustomTextWrap(width=3).wrap(\"a 글글\")\n>>> out, [wcwidth.wcswidth(x) for x in out]\n(['a 글', '글'], [4, 2])        # master @ 268615a: first line is 4 columns in a 3-column width\n```\n\nBefore 032dc0d (and on PyPI 0.10.0): `['a ', '글', '글']`, which fits.\n\nIn a table:\n\n```python\n>>> print(tabulate.tabulate([[\"a 글글\"]], maxcolwidths=[3], tablefmt=\"grid\"))\n+------+\n| a 글 |\n| 글   |\n+------+\n```\n\n### Cause\n\nIn `_handle_long_word`:\n\n```python\ni = max(i, 2)\n```\n\nThis forces at least one character onto the line even when `cur_line` already has content, so a wide character that doesn't fit in the remaining space gets squeezed onto a non-empty line. Forcing progress is only needed when the line is empty. Taking the character in that case still breaks the loop, and otherwise the chunk can move to the next line as before:\n\n```python\nif i == 1 and not cur_line and stripped_chunk:\n    i = 2\n```\n\n### How I found it\n\nI compared the pre-fix code and master on 6,910 random strings (a mix of ASCII, CJK, emoji, combining marks and ANSI codes, at widths 1/2/3/4/7). The pre-fix code hangs on 1,291 of them. Master fixes all of those hangs, but changes 201 outputs that previously terminated, and all 201 now have a line wider than `width`. With the guard above, every hang is fixed and none of the previously-terminating outputs change. The full `test/` suite passes, including the #399 test.\n\nHappy to open a PR with this change and a regression test if that's useful.\n","author":{"url":"https://github.com/RootCauseWeekly","@type":"Person","name":"RootCauseWeekly"},"datePublished":"2026-10-23T21:08:47Z","url":"https://github.com/astanin/python-tabulate/issues/478"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:90db446a-6974-4440-5b1d-1141bde3109a
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idE650:222894:9D053E:D5D045:6AFF3C8E
html-safe-noncee39ec008a1080a22d111fdced4c913e1fb1822d2d30e20c6070791b3e89cfa30
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNjUwOjIyMjg5NDo5RDA1M0U6RDVEMDQ1OjZBRkYzQzhFIiwidmlzaXRvcl9pZCI6IjUwODcxNTcwNjc2MDEzNjIwNjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac730ca7e5f810a9aa87c8a150e1a55d0d8f3707fb0376a5a21a025744c9ffac7f
hovercard-subject-tagissue:6005479461
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/astanin/python-tabulate/478/issue_layout
twitter:imagehttps://opengraph.githubassets.com/84a8d15fb565866ea2bf85dd4a7b92625be168474f02c14dc25f645fc91f6d14/astanin/python-tabulate/issues/478
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/84a8d15fb565866ea2bf85dd4a7b92625be168474f02c14dc25f645fc91f6d14/astanin/python-tabulate/issues/478
og:image:altThe fix for #399 (032dc0d, on master, not in a release yet) stops the infinite loop, but it also makes some lines wider than the requested width. Before that commit, the same inputs wrapped correct...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameRootCauseWeekly
hostnamegithub.com
expected-hostnamegithub.com
None07f40d184b74ca701a2005d4a164bf7038be26fc145c2623336a91fe477cc584
turbo-cache-controlno-preview
go-importgithub.com/astanin/python-tabulate git https://github.com/astanin/python-tabulate.git
octolytics-dimension-user_id71802
octolytics-dimension-user_loginastanin
octolytics-dimension-repository_id205875548
octolytics-dimension-repository_nwoastanin/python-tabulate
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id205875548
octolytics-dimension-repository_network_root_nwoastanin/python-tabulate
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release8e428a801c2dccf4d1f411040a0e0b7fab7d4061
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/astanin/python-tabulate/issues/478#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fastanin%2Fpython-tabulate%2Fissues%2F478
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fastanin%2Fpython-tabulate%2Fissues%2F478
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=astanin%2Fpython-tabulate
Reloadhttps://github.com/astanin/python-tabulate/issues/478
Reloadhttps://github.com/astanin/python-tabulate/issues/478
Reloadhttps://github.com/astanin/python-tabulate/issues/478
astaninhttps://github.com/astanin
python-tabulatehttps://github.com/astanin/python-tabulate
Codehttps://github.com/astanin/python-tabulate
Issues75 (75)https://github.com/astanin/python-tabulate/issues
Pull requests63 (63)https://github.com/astanin/python-tabulate/pulls
Actionshttps://github.com/astanin/python-tabulate/actions
Security and qualityhttps://github.com/astanin/python-tabulate/security
Insightshttps://github.com/astanin/python-tabulate/pulse
https://github.com/astanin/python-tabulate
New issuehttps://github.com/login?return_to=https://github.com/astanin/python-tabulate/issues/478
New issuehttps://github.com/login?return_to=https://github.com/astanin/python-tabulate/issues/478
#479https://github.com/astanin/python-tabulate/pull/479
_CustomTextWrap produces lines wider than width after the #399 fix (032dc0d)https://github.com/astanin/python-tabulate/issues/478#top
#479https://github.com/astanin/python-tabulate/pull/479
https://github.com/RootCauseWeekly
RootCauseWeeklyhttps://github.com/RootCauseWeekly
on Oct 23, 2026https://github.com/astanin/python-tabulate/issues/478#issue-6005479461
#399https://github.com/astanin/python-tabulate/issues/399
032dc0dhttps://github.com/astanin/python-tabulate/commit/032dc0d107fedd4ce7921c1a494a76a2910f49ff
032dc0dhttps://github.com/astanin/python-tabulate/commit/032dc0d107fedd4ce7921c1a494a76a2910f49ff
#399https://github.com/astanin/python-tabulate/issues/399
https://github.com/MbappeWU
MbappeWUhttps://github.com/MbappeWU
on Oct 24, 2026https://github.com/astanin/python-tabulate/issues/478#issuecomment-6377969225
#399https://github.com/astanin/python-tabulate/issues/399
https://github.com/MbappeWU
MbappeWUhttps://github.com/MbappeWU
on Oct 29, 2026https://github.com/astanin/python-tabulate/issues/478#issuecomment-6484983204
#399https://github.com/astanin/python-tabulate/issues/399
Sign up for freehttps://github.com/signup?return_to=https://github.com/astanin/python-tabulate/issues/478
Sign in to commenthttps://github.com/login?return_to=https://github.com/astanin/python-tabulate/issues/478
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.