Title: Prevent --browser from opening when no report is generated · Issue #145306 · python/cpython · GitHub
Open Graph Title: Prevent --browser from opening when no report is generated · Issue #145306 · python/cpython
X Title: Prevent --browser from opening when no report is generated · Issue #145306 · python/cpython
Description: Bug report Bug description: When profiling a script that does not produce HTML output, the following warning is displayed: Warning: No functions found in profiling data. Check if sampling captured any data. However, when the --browser op...
Open Graph Description: Bug report Bug description: When profiling a script that does not produce HTML output, the following warning is displayed: Warning: No functions found in profiling data. Check if sampling captured ...
X Description: Bug report Bug description: When profiling a script that does not produce HTML output, the following warning is displayed: Warning: No functions found in profiling data. Check if sampling captured ...
Opengraph URL: https://github.com/python/cpython/issues/145306
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Prevent --browser from opening when no report is generated","articleBody":"# Bug report\n\n### Bug description:\n\nWhen profiling a script that does not produce HTML output, the following warning is displayed:\n`Warning: No functions found in profiling data. Check if sampling captured any data.`\nHowever, when the `--browser` option is specified, the program still attempts to open the output file in a browser.\n\n```\n./python -m profiling.sampling run --flamegraph --browser script.py\n```\n\n```python\n# script.py\nprint(\"hello world\")\n```\n\n## Suggested Fix\n\n\n```diff\ndiff --git a/Lib/profiling/sampling/cli.py b/Lib/profiling/sampling/cli.py\nindex f4b31aad45b..75a21429705 100644\n--- a/Lib/profiling/sampling/cli.py\n+++ b/Lib/profiling/sampling/cli.py\n@@ -607,6 +607,10 @@ def _open_in_browser(path):\n \"\"\"\n abs_path = os.path.abspath(path)\n \n+ if not os.path.exists(abs_path):\n+ print(f\"Warning: Could not find {abs_path}\", file=sys.stderr)\n+ return\n+\n # For heatmap directories, open the index.html file\n if os.path.isdir(abs_path):\n index_path = os.path.join(abs_path, 'index.html')\n```\n\nI can open a PR with a proposed fix\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-145339\n* gh-150017\n* gh-152447\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/misa-j","@type":"Person","name":"misa-j"},"datePublished":"2026-02-27T10:05:51.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/145306/cpython/issues/145306"}
| 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:7c3ea120-6fbf-e538-410f-aa20b16b014d |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B08:118815:65837D:8B835B:6A507630 |
| html-safe-nonce | 9b614c371809f78a5478fbbf6a487cde22a1a2cfbad97f38f0d00ca5cccee7a9 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjA4OjExODgxNTo2NTgzN0Q6OEI4MzVCOjZBNTA3NjMwIiwidmlzaXRvcl9pZCI6IjMyMTY0NTE3MTIxMjM0MzQ1NDQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 5c8bbb8a64c8c2ce83824baba1caa3e173c8eefd5bdbf4ae32d79cc364af9281 |
| hovercard-subject-tag | issue:4000215448 |
| 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/145306/issue_layout |
| twitter:image | https://opengraph.githubassets.com/12f3cec161107e383393d7fdddf19b86754c867439672dce187537ffa9209692/python/cpython/issues/145306 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/12f3cec161107e383393d7fdddf19b86754c867439672dce187537ffa9209692/python/cpython/issues/145306 |
| og:image:alt | Bug report Bug description: When profiling a script that does not produce HTML output, the following warning is displayed: Warning: No functions found in profiling data. Check if sampling captured ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | misa-j |
| hostname | github.com |
| expected-hostname | github.com |
| None | d6dc8294eb500fa36bbc57472d61fe87c522f9c3c1d64f70f4926f66a66a7efb |
| 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 | 7ac0ad2f2c7e4b9056617355fd9e33e22b0c8df9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width