tkrajina/gpxpy

Bug: `free variable 'from_start_to_end' referenced before assignment in enclosing scope`

martinlehoux opened this issue · 1 comments

GPXpy: 1.4.2
Python: 3.8.3

Issue

I ran the following line:

gpx = gpxpy.parse(self.source_file.open())

and encountered the following issue:

free variable 'from_start_to_end' referenced before assignment in enclosing scope

Ideas

The following line seems to have an issue (at least I ran into one):

return [(distance / from_start_to_end) if from_start_to_end else 0

The few lines above do not define from_start_to_end when dist is falsy

dist = interval[-1].distance_3d(end)
if dist:
    from_start_to_end = distances[-1] + dist

Maybe default to 0 ?

Here is the failing track, I can open it successfully in gnome-maps
track.zip