Title: Empty core-property date elements raise TypeError instead of returning None · Issue #1622 · python-openxml/python-docx · GitHub
Open Graph Title: Empty core-property date elements raise TypeError instead of returning None · Issue #1622 · python-openxml/python-docx
X Title: Empty core-property date elements raise TypeError instead of returning None · Issue #1622 · python-openxml/python-docx
Description: Description Reading an empty core-property date element raises TypeError, while a missing element or an invalid date string returns None. This affects created, modified, and last_printed when a document contains an empty corresponding XM...
Open Graph Description: Description Reading an empty core-property date element raises TypeError, while a missing element or an invalid date string returns None. This affects created, modified, and last_printed when a doc...
X Description: Description Reading an empty core-property date element raises TypeError, while a missing element or an invalid date string returns None. This affects created, modified, and last_printed when a doc...
Opengraph URL: https://github.com/python-openxml/python-docx/issues/1622
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Empty core-property date elements raise TypeError instead of returning None","articleBody":"### Description\n\nReading an empty core-property date element raises `TypeError`, while a missing element or an invalid date string returns `None`.\n\nThis affects `created`, `modified`, and `last_printed` when a document contains an empty corresponding XML element.\n\n### Reproduction\n\n```python\nfrom docx.opc.coreprops import CoreProperties\nfrom docx.oxml.parser import parse_xml\n\nxml = b'''\u003ccp:coreProperties\n xmlns:cp=\"http://schemas.openxmlformats.org/package/2006/metadata/core-properties\"\n xmlns:dcterms=\"http://purl.org/dc/terms/\">\n \u003cdcterms:created/>\n\u003c/cp:coreProperties>'''\n\nprint(CoreProperties(parse_xml(xml)).created)\n```\n\nExpected: `None`, consistent with the existing handling of absent or invalid dates.\n\nActual: `TypeError: 'NoneType' object is not subscriptable` in `_parse_W3CDTF_to_datetime`.\n\nReproduced on current `master` with Python 3.12. Regression cases fail for all three empty date elements; whitespace and invalid-string controls already pass. I can submit a small guard with these tests.\n\nI checked the existing fractional-seconds PR #1608; it changes date parsing but does not handle empty elements, so this is a separate case.\n\nAI assistance was used to investigate and test this report.\n","author":{"url":"https://github.com/GreedyC","@type":"Person","name":"GreedyC"},"datePublished":"2026-10-02T13:19:48Z","url":"https://github.com/python-openxml/python-docx/issues/1622"}
| 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:4711ca4c-cd5b-52c5-5584-4927220f6776 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A4E:A0638:76CE4A:885408:6AFF6392 |
| html-safe-nonce | abf963ad153b759bc989dce8596e495e3722e50352d47e463a5fcfc8db6b5e17 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTRFOkEwNjM4Ojc2Q0U0QTo4ODU0MDg6NkFGRjYzOTIiLCJ2aXNpdG9yX2lkIjoiMTM1ODUxODI0MDc4Njk5ODE2MiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b4e60b82c3ccb36e5c0c7ec827a5d6b52bbe4f13a15a6eeb0bfbfd8a4e1fe371 |
| hovercard-subject-tag | issue:5677990151 |
| 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-openxml/python-docx/1622/issue_layout |
| twitter:image | https://opengraph.githubassets.com/37fe7cd8d1459b87fb3831330a324cb9849dd05cbc42e09038b26c55b234be8f/python-openxml/python-docx/issues/1622 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/37fe7cd8d1459b87fb3831330a324cb9849dd05cbc42e09038b26c55b234be8f/python-openxml/python-docx/issues/1622 |
| og:image:alt | Description Reading an empty core-property date element raises TypeError, while a missing element or an invalid date string returns None. This affects created, modified, and last_printed when a doc... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | GreedyC |
| hostname | github.com |
| expected-hostname | github.com |
| None | 41b58589a1c4eda1e3c8904144a412b88ca4455f63ca2ad3629f2e9f3c3a1d12 |
| turbo-cache-control | no-preview |
| go-import | github.com/python-openxml/python-docx git https://github.com/python-openxml/python-docx.git |
| octolytics-dimension-user_id | 3403760 |
| octolytics-dimension-user_login | python-openxml |
| octolytics-dimension-repository_id | 13592924 |
| octolytics-dimension-repository_nwo | python-openxml/python-docx |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 13592924 |
| octolytics-dimension-repository_network_root_nwo | python-openxml/python-docx |
| 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 | 8968d6d6acc65d74e4df332d23932dd3fd0502a4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width