Skip to content

Fix strftime on windows. #49499

Closed
Closed

Description

@ocean-city
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']

    Activity

    1. ocean-city commented on Feb 13, 2009

      ocean-citymannequin
      MannequinAuthor

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

    2. added
      extension-modules
      type-bug
      on Feb 13, 2009
    3. loewis commented on Feb 14, 2009

      loewismannequin
      Mannequin

      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).

    4. ocean-city commented on Feb 14, 2009

      ocean-citymannequin
      MannequinAuthor

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

    5. ocean-city commented on Feb 14, 2009

      ocean-citymannequin
      MannequinAuthor

      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? ;-)

    6. loewis commented on Feb 14, 2009

      loewismannequin
      Mannequin

      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.

    7. ocean-city commented on Feb 16, 2009

      ocean-citymannequin
      MannequinAuthor

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

    8. loewis commented on Feb 16, 2009

      loewismannequin
      Mannequin

      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.

    9. ocean-city commented on Feb 16, 2009

      ocean-citymannequin
      MannequinAuthor

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

    10. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      OS-windowsextension-modulestype-bug

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions