@@ -209,10 +209,15 @@ get_future_loop(PyObject *fut)
209
209
return loop ;
210
210
}
211
211
212
- if (_PyObject_LookupAttrId (fut , & PyId_get_loop , & getloop ) < 0 ) {
212
+ /* if (_PyObject_LookupAttrId(fut, &PyId_get_loop, &getloop) < 0) {
213
213
return NULL;
214
- }
215
- if (getloop != NULL ) {
214
+ } */
215
+ getloop = _PyObject_GetAttrId (fut , & PyId_get_loop );
216
+ if (getloop == NULL ) {
217
+ if (!PyErr_ExceptionMatches (PyExc_AttributeError ))
218
+ return NULL ;
219
+ PyErr_Clear ();
220
+ } else {
216
221
PyObject * res = _PyObject_CallNoArg (getloop );
217
222
Py_DECREF (getloop );
218
223
return res ;
@@ -228,7 +233,7 @@ get_running_loop(PyObject **loop)
228
233
PyObject * rl ;
229
234
230
235
PyThreadState * ts = PyThreadState_Get ();
231
- // As unique ID of PyThreadState not implemented in Python 3.6,
236
+ // 7TO6: As unique ID of PyThreadState not implemented in Python 3.6,
232
237
// we cannot utilize caching mechanism for it.
233
238
/* if (ts->id == cached_running_holder_tsid && cached_running_holder != NULL) {
234
239
// Fast path, check the cache.
@@ -250,6 +255,7 @@ get_running_loop(PyObject **loop)
250
255
}
251
256
}
252
257
258
+ // 7TO6: End of PyThreadState compatibility
253
259
/* cached_running_holder = rl; // borrowed
254
260
cached_running_holder_tsid = ts->id;
255
261
}*/
@@ -503,7 +509,8 @@ future_init(FutureObj *fut, PyObject *loop)
503
509
if (is_true < 0 ) {
504
510
return -1 ;
505
511
}
506
- if (is_true && !_Py_IsFinalizing ()) {
512
+ // 7TO6: _Py_IsFinalizing -> _PyFinalizing
513
+ if (is_true && !_Py_Finalizing ) {
507
514
/* Only try to capture the traceback if the interpreter is not being
508
515
finalized. The original motivation to add a `_Py_IsFinalizing()`
509
516
call was to prevent SIGSEGV when a Future is created in a __del__
@@ -904,15 +911,16 @@ _asyncio_Future_add_done_callback_impl(FutureObj *self, PyObject *fn,
904
911
PyObject * context )
905
912
/*[clinic end generated code: output=7ce635bbc9554c1e input=15ab0693a96e9533]*/
906
913
{
907
- if (context == NULL ) {
914
+ // 7TO6: Ignore context as is implemented in pure Python
915
+ /* if (context == NULL) {
908
916
context = PyContext_CopyCurrent();
909
917
if (context == NULL) {
910
918
return NULL;
911
919
}
912
920
PyObject *res = future_add_done_callback(self, fn, context);
913
921
Py_DECREF(context);
914
922
return res;
915
- }
923
+ } */
916
924
return future_add_done_callback (self , fn , context );
917
925
}
918
926
@@ -1713,7 +1721,8 @@ static PyObject *
1713
1721
TaskStepMethWrapper_call (TaskStepMethWrapper * o ,
1714
1722
PyObject * args , PyObject * kwds )
1715
1723
{
1716
- if (kwds != NULL && PyDict_GET_SIZE (kwds ) != 0 ) {
1724
+ // 7TO6: PyDict_GET_SIZE -> PyDict_Size
1725
+ if (kwds != NULL && PyDict_Size (kwds ) != 0 ) {
1717
1726
PyErr_SetString (PyExc_TypeError , "function takes no keyword arguments" );
1718
1727
return NULL ;
1719
1728
}
@@ -1789,7 +1798,8 @@ TaskWakeupMethWrapper_call(TaskWakeupMethWrapper *o,
1789
1798
{
1790
1799
PyObject * fut ;
1791
1800
1792
- if (kwds != NULL && PyDict_GET_SIZE (kwds ) != 0 ) {
1801
+ // 7TO6: PyDict_GET_SIZE -> PyDict_Size
1802
+ if (kwds != NULL && PyDict_Size (kwds ) != 0 ) {
1793
1803
PyErr_SetString (PyExc_TypeError , "function takes no keyword arguments" );
1794
1804
return NULL ;
1795
1805
}
@@ -1984,10 +1994,11 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop)
1984
1994
return -1 ;
1985
1995
}
1986
1996
1987
- Py_XSETREF (self -> task_context , PyContext_CopyCurrent ());
1997
+ // 7TO6: Ignore context as is implemented in pure Python
1998
+ /* Py_XSETREF(self->task_context, PyContext_CopyCurrent());
1988
1999
if (self->task_context == NULL) {
1989
2000
return -1;
1990
- }
2001
+ } */
1991
2002
1992
2003
Py_CLEAR (self -> task_fut_waiter );
1993
2004
self -> task_must_cancel = 0 ;
0 commit comments