from datetime import timedelta
import time_machine
with time_machine.travel(timedelta()):
pass
crashes due to a segmentation fault in the constructor of the travel class.
The crash happens when the constructor tries to determine the destination timestamp like this:
timestamp = time() + dest.total_seconds()
where time() calls result = _time_machine.original_time() which crashes if time_machine's patches are not applied yet and thus the original_time function pointer is still NULL.
This happens when trying to initialize travel with timedelta only when travel was not successfully used yet in the same process before. Those conditions are hard to meet in the test cases of this library so we fix the bug without adding a new test that would prove that the fix works.
The following Python script:
crashes due to a segmentation fault in the constructor of the
travel
class.The crash happens when the constructor tries to determine the destination timestamp like this:
where
time()
callsresult = _time_machine.original_time()
which crashes if time_machine's patches are not applied yet and thus theoriginal_time
function pointer is stillNULL
.This happens when trying to initialize
travel
withtimedelta
only whentravel
was not successfully used yet in the same process before. Those conditions are hard to meet in the test cases of this library so we fix the bug without adding a new test that would prove that the fix works.Closes #431