-
Type:
Build Failure
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: BSON
-
None
Detailed steps to reproduce the problem?
bson.decode_all() disagrees between the C extension and the pure-Python
implementation for a 1-byte input. The C extension raises InvalidBSON. The
pure-Python implementation returns [].
$ python -c " import sys import bson as bson_c # C extension saved = {k: sys.modules.pop(k) for k in list(sys.modules) if k == 'bson' or k.startswith('bson.')} sys.modules['bson._cbson'] = None import bson as bson_pure for k in list(sys.modules): if k == 'bson' or k.startswith('bson.'): del sys.modules[k] sys.modules.update(saved) print(bson_c.decode_all(b'\x00')) # InvalidBSON: not enough data for a BSON document print(bson_pure.decode_all(b'\x00')) # [] <-- bug "
Definition of done: what must be done to consider the task complete?
- The pure-Python implementation raises InvalidBSON for a 1-byte buffer,
matching the C extension. Empty input (b"") must still return []. - Pytest regression test covering both implementations.
The exact Python version used, with patch level:
CPython 3.11.9.
The exact version of PyMongo used, with patch level:
All versions since 3.9.0.
Describe how MongoDB is set up. Local vs Hosted, version, topology, load balanced, etc.
Not applicable. No server is involved; the bug is in offline decoding of a
bytes buffer.
The operating system and version (e.g. Windows 7, OSX 10.8, ...)
Any. No platform dependence.
Web framework or asynchronous network library used, if any, with version (e.g. Django 1.7, mod_wsgi 4.3.0, gevent 1.0.1, Tornado 4.0.2, ...)
None.
Security Vulnerabilities
Low severity correctness bug, no CVE.