Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:
FWIW, there is a public API to get at the same information: Decimal.as_tuple(). That being said, I don't see how your len(value._int) test could be correct. The exponent will potentially shift the value way out-of-bounds for a database. Consider Decimal('999E+10') or Decimal('999E-10') whose database storage sizes do not fit in a DECIMAL(7,4) field eventhough their len(value._int) is three. To see if the fractional part of a decimal number fits in a database, set the context precision to the database precision and quantize the decimal to the allowed number of decimal places. If the Inexact flag gets set, then it didn't fit. -1 on extending the API any further from the underlying IBM specification. ---------- message_count: 1.0 -> 2.0 nosy: +rhettinger nosy_count: 1.0 -> 2.0 resolution: -> rejected status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5448> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com