-# -*-pyrex-*-
-#
-# $Id$
-#
-# Miscellaneous support gubbins
-#
-# (c) 2005 Straylight/Edgeware
-#
-
-#----- Licensing notice -----------------------------------------------------
-#
-# This file is part of the Python interface to mLib.
-#
-# mLib/Python is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# mLib/Python is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with mLib/Python; if not, write to the Free Software Foundation,
-# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-cdef object _u32(uint32 x):
- if x <= LONG_MAX:
- return PyInt_FromLong(x)
- else:
- return PyLong_FromUnsignedLong(x)
+### -*-pyrex-*-
+###
+### Miscellaneous support gubbins
+###
+### (c) 2005 Straylight/Edgeware
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of the Python interface to mLib.
+###
+### mLib/Python is free software; you can redistribute it and/or modify
+### it under the terms of the GNU General Public License as published by
+### the Free Software Foundation; either version 2 of the License, or
+### (at your option) any later version.
+###
+### mLib/Python is distributed in the hope that it will be useful,
+### but WITHOUT ANY WARRANTY; without even the implied warranty of
+### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+### GNU General Public License for more details.
+###
+### You should have received a copy of the GNU General Public License
+### along with mLib/Python; if not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+cdef const char *_text_strlen(object s, Py_ssize_t *sz) except NULL:
+ cdef const char *p
+ TEXT_PTRLEN(s, &p, sz)
+ return p
cdef object _oserror():
- raise OSError, (errno, strerror(errno))
-
-cdef object _tobool(int i):
- if i:
- return True
- else:
- return False
+ raise OSError(errno, strerror(errno))
cdef int _getfd(object fdobj):
try:
- return fdobj
+ fd = int(fdobj)
except TypeError:
- return fdobj.fileno()
+ fd = fdobj.fileno()
+ return fd
-cdef object _checkcallable(f, what):
- if f is not None and not callable(f):
- raise TypeError, '%s must be callable' % what
- return f
+#cdef object _checkcallable(object f, object what):
+# if f is not None and not callable(f):
+# raise TypeError('%s must be callable' % what)
+# return f
-cdef object _maybecall(f, args):
- if f is None:
- return None
- return f(*args)
+#cdef object _maybecall(object f, object args):
+# if f is None:
+# return None
+# return f(*args)
-#----- That's all, folks ----------------------------------------------------
+###----- That's all, folks --------------------------------------------------