Title: Assigning hn.C after construction bypasses constants validation and fails far from the cause · Issue #239 · derek73/python-nameparser · GitHub
Open Graph Title: Assigning hn.C after construction bypasses constants validation and fails far from the cause · Issue #239 · derek73/python-nameparser
X Title: Assigning hn.C after construction bypasses constants validation and fails far from the cause · Issue #239 · derek73/python-nameparser
Description: #226 added validation of the constants argument in HumanName.__init__, but C is a plain attribute, so post-construction assignment bypasses it entirely: from nameparser import HumanName hn = HumanName('John Doe') hn.C = 'garbage' # accep...
Open Graph Description: #226 added validation of the constants argument in HumanName.__init__, but C is a plain attribute, so post-construction assignment bypasses it entirely: from nameparser import HumanName hn = HumanN...
X Description: #226 added validation of the constants argument in HumanName.__init__, but C is a plain attribute, so post-construction assignment bypasses it entirely: from nameparser import HumanName hn = HumanN...
Opengraph URL: https://github.com/derek73/python-nameparser/issues/239
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Assigning hn.C after construction bypasses constants validation and fails far from the cause","articleBody":"#226 added validation of the `constants` argument in `HumanName.__init__`, but `C` is a plain attribute, so post-construction assignment bypasses it entirely:\n\n```python\nfrom nameparser import HumanName\n\nhn = HumanName('John Doe')\nhn.C = 'garbage' # accepted silently\nhn.full_name = 'Dr John Smith'\n# AttributeError: 'str' object has no attribute 'regexes'\n# — raised deep inside collapse_whitespace, no mention of C\n```\n\nThe error surfaces at the wrong layer with no pointer to the actual mistake.\n\nFix: make `C` a property whose setter reuses the constructor's check (extract a shared `_validate_constants` helper) so both assignment paths give the same immediate `TypeError`.\n\nRelated detail once this is fixed at the source: the pickle sentinel in `__getstate__`/`__setstate__` maps `C is CONSTANTS` to `None` and any `None` back to `CONSTANTS`, so an instance whose `C` was corrupted to `None` via this bypass currently round-trips to the shared singleton — silently \"healing\" the corruption and flipping `has_own_config`. A dedicated module-level sentinel object instead of `None` would remove that ambiguity; likely moot if the setter validation lands.\n\nFound by review of PR #237 — pre-existing, unrelated to that change.","author":{"url":"https://github.com/derek73","@type":"Person","name":"derek73"},"datePublished":"2026-07-06T00:49:30.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/239/python-nameparser/issues/239"}
| 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:b8f40ed5-5e6e-b710-1cb8-0625525f66c7 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 930A:34C3B1:FA40AF:16E1460:6A575D27 |
| html-safe-nonce | e2c9d54e2d5640a1b0ed846d963afea712b2f51fe5aa3962d7ba86b835f54b18 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MzBBOjM0QzNCMTpGQTQwQUY6MTZFMTQ2MDo2QTU3NUQyNyIsInZpc2l0b3JfaWQiOiIyMjM4Nzg4Mzc5NTQ5ODUwOTE5IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | af91424c1f8634f2130f46674ba2a89b66ba65866e487358b022e5d8887cf5a8 |
| hovercard-subject-tag | issue:4815114582 |
| 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/derek73/python-nameparser/239/issue_layout |
| twitter:image | https://opengraph.githubassets.com/aea56086add2aa52ec552c5fad1701c74906de2e867050217f5d65a029f22685/derek73/python-nameparser/issues/239 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/aea56086add2aa52ec552c5fad1701c74906de2e867050217f5d65a029f22685/derek73/python-nameparser/issues/239 |
| og:image:alt | #226 added validation of the constants argument in HumanName.__init__, but C is a plain attribute, so post-construction assignment bypasses it entirely: from nameparser import HumanName hn = HumanN... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | derek73 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4e7a7296a3830877cf21a6ad2a972c9e618a48915e03966cf0c53eb08e5aad98 |
| turbo-cache-control | no-preview |
| go-import | github.com/derek73/python-nameparser git https://github.com/derek73/python-nameparser.git |
| octolytics-dimension-user_id | 18306 |
| octolytics-dimension-user_login | derek73 |
| octolytics-dimension-repository_id | 18353524 |
| octolytics-dimension-repository_nwo | derek73/python-nameparser |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 18353524 |
| octolytics-dimension-repository_network_root_nwo | derek73/python-nameparser |
| 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 | 87685a1c739dbf97e95760413799bb0221799457 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width