Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1213

Make decimal128 work with cdecimal

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.5
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      Python2.7

      Edit

      PyMongo's decimal128 support, added in PyMongo 3.4, supports the standard library decimal module which first appeared in CPython 2.4. Some users want to use the cdecimal module from pypi, which became the basis of the decimal module re-write in CPython 3.3, and install cdecimal so that it shadows the standard library module. Contrary to cdecimal's documentation, it is not a drop in replacement. There are subtle API differences that make it incompatible with the standard library decimal module, and decimal128.py.

      The goal here is to work around the incompatibilities so that environments that monkey-patch cdecimal over the stdlib decimal module work properly.

      Original ticket description continues below.
      ------------------------------------------------------

      if _PY3:
      _CTX_OPTIONS['clamp'] = 1
      else:
      _CTX_OPTIONS['_clamp'] = 1

      This is incorrect, as '_clamp' is a valid argument to decimal.Context() for python2.3, ad 'clamp' is correct for python2.7 and 3.0...

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            stevenpainter Steven Painter
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: