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

[python-bsonjs] bsonjs package shadows pymongo's bson packge

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • python-bsonjs-0.4.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Python Drivers

      Install python-bsonjs latest from source and any version of pymongo, then try to import something from bson. It will fail like this:

      >>> from bson import encode
      Traceback (most recent call last):
        File "<stdin>", line 1, in <module>
      ImportError: cannot import name 'encode' from 'bson' (unknown location)
      

      bsonjs is shadowing the bson package from pymongo:

      >>> import bson
      >>> bson
      <module 'bson' (<_frozen_importlib_external.NamespaceLoader object at 0x102f51550>)>
      >>> dir(bson)
      ['__doc__', '__file__', '__loader__', '__name__', '__package__', '__path__', '__spec__', 'binary', 'codec_options', 'errors', 'objectid', 'typings', 'tz_util']
      >>> bson.__spec__
      ModuleSpec(name='bson', loader=<_frozen_importlib_external.NamespaceLoader object at 0x102f51550>, submodule_search_locations=_NamespacePath(['/Users/shane/git/python-bsonjs/src/bson']))
      

      This was caused by PYTHON-3882.

            Assignee:
            shane.harvey@mongodb.com Shane Harvey
            Reporter:
            shane.harvey@mongodb.com Shane Harvey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: