Title: Document sys.exc_info behaviour difference · Issue #594 · PythonCharmers/python-future · GitHub
Open Graph Title: Document sys.exc_info behaviour difference · Issue #594 · PythonCharmers/python-future
X Title: Document sys.exc_info behaviour difference · Issue #594 · PythonCharmers/python-future
Description: Easy, clean, reliable Python 2/3 compatibility. Contribute to PythonCharmers/python-future development by creating an account on GitHub.
Open Graph Description: Easy, clean, reliable Python 2/3 compatibility. Contribute to PythonCharmers/python-future development by creating an account on GitHub.
X Description: Easy, clean, reliable Python 2/3 compatibility. Contribute to PythonCharmers/python-future development by creating an account on GitHub.
Opengraph URL: https://github.com/PythonCharmers/python-future
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Document sys.exc_info behaviour difference","articleBody":"The following snippet produces different output between python 2 & 3\r\n\r\n```python\r\n# exc_info_test.py\r\nimport sys\r\n\r\ndef f():\r\n try:\r\n raise RuntimeError()\r\n except Exception as e:\r\n print(\"f:\", sys.exc_info())\r\n g()\r\n\r\ndef g():\r\n print(\"g:\", sys.exc_info())\r\n\r\nf()\r\n```\r\n\r\nOutput\r\n```bash\r\n> python2 exc_info_test.py\r\n('f:', (\u003ctype 'exceptions.RuntimeError'>, RuntimeError(), \u003ctraceback object at 0x7f99aa4ccd70>))\r\n('g:', (\u003ctype 'exceptions.RuntimeError'>, RuntimeError(), \u003ctraceback object at 0x7f99aa4ccd70>))\r\n\r\n> python3 exc_info_test.py\r\nf: (\u003cclass 'RuntimeError'>, RuntimeError(), \u003ctraceback object at 0x7fc14fb67d00>)\r\ng: (None, None, None)\r\n```\r\n\r\nThough the behaviour difference is documented, it is too subtle to notice the difference\r\n\r\nhttps://docs.python.org/2/library/sys.html\r\n> Here, “handling an exception” is defined as “executing or having executed an except clause.” For any stack frame, only information about the most recently handled exception is accessible.\r\n\r\nhttps://docs.python.org/3/library/sys.html\r\n> Here, “handling an exception” is defined as “executing an except clause.” For any stack frame, only information about the exception being currently handled is accessible.\r\n\r\nTo make the difference highlighted, I suggest to document the `sys.exc_info` behaviour difference in [Cheat Sheets](http://python-future.org/compatible_idioms.html) or in an appropriate page.","author":{"url":"https://github.com/sivachandran","@type":"Person","name":"sivachandran"},"datePublished":"2021-09-15T08:40:56Z","url":"https://github.com/PythonCharmers/python-future/issues/594"}
| 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 | /:user_id/:repository/issues/:id(.:format) |
| route-controller | issues |
| route-action | show |
| fetch-nonce | v2:437baba7-59b4-cbaa-81ad-a113f846a7c5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AFAC:D405E:2D404CD:3AD0CA7:6B041644 |
| html-safe-nonce | b8ab45a402247d2ac7a716f1662496f4450439a83c5435cb0bd1b6ee3410f70b |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRkFDOkQ0MDVFOjJENDA0Q0Q6M0FEMENBNzo2QjA0MTY0NCIsInZpc2l0b3JfaWQiOiI3NTI5NjMwMzM5NDg1MTQ0NjQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | fdacd2731057aeed03e6be5ff427d73d1ba5dff2106a908c179fd5fb6b7f2ed8 |
| hovercard-subject-tag | repository:11403699 |
| 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/PythonCharmers/python-future/issues/594 |
| twitter:image | https://opengraph.githubassets.com/ea9840493f00493b0ddcb319049cfd79dd9139d2b4352bbf4a48e00afcda75d2/PythonCharmers/python-future |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ea9840493f00493b0ddcb319049cfd79dd9139d2b4352bbf4a48e00afcda75d2/PythonCharmers/python-future |
| og:image:alt | Easy, clean, reliable Python 2/3 compatibility. Contribute to PythonCharmers/python-future development by creating an account on GitHub. |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-cache |
| go-import | github.com/PythonCharmers/python-future git https://github.com/PythonCharmers/python-future.git |
| octolytics-dimension-user_id | 3365815 |
| octolytics-dimension-user_login | PythonCharmers |
| octolytics-dimension-repository_id | 11403699 |
| octolytics-dimension-repository_nwo | PythonCharmers/python-future |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 11403699 |
| octolytics-dimension-repository_network_root_nwo | PythonCharmers/python-future |
| 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:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width