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
6bd238cb
Commit
6bd238cb
authored
Nov 22, 2007
by
Walter Dörwald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use PyString instead of PyBytes in wrap_strftime().
parent
f386311f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
10 deletions
+10
-10
Modules/datetimemodule.c
Modules/datetimemodule.c
+10
-10
No files found.
Modules/datetimemodule.c
View file @
6bd238cb
...
...
@@ -1237,9 +1237,9 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
* is expensive, don't unless they're actually used.
*/
totalnew
=
flen
+
1
;
/* realistic if no %z/%Z */
newfmt
=
Py
Bytes
_FromStringAndSize
(
NULL
,
totalnew
);
newfmt
=
Py
String
_FromStringAndSize
(
NULL
,
totalnew
);
if
(
newfmt
==
NULL
)
goto
Done
;
pnew
=
Py
Bytes
_AsString
(
newfmt
);
pnew
=
Py
String
_AsString
(
newfmt
);
usednew
=
0
;
while
((
ch
=
*
pin
++
)
!=
'\0'
)
{
...
...
@@ -1259,7 +1259,7 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
/* format utcoffset */
char
buf
[
100
];
PyObject
*
tzinfo
=
get_tzinfo_member
(
object
);
zreplacement
=
Py
Bytes
_FromStringAndSize
(
""
,
0
);
zreplacement
=
Py
String
_FromStringAndSize
(
""
,
0
);
if
(
zreplacement
==
NULL
)
goto
Done
;
if
(
tzinfo
!=
Py_None
&&
tzinfo
!=
NULL
)
{
assert
(
tzinfoarg
!=
NULL
);
...
...
@@ -1271,15 +1271,15 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
goto
Done
;
Py_DECREF
(
zreplacement
);
zreplacement
=
Py
Bytes
_FromStringAndSize
(
buf
,
Py
String
_FromStringAndSize
(
buf
,
strlen
(
buf
));
if
(
zreplacement
==
NULL
)
goto
Done
;
}
}
assert
(
zreplacement
!=
NULL
);
ptoappend
=
Py
Bytes
_AS_STRING
(
zreplacement
);
ntoappend
=
Py
Bytes
_GET_SIZE
(
zreplacement
);
ptoappend
=
Py
String
_AS_STRING
(
zreplacement
);
ntoappend
=
Py
String
_GET_SIZE
(
zreplacement
);
}
else
if
(
ch
==
'Z'
)
{
/* format tzname */
...
...
@@ -1314,10 +1314,10 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
PyErr_NoMemory
();
goto
Done
;
}
if
(
PyBytes_Resize
(
newfmt
,
bigger
)
<
0
)
if
(
_PyString_Resize
(
&
newfmt
,
bigger
)
<
0
)
goto
Done
;
totalnew
=
bigger
;
pnew
=
Py
Bytes
_AsString
(
newfmt
)
+
usednew
;
pnew
=
Py
String
_AsString
(
newfmt
)
+
usednew
;
}
memcpy
(
pnew
,
ptoappend
,
ntoappend
);
pnew
+=
ntoappend
;
...
...
@@ -1325,14 +1325,14 @@ wrap_strftime(PyObject *object, PyObject *format, PyObject *timetuple,
assert
(
usednew
<=
totalnew
);
}
/* end while() */
if
(
PyBytes_Resize
(
newfmt
,
usednew
)
<
0
)
if
(
_PyString_Resize
(
&
newfmt
,
usednew
)
<
0
)
goto
Done
;
{
PyObject
*
format
;
PyObject
*
time
=
PyImport_ImportModule
(
"time"
);
if
(
time
==
NULL
)
goto
Done
;
format
=
PyUnicode_FromString
(
Py
Bytes
_AS_STRING
(
newfmt
));
format
=
PyUnicode_FromString
(
Py
String
_AS_STRING
(
newfmt
));
if
(
format
!=
NULL
)
{
result
=
PyObject_CallMethod
(
time
,
"strftime"
,
"OO"
,
format
,
timetuple
);
...
...
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