3030# Distributed under the terms of the GNU General Public License (GPL)
3131# https://www.gnu.org/licenses/
3232# *****************************************************************************
33-
33+ from sage . misc . cachefunc import cached_method
3434from sage .misc .lazy_import import lazy_import
3535from sage .misc .lazy_attribute import lazy_class_attribute
3636from sage .categories .category_with_axiom import CategoryWithAxiom
@@ -174,6 +174,22 @@ def localization(self, additional_units, names=None, normalize=True, category=No
174174 from sage .rings .localization import Localization
175175 return Localization (self , additional_units , names = names , normalize = normalize , category = category )
176176
177+ @cached_method
178+ def fraction_field (self ):
179+ """
180+ Return the fraction field of ``self``.
181+
182+ EXAMPLES::
183+
184+ sage: R = GF(61)['x,y']
185+ sage: Frac(R)
186+ Fraction Field of Multivariate Polynomial Ring in x, y over Finite Field of size 61
187+ sage: R.fraction_field()
188+ Fraction Field of Multivariate Polynomial Ring in x, y over Finite Field of size 61
189+ """
190+ import sage .rings .fraction_field
191+ return sage .rings .fraction_field .FractionField_generic (self )
192+
177193 def _test_fraction_field (self , ** options ):
178194 r"""
179195 Test that the fraction field, if it is implemented, works
@@ -184,14 +200,7 @@ def _test_fraction_field(self, **options):
184200 sage: ZZ._test_fraction_field()
185201 """
186202 tester = self ._tester (** options )
187- try :
188- fraction_field = self .fraction_field ()
189- except (AttributeError , ImportError ):
190- # some integral domains do not implement fraction_field() yet
191- if self in Fields ():
192- raise
193- return
194-
203+ fraction_field = self .fraction_field ()
195204 for x in tester .some_elements ():
196205 # check that we can coerce into the fraction field
197206 fraction_field .coerce (x )
0 commit comments