Title: `glob.translate()` rejects non-recursive pattern segments that include "**" · Issue #116377 · python/cpython · GitHub
Open Graph Title: `glob.translate()` rejects non-recursive pattern segments that include "**" · Issue #116377 · python/cpython
X Title: `glob.translate()` rejects non-recursive pattern segments that include "**" · Issue #116377 · python/cpython
Description: Bug report Bug description: glob.translate(recursive=True) (new in 3.13) rejects any pattern with a segment that includes **, unless ** is the entire segment. For example, translate('**a') is rejected but not translate('**') Rejecting su...
Open Graph Description: Bug report Bug description: glob.translate(recursive=True) (new in 3.13) rejects any pattern with a segment that includes **, unless ** is the entire segment. For example, translate('**a') is rejec...
X Description: Bug report Bug description: glob.translate(recursive=True) (new in 3.13) rejects any pattern with a segment that includes **, unless ** is the entire segment. For example, translate('**a') ...
Opengraph URL: https://github.com/python/cpython/issues/116377
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`glob.translate()` rejects non-recursive pattern segments that include \"**\"","articleBody":"# Bug report\r\n\r\n### Bug description:\r\n\r\n`glob.translate(recursive=True)` (new in 3.13) rejects any pattern with a segment that includes `**`, unless `**` is the entire segment. For example, `translate('**a')` is rejected but not `translate('**')`\r\n\r\nRejecting such segments is longstanding **pathlib** behaviour, but it has no precedent in the **glob** module -- `glob.glob(recursive=True)` happily accepts such segments.\r\n\r\n```python\r\n\u003e\u003e\u003e import glob\r\n\u003e\u003e\u003e glob.glob('**.py', recursive=True)\r\n['blah.py']\r\n\u003e\u003e\u003e glob.translate('**.py', recursive=True)\r\nTraceback (most recent call last):\r\n File \"\u003cstdin\u003e\", line 1, in \u003cmodule\u003e\r\n glob.translate('**.py', recursive=True)\r\n ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^\r\n File \"/home/barney/projects/cpython/Lib/glob.py\", line 304, in translate\r\n raise ValueError(\"Invalid pattern: '**' can only be an entire path component\")\r\nValueError: Invalid pattern: '**' can only be an entire path component\r\n```\r\n\r\n`translate()` should treat these segments similar to `glob()`, and leave the pattern validation stuff to pathlib.\r\n\r\n### CPython versions tested on:\r\n\r\nCPython main branch\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-116378\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/barneygale","@type":"Person","name":"barneygale"},"datePublished":"2024-03-05T19:34:32.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/116377/cpython/issues/116377"}
| 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:71e02584-8606-4b80-8950-4696dff9c2b5 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8174:2A5BE9:21FC2:2ADE0:696AF7F1 |
| html-safe-nonce | cdb2cc03a15d35b333da34d0e5946d70bc319f279699d86e11787682e2cebdab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MTc0OjJBNUJFOToyMUZDMjoyQURFMDo2OTZBRjdGMSIsInZpc2l0b3JfaWQiOiI4NTkwNTk3MDIzNzU0NTQ5MjMzIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 640cb9a21a091a6934a0e4361c55e45ebca25ab278fb345016c12cbe7f01eb30 |
| hovercard-subject-tag | issue:2170003693 |
| 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/116377/issue_layout |
| twitter:image | https://opengraph.githubassets.com/28f1f16483c79ed7ad60be29d00c29dac74d3abe51f9d9bca7a126ed03cc97e3/python/cpython/issues/116377 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/28f1f16483c79ed7ad60be29d00c29dac74d3abe51f9d9bca7a126ed03cc97e3/python/cpython/issues/116377 |
| og:image:alt | Bug report Bug description: glob.translate(recursive=True) (new in 3.13) rejects any pattern with a segment that includes **, unless ** is the entire segment. For example, translate('**a') is rejec... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | barneygale |
| hostname | github.com |
| expected-hostname | github.com |
| None | 5f99f7c1d70f01da5b93e5ca90303359738944d8ab470e396496262c66e60b8d |
| 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 | 82560a55c6b2054555076f46e683151ee28a19bc |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width