@@ -209,10 +209,15 @@ get_future_loop(PyObject *fut)
209209 return loop ;
210210 }
211211
212- if (_PyObject_LookupAttrId (fut , & PyId_get_loop , & getloop ) < 0 ) {
212+ /* if (_PyObject_LookupAttrId(fut, &PyId_get_loop, &getloop) < 0) {
213213 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 {
216221 PyObject * res = _PyObject_CallNoArg (getloop );
217222 Py_DECREF (getloop );
218223 return res ;
@@ -228,7 +233,7 @@ get_running_loop(PyObject **loop)
228233 PyObject * rl ;
229234
230235 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,
232237 // we cannot utilize caching mechanism for it.
233238 /* if (ts->id == cached_running_holder_tsid && cached_running_holder != NULL) {
234239 // Fast path, check the cache.
@@ -250,6 +255,7 @@ get_running_loop(PyObject **loop)
250255 }
251256 }
252257
258+ // 7TO6: End of PyThreadState compatibility
253259 /* cached_running_holder = rl; // borrowed
254260 cached_running_holder_tsid = ts->id;
255261 }*/
@@ -503,7 +509,8 @@ future_init(FutureObj *fut, PyObject *loop)
503509 if (is_true < 0 ) {
504510 return -1 ;
505511 }
506- if (is_true && !_Py_IsFinalizing ()) {
512+ // 7TO6: _Py_IsFinalizing -> _PyFinalizing
513+ if (is_true && !_Py_Finalizing ) {
507514 /* Only try to capture the traceback if the interpreter is not being
508515 finalized. The original motivation to add a `_Py_IsFinalizing()`
509516 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,
904911 PyObject * context )
905912/*[clinic end generated code: output=7ce635bbc9554c1e input=15ab0693a96e9533]*/
906913{
907- if (context == NULL ) {
914+ // 7TO6: Ignore context as is implemented in pure Python
915+ /* if (context == NULL) {
908916 context = PyContext_CopyCurrent();
909917 if (context == NULL) {
910918 return NULL;
911919 }
912920 PyObject *res = future_add_done_callback(self, fn, context);
913921 Py_DECREF(context);
914922 return res;
915- }
923+ } */
916924 return future_add_done_callback (self , fn , context );
917925}
918926
@@ -1713,7 +1721,8 @@ static PyObject *
17131721TaskStepMethWrapper_call (TaskStepMethWrapper * o ,
17141722 PyObject * args , PyObject * kwds )
17151723{
1716- if (kwds != NULL && PyDict_GET_SIZE (kwds ) != 0 ) {
1724+ // 7TO6: PyDict_GET_SIZE -> PyDict_Size
1725+ if (kwds != NULL && PyDict_Size (kwds ) != 0 ) {
17171726 PyErr_SetString (PyExc_TypeError , "function takes no keyword arguments" );
17181727 return NULL ;
17191728 }
@@ -1789,7 +1798,8 @@ TaskWakeupMethWrapper_call(TaskWakeupMethWrapper *o,
17891798{
17901799 PyObject * fut ;
17911800
1792- if (kwds != NULL && PyDict_GET_SIZE (kwds ) != 0 ) {
1801+ // 7TO6: PyDict_GET_SIZE -> PyDict_Size
1802+ if (kwds != NULL && PyDict_Size (kwds ) != 0 ) {
17931803 PyErr_SetString (PyExc_TypeError , "function takes no keyword arguments" );
17941804 return NULL ;
17951805 }
@@ -1984,10 +1994,11 @@ _asyncio_Task___init___impl(TaskObj *self, PyObject *coro, PyObject *loop)
19841994 return -1 ;
19851995 }
19861996
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());
19881999 if (self->task_context == NULL) {
19892000 return -1;
1990- }
2001+ } */
19912002
19922003 Py_CLEAR (self -> task_fut_waiter );
19932004 self -> task_must_cancel = 0 ;
0 commit comments