Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop singleton provider from recreating objects implementing __len__ #41

Merged
merged 1 commit into from
Oct 28, 2023
Merged

Stop singleton provider from recreating objects implementing __len__ #41

merged 1 commit into from
Oct 28, 2023

Conversation

Klavionik
Copy link
Contributor

Hello Roberto! A tiny bugfix if you please.

Right now the singleton provider checks if the singleton instance already present using if not self._instance check. This doesn't work well with objects implementing Sized protocol. Python calls __len__ on such objects to check it for truthyness, and if the call returns 0, the condition evaluates to True - even if the instance was already created earlier.

I fixed it simply to compare against None.

@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2023

We're currently processing your upload. This comment will be updated when the results are available.

@RobertoPrevato
Copy link
Member

Hi @Klavionik,
Thank You for this PR - I will publish a new version today. :)
PS. Sorry for replying late.

@RobertoPrevato RobertoPrevato merged commit 99b889c into Neoteroi:main Oct 28, 2023
6 checks passed
@RobertoPrevato
Copy link
Member

@Klavionik your contribution is available with 2.0.4 - again Thank You for reporting and fixing this bug.
https://pypi.org/project/rodi/2.0.4/

@Klavionik
Copy link
Contributor Author

Thank you for releasing it swifty!

Sign up for free to 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.

3 participants