8000 gh-71587: Establish global state in `_datetime` by erlend-aasland · Pull Request #110475 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-71587: Establish global state in _datetime #110475

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Apply PEP-7 to modified code
  • Loading branch information
erlend-aasland committed Oct 6, 2023
commit f5ede1e9bb477c1618dbb6b16c3a02982c77afc4
5 changes: 4 additions & 1 deletion Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -3953,8 +3953,9 @@ timezone_repr(PyDateTime_TimeZone *self)
const char *type_name = Py_TYPE(self)->tp_name;

datetime_state *st = GLOBAL_STATE();
if (((PyObject *)self) == st->PyDateTime_TimeZone_UTC)
if (((PyObject *)self) == st->PyDateTime_TimeZone_UTC) {
return PyUnicode_FromFormat("%s.utc", type_name);
}

if (self->name == NULL)
return PyUnicode_FromFormat("%s(%R)", type_name, self->offset);
Expand All @@ -3979,7 +3980,9 @@ timezone_str(PyDateTime_TimeZone *self)
(GET_TD_DAYS(self->offset) == 0 &&
GET_TD_SECONDS(self->offset) == 0 &&
GET_TD_MICROSECONDS(self->offset) == 0))
{
return PyUnicode_FromString("UTC");
}
/* Offset is normalized, so it is negative if days < 0 */
if (GET_TD_DAYS(self->offset) < 0) {
sign = '-';
Expand Down
0