This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients BreamoreBoy, JohnLeitch, belopolsky, brycedarling, eryksun, georg.brandl, larry, lemburg, paul.moore, python-dev, steve.dower, tim.golden, vstinner, zach.ware
Date 2015-09-06.22:45:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1441579538.48.0.455263715426.issue24917@psf.upfronthosting.co.za>
In-reply-to
Content
With MSVC, if errno is cleared before calling strftime, then when buflen == 0 you know whether it's an invalid format string (EINVAL) or maxsize is too small (ERANGE). There's no need to guess. Oddly, only EINVAL is documented, even though setting ERANGE has been in the implementation for years. 

VC 10 (strftime.c):

            /* error - return an empty string */
            *(strstart)='\0';

            /* now return our error/insufficient buffer indication */
            if ( !failed && left <= 0 )
            {
                /* do not report this as an error to allow the caller to resize */
                errno=ERANGE;
            }
            else
            {
                _VALIDATE_RETURN( FALSE, EINVAL, 0);
            }

VC 14 (time/wcsftime.cpp):

        // Error:  return an empty string:
        *string = L'\0';

        // Now return our error/insufficient buffer indication:
        if (!failed && remaining <= 0)
        {
            // Do not report this as an error to allow the caller to resize:
            errno = ERANGE;
        }
        else
        {
            _VALIDATE_RETURN(false, EINVAL, 0);
        }
History
Date User Action Args
2015-09-06 22:45:38eryksunsetrecipients: + eryksun, lemburg, georg.brandl, paul.moore, belopolsky, vstinner, larry, tim.golden, BreamoreBoy, python-dev, zach.ware, steve.dower, JohnLeitch, brycedarling
2015-09-06 22:45:38eryksunsetmessageid: <1441579538.48.0.455263715426.issue24917@psf.upfronthosting.co.za>
2015-09-06 22:45:38eryksunlinkissue24917 messages
2015-09-06 22:45:38eryksuncreate