Title: gh-101607 causes regression in third-party psutil package on macOS · Issue #102493 · python/cpython · GitHub
Open Graph Title: gh-101607 causes regression in third-party psutil package on macOS · Issue #102493 · python/cpython
X Title: gh-101607 causes regression in third-party psutil package on macOS · Issue #102493 · python/cpython
Description: As part of the cPython release process for macOS installers, besides the standard cPython test suite, we run a small set of additional smoke tests. One of these involves an install from source of the psutil package which includes the bui...
Open Graph Description: As part of the cPython release process for macOS installers, besides the standard cPython test suite, we run a small set of additional smoke tests. One of these involves an install from source of t...
X Description: As part of the cPython release process for macOS installers, besides the standard cPython test suite, we run a small set of additional smoke tests. One of these involves an install from source of t...
Opengraph URL: https://github.com/python/cpython/issues/102493
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"gh-101607 causes regression in third-party psutil package on macOS","articleBody":"As part of the cPython release process for macOS installers, besides the standard cPython test suite, we run a small set of additional smoke tests. One of these involves an install from source of [the psutil package](https://github.com/giampaolo/psutil) which includes the building of a C extension module. In the run up to the 3.12.0a6 release, we found that our long-unchanged simple test was now failing, a regression from 3.12.0a5 and 3.11.x. The commit causing the failure was bisected to feec49c40736fc05626a183a8d14c4ebbea5ae28 from GH-101607, a part of issue #101578. From a cursory glance at the traceback and the psutil code, it appears that psutil uses a [decorator to translate certain OSError exceptions](https://github.com/giampaolo/psutil/blob/master/psutil/_psosx.py#L339) from its C module into other Python exceptions that its calling code is prepared to handle or ignore. For some reason, that exception translation is now failing. FWIW, this is the first failure of this psutil smoke test in recent memory including previous 3.12.0 alphas. Also, FWIW, this same smoke test does not fail on a reasonably recent Debian Linux system but, of course, that exercises a different platform-dependent code path in psutil.\r\n\r\nBecause of its dependencies, it is a bit complicated to build and reproduce without changes. Here is one way to do it; it is likely not optimal. This assumes a fairly recent macOS system with Homebrew installed (as described in the devguide) and assumes git checkouts of the cpython and psutil Github repos.\r\n\r\n```\r\nbrew install pkg-config openssl@1.1 xz\r\n\r\nmkdir /tmp/test_psutil\r\ncd /tmp/test_psutil\r\ngit clone https://github.com/giampaolo/psutil.git\r\ngit clone https://github.com/python/cpython.git # or from an existing repo\r\n\r\ncd cpython\r\ngit checkout feec49c40736fc05626a183a8d14c4ebbea5ae28^ # last good commit\r\ngit clean -fdxq\r\n./configure -q --prefix=/tmp/none --with-pydebug \\\r\n --with-openssl=\"$(brew --prefix openssl@1.1)\"\r\nmake -s -j2\r\ncd ..\r\ngit -C ./psutil clean -fdxq\r\nrm -rf venv\r\n./cpython/python.exe -m venv venv\r\nvenv/bin/python -m pip install --no-binary psutil ./psutil/\r\nvenv/bin/python -c 'import psutil, pprint; pprint.pprint(list(psutil.process_iter()))'\r\n```\r\nThe expected result should be something like:\r\n\r\n\r\n```\r\n[psutil.Process(pid=0, name='kernel_task', status='running', started='03:25:52'),\r\n psutil.Process(pid=1, name='launchd', status='running', started='03:25:52'),\r\n psutil.Process(pid=75, name='logd', status='running', started='03:25:54'),\r\n psutil.Process(pid=76, name='UserEventAgent', status='running', started='03:25:54'),\r\n ...\r\n\r\n```\r\n\r\nWith the failing commit applied (up to and including the current head of the main branch):\r\n\r\n`git checkout feec49c40736fc05626a183a8d14c4ebbea5ae28 # failing commit\r\n`\r\n\r\nand repeating the above build and test, the result is now something like:\r\n\r\n \r\n```\r\nTraceback (most recent call last):\r\n File \"\u003cstring\u003e\", line 1, in \u003cmodule\u003e\r\n File \"/private/tmp/cpython/Lib/pprint.py\", line 55, in pprint\r\n printer.pprint(object)\r\n File \"/private/tmp/cpython/Lib/pprint.py\", line 153, in pprint\r\n self._format(object, self._stream, 0, 0, {}, 0)\r\n File \"/private/tmp/cpython/Lib/pprint.py\", line 175, in _format\r\n rep = self._repr(object, context, level)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/private/tmp/cpython/Lib/pprint.py\", line 455, in _repr\r\n repr, readable, recursive = self.format(object, context.copy(),\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/private/tmp/cpython/Lib/pprint.py\", line 468, in format\r\n return self._safe_repr(object, context, maxlevels, level)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/private/tmp/cpython/Lib/pprint.py\", line 619, in _safe_repr\r\n orepr, oreadable, orecur = self.format(\r\n ^^^^^^^^^^^^\r\n File \"/private/tmp/cpython/Lib/pprint.py\", line 468, in format\r\n return self._safe_repr(object, context, maxlevels, level)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/private/tmp/cpython/Lib/pprint.py\", line 629, in _safe_repr\r\n rep = repr(object)\r\n ^^^^^^^^^^^^\r\n File \"/private/tmp/venv/lib/python3.12/site-packages/psutil/__init__.py\", line 389, in __str__\r\n info[\"name\"] = self.name()\r\n ^^^^^^^^^^^\r\n File \"/private/tmp/venv/lib/python3.12/site-packages/psutil/__init__.py\", line 628, in name\r\n cmdline = self.cmdline()\r\n ^^^^^^^^^^^^^^\r\n File \"/private/tmp/venv/lib/python3.12/site-packages/psutil/__init__.py\", line 681, in cmdline\r\n return self._proc.cmdline()\r\n ^^^^^^^^^^^^^^^^^^^^\r\n File \"/private/tmp/venv/lib/python3.12/site-packages/psutil/_psosx.py\", line 346, in wrapper\r\n return fun(self, *args, **kwargs)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/private/tmp/venv/lib/python3.12/site-packages/psutil/_psosx.py\", line 404, in cmdline\r\n return cext.proc_cmdline(self.pid)\r\n ^^^^^^^^^^^^^^^^^^^^^^^^^^^\r\nOSError: [Errno 1] Operation not permitted (originated from sysctl(KERN_PROCARGS2))\r\n\r\n```\r\n\r\nNote this seems to come from trying to inspect a privileged process and the point of the exception wrapping is to effectively ignore such errors.\r\n\r\nFlagging as a potential release-blocker for @Yhg1s\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-102502\n* gh-102602\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/ned-deily","@type":"Person","name":"ned-deily"},"datePublished":"2023-03-07T09:56:33.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":9},"url":"https://github.com/102493/cpython/issues/102493"}
| 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:2bf29f32-acab-9efb-7c25-ed8a5e021e0b |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AF7E:225E33:9D20EC:D34E14:69697E27 |
| html-safe-nonce | d1d5c3950fdf71431b7d10539e7982a08049dfb99f5126db1baae7946ebb9752 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBRjdFOjIyNUUzMzo5RDIwRUM6RDM0RTE0OjY5Njk3RTI3IiwidmlzaXRvcl9pZCI6IjMyMzU0MDQ5MDQ1NjkzMzk0MzEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | a5cc65cb97c2e7e4413fd0a9fda561aa73fd55dc4afd6276aaeff1e3c587f2dc |
| hovercard-subject-tag | issue:1613091359 |
| 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/102493/issue_layout |
| twitter:image | https://opengraph.githubassets.com/62fee32ecf5bb24de5628bdec492c97c693b5aebf0a6dd23dbf6342cb0a9d061/python/cpython/issues/102493 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/62fee32ecf5bb24de5628bdec492c97c693b5aebf0a6dd23dbf6342cb0a9d061/python/cpython/issues/102493 |
| og:image:alt | As part of the cPython release process for macOS installers, besides the standard cPython test suite, we run a small set of additional smoke tests. One of these involves an install from source of t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ned-deily |
| hostname | github.com |
| expected-hostname | github.com |
| None | f33e4b94c8824ab2b434d82a94139432fb5ebee9df4b75304140ad22508c4a77 |
| 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 | 48f380098b30acbb700b04f1724481ca10d574fc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width