scitran / core

RESTful API
https://scitran.github.io
MIT License
18 stars 18 forks source link

bson.InvalidId -> bson.errors.InvalidId #981

Closed hkethi002 closed 6 years ago

hkethi002 commented 7 years ago

Was getting this error in the log traceback

  File "./api/dao/base.py", line 176, in get_el
    except bson.InvalidId as e:
AttributeError: 'module' object has no attribute 'InvalidId'

http://api.mongodb.com/python/current/api/bson/errors.html

Review Checklist

codecov-io commented 7 years ago

Codecov Report

Merging #981 into master will not change coverage. The diff coverage is 0%.

@@          Coverage Diff          @@
##           master   #981   +/-   ##
=====================================
  Coverage      90%    90%           
=====================================
  Files          49     49           
  Lines        6640   6640           
=====================================
  Hits         5976   5976           
  Misses        664    664
kofalt commented 7 years ago

What am I missing here?

>>> import bson
>>> bson.errors.InvalidId
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'errors'
$ pip list | grep bson
bson (0.5.0)
hkethi002 commented 7 years ago

So when I first imported bson, I was getting the same error, but after installing pymongo as well, then I had access to the InvalidId exception.

Harsha-Macbook-Pro:Clear harshakethineni$ python
Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import bson
>>> bson.errors.InvalidId
<class 'bson.errors.InvalidId'>
Harsha-Macbook-Pro:Clear harshakethineni$ pip list | grep bson
DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
bson (0.5.0)