python / cpython

The Python programming language
https://www.python.org
Other
63.46k stars 30.39k forks source link

Assertion failure in datetime.strftime() #46742

Closed 8d2e9447-92e7-4a6a-8a98-25a1b31e7ec7 closed 16 years ago

8d2e9447-92e7-4a6a-8a98-25a1b31e7ec7 commented 16 years ago
BPO 2490
Nosy @birkenfeld, @benjaminp
Files
  • test.py: Sample code broken in Python 2.5 but working in 2.4
  • 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: ```python assignee = None closed_at = created_at = labels = ['extension-modules', 'type-bug'] title = 'Assertion failure in datetime.strftime()' updated_at = user = 'https://bugs.python.org/genepi' ``` bugs.python.org fields: ```python activity = actor = 'georg.brandl' assignee = 'none' closed = True closed_date = closer = 'georg.brandl' components = ['Extension Modules'] creation = creator = 'genepi' dependencies = [] files = ['9862'] hgrepos = [] issue_num = 2490 keywords = [] message_count = 6.0 messages = ['64536', '64539', '64549', '64553', '64559', '64563'] nosy_count = 3.0 nosy_names = ['georg.brandl', 'benjamin.peterson', 'genepi'] pr_nums = [] priority = 'normal' resolution = 'out of date' stage = None status = 'closed' superseder = None type = 'behavior' url = 'https://bugs.python.org/issue2490' versions = ['Python 2.5'] ```

    8d2e9447-92e7-4a6a-8a98-25a1b31e7ec7 commented 16 years ago

    datetime.strftime(pattern) fails in assertion if pattern is big enough (> 100 chars) while time.strftime(pattern) gives the expected result.

    This occurs on Python 2.5 (tested on OLPC XO laptop, Fedora 9). Python 2.4 (Debian Etch) does not exhibit this bug.

    benjaminp commented 16 years ago

    Can you give us an example of the data that caused the failure?

    8d2e9447-92e7-4a6a-8a98-25a1b31e7ec7 commented 16 years ago

    There is an example of a long strftime pattern in the test.py file attached to that issue. Just change the length of the pattern to see that it works for smaller patterns in Python 2.5.

    The pattern where it occured in my application is a Pango markup string used for localization: "\<markup>\<span lang=\"en\" font_desc=\"Sans,Monospace Bold 130\">\<span foreground=\"#0000FF\">%H\</span>:\<span foreground=\"#00FF00\">%M\</span>:\<span foreground=\"#FF0000\">%S\</span>\</span>\</markup>"

    birkenfeld commented 16 years ago

    I cannot reproduce this with test.py with Python 2.5.1 on x86 Linux.

    8d2e9447-92e7-4a6a-8a98-25a1b31e7ec7 commented 16 years ago

    I did a mistake: OLPC XO is based on Fedora 7 and not 9. They plan to upgrade to 9 later this year (http://wiki.laptop.org/go/Fedora), so this bug will disappear by itself if it's confirmed that test.py runs correctly on Python 2.5.x and Fedora 9 ships with the latest version.

    birkenfeld commented 16 years ago

    Okay, closing as out of date.