Tracks without track number get 0

Bug #530325 reported by Iakov Davydov
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Exaile
Fix Released
Low
Thibault Saunier

Bug Description

In 0.3.1b tracks having no id3 track number automatically get number 0.

How to reproduce:
Load in collection mp3 file without id3 track number tag.

What happens:
0 is shown as track number.

What should happen:
Nothing should be shown as a track number.

Revision history for this message
reacocard (reacocard) wrote :

also applies to disc number.

Changed in exaile:
importance: Undecided → Low
milestone: none → 0.3.1
status: New → Confirmed
Changed in exaile:
assignee: nobody → Thibault Saunier (saunierthibault)
Revision history for this message
Thibault Saunier (saunierthibault) wrote :

Corrects the bug, needs a review.

Revision history for this message
Iakov Davydov (iakov-davydov) wrote :

This fixes the bug for me.

Revision history for this message
Thibault Saunier (saunierthibault) wrote :
Revision history for this message
Johannes Sasongko (sjohannes) wrote :

I haven't really looked at the patch thoroughly, but

- if track == -1:
+ if not track:
             cell.set_property('text', '')

Should this be "if track is None"?

Changed in exaile:
status: Confirmed → In Progress
Revision history for this message
Thibault Saunier (saunierthibault) wrote :

@Johannes Sasongko, What is the difference between "if not track" and "if track is None"?

I haven't coded so much in Python and I actually don't reallyy no the good practices.

Thanks for the quick review ;)

Revision history for this message
reacocard (reacocard) wrote :

"if not track" could catch any case where track evaluates to False, so None, 0, False, any empty container, etc. would all match this case. "if track is not None" explicitly checks it against None, so 0, False, etc. won't match. While not a big deal for this situation, it's a good habit to use as it makes your code more robust. Additionally, it also hints to people reading your code that you _expect_ track to be None sometimes, which is useful information.

Revision history for this message
Thibault Saunier (saunierthibault) wrote :

Thanks for your clear and neat explanations ;)

Revision history for this message
reacocard (reacocard) wrote :

patch committed trunk/2891, thanks!

Changed in exaile:
status: In Progress → Fix Committed
reacocard (reacocard)
Changed in exaile:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.