New submission from Sverre Johansen <sverre.johan...@gmail.com>: There seems to be a platform difference in the way stftime handles unknown format codes.
In OSX Python removes the percentage sign from the returned string when the format code is unknown. In Linux it leaves it. Look at the following example: This is Python 3.1.2 in Ubuntu: Python 3.1.2 (r312:79147, Apr 15 2010, 15:35:48) [GCC 4.4.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> datetime.datetime.now().strftime("%q") '%q' And this is Python 3.1.2 on Max OSX: Python 3.1.2 (r312:79147, Sep 9 2010, 11:11:24) [GCC 4.2.1 (Apple Inc. build 5664)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import datetime >>> datetime.datetime.now().strftime("%q") 'q' I've gotten the same result in 2.5, 2.6 and 3.1. FYI, this broke some code that parsed the same string first with strftime, and then used string interpolation (The mac version deleted all percentage signs before '('): >>> datetime.datetime.now().strftime("%Y - %(foobar)s") % {"foobar": "egg"} This does not work in OSX. ---------- components: Library (Lib) messages: 115933 nosy: sverrejoh priority: normal severity: normal status: open title: strftime strips '%' from unknown format codes on OS X type: behavior versions: Python 3.1 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue9811> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com