Author: Amaury Forgeot d'Arc <[email protected]>
Branch: decimal-libmpdec
Changeset: r73795:d7400a663d3b
Date: 2014-09-19 00:04 +0200
http://bitbucket.org/pypy/pypy/changeset/d7400a663d3b/

Log:    Add _decimal.__version__ and __libmpdec_version__

diff --git a/pypy/module/_decimal/__init__.py b/pypy/module/_decimal/__init__.py
--- a/pypy/module/_decimal/__init__.py
+++ b/pypy/module/_decimal/__init__.py
@@ -24,6 +24,9 @@
         'MIN_ETINY': 'space.wrap(interp_decimal.MIN_ETINY)',
 
         'HAVE_THREADS': 'space.wrap(space.config.translation.thread)',
+
+        '__version__': 'space.wrap(interp_decimal.VERSION)',
+        '__libmpdec_version__': 'space.wrap(interp_decimal.LIBMPDEC_VERSION)',
         }
     for name in rmpdec.ROUND_CONSTANTS:
         interpleveldefs[name] = 'space.wrap(%r)' % name
diff --git a/pypy/module/_decimal/interp_decimal.py 
b/pypy/module/_decimal/interp_decimal.py
--- a/pypy/module/_decimal/interp_decimal.py
+++ b/pypy/module/_decimal/interp_decimal.py
@@ -12,6 +12,9 @@
 from pypy.objspace.std.floatobject import HASH_MODULUS, HASH_INF, HASH_NAN
 from pypy.module._decimal import interp_context
 
+VERSION = "1.7"
+LIBMPDEC_VERSION = rffi.charp2str(rmpdec.mpd_version())
+
 if HASH_MODULUS == 2**31 - 1:
     INVERSE_10_MODULUS = 1503238553
 elif HASH_MODULUS == 2**61 - 1:
diff --git a/pypy/module/_decimal/test/test_module.py 
b/pypy/module/_decimal/test/test_module.py
--- a/pypy/module/_decimal/test/test_module.py
+++ b/pypy/module/_decimal/test/test_module.py
@@ -9,6 +9,11 @@
         import _decimal
         assert isinstance(_decimal.Decimal, type)
 
+    def test_versions(self):
+        import _decimal
+        assert isinstance(_decimal.__version__, str)
+        assert isinstance(_decimal.__libmpdec_version__, str)
+
     def test_context(self):
         import _decimal
         context = _decimal.Context(
diff --git a/rpython/rlib/rmpdec.py b/rpython/rlib/rmpdec.py
--- a/rpython/rlib/rmpdec.py
+++ b/rpython/rlib/rmpdec.py
@@ -64,6 +64,7 @@
         "mpd_qand", "mpd_qor", "mpd_qxor",
         "mpd_qcopy_sign", "mpd_qcopy_abs", "mpd_qcopy_negate",
         "mpd_qround_to_int", "mpd_qround_to_intx",
+        "mpd_version",
         ],
     compile_extra=compile_extra,
     libraries=['m'],
@@ -393,3 +394,5 @@
 mpd_qround_to_intx = external(
     'mpd_qround_to_intx', [MPD_PTR, MPD_PTR, MPD_CONTEXT_PTR, rffi.UINTP],
     lltype.Void)
+
+mpd_version = external('mpd_version', [], rffi.CCHARP, macro=True)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to