Skip to content

Conversation

@sentrivana
Copy link
Contributor

Description

Folks might have a channels module that has nothing to do with the channels package we're expecting. This will then make the code throw an AttributeError which we don't handle.

Issues

Reminders

@sentrivanasentrivana requested a review from a team as a code ownerJanuary 12, 2026 16:39
Copy link
Contributor

@alexander-alderman-webbalexander-alderman-webb left a comment

Choose a reason for hiding this comment

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

💯

javiertejero

This comment was marked as outdated.


channels_version=channels.__version__
exceptImportError:
except(ImportError, AttributeError):

Choose a reason for hiding this comment

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

this implies that if there is an AttributeError because of channels line, django_version will be set to None and that is not ideal... perhaps we should split this try/except in 2 parts, 1 for django and another for channels?


channels_version=channels.__version__
exceptImportError:
except(ImportError, AttributeError):

Choose a reason for hiding this comment

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

this implies that if there is an AttributeError because of channels line, django_version will be set to None and that is not ideal... perhaps we should split this try/except in 2 parts, 1 for django and another for channels?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

That's ok, django_version and channels_version both are only used for warning about a very specific Django/channels/sentry-sdk incompatibility that only appears in specific versions.

But you raise a good point in that it's not clear what the variable is used for. It might happen that someone extends the logic at some point using django_version for some other purpose, not realizing it's not always populated correctly. So it's worth making this nicer.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

@github-actions
Copy link
Contributor

github-actionsbot commented Jan 13, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

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


Bug Fixes 🐛

  • fix(clickhouse): Guard against module shadowing by alexander-alderman-webb in #5250
  • fix(gql): Revert signature change of patched gql.Client.execute by alexander-alderman-webb in #5289
  • fix(litellm): Guard against module shadowing by alexander-alderman-webb in #5249
  • fix(pure-eval): Guard against module shadowing by alexander-alderman-webb in #5252
  • fix(ray): Guard against module shadowing by alexander-alderman-webb in #5254
  • fix(threading): Handle channels shadowing by sentrivana in #5299
  • fix(typer): Guard against module shadowing by alexander-alderman-webb in #5253

Documentation 📚

  • docs: Update Python versions banner in README by sentrivana in #5287

Internal Changes 🔧

  • ci(release): Switch from action-prepare-release to Craft by BYK in #5290

🤖 This preview updates automatically when you update the PR.

@sentrivanasentrivana changed the title fix: Handle channels shadowingfix(threading): Handle channels shadowingJan 13, 2026
@sentrivanasentrivana enabled auto-merge (squash) January 13, 2026 09:56
@sentrivanasentrivana merged commit a350506 into masterJan 13, 2026
155 checks passed
@sentrivanasentrivana deleted the ivana/fix-channels-import branch January 13, 2026 10:02
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AttributeError: module 'channels' has no attribute '__version__'

4 participants

@sentrivana@javiertejero@alexander-alderman-webb