richardbarran / django-photologue

A customizable plug-in photo gallery management application for the Django web framework.
BSD 3-Clause "New" or "Revised" License
674 stars 239 forks source link

Fix Photologue on Python 3.11 #226

Closed emirisman closed 10 months ago

emirisman commented 10 months ago

Photologue on Python 3.11 fails with:

   File "/usr/local/lib/python3.11/dist-packages/photologue/models.py", line 216, in sample
    return random.sample(set(photo_set), count)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/usr/lib/python3.11/random.py", line 439, in sample
    raise TypeError("Population must be a sequence.  "
TypeError: Population must be a sequence.  For dicts or sets, use sorted(d).

This PR fixes the issue by wrapping converting the set into a list.

codecov-commenter commented 10 months ago

Codecov Report

Merging #226 (18a7b05) into master (95c8112) will not change coverage. The diff coverage is 100.00%.

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

@@           Coverage Diff           @@
##           master     #226   +/-   ##
=======================================
  Coverage   72.22%   72.22%           
=======================================
  Files          29       29           
  Lines        1163     1163           
=======================================
  Hits          840      840           
  Misses        323      323           
Files Coverage Δ
photologue/models.py 85.11% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

richardbarran commented 10 months ago

Thanks for the PR, looks good to me. My machine is fairly old and I don't have 3.11 installed :-( so thanks for the debugging. Do you want a new release of Photologue with your bugfix?

emirisman commented 10 months ago

Thanks for the PR, looks good to me.

My machine is fairly old and I don't have 3.11 installed :-( so thanks for the debugging.

Do you want a new release of Photologue with your bugfix?

Yes please, would be great :)

richardbarran commented 10 months ago

Thanks for the PR, looks good to me. My machine is fairly old and I don't have 3.11 installed :-( so thanks for the debugging. Do you want a new release of Photologue with your bugfix?

Yes please, would be great :)

Done.