@@ -871,11 +871,13 @@ context_getattro(PyObject *self, PyObject *nameobj)
871871
872872 if (!strncmp (attrname , "append_name" , strlen ("append_name" ))) {
873873 getdns_append_name_t value ;
874+ PyObject * py_value ;
874875 if ((ret = getdns_context_get_append_name (context , & value )) != GETDNS_RETURN_GOOD ) {
875876 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
876877 return NULL ;
877878 }
878- return PyLong_FromLong ((long )value );
879+ py_value = PyLong_FromLong ((long )value );
880+ return py_value ;
879881 }
880882
881883 if (!strncmp (attrname , "dns_root_servers" , strlen ("dns_root_servers" ))) {
@@ -916,64 +918,77 @@ context_getattro(PyObject *self, PyObject *nameobj)
916918 api_info = getdns_context_get_api_information (context );
917919 if (!strncmp (attrname , "resolution_type" , strlen ("resolution_type" ))) {
918920 getdns_resolution_t value ;
921+ PyObject * py_value ;
919922 if ((ret = getdns_context_get_resolution_type (context , & value )) != GETDNS_RETURN_GOOD ) {
920923 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
921924 return NULL ;
922925 }
923- return PyLong_FromLong ((long )value );
926+ py_value = PyLong_FromLong ((long )value );
927+ return py_value ;
924928 }
925929 if ((ret = getdns_dict_get_dict (api_info , "all_context" , & all_context )) != GETDNS_RETURN_GOOD ) {
926930 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
927931 return NULL ;
928932 }
929933 if (!strncmp (attrname , "implementation_string" , strlen ("implementation_string" ))) {
930934 getdns_bindata * implementation_string ;
935+ PyObject * py_is ;
931936 if ((ret = getdns_dict_get_bindata (api_info , "implementation_string" , & implementation_string )) != GETDNS_RETURN_GOOD ) {
932937 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
933938 return NULL ;
934939 }
935940#if PY_MAJOR_VERSION >= 3
936- return PyUnicode_FromStringAndSize ((char * )implementation_string -> data ,
937- (Py_ssize_t )implementation_string -> size );
941+ py_is = PyUnicode_FromStringAndSize ((char * )implementation_string -> data ,
942+ (Py_ssize_t )implementation_string -> size );
943+ return py_is ;
938944#else
939- return PyString_FromStringAndSize ((char * )implementation_string -> data ,
940- (Py_ssize_t )implementation_string -> size );
945+ py_is = PyString_FromStringAndSize ((char * )implementation_string -> data ,
946+ (Py_ssize_t )implementation_string -> size );
947+ return py_is ;
941948#endif
942949 }
943950 if (!strncmp (attrname , "version_string" , strlen ("version_string" ))) {
944951 getdns_bindata * version_string ;
952+ PyObject * py_vs ;
945953 if ((ret = getdns_dict_get_bindata (api_info , "version_string" , & version_string )) != GETDNS_RETURN_GOOD ) {
946954 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
947955 return NULL ;
948956 }
949957#if PY_MAJOR_VERSION >= 3
950- return PyUnicode_FromStringAndSize ((char * )version_string -> data ,
958+ py_vs = PyUnicode_FromStringAndSize ((char * )version_string -> data ,
951959 (Py_ssize_t )version_string -> size );
960+ return py_vs ;
952961#else
953- return PyString_FromStringAndSize ((char * )version_string -> data ,
962+ py_vs = PyString_FromStringAndSize ((char * )version_string -> data ,
954963 (Py_ssize_t )version_string -> size );
964+ return py_vs ;
955965#endif
956966 }
957967
958968 if (!strncmp (attrname , "timeout" , strlen ("timeout" ))) {
959969 uint64_t value ;
970+ PyObject * py_value ;
960971 if ((ret = getdns_context_get_timeout (context , & value )) != GETDNS_RETURN_GOOD ) {
961972 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
962973 return NULL ;
963974 }
964- return PyLong_FromLong ((long )value );
975+ py_value = PyLong_FromLong ((long )value );
976+ return py_value ;
965977 }
966978 if (!strncmp (attrname , "idle_timeout" , strlen ("idle_timeout" ))) {
967979 uint64_t timeout ;
980+ PyObject * py_to ;
968981 if ((ret = getdns_context_get_idle_timeout (context , & timeout )) != GETDNS_RETURN_GOOD ) {
969982 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
970983 return NULL ;
971984 }
972- return PyLong_FromLong ((long )timeout );
985+ py_to = PyLong_FromLong ((long )timeout );
986+ return py_to ;
973987 }
974988 if (!strncmp (attrname , "dns_transport_list" , strlen ("dns_transport_list" ))) {
975989 getdns_transport_list_t * transports ;
976990 PyObject * py_transports ;
991+ PyObject * py_t ;
977992 size_t transport_count ;
978993 int i ;
979994 if ((ret = getdns_context_get_dns_transport_list (context , & transport_count , & transports )) !=
@@ -986,59 +1001,70 @@ context_getattro(PyObject *self, PyObject *nameobj)
9861001 return NULL ;
9871002 }
9881003 for ( i = 0 ; i < transport_count ; i ++ ) {
989- PyList_SetItem (py_transports , (Py_ssize_t )i , PyLong_FromLong ((long )transports [i ]));
1004+ py_t = PyLong_FromLong ((long )transports [i ]);
1005+ PyList_SetItem (py_transports , (Py_ssize_t )i , py_t );
9901006 }
9911007 return py_transports ;
9921008 }
9931009
9941010 if (!strncmp (attrname , "limit_outstanding_queries" , strlen ("limit_outstanding_queries" ))) {
9951011 uint16_t value ;
1012+ PyObject * py_value ;
9961013 if ((ret = getdns_context_get_limit_outstanding_queries (context , & value )) !=
9971014 GETDNS_RETURN_GOOD ) {
9981015 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
9991016 return NULL ;
10001017 }
1001- return PyLong_FromLong (value );
1018+ py_value = PyLong_FromLong (value );
1019+ return py_value ;
10021020 }
10031021
10041022 if (!strncmp (attrname , "tls_query_padding_blocksize" , strlen ("tls_query_padding_blocksize" ))) {
10051023 uint16_t tls_query_padding_blocksize ;
1024+ PyObject * py_bs ;
10061025 if ((ret = getdns_context_get_tls_query_padding_blocksize (context , & tls_query_padding_blocksize )) !=
10071026 GETDNS_RETURN_GOOD ) {
10081027 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10091028 return NULL ;
10101029 }
1011- return PyLong_FromLong ((long )tls_query_padding_blocksize );
1030+ py_bs = PyLong_FromLong ((long )tls_query_padding_blocksize );
1031+ return py_bs ;
10121032 }
10131033
10141034 if (!strncmp (attrname , "edns_client_subnet_private" , strlen ("edns_client_subnet_private" ))) {
10151035 uint8_t edns_client_subnet_private ;
1036+ PyObject * py_sp ;
10161037 if ((ret = getdns_context_get_edns_client_subnet_private (context , & edns_client_subnet_private )) !=
10171038 GETDNS_RETURN_GOOD ) {
10181039 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10191040 return NULL ;
10201041 }
1021- return PyLong_FromLong ((long )edns_client_subnet_private );
1042+ py_sp = PyLong_FromLong ((long )edns_client_subnet_private );
1043+ return py_sp ;
10221044 }
10231045
10241046 if (!strncmp (attrname , "tls_authentication" , strlen ("tls_authentication" ))) {
10251047 getdns_tls_authentication_t value ;
1048+ PyObject * py_value ;
10261049 if ((ret = getdns_context_get_tls_authentication (context , & value )) !=
10271050 GETDNS_RETURN_GOOD ) {
10281051 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10291052 return NULL ;
10301053 }
1031- return PyLong_FromLong ((long )value );
1054+ py_value = PyLong_FromLong ((long )value );
1055+ return py_value ;
10321056 }
10331057
10341058 if (!strncmp (attrname , "follow_redirects" , strlen ("follow_redirects" ))) {
10351059 getdns_redirects_t value ;
1060+ PyObject * py_value ;
10361061 if ((ret = getdns_context_get_follow_redirects (context , & value )) !=
10371062 GETDNS_RETURN_GOOD ) {
10381063 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10391064 return NULL ;
10401065 }
1041- return PyLong_FromLong ((long )value );
1066+ py_value = PyLong_FromLong ((long )value );
1067+ return py_value ;
10421068 }
10431069 if (!strncmp (attrname , "dnssec_trust_anchors" , strlen ("dnssec_trust_anchors" ))) {
10441070 getdns_list * value ;
@@ -1054,52 +1080,63 @@ context_getattro(PyObject *self, PyObject *nameobj)
10541080
10551081 if (!strncmp (attrname , "dnssec_allowed_skew" , strlen ("dnssec_allowed_skew" ))) {
10561082 uint32_t value ;
1083+ PyObject * py_value ;
10571084 if ((ret = getdns_context_get_dnssec_allowed_skew (context , & value )) !=
10581085 GETDNS_RETURN_GOOD ) {
10591086 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10601087 return NULL ;
10611088 }
1062- return PyLong_FromLong ((long )value );
1089+ py_value = PyLong_FromLong ((long )value );
1090+ return py_value ;
10631091 }
10641092 if (!strncmp (attrname , "edns_maximum_udp_payload_size" , strlen ("edns_maximum_udp_payload_size" ))) {
10651093 uint16_t value ;
1094+ PyObject * py_value ;
10661095 if ((ret = getdns_context_get_edns_maximum_udp_payload_size (context , & value )) !=
10671096 GETDNS_RETURN_GOOD ) {
10681097 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10691098 return NULL ;
10701099 }
1071- return PyLong_FromLong ((long )value );
1100+ py_value = PyLong_FromLong ((long )value );
1101+ return py_value ;
10721102 }
10731103 if (!strncmp (attrname , "edns_extended_rcode" , strlen ("edns_extended_rcode" ))) {
10741104 uint8_t value ;
1105+ PyObject * py_value ;
10751106 if ((ret = getdns_context_get_edns_extended_rcode (context , & value )) !=
10761107 GETDNS_RETURN_GOOD ) {
10771108 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10781109 return NULL ;
10791110 }
1080- return PyLong_FromLong ((long )value );
1111+ py_value = PyLong_FromLong ((long )value );
1112+ return py_value ;
10811113 }
10821114 if (!strncmp (attrname , "edns_version" , strlen ("edns_version" ))) {
10831115 uint8_t value ;
1116+ PyObject * py_value ;
10841117 if ((ret = getdns_context_get_edns_version (context , & value )) !=
10851118 GETDNS_RETURN_GOOD ) {
10861119 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10871120 return NULL ;
10881121 }
1089- return PyLong_FromLong ((long )value );
1122+ py_value = PyLong_FromLong ((long )value );
1123+ return py_value ;
10901124 }
10911125 if (!strncmp (attrname , "edns_do_bit" , strlen ("edns_do_bit" ))) {
10921126 uint8_t value ;
1127+ PyObject * py_value ;
10931128 if ((ret = getdns_context_get_edns_do_bit (context , & value )) !=
10941129 GETDNS_RETURN_GOOD ) {
10951130 PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
10961131 return NULL ;
10971132 }
1098- return PyLong_FromLong ((long )value );
1133+ py_value = PyLong_FromLong ((long )value );
1134+ return py_value ;
10991135 }
11001136
11011137 if (!strncmp (attrname , "namespaces" , strlen ("namespaces" ))) {
11021138 PyObject * py_namespaces ;
1139+ PyObject * py_ns ;
11031140 getdns_namespace_t * namespaces ;
11041141 getdns_return_t ret ;
11051142 size_t count ;
@@ -1112,8 +1149,10 @@ context_getattro(PyObject *self, PyObject *nameobj)
11121149 }
11131150 if (count ) {
11141151 py_namespaces = PyList_New (count );
1115- for (i = 0 ; i < count ; i ++ )
1116- PyList_SetItem (py_namespaces , i , PyLong_FromLong ((long )namespaces [i ]));
1152+ for (i = 0 ; i < count ; i ++ ) {
1153+ py_ns = PyLong_FromLong ((long )namespaces [i ]);
1154+ PyList_SetItem (py_namespaces , i , py_ns );
1155+ }
11171156 return py_namespaces ;
11181157 } else
11191158 Py_RETURN_NONE ;
@@ -1138,12 +1177,12 @@ context_getattro(PyObject *self, PyObject *nameobj)
11381177
11391178 if (!strncmp (attrname , "num_pending_requests" , strlen ("num_pending_requests" ))) {
11401179 uint32_t num_pending_requests ;
1141-
1180+ PyObject * py_npr ;
11421181 num_pending_requests = getdns_context_get_num_pending_requests (context , 0 );
1143- return PyLong_FromLong ((long )num_pending_requests );
1182+ py_npr = PyLong_FromLong ((long )num_pending_requests );
1183+ return py_npr ;
11441184 }
11451185
1146-
11471186 return PyObject_GenericGetAttr ((PyObject * )self , nameobj );
11481187}
11491188
@@ -1284,6 +1323,7 @@ context_str(PyObject *self)
12841323 struct getdns_context * context ;
12851324 getdns_dict * api_info ;
12861325 char * str_api_dict ;
1326+ PyObject * py_str ;
12871327
12881328 context = PyCapsule_GetPointer (myself -> py_context , "context" );
12891329 api_info = getdns_context_get_api_information (context );
@@ -1292,10 +1332,11 @@ context_str(PyObject *self)
12921332 return NULL ;
12931333 }
12941334#if PY_MAJOR_VERSION >= 3
1295- return ( PyUnicode_FromString (str_api_dict ) );
1335+ py_str = PyUnicode_FromString (str_api_dict );
12961336#else
1297- return ( PyString_FromString (str_api_dict ) );
1337+ py_str = PyString_FromString (str_api_dict );
12981338#endif
1339+ return py_str ;
12991340}
13001341
13011342
0 commit comments