@@ -871,11 +871,13 @@ context_getattro(PyObject *self, PyObject *nameobj)
871
871
872
872
if (!strncmp (attrname , "append_name" , strlen ("append_name" ))) {
873
873
getdns_append_name_t value ;
874
+ PyObject * py_value ;
874
875
if ((ret = getdns_context_get_append_name (context , & value )) != GETDNS_RETURN_GOOD ) {
875
876
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
876
877
return NULL ;
877
878
}
878
- return PyLong_FromLong ((long )value );
879
+ py_value = PyLong_FromLong ((long )value );
880
+ return py_value ;
879
881
}
880
882
881
883
if (!strncmp (attrname , "dns_root_servers" , strlen ("dns_root_servers" ))) {
@@ -916,64 +918,77 @@ context_getattro(PyObject *self, PyObject *nameobj)
916
918
api_info = getdns_context_get_api_information (context );
917
919
if (!strncmp (attrname , "resolution_type" , strlen ("resolution_type" ))) {
918
920
getdns_resolution_t value ;
921
+ PyObject * py_value ;
919
922
if ((ret = getdns_context_get_resolution_type (context , & value )) != GETDNS_RETURN_GOOD ) {
920
923
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
921
924
return NULL ;
922
925
}
923
- return PyLong_FromLong ((long )value );
926
+ py_value = PyLong_FromLong ((long )value );
927
+ return py_value ;
924
928
}
925
929
if ((ret = getdns_dict_get_dict (api_info , "all_context" , & all_context )) != GETDNS_RETURN_GOOD ) {
926
930
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
927
931
return NULL ;
928
932
}
929
933
if (!strncmp (attrname , "implementation_string" , strlen ("implementation_string" ))) {
930
934
getdns_bindata * implementation_string ;
935
+ PyObject * py_is ;
931
936
if ((ret = getdns_dict_get_bindata (api_info , "implementation_string" , & implementation_string )) != GETDNS_RETURN_GOOD ) {
932
937
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
933
938
return NULL ;
934
939
}
935
940
#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 ;
938
944
#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 ;
941
948
#endif
942
949
}
943
950
if (!strncmp (attrname , "version_string" , strlen ("version_string" ))) {
944
951
getdns_bindata * version_string ;
952
+ PyObject * py_vs ;
945
953
if ((ret = getdns_dict_get_bindata (api_info , "version_string" , & version_string )) != GETDNS_RETURN_GOOD ) {
946
954
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
947
955
return NULL ;
948
956
}
949
957
#if PY_MAJOR_VERSION >= 3
950
- return PyUnicode_FromStringAndSize ((char * )version_string -> data ,
958
+ py_vs = PyUnicode_FromStringAndSize ((char * )version_string -> data ,
951
959
(Py_ssize_t )version_string -> size );
960
+ return py_vs ;
952
961
#else
953
- return PyString_FromStringAndSize ((char * )version_string -> data ,
962
+ py_vs = PyString_FromStringAndSize ((char * )version_string -> data ,
954
963
(Py_ssize_t )version_string -> size );
964
+ return py_vs ;
955
965
#endif
956
966
}
957
967
958
968
if (!strncmp (attrname , "timeout" , strlen ("timeout" ))) {
959
969
uint64_t value ;
970
+ PyObject * py_value ;
960
971
if ((ret = getdns_context_get_timeout (context , & value )) != GETDNS_RETURN_GOOD ) {
961
972
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
962
973
return NULL ;
963
974
}
964
- return PyLong_FromLong ((long )value );
975
+ py_value = PyLong_FromLong ((long )value );
976
+ return py_value ;
965
977
}
966
978
if (!strncmp (attrname , "idle_timeout" , strlen ("idle_timeout" ))) {
967
979
uint64_t timeout ;
980
+ PyObject * py_to ;
968
981
if ((ret = getdns_context_get_idle_timeout (context , & timeout )) != GETDNS_RETURN_GOOD ) {
969
982
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
970
983
return NULL ;
971
984
}
972
- return PyLong_FromLong ((long )timeout );
985
+ py_to = PyLong_FromLong ((long )timeout );
986
+ return py_to ;
973
987
}
974
988
if (!strncmp (attrname , "dns_transport_list" , strlen ("dns_transport_list" ))) {
975
989
getdns_transport_list_t * transports ;
976
990
PyObject * py_transports ;
991
+ PyObject * py_t ;
977
992
size_t transport_count ;
978
993
int i ;
979
994
if ((ret = getdns_context_get_dns_transport_list (context , & transport_count , & transports )) !=
@@ -986,59 +1001,70 @@ context_getattro(PyObject *self, PyObject *nameobj)
986
1001
return NULL ;
987
1002
}
988
1003
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 );
990
1006
}
991
1007
return py_transports ;
992
1008
}
993
1009
994
1010
if (!strncmp (attrname , "limit_outstanding_queries" , strlen ("limit_outstanding_queries" ))) {
995
1011
uint16_t value ;
1012
+ PyObject * py_value ;
996
1013
if ((ret = getdns_context_get_limit_outstanding_queries (context , & value )) !=
997
1014
GETDNS_RETURN_GOOD ) {
998
1015
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
999
1016
return NULL ;
1000
1017
}
1001
- return PyLong_FromLong (value );
1018
+ py_value = PyLong_FromLong (value );
1019
+ return py_value ;
1002
1020
}
1003
1021
1004
1022
if (!strncmp (attrname , "tls_query_padding_blocksize" , strlen ("tls_query_padding_blocksize" ))) {
1005
1023
uint16_t tls_query_padding_blocksize ;
1024
+ PyObject * py_bs ;
1006
1025
if ((ret = getdns_context_get_tls_query_padding_blocksize (context , & tls_query_padding_blocksize )) !=
1007
1026
GETDNS_RETURN_GOOD ) {
1008
1027
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1009
1028
return NULL ;
1010
1029
}
1011
- return PyLong_FromLong ((long )tls_query_padding_blocksize );
1030
+ py_bs = PyLong_FromLong ((long )tls_query_padding_blocksize );
1031
+ return py_bs ;
1012
1032
}
1013
1033
1014
1034
if (!strncmp (attrname , "edns_client_subnet_private" , strlen ("edns_client_subnet_private" ))) {
1015
1035
uint8_t edns_client_subnet_private ;
1036
+ PyObject * py_sp ;
1016
1037
if ((ret = getdns_context_get_edns_client_subnet_private (context , & edns_client_subnet_private )) !=
1017
1038
GETDNS_RETURN_GOOD ) {
1018
1039
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1019
1040
return NULL ;
1020
1041
}
1021
- return PyLong_FromLong ((long )edns_client_subnet_private );
1042
+ py_sp = PyLong_FromLong ((long )edns_client_subnet_private );
1043
+ return py_sp ;
1022
1044
}
1023
1045
1024
1046
if (!strncmp (attrname , "tls_authentication" , strlen ("tls_authentication" ))) {
1025
1047
getdns_tls_authentication_t value ;
1048
+ PyObject * py_value ;
1026
1049
if ((ret = getdns_context_get_tls_authentication (context , & value )) !=
1027
1050
GETDNS_RETURN_GOOD ) {
1028
1051
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1029
1052
return NULL ;
1030
1053
}
1031
- return PyLong_FromLong ((long )value );
1054
+ py_value = PyLong_FromLong ((long )value );
1055
+ return py_value ;
1032
1056
}
1033
1057
1034
1058
if (!strncmp (attrname , "follow_redirects" , strlen ("follow_redirects" ))) {
1035
1059
getdns_redirects_t value ;
1060
+ PyObject * py_value ;
1036
1061
if ((ret = getdns_context_get_follow_redirects (context , & value )) !=
1037
1062
GETDNS_RETURN_GOOD ) {
1038
1063
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1039
1064
return NULL ;
1040
1065
}
1041
- return PyLong_FromLong ((long )value );
1066
+ py_value = PyLong_FromLong ((long )value );
1067
+ return py_value ;
1042
1068
}
1043
1069
if (!strncmp (attrname , "dnssec_trust_anchors" , strlen ("dnssec_trust_anchors" ))) {
1044
1070
getdns_list * value ;
@@ -1054,52 +1080,63 @@ context_getattro(PyObject *self, PyObject *nameobj)
1054
1080
1055
1081
if (!strncmp (attrname , "dnssec_allowed_skew" , strlen ("dnssec_allowed_skew" ))) {
1056
1082
uint32_t value ;
1083
+ PyObject * py_value ;
1057
1084
if ((ret = getdns_context_get_dnssec_allowed_skew (context , & value )) !=
1058
1085
GETDNS_RETURN_GOOD ) {
1059
1086
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1060
1087
return NULL ;
1061
1088
}
1062
- return PyLong_FromLong ((long )value );
1089
+ py_value = PyLong_FromLong ((long )value );
1090
+ return py_value ;
1063
1091
}
1064
1092
if (!strncmp (attrname , "edns_maximum_udp_payload_size" , strlen ("edns_maximum_udp_payload_size" ))) {
1065
1093
uint16_t value ;
1094
+ PyObject * py_value ;
1066
1095
if ((ret = getdns_context_get_edns_maximum_udp_payload_size (context , & value )) !=
1067
1096
GETDNS_RETURN_GOOD ) {
1068
1097
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1069
1098
return NULL ;
1070
1099
}
1071
- return PyLong_FromLong ((long )value );
1100
+ py_value = PyLong_FromLong ((long )value );
1101
+ return py_value ;
1072
1102
}
1073
1103
if (!strncmp (attrname , "edns_extended_rcode" , strlen ("edns_extended_rcode" ))) {
1074
1104
uint8_t value ;
1105
+ PyObject * py_value ;
1075
1106
if ((ret = getdns_context_get_edns_extended_rcode (context , & value )) !=
1076
1107
GETDNS_RETURN_GOOD ) {
1077
1108
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1078
1109
return NULL ;
1079
1110
}
1080
- return PyLong_FromLong ((long )value );
1111
+ py_value = PyLong_FromLong ((long )value );
1112
+ return py_value ;
1081
1113
}
1082
1114
if (!strncmp (attrname , "edns_version" , strlen ("edns_version" ))) {
1083
1115
uint8_t value ;
1116
+ PyObject * py_value ;
1084
1117
if ((ret = getdns_context_get_edns_version (context , & value )) !=
1085
1118
GETDNS_RETURN_GOOD ) {
1086
1119
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1087
1120
return NULL ;
1088
1121
}
1089
- return PyLong_FromLong ((long )value );
1122
+ py_value = PyLong_FromLong ((long )value );
1123
+ return py_value ;
1090
1124
}
1091
1125
if (!strncmp (attrname , "edns_do_bit" , strlen ("edns_do_bit" ))) {
1092
1126
uint8_t value ;
1127
+ PyObject * py_value ;
1093
1128
if ((ret = getdns_context_get_edns_do_bit (context , & value )) !=
1094
1129
GETDNS_RETURN_GOOD ) {
1095
1130
PyErr_SetString (getdns_error , getdns_get_errorstr_by_id (ret ));
1096
1131
return NULL ;
1097
1132
}
1098
- return PyLong_FromLong ((long )value );
1133
+ py_value = PyLong_FromLong ((long )value );
1134
+ return py_value ;
1099
1135
}
1100
1136
1101
1137
if (!strncmp (attrname , "namespaces" , strlen ("namespaces" ))) {
1102
1138
PyObject * py_namespaces ;
1139
+ PyObject * py_ns ;
1103
1140
getdns_namespace_t * namespaces ;
1104
1141
getdns_return_t ret ;
1105
1142
size_t count ;
@@ -1112,8 +1149,10 @@ context_getattro(PyObject *self, PyObject *nameobj)
1112
1149
}
1113
1150
if (count ) {
1114
1151
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
+ }
1117
1156
return py_namespaces ;
1118
1157
} else
1119
1158
Py_RETURN_NONE ;
@@ -1138,12 +1177,12 @@ context_getattro(PyObject *self, PyObject *nameobj)
1138
1177
1139
1178
if (!strncmp (attrname , "num_pending_requests" , strlen ("num_pending_requests" ))) {
1140
1179
uint32_t num_pending_requests ;
1141
-
1180
+ PyObject * py_npr ;
1142
1181
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 ;
1144
1184
}
1145
1185
1146
-
1147
1186
return PyObject_GenericGetAttr ((PyObject * )self , nameobj );
1148
1187
}
1149
1188
@@ -1284,6 +1323,7 @@ context_str(PyObject *self)
1284
1323
struct getdns_context * context ;
1285
1324
getdns_dict * api_info ;
1286
1325
char * str_api_dict ;
1326
+ PyObject * py_str ;
1287
1327
1288
1328
context = PyCapsule_GetPointer (myself -> py_context , "context" );
1289
1329
api_info = getdns_context_get_api_information (context );
@@ -1292,10 +1332,11 @@ context_str(PyObject *self)
1292
1332
return NULL ;
1293
1333
}
1294
1334
#if PY_MAJOR_VERSION >= 3
1295
- return ( PyUnicode_FromString (str_api_dict ) );
1335
+ py_str = PyUnicode_FromString (str_api_dict );
1296
1336
#else
1297
- return ( PyString_FromString (str_api_dict ) );
1337
+ py_str = PyString_FromString (str_api_dict );
1298
1338
#endif
1339
+ return py_str ;
1299
1340
}
1300
1341
1301
1342
0 commit comments