You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all thank you very much for this great Project helping me to extract meta data from photos!
Using exifread for reading the GPS data from images and I ran into an unexpected exception calling the "decimal" function of a Rational object and adding rationals with the addition ("+") operator.
The following three lines in an interactive python shell can be used to reproduce the error:
How severe is this issue? The photos taken with my ordinary smartphone have some exif data for GPS coordinates stored that I read with exifread yielding exactly the "0/0" Rational issue:
Bug fix brainstorming ideas ( Idid not really think through any of this ideas in depth):
Initialize denominator with '1' if the numerator is '0'
The Ratio object is intended to be immutable either way, hence this modification should not harm e.g., when the user would change the numerator, but still this must be considered with more care maybe!
Throw an exception when the denominator is initialized to '0' (-> remove except block in the new function)
I don't know the reasoning for the except block, but maybe it is obsolete or exception can be catched elsewhere?
Introduce a variable which can accessed to query the "state" of the Ratio object, and a specific exception when using an "invalid" Ratio object, e.g., (dummy code):
class Ratio:
def __new__(self):
...
self.state = "invalid" if self.den == 0 else "valid"
def decimal(self) -> float:
if self.den == 0:
raise RatioInvalidException(f"The Ratio {self} is invalid and cannot be converted to a decimal")
# mathematically something like if self.den == 0: return float("inf") maybe also makes sense (sign must be handled too)
...
The text was updated successfully, but these errors were encountered:
First of all thank you very much for this great Project helping me to extract meta data from photos!
Using exifread for reading the GPS data from images and I ran into an unexpected exception calling the "decimal" function of a Rational object and adding rationals with the addition ("+") operator.
The following three lines in an interactive python shell can be used to reproduce the error:
How severe is this issue? The photos taken with my ordinary smartphone have some exif data for GPS coordinates stored that I read with exifread yielding exactly the "0/0" Rational issue:
Bug fix brainstorming ideas ( Idid not really think through any of this ideas in depth):
The text was updated successfully, but these errors were encountered: