Skip to content

fix(dockerfile-utils): keep Python digit classes ASCII-only - #2132

Merged
devin-ai-integration[bot] merged 1 commit into
e2b-dev:devin/1794583693-accept-pr-2132from
fhgffy:codex/fix-dockerignore-ascii-20261113
Nov 13, 2026
Merged

devin-ai-integration[bot] merged 1 commit into
e2b-dev:devin/1794583693-accept-pr-2132from
fhgffy:codex/fix-dockerignore-ascii-20261113

Conversation

@fhgffy

@fhgffy fhgffy commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Python treats \d as a Unicode digit class, so a Dockerignore pattern such as [\d] excludes the file ١ (U+0661). Moby's matcher and the JavaScript utility use ASCII digit semantics and keep that file. Compile Python patterns with re.ASCII, and cover the public matcher with an ASCII digit, a non-ASCII digit and an ordinary letter.

from e2b_dockerfile_utils import PatternMatcher

matcher = PatternMatcher([r"[\d]"])
matcher.matches("5")       # True
matcher.matches("\u0661")  # False
matcher.matches("d")       # False

The expected class follows Go regexp syntax and the Moby pattern compiler. Existing non-ASCII literals and ranges remain covered by the package suite.

Validation on Windows / Python 3.12.2:

  • Full Python utility suite: before, 945 passed / 1 failed / 1 skipped; after, 946 passed / 1 skipped. The failing case is U+0661; the test stays unchanged.
  • Ruff check, Ruff format check and ty check e2b_dockerfile_utils pass.
  • The unchanged JS public matcher passes the same three source-level controls on Node 24.14.0.

The Python run uses the checkout on PYTHONPATH because Python 3.12 does not resolve the Unicode editable .pth path in this Windows environment. The skipped BuildKit fixture is the existing quote-aware ADD/COPY case. Includes a patch changeset for @e2b/dockerfile-utils-python.


Devin Review

@fhgffy
fhgffy requested a review from mishushakov as a code owner November 12, 2026 22:07
@cla-bot cla-bot Bot added the cla-signed label Nov 12, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T22:09:43.646512Z 357b67f PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@changeset-bot

changeset-bot Bot commented Nov 12, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 357b67f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
@e2b/dockerfile-utils-python Patch
@e2b/python-sdk Patch
@e2b/code-interpreter-python Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TASTE.md review: complies, 0 violations. I checked parity (T-1: the Python matcher's \d is now ASCII-only, which matches the JS dockerignore.ts regex built with the u flag) and public-surface rules T-3 to T-25 and T-57 to T-63. None of them are affected because the change is internal to _compile, with no new API, options or error types.

Written by Devin

@mishushakov

Copy link
Copy Markdown
Member

/accept

@mishushakov

Copy link
Copy Markdown
Member

Thank you!

@devin-ai-integration
devin-ai-integration Bot changed the base branch from main to devin/1794583693-accept-pr-2132 November 13, 2026 15:28
@devin-ai-integration
devin-ai-integration Bot merged commit 74f903b into e2b-dev:devin/1794583693-accept-pr-2132 Nov 13, 2026
2 of 3 checks passed
mishushakov pushed a commit that referenced this pull request Nov 13, 2026
## Summary

Brings in community PR #2132 by @fhgffy (squash-merged into this branch
as 74f903b), accepted via `/accept` by @mishushakov, plus a follow-up
for JS/Python parity.

Python's `\d` is a Unicode digit class, so a `.dockerignore` pattern
like `[\d]` excluded `١` (U+0661), unlike Moby's matcher and the JS
utility, which use ASCII digit semantics. `dockerignore.py` now compiles
patterns with `re.ASCII`.

`re.ASCII` also narrows Python's `\s`. JS `\s` still matched Unicode
spaces, so JS `translateClass` now expands `\s` → `\t-\r ` and `\S` →
its complement. Both SDKs now treat every class escape as ASCII, as
Go/Moby does. Ranges with a whitespace escape endpoint (`[\s-x]`) are
still rejected.

```python
from e2b_dockerfile_utils import PatternMatcher

PatternMatcher([r"[\d]"]).matches("\u0661")  # False
PatternMatcher([r"[\s]"]).matches("\u00a0")  # False (same in JS)
PatternMatcher([r"[\S]"]).matches("\u00a0")  # True
```

Includes patch changesets for `@e2b/dockerfile-utils-python` and
`@e2b/dockerfile-utils`.

Link to Devin session:
https://app.devin.ai/sessions/3f7fc785862843c38122d687b28c86bf
Open in Devin Desktop:
https://app.devin.ai/desktop/session/3f7fc785862843c38122d687b28c86bf?variant=devin
<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/e2b-dev/e2b/pull/2139"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->

---------

Co-authored-by: fhgffy <102001626+fhgffy@users.noreply.github.com>
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@e2b-dev e2b-dev deleted a comment from devin-ai-integration Bot Nov 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants