Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong ObjectIdField to_mongo() and validate() methods behavior on Python 3 #618

Closed
lig opened this issue Apr 1, 2014 · 2 comments
Closed

Comments

@lig
Copy link
Contributor

lig commented Apr 1, 2014

ObjectIdField uses unicode(value) to prepare value. 2to3 converts it into str(value) that will lead to "b'…'" strings for values of type bytes on Python 3.

It is better to use decode() method on bytes instances on Python 3. Not sure how to achieve this via 2to3.

@lig
Copy link
Contributor Author

lig commented Apr 1, 2014

Something like

if isinstance(basestring, value) and hasattr(value, 'decode'):
    value = value.decode()

after if not isinstance(value, ObjectId): in ObjectIdField.to_mongo should help.

@bagerard
Copy link
Collaborator

I believe this got fixed and could be closed. The current code in ObjectIdField uses the six library

@lig lig closed this as completed Aug 19, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants