8.1 Stack with Max API weird error - Python


I found a weird error with 8.1 Stack with Max API second implementation storing Max With Count.
In the push and pop methods, getting current max using
current_max = self._cached_max_with_count[-1].max
passes all test cases, but calling the max function defined
current_max = self.max()
doesn’t work and fails the test cases. But self.max is returning the same value, so why does calling the function fail?