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

Fix strftime on windows. #49499

Closed
ocean-city mannequin opened this issue Feb 13, 2009 · 8 comments
Closed

Fix strftime on windows. #49499

ocean-city mannequin opened this issue Feb 13, 2009 · 8 comments
Labels
extension-modules C modules in the Modules dir OS-windows type-bug An unexpected behavior, bug, or error

Comments

@ocean-city
Copy link
Mannequin

ocean-city mannequin commented Feb 13, 2009

BPO 5249
Nosy @loewis
Files
  • fix_strftime_on_windows.patch
  • experimental_wcsftime.patch: this is not fix. just experimental patch
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2009-02-16.09:30:04.679>
    created_at = <Date 2009-02-13.16:24:06.978>
    labels = ['extension-modules', 'type-bug', 'OS-windows']
    title = 'Fix strftime on windows.'
    updated_at = <Date 2010-04-27.20:32:07.143>
    user = 'https://bugs.python.org/ocean-city'

    bugs.python.org fields:

    activity = <Date 2010-04-27.20:32:07.143>
    actor = 'loewis'
    assignee = 'none'
    closed = True
    closed_date = <Date 2009-02-16.09:30:04.679>
    closer = 'ocean-city'
    components = ['Extension Modules', 'Windows']
    creation = <Date 2009-02-13.16:24:06.978>
    creator = 'ocean-city'
    dependencies = []
    files = ['13072', '13079']
    hgrepos = []
    issue_num = 5249
    keywords = ['patch']
    message_count = 8.0
    messages = ['81946', '81981', '81993', '81994', '81998', '82222', '82225', '82228']
    nosy_count = 3.0
    nosy_names = ['loewis', 'ocean-city', 'kevinwatters']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue5249'
    versions = ['Python 3.0', 'Python 3.1']

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Feb 13, 2009

    On windows, format string should be encoded as mbcs. Otherwise, result
    of strftime would be broken. Here is the patch.

    @ocean-city ocean-city mannequin added extension-modules C modules in the Modules dir OS-windows type-bug An unexpected behavior, bug, or error labels Feb 13, 2009
    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Feb 14, 2009

    I think we should use wcsftime on Windows, even though it works very
    similar to your patch (with the primary difference being that it uses
    alloca instead of Py_Malloc).

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Feb 14, 2009

    I experimentally implemented with wcsftime, but I couldn't get same
    result as strftime + mbcs conversion. Probably because wcsftime depends
    on locale.

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Feb 14, 2009

    Sorry, if we use wcsftime, I cannot create the patch. On VC6, wcsftime
    returns not unicode but mbcs string which copied to wchar array.

    Maybe on snakebite.org, I can access VC9 and confirm its behavior on it? ;-)

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Feb 14, 2009

    On VC6, wcsftime simply converts *format* to mbcs string, calls
    strftime, and converts result to unicode, so there is no difference
    between my patch and wcsftime.

    Right.

    (Newer VC's wcsftime might have different
    implementation though) Maybe you are concerning about the cost of extra
    unicode object creation on non-windows platform?

    No. I'm concerned primarily about code cleanliness, by relying on
    library code rather than implementing stuff ourselves.

    OTOH, the conversion to narrow strings still needs to happen on Unix
    (and probably needs to use the locale's encoding, not UTF-8), so
    a uniform treatment also has a value.

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Feb 16, 2009

    Locale is my weak point. :-(
    If there is locale encoding function like PyUnicode_DecodeFSDefault for
    file system encoding, I think I can use it.

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Feb 16, 2009

    Using TZNAME_ENCODING is fine; I just think it has an incorrect value on
    Unix.

    All in all, I think the (original) patch is fine, please apply.

    @ocean-city
    Copy link
    Mannequin Author

    ocean-city mannequin commented Feb 16, 2009

    Thanks, fixed in r69664(py3k) and r69665(release30-maint).

    @ocean-city ocean-city mannequin closed this as completed Feb 16, 2009
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir OS-windows type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    0 participants