#23 Fix PyTime.Format (null pointer error)

closed-fixed
None
5
2004-04-25
2004-01-09
No

PyTime.Format currently crashes with a null pointer
exception on times before 1970. (pywintypes.Time(x)
where x < -1)

In Patch 808465 I submitted a change to PyTime.Format
that used mktime and localtime to generate the day of
week and day of year since day of year is not included
in the SYSTEMTIME struct. This can crash because if the
time is before 1970 (e.g. pywintypes.Time(-10)) then
mktime returns -1 and localtime returns NULL.

This is a patch that rather does the calculations
properly (they are just numeric).
I took the code directly from the Python 2.3 datetime
module and merged in the required functions.
The resulting code is therefore simple and more reliable.

Discussion

  • David Fraser

    David Fraser - 2004-01-09

    patch to calculate day of week and year in PyTime.format without null pointer error

     
  • David Fraser

    David Fraser - 2004-01-19
    • priority: 5 --> 7
     
  • David Fraser

    David Fraser - 2004-01-19

    Logged In: YES
    user_id=221678

    fixes a crash, so should be applied soon

     
  • David Fraser

    David Fraser - 2004-03-02
    • priority: 7 --> 9
    • assigned_to: nobody --> mhammond
     
  • David Fraser

    David Fraser - 2004-03-02

    Logged In: YES
    user_id=221678

    Changing priority - this should be fixed soon!
    There is a test to demonstrate it in bug 873847

     
  • David Fraser

    David Fraser - 2004-03-05
    • priority: 9 --> 5
     
  • David Fraser

    David Fraser - 2004-03-05

    Logged In: YES
    user_id=221678

    No longer high priority as a fix for the crash has been applied.
    But still, this is more general code.
    Should it still be applied?
    Or linked to the Python 2.3 datetime module?

     
  • Mark Hammond

    Mark Hammond - 2004-04-25
    • status: open --> closed
     
  • Mark Hammond

    Mark Hammond - 2004-04-25

    Logged In: YES
    user_id=14198

    Sorry for the delay. I checked this in, with the addition
    of setting the is_dst flag correctly from the current
    system. Thanks!

    Checking in PyTime.cpp;
    new revision: 1.11; previous revision: 1.10

     
  • Mark Hammond

    Mark Hammond - 2004-04-25
    • status: closed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks