Author: Amaury Forgeot d'Arc <[email protected]>
Branch: decimal-libmpdec
Changeset: r73813:468148a8888b
Date: 2014-10-02 19:38 +0200
http://bitbucket.org/pypy/pypy/changeset/468148a8888b/
Log: more methods
diff --git a/pypy/module/_decimal/interp_context.py
b/pypy/module/_decimal/interp_context.py
--- a/pypy/module/_decimal/interp_context.py
+++ b/pypy/module/_decimal/interp_context.py
@@ -284,6 +284,11 @@
w_a = interp_decimal.convert_op_raise(space, self, w_v)
return w_a.to_eng_string_w(space, self)
+ def to_sci_string_w(self, space, w_v):
+ from pypy.module._decimal import interp_decimal
+ w_a = interp_decimal.convert_op_raise(space, self, w_v)
+ return w_a.descr_str(space, self)
+
def divmod_w(self, space, w_x, w_y):
from pypy.module._decimal import interp_decimal
return interp_decimal.W_Decimal.divmod_impl(space, self, w_x, w_y)
@@ -464,6 +469,7 @@
logical_invert=make_unary_method('mpd_qinvert'),
number_class=interp2app(W_Context.number_class_w),
to_eng_string=interp2app(W_Context.to_eng_string_w),
+ to_sci_string=interp2app(W_Context.to_sci_string_w),
# Binary Operations
add=make_binary_method('mpd_qadd'),
subtract=make_binary_method('mpd_qsub'),
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
@@ -80,8 +80,8 @@
rmpdec.mpd_qfinalize(w_result.mpd, context.ctx, status_ptr)
return w_result
- def descr_str(self, space):
- context = interp_context.getcontext(space)
+ def descr_str(self, space, w_context=None):
+ context = convert_context(space, w_context)
with lltype.scoped_alloc(rffi.CCHARPP.TO, 1) as cp_ptr:
size = rmpdec.mpd_to_sci_size(cp_ptr, self.mpd, context.capitals)
if size < 0:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit