@@ -65,7 +65,7 @@ class Future:
6565 # `yield Future()` (incorrect).
6666 _asyncio_future_blocking = False
6767
68- _log_traceback = False
68+ __log_traceback = False
6969
7070 def __init__ (self , * , loop = None ):
7171 """Initialize the future.
@@ -90,7 +90,7 @@ def __repr__(self):
9090 ' ' .join (self ._repr_info ()))
9191
9292 def __del__ (self ):
93- if not self ._log_traceback :
93+ if not self .__log_traceback :
9494 # set_exception() was not called, or result() or exception()
9595 # has consumed the exception
9696 return
@@ -105,6 +105,16 @@ def __del__(self):
105105 context ['source_traceback' ] = self ._source_traceback
106106 self ._loop .call_exception_handler (context )
107107
108+ @property
109+ def _log_traceback (self ):
110+ return self .__log_traceback
111+
112+ @_log_traceback .setter
113+ def _log_traceback (self , val ):
114+ if bool (val ):
115+ raise ValueError ('_log_traceback can only be set to False' )
116+ self .__log_traceback = False
117+
108118 def get_loop (self ):
109119 """Return the event loop the Future is bound to."""
110120 return self ._loop
@@ -116,7 +126,7 @@ def cancel(self):
116126 change the future's state to cancelled, schedule the callbacks and
117127 return True.
118128 """
119- self ._log_traceback = False
129+ self .__log_traceback = False
120130 if self ._state != _PENDING :
121131 return False
122132 self ._state = _CANCELLED
@@ -162,7 +172,7 @@ def result(self):
162172 raise CancelledError
163173 if self ._state != _FINISHED :
164174 raise InvalidStateError ('Result is not ready.' )
165- self ._log_traceback = False
175+ self .__log_traceback = False
166176 if self ._exception is not None :
167177 raise self ._exception
168178 return self ._result
@@ -179,7 +189,7 @@ def exception(self):
179189 raise CancelledError
180190 if self ._state != _FINISHED :
181191 raise InvalidStateError ('Exception is not set.' )
182- self ._log_traceback = False
192+ self .__log_traceback = False
183193 return self ._exception
184194
185195 def add_done_callback (self , fn ):
@@ -237,7 +247,7 @@ def set_exception(self, exception):
237247 self ._exception = exception
238248 self ._state = _FINISHED
239249 self ._schedule_callbacks ()
240- self ._log_traceback = True
250+ self .__log_traceback = True
241251
242252 def __await__ (self ):
243253 if not self .done ():
0 commit comments