Skip to content

remove python 3.6 compat code#5892

Closed
knQzx wants to merge 1 commit intogetsentry:masterfrom
knQzx:remove-py36-compat
Closed

remove python 3.6 compat code#5892
knQzx wants to merge 1 commit intogetsentry:masterfrom
knQzx:remove-py36-compat

Conversation

@knQzx
Copy link
Copy Markdown

@knQzx knQzx commented Mar 26, 2026

remove compat code that only existed for python 3.6 - PY37 constant, re.Pattern fallbacks, custom nullcontext, ModuleNotFoundError shim, pre-3.7 aws lambda runtime, and gevent version guard. does not touch contextvars or datetime_from_isoformat

fixes #5040

@knQzx knQzx requested a review from a team as a code owner March 26, 2026 21:56
@github-actions github-actions bot marked this pull request as draft March 26, 2026 21:57
@sdk-maintainer-bot sdk-maintainer-bot bot added the converted-to-draft Used for automated contribution checks. label Mar 26, 2026
@sdk-maintainer-bot
Copy link
Copy Markdown

This PR has been automatically converted to draft. All PRs must start as drafts per our contributing guidelines.

Next steps:

  1. Ensure CI passes
  2. Fill in the PR description completely
  3. Mark as "Ready for review" when you're done

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 26, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Langchain

  • Set gen_ai.operation.name and gen_ai.pipeline.name on LLM spans by ericapisani in #5849
  • Broaden AI provider detection beyond OpenAI and Anthropic by ericapisani in #5707
  • Update LLM span operation to gen_ai.generate_text by ericapisani in #5796

Bug Fixes 🐛

Ci

  • Use gh CLI to convert PR to draft by stephanie-anderson in #5874
  • Use GitHub App token for draft PR enforcement by stephanie-anderson in #5871

Openai

  • Always set gen_ai.response.streaming for Responses by alexander-alderman-webb in #5697
  • Simplify Responses input handling by alexander-alderman-webb in #5695
  • Use max_output_tokens for Responses API by alexander-alderman-webb in #5693
  • Always set gen_ai.response.streaming for Completions by alexander-alderman-webb in #5692
  • Simplify Completions input handling by alexander-alderman-webb in #5690
  • Simplify embeddings input handling by alexander-alderman-webb in #5688

Other

  • (google-genai) Guard response extraction by alexander-alderman-webb in #5869
  • (workflow) Fix permission issue with github app and PR draft graphql endpoint by Jeffreyhung in #5887

Documentation 📚

  • Update CONTRIBUTING.md with contribution requirements and TOC by stephanie-anderson in #5896

Internal Changes 🔧

Langchain

  • Add text completion test by alexander-alderman-webb in #5740
  • Add tool execution test by alexander-alderman-webb in #5739
  • Add basic agent test with Responses call by alexander-alderman-webb in #5726
  • Replace mocks with httpx types by alexander-alderman-webb in #5724
  • Consolidate span origin assertion by alexander-alderman-webb in #5723
  • Consolidate available tools assertion by alexander-alderman-webb in #5721

Openai

  • Replace mocks with httpx types for streaming Responses by alexander-alderman-webb in #5882
  • Replace mocks with httpx types for streaming Completions by alexander-alderman-webb in #5879
  • Move input handling code into API-specific functions by alexander-alderman-webb in #5687

Other

  • (ai) Rename generate_text to text_completion by ericapisani in #5885
  • (asyncpg) Normalize query whitespace in integration by ericapisani in #5855
  • Add workflow to close unvetted non-maintainer PRs by stephanie-anderson in #5895
  • Exclude compromised litellm versions by alexander-alderman-webb in #5876
  • Reactivate litellm tests by alexander-alderman-webb in #5853
  • Add note to coordinate with assignee before PR submission by sentrivana in #5868
  • Temporarily stop running litellm tests by alexander-alderman-webb in #5851

Other

  • remove python 3.6 compat code by knQzx in #5892
  • ci+docs: Add draft PR enforcement by stephanie-anderson in #5867

🤖 This preview updates automatically when you update the PR.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

)
)

if self.options["_experiments"].get("otel_powered_performance", False):
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Accidentally removed otel_powered_performance experiment handling code

High Severity

The block handling the _experiments["otel_powered_performance"] option was removed alongside the Python 3.6 compat code, but it's unrelated to Python 3.6 compatibility. This code was responsible for setting instrumenter to INSTRUMENTER.OTEL and dynamically adding OpenTelemetryIntegration to _DEFAULT_INTEGRATIONS. Without it, the experimental OTel-powered performance feature silently stops working. The option is still defined in consts.py and still referenced by tests in test_experimental.py, which will now fail.

Fix in Cursor Fix in Web

Comment on lines 414 to 419
)
)

if self.options["_experiments"].get("otel_powered_performance", False):
logger.debug(
"[OTel] Enabling experimental OTel-powered performance monitoring."
)
self.options["instrumenter"] = INSTRUMENTER.OTEL
if (
"sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration"
not in _DEFAULT_INTEGRATIONS
):
_DEFAULT_INTEGRATIONS.append(
"sentry_sdk.integrations.opentelemetry.integration.OpenTelemetryIntegration",
)

self.integrations = setup_integrations(
self.options["integrations"],
with_defaults=self.options["default_integrations"],
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: The removal of the otel_powered_performance experiment handling logic breaks the feature. Setting this experiment flag will no longer enable the OpenTelemetryIntegration as intended.
Severity: MEDIUM

Suggested Fix

Restore the deleted code block in sentry_sdk/client.py. This block correctly checks for the otel_powered_performance experiment and enables the OpenTelemetryIntegration. It was not Python 3.6 compatibility code and was removed by mistake.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: sentry_sdk/client.py#L414-L419

Potential issue: The pull request removes a block of code responsible for activating
OpenTelemetry-powered performance monitoring. This logic checks for the
`otel_powered_performance` experiment flag and, if enabled, sets the instrumenter to
`INSTRUMENTER.OTEL` and adds the `OpenTelemetryIntegration`. With this code removed,
setting `_experiments={"otel_powered_performance": True}` during `sentry_init` will no
longer have any effect. This is a silent regression, as the feature will simply stop
working for users who have opted into this experiment, without any warning or error. The
experiment flag is still declared and tests exist that expect this functionality to
work.

Did we get this right? 👍 / 👎 to inform future reviews.

remove PY37 constant, re.Pattern try/except fallbacks, custom
nullcontext, ModuleNotFoundError try/except, pre-3.7 aws lambda
runtime branch, and gevent version_info guard. does not touch
contextvars or datetime_from_isoformat compat

fixes getsentry#5040
@knQzx knQzx force-pushed the remove-py36-compat branch from 40f3c2c to 0a6eac1 Compare March 26, 2026 22:18
@stephanie-anderson stephanie-anderson added the violating-contribution-guidelines Used for automated community contribution checks. label Mar 27, 2026
@stephanie-anderson
Copy link
Copy Markdown
Contributor

This PR has been closed. The referenced issue does not show a discussion between you and a maintainer.

To avoid wasted effort on both sides, please discuss your proposed approach in the issue first and wait for a maintainer to respond before opening a PR.

Please review our contributing guidelines for more details.

@stephanie-anderson stephanie-anderson added missing-maintainer-discussion Used for automated community contribution checks. and removed converted-to-draft Used for automated contribution checks. labels Mar 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

missing-maintainer-discussion Used for automated community contribution checks. violating-contribution-guidelines Used for automated community contribution checks.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove 3.6 compat code

2 participants