Skip to content

Commit 1f400b3

Browse files
committed
make fi_future read-only, use __slots__
1 parent 3861200 commit 1f400b3

1 file changed

Lines changed: 11 additions & 5 deletions

File tree

‎Lib/asyncio/futures.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -302,18 +302,24 @@ def _await(self):
302302
return self.result() # May raise too.
303303

304304
def __await__(self):
305+
# Return an object that exposes fi_future in addition to being
306+
# a generator, for compatability with the C version.
305307
return _FutureIter(self)
306308

307309
__iter__ = __await__ # make compatible with 'yield from'.
308310

309311

310312
class _FutureIter:
313+
__slots__ = ('__future', '__gen')
314+
311315
def __init__(self, fut):
312-
# The whole point of this class is to expose fi_future, like the C
313-
# version
314-
self.fi_future = fut
316+
self.__future = fut
315317
self.__gen = fut._await()
316318

319+
@property
320+
def fi_future(self):
321+
return self.__future
322+
317323
def __iter__(self):
318324
return self
319325

@@ -324,11 +330,11 @@ def send(self, v, /):
324330
return self.__gen.send(v)
325331

326332
def throw(self, *args):
327-
self.fi_future = None
333+
self.__future = None
328334
return self.__gen.throw(*args)
329335

330336
def close(self):
331-
self.fi_future = None
337+
self.__future = None
332338
self.__gen.close()
333339

334340

0 commit comments

Comments
 (0)