ValueError: microsecond must be in 0..999999
See original GitHub issueHello, all
I’ve got a new error after the v2.0.0 milestone, likely relating to #172. Here’s the error text:
File "/Users/space/Documents/Programming/dt-blog-platform/api-server/db/objs.py", line 268, in commit
self.updatedon = datetime.datetime.utcnow()
File "/var/root/.local/share/virtualenvs/api-server-DI-zCP9m/lib/python3.6/site-packages/umongo/document.py", line 295, in __setattr__
self._data.set(name, value, to_raise=AttributeError)
File "/var/root/.local/share/virtualenvs/api-server-DI-zCP9m/lib/python3.6/site-packages/umongo/data_proxy.py", line 152, in set
value = field._deserialize(value, name, None)
File "/var/root/.local/share/virtualenvs/api-server-DI-zCP9m/lib/python3.6/site-packages/umongo/fields.py", line 245, in _deserialize
return ret.replace(microsecond=round(ret.microsecond, -3))
ValueError: microsecond must be in 0..999999
My guess is something funky is going on either with my system, or maybe the round isn’t working properly? Not too sure, but this should be a simple one.
The way I did this is set a StrictDateTimeField
equal to datetime.datetime.utcnow()
in an overriden commit
method. Ex:
@instance.register
class Foo(Document):
name = fields.StringField()
updatedon = fields.StrictDateTimeField()
def commit(self, *args, **kwargs):
self.updatedon = datetime.datetime.utcnow()
return super(Foo, self).commit(*args, **kwargs)
This error happens when calling the commit method on the object.
Thanks in advance!
Issue Analytics
- State:
- Created 4 years ago
- Comments:6
Top Results From Across the Web
Python: ValueError: microsecond must be in 0..999999 while ...
I'm currently trying calculate the leadtime of all outlook messages within a specific outlook folder using python. In general the script ...
Read more >How do I fix ValueError: microsecond must be in 0..999999?
A microsecond field value must be in the range . A negative value or a value greater than or equal to one million...
Read more >fix bug: microsecond must be in 0..999999 #1655 - GitHub
I used pywin32 to access outlook and sometimes exception thrown by pywin32. It is critical value problem, so I just set milliseconds to...
Read more >str(datetime_obj) doesn't include microseconds if their value is 0
This behavior is intentional and is documented in the datetime.isoformat() docs: """ Return a string representing the date and time in ISO 8601...
Read more >pypyodbc - issue #36 - Google Code
TIMESTAMP columns in SAP HANA cause ValueError: microsecond must be in 0.999999. Posted on Feb 25, 2014 by Swift Elephant.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can do. I’ll have a report for you tomorrow morning EDT
Thanks, Eamonn
Sent from my iPhone
I prefer to rely on comprehensive testing rather than release into the wild until someone complains about a broken app. But frankly, I’m confident about the patch.