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
fix bug: microsecond must be in 0..999999 #1655
Comments
in PyTime.cpp
#ifdef PYWIN_HAVE_DATETIME_CAPI
#endif // PYWIN_HAVE_DATETIME_CAPI #ifndef NO_PYWINTYPES_TIME Is that a properly fix? |
Do you have a test case for the issue being fixed? |
I used pywin32 to access outlook and sometimes exception thrown by pywin32. |
In PyTime.cpp static double round(double Value, int Digits) double milliseconds = round((seconds - (int)seconds) * 1000.0, 0); =>
so milliseconds will cause an exception |
FWIW, I spent some time trying to reproduce this with the test COM objects and failed. I'll have another go soon, but I'm reluctant to check in a speculative fix without any certainty around whether it actually fixes the problem. |
I have the same problem with the following link: |
Also this issue: #1466 Some date values in Excel cause ValueError: microsecond must be in 0..999999 |
@mhammond any suggestion? |
The links above are other reports of the same bug, which I don't doubt exists. However, they don't seem to get me any closer to a repro. |
My fix is not good, I know that |
It might be good!
Yeah - which is why I'd rather spend a little more time trying to get a repro rather than making a speculative fix. A tweak to the c++ test server that manages to find a float that causes this problem should be possible, but I failed to find it in my first attempt. |
@mhammond I construct a double date with milliseconds: 18712.308206013888 |
Is there a workaround? I am getting datetimes from Outlook (ReceivedTime on a Message). I don't need microseconds so would happily zero them out ahead of referencing the ReceivedTime which generates the ValueError Exception. Is that possible? |
Alternatively, do you think this bugfix will be released in the near future? |
I just merged that PR, so it will be in the next release, but I can't predict when that might be. |
Note that issues in this repository are only for bugs or feature requests in the pywin32.
If you need support or help using this package, please follow these instructions - support or help requests will be closed without comment.
For all bugs, please provide the following information.
Expected behavior and actual behavior.
Steps to reproduce the problem.
Version of Python and pywin32
The text was updated successfully, but these errors were encountered: