Title: convert_date raises raw TypeError for incomplete values instead of returning them as str · Issue #1286 · PyMySQL/PyMySQL · GitHub
Open Graph Title: convert_date raises raw TypeError for incomplete values instead of returning them as str · Issue #1286 · PyMySQL/PyMySQL
X Title: convert_date raises raw TypeError for incomplete values instead of returning them as str · Issue #1286 · PyMySQL/PyMySQL
Description: convert_date raises raw TypeError for incomplete values, violating its documented "illegal values are returned as str" contract Repro (PyMySQL 1.5.x, current main): from pymysql.converters import convert_date, convert_datetime convert_da...
Open Graph Description: convert_date raises raw TypeError for incomplete values, violating its documented "illegal values are returned as str" contract Repro (PyMySQL 1.5.x, current main): from pymysql.converters import c...
X Description: convert_date raises raw TypeError for incomplete values, violating its documented "illegal values are returned as str" contract Repro (PyMySQL 1.5.x, current main): from pymysql.converter...
Opengraph URL: https://github.com/PyMySQL/PyMySQL/issues/1286
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"convert_date raises raw TypeError for incomplete values instead of returning them as str","articleBody":"## `convert_date` raises raw `TypeError` for incomplete values, violating its documented \"illegal values are returned as str\" contract\n\n**Repro** (PyMySQL 1.5.x, current `main`):\n\n```python\nfrom pymysql.converters import convert_date, convert_datetime\n\nconvert_date('2007-02') # TypeError: function missing required argument 'day' (pos 3)\nconvert_datetime('2007-02') # TypeError: function missing required argument 'day' (pos 3)\n```\n\nThe docstrings and doctests of the converters document that illegal values are returned unchanged as a string (`convert_date('2007-02-31')` → `'2007-02-31'`, `convert_datetime('0000-00-00 00:00:00')` → str), and every other malformed input follows that contract. But a value with fewer than three `-`-separated components passes the `int()` conversion and then fails `datetime.date()`'s arity with a raw `TypeError`:\n\n```\nTypeError: function missing required argument 'day' (pos 3)\n```\n\n`convert_datetime` reaches the same crash through its `except ValueError: return convert_date(obj)` fallback (the fallback itself raises). A result row containing such a string (e.g. a server returning a partial/zero date, or a user mapping the DATE converter onto a TEXT column) crashes inside result decoding instead of yielding the value.\n\n## Expected\n\n`convert_date('2007-02')` → `'2007-02'`, consistent with every other illegal value, per the module's own doctest convention (`# Run doctests with pytest --doctest-modules pymysql/converters.py`).\n\nHappy to send a PR — it's a one-line fix plus a doctest.\n","author":{"url":"https://github.com/rahul05ranjan","@type":"Person","name":"rahul05ranjan"},"datePublished":"2026-10-29T05:25:38Z","url":"https://github.com/PyMySQL/PyMySQL/issues/1286"}
| 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:29e93ab5-48f4-b68e-d081-4fc38da6ef57 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A06E:352B6A:A414A6:DF338F:6AFE7C08 |
| html-safe-nonce | 67348884ab759c9d5ac7162965bde7c7fbf36c24972bfabdb85ed5998c73e576 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBMDZFOjM1MkI2QTpBNDE0QTY6REYzMzhGOjZBRkU3QzA4IiwidmlzaXRvcl9pZCI6IjY0NDQ5ODgzNTY2Mzg5NjQ3NDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | cf9900b93b8c94312a90a0a0a67e1f553b40fc19e1f6c263b57bebe702e4e068 |
| hovercard-subject-tag | issue:6093485150 |
| 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/PyMySQL/PyMySQL/1286/issue_layout |
| twitter:image | https://opengraph.githubassets.com/30eb258bcccc9cb3ddec11e09f51652af783f918c8bb2d85393135c509d0fa65/PyMySQL/PyMySQL/issues/1286 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/30eb258bcccc9cb3ddec11e09f51652af783f918c8bb2d85393135c509d0fa65/PyMySQL/PyMySQL/issues/1286 |
| og:image:alt | convert_date raises raw TypeError for incomplete values, violating its documented "illegal values are returned as str" contract Repro (PyMySQL 1.5.x, current main): from pymysql.converters import c... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | rahul05ranjan |
| hostname | github.com |
| expected-hostname | github.com |
| None | b3c0f155eafc27e60db6e254d1ffff0e072e9ab3b4018a5ee518797c19d89f86 |
| turbo-cache-control | no-preview |
| go-import | github.com/PyMySQL/PyMySQL git https://github.com/PyMySQL/PyMySQL.git |
| octolytics-dimension-user_id | 5338312 |
| octolytics-dimension-user_login | PyMySQL |
| octolytics-dimension-repository_id | 2114213 |
| octolytics-dimension-repository_nwo | PyMySQL/PyMySQL |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 2114213 |
| octolytics-dimension-repository_network_root_nwo | PyMySQL/PyMySQL |
| 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 | 4a10310af51a1bfffbedc4fd81cb582acf0cb0ff |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width