Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
720f34a3
Commit
720f34a3
authored
Dec 09, 2011
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #5905: time.strftime() is now using the locale encoding, instead of
UTF-8, if the wcsftime() function is not available.
parent
383dd585
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
Misc/NEWS
Misc/NEWS
+3
-0
Modules/timemodule.c
Modules/timemodule.c
+4
-9
No files found.
Misc/NEWS
View file @
720f34a3
...
...
@@ -90,6 +90,9 @@ Core and Builtins
Library
-------
- Issue #5905: time.strftime() is now using the locale encoding, instead of
UTF-8, if the wcsftime() function is not available.
- Issue #8641: Update IDLE 3 syntax coloring to recognize b".." and not u"..".
Patch by Tal Einat.
...
...
Modules/timemodule.c
View file @
720f34a3
...
...
@@ -3,8 +3,6 @@
#include "Python.h"
#include "_time.h"
#define TZNAME_ENCODING "utf-8"
#include <ctype.h>
#ifdef HAVE_SYS_TYPES_H
...
...
@@ -48,8 +46,6 @@ static long main_thread;
#if defined(MS_WINDOWS) && !defined(__BORLANDC__)
/* Win32 has better clock replacement; we have our own version below. */
#undef HAVE_CLOCK
#undef TZNAME_ENCODING
#define TZNAME_ENCODING "mbcs"
#endif
/* MS_WINDOWS && !defined(__BORLANDC__) */
#if defined(PYOS_OS2)
...
...
@@ -502,7 +498,7 @@ time_strftime(PyObject *self, PyObject *args)
fmt
=
format
;
#else
/* Convert the unicode string to an ascii one */
format
=
PyUnicode_
AsEncodedString
(
format_arg
,
TZNAME_ENCODING
,
NULL
);
format
=
PyUnicode_
EncodeFSDefault
(
format_arg
);
if
(
format
==
NULL
)
return
NULL
;
fmt
=
PyBytes_AS_STRING
(
format
);
...
...
@@ -546,8 +542,7 @@ time_strftime(PyObject *self, PyObject *args)
#ifdef HAVE_WCSFTIME
ret
=
PyUnicode_FromWideChar
(
outbuf
,
buflen
);
#else
ret
=
PyUnicode_Decode
(
outbuf
,
buflen
,
TZNAME_ENCODING
,
NULL
);
ret
=
PyUnicode_DecodeFSDefaultAndSize
(
outbuf
,
buflen
);
#endif
PyMem_Free
(
outbuf
);
break
;
...
...
@@ -789,8 +784,8 @@ PyInit_timezone(PyObject *m) {
#endif
/* PYOS_OS2 */
#endif
PyModule_AddIntConstant
(
m
,
"daylight"
,
daylight
);
otz0
=
PyUnicode_Decode
(
tzname
[
0
],
strlen
(
tzname
[
0
]),
TZNAME_ENCODING
,
NULL
);
otz1
=
PyUnicode_Decode
(
tzname
[
1
],
strlen
(
tzname
[
1
]),
TZNAME_ENCODING
,
NULL
);
otz0
=
PyUnicode_Decode
FSDefaultAndSize
(
tzname
[
0
],
strlen
(
tzname
[
0
])
);
otz1
=
PyUnicode_Decode
FSDefaultAndSize
(
tzname
[
1
],
strlen
(
tzname
[
1
])
);
PyModule_AddObject
(
m
,
"tzname"
,
Py_BuildValue
(
"(NN)"
,
otz0
,
otz1
));
#else
/* !HAVE_TZNAME || __GLIBC__ || __CYGWIN__*/
#ifdef HAVE_STRUCT_TM_TM_ZONE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment