# Buggy code
def wrapped_strategy(self):
    if self.__wrapped_strategy is None:
        if not inspect.isfunction(self.__definition):
            raise InvalidArgument(
                (
                    "Excepted a definition to be a function but got %r of type"
                    " %s instead."
                )
                % (self.__definition, type(self.__definition).__name__)
            )
        result = self.__definition()
        if result is self:
            raise InvalidArgument("Cannot define a deferred strategy to be itself")
        if not isinstance(result, SearchStrategy):
            raise InvalidArgument(
                (
                    "Expected definition to return a SearchStrategy but "
                    "returned %r of type %s"
                )
                % (result, type(result).__name__)
            )
        self.__wrapped_strategy = result
        del self.__definition
    return self.__wrapped_strategy


# Traceback (AttributeError)
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "...\hypothesis\strategies\_internal\strategies.py", line 314, in example
example_generating_inner_function()
File "...\hypothesis\strategies\_internal\strategies.py", line 302, in example_generating_inner_function
@settings(
File "...\hypothesis\core.py", line 1023, in wrapped_test
processed_args = process_arguments_to_given(
File "...\hypothesis\core.py", line 441, in process_arguments_to_given
search_strategy.validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 377, in validate
self.do_validate()
File "...\hypothesis\strategies\_internal\collections.py", line 39, in do_validate
s.validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 377, in validate
self.do_validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 638, in do_validate
self.mapped_strategy.validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 377, in validate
self.do_validate()
File "...\hypothesis\strategies\_internal\lazy.py", line 118, in do_validate
w.validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 377, in validate
self.do_validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 638, in do_validate
self.mapped_strategy.validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 377, in validate
self.do_validate()
File "...\hypothesis\strategies\_internal\collections.py", line 39, in do_validate
s.validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 377, in validate
self.do_validate()
File "...\hypothesis\strategies\_internal\strategies.py", line 595, in do_validate
for e in self.element_strategies:
File "...\hypothesis\strategies\_internal\strategies.py", line 570, in element_strategies
if not arg.is_empty:
File "...\hypothesis\strategies\_internal\strategies.py", line 125, in accept
recur(self)
File "...\hypothesis\strategies\_internal\strategies.py", line 121, in recur
mapping[strat] = getattr(strat, calculation)(recur)
File "...\hypothesis\strategies\_internal\lazy.py", line 86, in calc_is_empty
return recur(self.wrapped_strategy)
File "...\hypothesis\strategies\_internal\strategies.py", line 121, in recur
mapping[strat] = getattr(strat, calculation)(recur)
File "...\hypothesis\strategies\_internal\deferred.py", line 80, in calc_is_empty
return recur(self.wrapped_strategy)
File "...\hypothesis\strategies\_internal\deferred.py", line 55, in wrapped_strategy
del self.__definition
AttributeError: _DeferredStrategy__definition

# Fixed code
def wrapped_strategy(self):
    if self.__wrapped_strategy is None:
        if not inspect.isfunction(self.__definition):
            raise InvalidArgument(
                (
                    "Excepted a definition to be a function but got %r of type"
                    " %s instead."
                )
                % (self.__definition, type(self.__definition).__name__)
            )
        result = self.__definition()
        if result is self:
            raise InvalidArgument("Cannot define a deferred strategy to be itself")
        if not isinstance(result, SearchStrategy):
            raise InvalidArgument(
                (
                    "Expected definition to return a SearchStrategy but "
                    "returned %r of type %s"
                )
                % (result, type(result).__name__)
            )
        self.__wrapped_strategy = result
        self.__definition = None
    return self.__wrapped_strategy