Conversation
The injector bootstrap script contains em-dashes in its header comments but declared no encoding, so Python 2.7 rejected the file at parse time (PEP 263) and the self-deactivation logic never ran: injected processes logged "'import sitecustomize' failed" instead of the warn-and-continue behavior the script promises. Add the PEP-263 declaration, bump the distro to 0.2.1, and add a CI job that byte-compiles the script under Python 2.7 and verifies end to end that an injected 2.7 process warns, self-deactivates, and keeps running. Fixes #36
The inline shell version shipped a broken grep pattern (a leading double quote that never occurs in the warn message), failing the job even though the script behaved correctly. Replace it with scripts/check_sitecustomize_python27.py: the assertion logic is a pure function covered by the scripts-test suite, and the workflow job shrinks to a single python3 invocation (the script is stdlib-only, so no uv).
Merged
mmanciop
added a commit
to dash0hq/dash0-operator
that referenced
this pull request
Jul 23, 2026
…-fix commit Adopts dash0hq/opentelemetry-python-distribution#37, which adds a PEP-263 encoding declaration to the packaged sitecustomize.py so it parses on Python 2.7 and can self-deactivate on unsupported interpreters (see dash0hq/opentelemetry-python-distribution#36 for the failure mode). Pinned to main HEAD (6197997e) because no v0.2.1 release has been cut yet; bump to the tag when it lands.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #36.
What
# -*- coding: utf-8 -*-) as the first line of the injector bootstrap script (sitecustomize.py), and extend its header comment to state that the declaration must stay on line 1 or 2.sitecustomize-python27CI job that byte-compiles the script underpython:2.7.18-busterand runs the issue's end-to-end scenario: a Python 2.7 process with the injected directory onPYTHONPATHmust emit the "unsupported Python version" warning, self-deactivate, and keep running — and must not log'import sitecustomize' failed.dash0-opentelemetry-distroto 0.2.1 (the script ships in the wheel) and add the chloggen entry.Why
The script's header comments contain em-dashes (U+2014). Without an encoding declaration, Python 2.7 rejects the whole file at parse time with
SyntaxError: Non-ASCII character '\xe2', so the self-deactivation logic never runs. This defeats the script's stated contract of parsing on unsupported interpreters and deactivating gracefully, and breaks consumers whose fleet includes Python 2.7 processes reached by the OpenTelemetry injector (e.g. the dash0-operator'spython-2.7 dont-crashinstrumentation-image test, dash0hq/dash0-operator#1248).