@@ -65,7 +65,7 @@ PyNetlinkIPaddress_from_rtnl_addr(struct rtnl_addr *addr)
6565 memset (& buf , 0 , sizeof (buf ));
6666 if ((peer_addr = rtnl_addr_get_peer (addr ))) {
6767 nl_addr2str (peer_addr , buf , sizeof (buf ));
68- py_obj -> peer = PyBytes_FromString (buf );
68+ py_obj -> peer = PyStr_FromString (buf );
6969 if (!py_obj -> local ) {
7070 goto error ;
7171 }
@@ -121,49 +121,40 @@ netlink_ip_address_dealloc(PyNetlinkIPaddress *obj)
121121static PyObject *
122122netlink_ip_address_repr (PyNetlinkIPaddress * obj )
123123{
124- PyObject * result = PyBytes_FromString ("ethtool.NetlinkIPaddress(family=" );
124+ PyObject * result = PyStr_FromString ("ethtool.NetlinkIPaddress(family=" );
125125 char buf [256 ];
126126
127127 memset (& buf , 0 , sizeof (buf ));
128128 nl_af2str (obj -> family , buf , sizeof (buf ));
129- PyBytes_ConcatAndDel (& result ,
130- PyBytes_FromFormat ("%s, address='" , buf ));
131- PyBytes_Concat (& result , obj -> local );
129+ result = PyStr_Concat (result ,
130+ PyStr_FromFormat ("%s, address='%s" ,
131+ buf ,
132+ PyStr_AsString (obj -> local )));
132133
133134 if (obj -> family == AF_INET ) {
134- PyBytes_ConcatAndDel ( & result ,
135- PyBytes_FromFormat ("', netmask=%d" ,
135+ result = PyStr_Concat ( result ,
136+ PyStr_FromFormat ("', netmask=%d" ,
136137 obj -> prefixlen ));
137138 } else if (obj -> family == AF_INET6 ) {
138- PyBytes_ConcatAndDel (& result ,
139- PyBytes_FromFormat ("/%d'" ,
140- obj -> prefixlen ));
139+ result = PyStr_Concat (result ,
140+ PyStr_FromFormat ("/%d'" , obj -> prefixlen ));
141141 }
142142
143143 if (obj -> peer ) {
144- PyBytes_ConcatAndDel ( & result , PyBytes_FromString ( ", peer_address='" ));
145- PyBytes_Concat ( & result , obj -> peer );
146- PyBytes_ConcatAndDel ( & result , PyBytes_FromString ( "'" ));
144+ result = PyStr_Concat ( result ,
145+ PyStr_FromFormat ( ", peer_address='%s'" ,
146+ PyStr_AsString ( obj -> peer ) ));
147147 }
148148
149149 if (obj -> family == AF_INET && obj -> ipv4_broadcast ) {
150- PyBytes_ConcatAndDel ( & result , PyBytes_FromString ( ", broadcast='" ));
151- PyBytes_Concat ( & result , obj -> ipv4_broadcast );
152- PyBytes_ConcatAndDel ( & result , PyBytes_FromString ( "'" ));
150+ result = PyStr_Concat ( result ,
151+ PyStr_FromFormat ( ", broadcast='%s'" ,
152+ PyStr_AsString ( obj -> ipv4_broadcast ) ));
153153 }
154154
155- PyBytes_ConcatAndDel (& result , PyBytes_FromString (", scope=" ));
156- PyBytes_Concat (& result , obj -> scope );
157-
158- PyBytes_ConcatAndDel (& result , PyBytes_FromString (")" ));
159-
160- #if PY_MAJOR_VERSION >= 3
161- {
162- PyObject * bytestr = result ;
163- result = PyUnicode_FromString (PyBytes_AsString (result ));
164- Py_DECREF (bytestr );
165- }
166- #endif
155+ result = PyStr_Concat (result ,
156+ PyStr_FromFormat (", scope=%s)" ,
157+ PyStr_AsString (obj -> scope )));
167158
168159 return result ;
169160}
0 commit comments