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
575d1330
Commit
575d1330
authored
Feb 16, 2009
by
Hirokazu Yamamoto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #5249: time.strftime returned malformed string when format string
contained non ascii character on windows.
parent
debb98d9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
3 deletions
+11
-3
Misc/NEWS
Misc/NEWS
+3
-0
Modules/timemodule.c
Modules/timemodule.c
+8
-3
No files found.
Misc/NEWS
View file @
575d1330
...
...
@@ -12,6 +12,9 @@ What's New in Python 3.1 alpha 0
Core and Builtins
-----------------
- Issue #5249: time.strftime returned malformed string when format string
contained non ascii character on windows.
- Issue #5186: Reduce hash collisions for objects with no __hash__ method by
rotating the object pointer by 4 bits to the right.
...
...
Modules/timemodule.c
View file @
575d1330
...
...
@@ -509,8 +509,10 @@ time_strftime(PyObject *self, PyObject *args)
}
/* Convert the unicode string to an ascii one */
fmt
=
_PyUnicode_AsString
(
format
);
format
=
PyUnicode_AsEncodedString
(
format
,
TZNAME_ENCODING
,
NULL
);
if
(
format
==
NULL
)
return
NULL
;
fmt
=
PyBytes_AS_STRING
(
format
);
fmtlen
=
strlen
(
fmt
);
/* I hate these functions that presume you know how big the output
...
...
@@ -519,6 +521,7 @@ time_strftime(PyObject *self, PyObject *args)
for
(
i
=
1024
;
;
i
+=
i
)
{
outbuf
=
(
char
*
)
PyMem_Malloc
(
i
);
if
(
outbuf
==
NULL
)
{
Py_DECREF
(
format
);
return
PyErr_NoMemory
();
}
buflen
=
strftime
(
outbuf
,
i
,
fmt
,
&
buf
);
...
...
@@ -532,6 +535,7 @@ time_strftime(PyObject *self, PyObject *args)
ret
=
PyUnicode_Decode
(
outbuf
,
buflen
,
TZNAME_ENCODING
,
NULL
);
PyMem_Free
(
outbuf
);
Py_DECREF
(
format
);
return
ret
;
}
PyMem_Free
(
outbuf
);
...
...
@@ -539,6 +543,7 @@ time_strftime(PyObject *self, PyObject *args)
/* VisualStudio .NET 2005 does this properly */
if
(
buflen
==
0
&&
errno
==
EINVAL
)
{
PyErr_SetString
(
PyExc_ValueError
,
"Invalid format string"
);
Py_DECREF
(
format
);
return
0
;
}
#endif
...
...
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