Skip to content

Commit c37329b

Browse files
authored
Merge branch 'main' into anyio
2 parents e737994 + cdc988a commit c37329b

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

ipykernel/pickleutil.py

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
from types import FunctionType
1111

1212
# This registers a hook when it's imported
13+
try:
14+
from ipyparallel.serialize import codeutil # noqa: F401
15+
except ImportError:
16+
pass
1317
from traitlets.log import get_logger
1418
from traitlets.utils.importstring import import_item
1519

tests/test_kernel.py

+14-9
Original file line numberDiff line numberDiff line change
@@ -620,20 +620,25 @@ def test_sequential_control_messages():
620620
# Get replies
621621
replies = [get_reply(kc, msg_id, channel="control") for msg_id in msg_ids]
622622

623+
def ensure_datetime(arg):
624+
# Support arg which is a datetime or str.
625+
if isinstance(arg, str):
626+
if sys.version_info[:2] < (3, 11) and arg.endswith("Z"):
627+
# Python < 3.11 doesn't support "Z" suffix in datetime.fromisoformat,
628+
# so use alternative timezone format.
629+
# https://github.com/python/cpython/issues/80010
630+
arg = arg[:-1] + "+00:00"
631+
return datetime.fromisoformat(arg)
632+
return arg
633+
623634
# Check messages are processed in order, one at a time, and of a sensible duration.
624635
previous_end = None
625636
for reply, sleep in zip(replies, sleeps):
626-
start_str = reply["metadata"]["started"]
627-
if sys.version_info[:2] < (3, 11) and start_str.endswith("Z"):
628-
# Python < 3.11 doesn't support "Z" suffix in datetime.fromisoformat,
629-
# so use alternative timezone format.
630-
# https://github.com/python/cpython/issues/80010
631-
start_str = start_str[:-1] + "+00:00"
632-
start = datetime.fromisoformat(start_str)
633-
end = reply["header"]["date"] # Already a datetime
637+
start = ensure_datetime(reply["metadata"]["started"])
638+
end = ensure_datetime(reply["header"]["date"])
634639

635640
if previous_end is not None:
636-
assert start > previous_end
641+
assert start >= previous_end
637642
previous_end = end
638643

639644
assert end >= start + timedelta(seconds=sleep)

0 commit comments

Comments
 (0)