Skip to content

Commit 67a3858

Browse files
committed
Minor code refactor in Python traits_asptr::asptr
1 parent e631b22 commit 67a3858

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Lib/python/pystdcommon.swg

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,22 @@ namespace swig {
4545
template <class Type>
4646
struct traits_asptr {
4747
static int asptr(PyObject *obj, Type **val) {
48+
int res = SWIG_ERROR;
49+
swig_type_info *descriptor = type_info<Type>();
4850
if (val) {
4951
Type *p = 0;
50-
swig_type_info *descriptor = type_info<Type>();
5152
int newmem = 0;
52-
int res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
53+
res = descriptor ? SWIG_ConvertPtrAndOwn(obj, (void **)&p, descriptor, 0, &newmem) : SWIG_ERROR;
5354
if (SWIG_IsOK(res)) {
5455
if (newmem & SWIG_CAST_NEW_MEMORY) {
5556
res |= SWIG_NEWOBJMASK;
5657
}
5758
*val = p;
5859
}
59-
return res;
6060
} else {
61-
swig_type_info *descriptor = type_info<Type>();
62-
int res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
63-
return res;
61+
res = descriptor ? SWIG_ConvertPtr(obj, 0, descriptor, 0) : SWIG_ERROR;
6462
}
63+
return res;
6564
}
6665
};
6766

0 commit comments

Comments
 (0)