Replace the Rational class by fractions.Fraction

Bug #514415 reported by Olivier Tilloy
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
pyexiv2
Fix Released
Wishlist
Olivier Tilloy

Bug Description

Python 2.6.4 provides the fractions module (http://docs.python.org/library/fractions.html) that implements what pyexiv2.utils.Rational does.

pyexiv2 should use it when available, and emulate it when not. Something along the line of:

try:
    from fractions import Fraction
except ImportError:
    # Python < 2.6
    from pyexiv2.utils import _Fraction as Fraction

where pyexiv2.utils._Fraction implements (part of) the required API.

Revision history for this message
Olivier Tilloy (osomon) wrote :

Note that the fractions.Fraction class implements handy features. For instance, a Fraction can be initialized from a string containing a floating point number.

Changed in pyexiv2:
importance: Medium → Wishlist
Revision history for this message
Olivier Tilloy (osomon) wrote :

lp:~osomon/pyexiv2/fractions completely replaces pyexiv2.utils.Rational by fractions.Fraction from the standard library (no conditional code, still to be determined whether a strong dependency on python 2.6 is not a problem in projects that use pyexiv2).

Revision history for this message
Mark Lee (malept) wrote :

FWIW, I'm using pyexiv2 in a Python 2.5 environment. Unfortunately, I'm stuck at that Python version, so it would be great if there was conditional compatibility code, so that I could upgrade to using 0.2 when it's released (I'm looking forward to the XMP support in particular).

Revision history for this message
Olivier Tilloy (osomon) wrote :

I won't merge this patch without conditional code, it potentially renders pyexiv2 unusable for users in Mark's situation.

Olivier Tilloy (osomon)
Changed in pyexiv2:
assignee: nobody → Olivier Tilloy (osomon)
status: Triaged → In Progress
Revision history for this message
Olivier Tilloy (osomon) wrote :

Implemented with revision 348 in the trunk.

pyexiv2 will use fractions.Fraction when available in the standard library (Python ≥ 2.6), or fallback on the custom Rational class in a transparent manner.

Changed in pyexiv2:
milestone: none → 0.3
status: In Progress → Fix Committed
Olivier Tilloy (osomon)
Changed in pyexiv2:
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.