Title: `TypeError` when trying to deepcopy `argparse.ArgumentParser()` · Issue #149614 · python/cpython · GitHub
Open Graph Title: `TypeError` when trying to deepcopy `argparse.ArgumentParser()` · Issue #149614 · python/cpython
X Title: `TypeError` when trying to deepcopy `argparse.ArgumentParser()` · Issue #149614 · python/cpython
Description: Crash report What happened? To reproduce: import argparse import copy parser = argparse.ArgumentParser() copy.deepcopy(parser) This results in the following exception. File ~/.local/share/uv/python/cpython-3.15.0b1-linux-x86_64-gnu/lib/p...
Open Graph Description: Crash report What happened? To reproduce: import argparse import copy parser = argparse.ArgumentParser() copy.deepcopy(parser) This results in the following exception. File ~/.local/share/uv/python...
X Description: Crash report What happened? To reproduce: import argparse import copy parser = argparse.ArgumentParser() copy.deepcopy(parser) This results in the following exception. File ~/.local/share/uv/python...
Opengraph URL: https://github.com/python/cpython/issues/149614
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`TypeError` when trying to deepcopy `argparse.ArgumentParser()`","articleBody":"# Crash report\n\n### What happened?\n\nTo reproduce:\n\n```python\nimport argparse\nimport copy\n\nparser = argparse.ArgumentParser()\ncopy.deepcopy(parser)\n```\n\nThis results in the following exception.\n```Python\nFile ~/.local/share/uv/python/cpython-3.15.0b1-linux-x86_64-gnu/lib/python3.15/copy.py:138, in deepcopy(x, memo)\n 136 copier = getattr(x, \"__deepcopy__\", None)\n 137 if copier is not None:\n--> 138 y = copier(memo)\n 139 else:\n 140 reductor = dispatch_table.get(cls)\n\nTypeError: 'str' object is not callable\n```\n\nThe root cause is `_ColorlessTheme.__getattr__()` in `argparse.py`.\n```Python\nclass _ColorlessTheme:\n # A 'fake' theme for no colors\n def __getattr__(self, name):\n # _colorize's no_color themes are just all empty strings\n # by directly using empty strings the import is avoided\n return \"\"\n```\n\nIt returns `\"\"` for the `__deepcopy__` atrribute, which `copy.deepcopy()` then tries to call.\n\n### CPython versions tested on:\n\n3.15, CPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n### Output from running 'python -VV' on the command line:\n\nPython 3.15.0b1 (main, May 8 2026, 18:33:09) [Clang 22.1.3 ]\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-149617\n* gh-149693\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/kmvanbrunt","@type":"Person","name":"kmvanbrunt"},"datePublished":"2026-05-09T18:15:29Z","url":"https://github.com/python/cpython/issues/149614"}
| 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:71d3f779-6b63-fe79-4b77-9df9f8bde40e |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D404:269AD9:32A1025:4399A65:6B01F3B3 |
| html-safe-nonce | bab80df3fef1e3eab296bc9fecdd448b04eea28db4940584d3a6d85da1fae315 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJENDA0OjI2OUFEOTozMkExMDI1OjQzOTlBNjU6NkIwMUYzQjMiLCJ2aXNpdG9yX2lkIjoiMjExOTA3MjgyNzY3OTMwNjY3NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 5cb85bc42def33e8c7174d8fba7937caa14438429fd0d8a3b860e473c7cc02b2 |
| hovercard-subject-tag | issue:4413423852 |
| 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/149614/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1a791554e60ee346c06e275af99f95dbbf0a849a593686c3663383fe1a082653/python/cpython/issues/149614 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1a791554e60ee346c06e275af99f95dbbf0a849a593686c3663383fe1a082653/python/cpython/issues/149614 |
| og:image:alt | Crash report What happened? To reproduce: import argparse import copy parser = argparse.ArgumentParser() copy.deepcopy(parser) This results in the following exception. File ~/.local/share/uv/python... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | kmvanbrunt |
| 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