Generated by Cython 0.29.37
Yellow lines hint at Python interaction.
Click on a line that starts with a "+
" to see the C code that Cython generated for it.
Raw output: sysctl.c
+001: # cython: c_string_type=unicode, c_string_encoding=ascii
__pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) __PYX_ERR(0, 1, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
002: """
003: Cython sysctl bindings
004:
005: Copyright (c) 2011-2012 Garrett Cooper, All rights reserved.
006:
007: Redistribution and use in source and binary forms, with or without
008: modification, are permitted provided that the following conditions
009: are met:
010: 1. Redistributions of source code must retain the above copyright
011: notice, this list of conditions and the following disclaimer.
012: 2. Redistributions in binary form must reproduce the above copyright
013: notice, this list of conditions and the following disclaimer in the
014: documentation and/or other materials provided with the distribution.
015:
016: THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
017: ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
018: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
019: ARE DISCLAIMED. IN NO EVENT SHALL Garrett Cooper OR CONTRIBUTORS BE LIABLE
020: FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
021: DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
022: OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
023: HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
024: LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
025: OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
026: SUCH DAMAGE.
027: """
028:
+029: import os
__pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 29, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+030: import types
__pyx_t_1 = __Pyx_Import(__pyx_n_s_types, 0, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_types, __pyx_t_1) < 0) __PYX_ERR(0, 30, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
031:
032: from libc.stdlib cimport free, malloc, realloc
033: from libc.string cimport memcpy, strcpy
034: from libc.errno cimport *
035: from cpython cimport array as c_array
036: from cpython.version cimport PY_MAJOR_VERSION
+037: from array import array
__pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); __Pyx_INCREF(__pyx_n_s_array); __Pyx_GIVEREF(__pyx_n_s_array); PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_array); __pyx_t_2 = __Pyx_Import(__pyx_n_s_array, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_array); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1); if (PyDict_SetItem(__pyx_d, __pyx_n_s_array, __pyx_t_1) < 0) __PYX_ERR(0, 37, __pyx_L1_error) __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
038:
039: cimport cython
040: cimport defs
041:
042: # XXX: sys/sysctl.h
+043: CTLTYPE = 0xf
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE, __pyx_int_15) < 0) __PYX_ERR(0, 43, __pyx_L1_error)
+044: CTLTYPE_INT = 2
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_INT, __pyx_int_2) < 0) __PYX_ERR(0, 44, __pyx_L1_error)
+045: CTLTYPE_STRING = 3
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_STRING, __pyx_int_3) < 0) __PYX_ERR(0, 45, __pyx_L1_error)
+046: CTLTYPE_S64 = 4
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_S64, __pyx_int_4) < 0) __PYX_ERR(0, 46, __pyx_L1_error)
+047: CTLTYPE_UINT = 6
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_UINT, __pyx_int_6) < 0) __PYX_ERR(0, 47, __pyx_L1_error)
+048: CTLTYPE_LONG = 7
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_LONG, __pyx_int_7) < 0) __PYX_ERR(0, 48, __pyx_L1_error)
+049: CTLTYPE_ULONG = 8
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_ULONG, __pyx_int_8) < 0) __PYX_ERR(0, 49, __pyx_L1_error)
+050: CTLTYPE_U64 = 9
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_U64, __pyx_int_9) < 0) __PYX_ERR(0, 50, __pyx_L1_error)
051:
+052: CTLTYPE_INTEGERS = [
__pyx_t_3 = PyList_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GIVEREF(__pyx_t_2); PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_3, 1, __pyx_t_1); __pyx_t_2 = 0; __pyx_t_1 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_INTEGERS, __pyx_t_3) < 0) __PYX_ERR(0, 52, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+053: CTLTYPE_INT,
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CTLTYPE_INT); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 53, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+054: CTLTYPE_UINT,
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_CTLTYPE_UINT); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 54, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
055: ]
056:
+057: CTLTYPE_LONGS = [
__pyx_t_5 = PyList_New(4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_3); PyList_SET_ITEM(__pyx_t_5, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_1); PyList_SET_ITEM(__pyx_t_5, 1, __pyx_t_1); __Pyx_GIVEREF(__pyx_t_2); PyList_SET_ITEM(__pyx_t_5, 2, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_4); PyList_SET_ITEM(__pyx_t_5, 3, __pyx_t_4); __pyx_t_3 = 0; __pyx_t_1 = 0; __pyx_t_2 = 0; __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_LONGS, __pyx_t_5) < 0) __PYX_ERR(0, 57, __pyx_L1_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+058: CTLTYPE_S64,
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_CTLTYPE_S64); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 58, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3);
+059: CTLTYPE_LONG,
__Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_CTLTYPE_LONG); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 59, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_1);
+060: CTLTYPE_ULONG,
__Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CTLTYPE_ULONG); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 60, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2);
+061: CTLTYPE_U64,
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_CTLTYPE_U64); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 61, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4);
062: ]
063:
+064: CTLTYPE_ALL_INTEGERS = CTLTYPE_INTEGERS + CTLTYPE_LONGS
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_CTLTYPE_INTEGERS); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_CTLTYPE_LONGS); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = PyNumber_Add(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTLTYPE_ALL_INTEGERS, __pyx_t_2) < 0) __PYX_ERR(0, 64, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
065:
+066: CTL_MAXNAME = 24
if (PyDict_SetItem(__pyx_d, __pyx_n_s_CTL_MAXNAME, __pyx_int_24) < 0) __PYX_ERR(0, 66, __pyx_L1_error)
067:
068:
069: cdef extern from "errno.h":
070: # XXX: this is wrong per POSIX spec.
071: extern int errno
072:
073:
074: # XXX: stdio.h
075: DEF BUFSIZ = 1024
076:
+077: def sysctl(name, old=True, new=None):
/* Python wrapper */ static PyObject *__pyx_pw_3bsd_6sysctl_1sysctl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_3bsd_6sysctl_sysctl[] = "Wrapper for sysctl(3) API.\n\n :Parameters:\n - name (int list): an array of integers which represent the MIB\n OID, e.g.\n\n # 4 = CTL_NET; 17 = PF_ROUTE; 1 = NET_RT_DUMP\n [ 4, 17, 0, 0, 1, 0 ]\n\n - new (object): new value for sysctl or None if the value isn't\n supposed to be changed.\n - old (bool): a boolean value to note whether or not the old\n value should be queried and returned.\n\n :Raises:\n OSError: the sysctl(3) call failed according to one of the\n ERRORS noted in the manpage.\n ValueError: an invalid value is provided for the 'name'\n parameter.\n\n :Returns:\n a character buffer (str) corresponding to the value returned\n when querying the sysctl by the OID represented by 'name' and\n 'old=True'. 'None' otherwise.\n\n "; static PyMethodDef __pyx_mdef_3bsd_6sysctl_1sysctl = {"sysctl", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3bsd_6sysctl_1sysctl, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3bsd_6sysctl_sysctl}; static PyObject *__pyx_pw_3bsd_6sysctl_1sysctl(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_name = 0; PyObject *__pyx_v_old = 0; PyObject *__pyx_v_new = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sysctl (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_old,&__pyx_n_s_new,0}; PyObject* values[3] = {0,0,0}; values[1] = ((PyObject *)Py_True); values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_old); if (value) { values[1] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sysctl") < 0)) __PYX_ERR(0, 77, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_name = values[0]; __pyx_v_old = values[1]; __pyx_v_new = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("sysctl", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 77, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("bsd.sysctl.sysctl", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_3bsd_6sysctl_sysctl(__pyx_self, __pyx_v_name, __pyx_v_old, __pyx_v_new); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_3bsd_6sysctl_sysctl(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_old, PyObject *__pyx_v_new) { char *__pyx_v_buf; char *__pyx_v_newp_s; int *__pyx_v_namep; int *__pyx_v_namet; void *__pyx_v_newp; void *__pyx_v_oldp; void *__pyx_v_tmpp; size_t __pyx_v_namelen; size_t __pyx_v_buflen; size_t __pyx_v_newlen; size_t __pyx_v_oldlen; unsigned long __pyx_v_new_i; int __pyx_v_ret; PyObject *__pyx_v_i = NULL; PyObject *__pyx_v_n = NULL; PyObject *__pyx_v_sysctl_type = NULL; PyObject *__pyx_v_old_arr = NULL; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sysctl", 0); /* … */ /* function exit code */ __pyx_r = Py_None; __Pyx_INCREF(Py_None); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_7); __Pyx_XDECREF(__pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __Pyx_AddTraceback("bsd.sysctl.sysctl", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_i); __Pyx_XDECREF(__pyx_v_n); __Pyx_XDECREF(__pyx_v_sysctl_type); __Pyx_XDECREF(__pyx_v_old_arr); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__5 = PyTuple_Pack(21, __pyx_n_s_name, __pyx_n_s_old, __pyx_n_s_new, __pyx_n_s_buf, __pyx_n_s_newp_s, __pyx_n_s_namep, __pyx_n_s_namet, __pyx_n_s_newp, __pyx_n_s_oldp, __pyx_n_s_tmpp, __pyx_n_s_namelen, __pyx_n_s_buflen, __pyx_n_s_newlen, __pyx_n_s_oldlen, __pyx_n_s_new_i, __pyx_n_s_c, __pyx_n_s_ret, __pyx_n_s_i, __pyx_n_s_n, __pyx_n_s_sysctl_type, __pyx_n_s_old_arr); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__5); __Pyx_GIVEREF(__pyx_tuple__5); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3bsd_6sysctl_1sysctl, NULL, __pyx_n_s_bsd_sysctl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sysctl, __pyx_t_2) < 0) __PYX_ERR(0, 77, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__6 = (PyObject*)__Pyx_PyCode_New(3, 0, 21, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__5, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_bsd_sysctl_pyx, __pyx_n_s_sysctl, 77, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__6)) __PYX_ERR(0, 77, __pyx_L1_error)
078: """Wrapper for sysctl(3) API.
079:
080: :Parameters:
081: - name (int list): an array of integers which represent the MIB
082: OID, e.g.
083:
084: # 4 = CTL_NET; 17 = PF_ROUTE; 1 = NET_RT_DUMP
085: [ 4, 17, 0, 0, 1, 0 ]
086:
087: - new (object): new value for sysctl or None if the value isn't
088: supposed to be changed.
089: - old (bool): a boolean value to note whether or not the old
090: value should be queried and returned.
091:
092: :Raises:
093: OSError: the sysctl(3) call failed according to one of the
094: ERRORS noted in the manpage.
095: ValueError: an invalid value is provided for the 'name'
096: parameter.
097:
098: :Returns:
099: a character buffer (str) corresponding to the value returned
100: when querying the sysctl by the OID represented by 'name' and
101: 'old=True'. 'None' otherwise.
102:
103: """
104:
105: cdef:
106: char *buf
107: char *newp_s
108: int *namep
109: int *namet
110: void *newp
111: void *oldp
112: void *tmpp
113: size_t namelen
114: size_t buflen
115: size_t newlen
116: size_t oldlen
117: unsigned long new_i
118: char c
119: int ret
120:
+121: buf = NULL
__pyx_v_buf = NULL;
+122: buflen = BUFSIZ
__pyx_v_buflen = 0x400;
+123: namep = NULL
__pyx_v_namep = NULL;
+124: namet = NULL
__pyx_v_namet = NULL;
+125: newp_s = NULL
__pyx_v_newp_s = NULL;
+126: oldp = NULL
__pyx_v_oldp = NULL;
+127: namelen = len(name)
__pyx_t_1 = PyObject_Length(__pyx_v_name); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 127, __pyx_L1_error) __pyx_v_namelen = __pyx_t_1;
128:
+129: if not name:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 129, __pyx_L1_error) __pyx_t_3 = ((!__pyx_t_2) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+130: raise ValueError("'name' must be a non-zero length iterable object")
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 130, __pyx_L1_error) /* … */ __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_name_must_be_a_non_zero_length); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 130, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple_); __Pyx_GIVEREF(__pyx_tuple_);
131:
+132: try:
/*try:*/ {
+133: buf = <char*>malloc(sizeof(char) * BUFSIZ)
__pyx_v_buf = ((char *)malloc(((sizeof(char)) * 0x400)));
+134: if not buf:
__pyx_t_3 = ((!(__pyx_v_buf != 0)) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+135: raise MemoryError()
PyErr_NoMemory(); __PYX_ERR(0, 135, __pyx_L5_error)
136:
+137: namep = <int*>malloc(sizeof(int) * namelen)
__pyx_v_namep = ((int *)malloc(((sizeof(int)) * __pyx_v_namelen)));
+138: if not namep:
__pyx_t_3 = ((!(__pyx_v_namep != 0)) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+139: raise MemoryError()
PyErr_NoMemory(); __PYX_ERR(0, 139, __pyx_L5_error)
140:
141: # Administrative functions for determining the type add an additional
142: # 2 elements to the OID.
+143: namet = <int*>malloc(sizeof(int) * (namelen + 2))
__pyx_v_namet = ((int *)malloc(((sizeof(int)) * (__pyx_v_namelen + 2))));
+144: if not namet:
__pyx_t_3 = ((!(__pyx_v_namet != 0)) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+145: raise MemoryError()
PyErr_NoMemory(); __PYX_ERR(0, 145, __pyx_L5_error)
146:
+147: namet[0] = 0
(__pyx_v_namet[0]) = 0;
+148: namet[1] = 4
(__pyx_v_namet[1]) = 4;
149:
+150: for i, n in enumerate(name):
__Pyx_INCREF(__pyx_int_0); __pyx_t_4 = __pyx_int_0; if (likely(PyList_CheckExact(__pyx_v_name)) || PyTuple_CheckExact(__pyx_v_name)) { __pyx_t_5 = __pyx_v_name; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0; __pyx_t_6 = NULL; } else { __pyx_t_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_v_name); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 150, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 150, __pyx_L5_error) } for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_5))) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 150, __pyx_L5_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 150, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 150, __pyx_L5_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 150, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 150, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_7); } __Pyx_XDECREF_SET(__pyx_v_n, __pyx_t_7); __pyx_t_7 = 0; __Pyx_INCREF(__pyx_t_4); __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_4); __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_t_4, __pyx_int_1, 1, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 150, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = __pyx_t_7; __pyx_t_7 = 0; /* … */ } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+151: namep[i] = n
__pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_n); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L5_error) __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L5_error) (__pyx_v_namep[__pyx_t_9]) = __pyx_t_8;
+152: namet[i + 2] = n
__pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_n); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L5_error) __pyx_t_7 = __Pyx_PyInt_AddObjC(__pyx_v_i, __pyx_int_2, 2, 0, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 152, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_t_7); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 152, __pyx_L5_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; (__pyx_v_namet[__pyx_t_9]) = __pyx_t_8;
153:
+154: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L14; } __pyx_L14:; } }
+155: ret = defs.sysctl(namet, namelen + 2, buf, &buflen, NULL, 0)
__pyx_v_ret = sysctl(__pyx_v_namet, (__pyx_v_namelen + 2), __pyx_v_buf, (&__pyx_v_buflen), NULL, 0); }
156:
+157: if ret == -1:
__pyx_t_3 = ((__pyx_v_ret == -1L) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+158: raise OSError(errno, os.strerror(errno))
__pyx_t_4 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 158, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_os); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 158, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_strerror); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 158, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 158, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); } } __pyx_t_5 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, __pyx_t_7) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_7); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 158, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 158, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 158, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 158, __pyx_L5_error)
+159: sysctl_type = (<int*>buf)[0] & CTLTYPE
__pyx_t_5 = __Pyx_PyInt_From_int((((int *)__pyx_v_buf)[0])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 159, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_CTLTYPE); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 159, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_4 = PyNumber_And(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 159, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_v_sysctl_type = __pyx_t_4; __pyx_t_4 = 0;
160:
+161: if new is None:
__pyx_t_3 = (__pyx_v_new == Py_None); __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* … */ goto __pyx_L16; }
+162: newp = NULL
__pyx_v_newp = NULL;
+163: newlen = 0
__pyx_v_newlen = 0;
164: else:
+165: if sysctl_type in CTLTYPE_ALL_INTEGERS:
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_CTLTYPE_ALL_INTEGERS); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 165, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_sysctl_type, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 165, __pyx_L5_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* … */ goto __pyx_L17; }
+166: new_i = new
__pyx_t_12 = __Pyx_PyInt_As_unsigned_long(__pyx_v_new); if (unlikely((__pyx_t_12 == (unsigned long)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L5_error) __pyx_v_new_i = __pyx_t_12;
+167: newp = <void*>&new_i
__pyx_v_newp = ((void *)(&__pyx_v_new_i));
168:
+169: if sysctl_type in CTLTYPE_INTEGERS:
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_CTLTYPE_INTEGERS); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_sysctl_type, __pyx_t_4, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 169, __pyx_L5_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* … */ goto __pyx_L18; }
+170: newlen = sizeof(int)
__pyx_v_newlen = (sizeof(int));
171: else:
+172: newlen = sizeof(long)
/*else*/ { __pyx_v_newlen = (sizeof(long)); } __pyx_L18:;
173: else:
+174: if sysctl_type == CTLTYPE_STRING:
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_CTLTYPE_STRING); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 174, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = PyObject_RichCompare(__pyx_v_sysctl_type, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 174, __pyx_L5_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 174, __pyx_L5_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_2) { /* … */ goto __pyx_L19; }
+175: newlen = len(new) + 1
__pyx_t_1 = PyObject_Length(__pyx_v_new); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 175, __pyx_L5_error) __pyx_v_newlen = (__pyx_t_1 + 1);
176: else:
+177: newlen = len(new)
/*else*/ { __pyx_t_1 = PyObject_Length(__pyx_v_new); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 177, __pyx_L5_error) __pyx_v_newlen = __pyx_t_1; } __pyx_L19:;
178: # String or opaque
+179: newp_s = <char*>malloc(sizeof(char) * newlen)
__pyx_v_newp_s = ((char *)malloc(((sizeof(char)) * __pyx_v_newlen)));
+180: if not newp_s:
__pyx_t_2 = ((!(__pyx_v_newp_s != 0)) != 0); if (unlikely(__pyx_t_2)) { /* … */ }
+181: raise MemoryError()
PyErr_NoMemory(); __PYX_ERR(0, 181, __pyx_L5_error)
182: # NOTE: void* cast does the wrong thing here.
+183: memcpy(newp_s, <char*>new, newlen)
__pyx_t_13 = __Pyx_PyObject_AsWritableString(__pyx_v_new); if (unlikely((!__pyx_t_13) && PyErr_Occurred())) __PYX_ERR(0, 183, __pyx_L5_error) (void)(memcpy(__pyx_v_newp_s, ((char *)__pyx_t_13), __pyx_v_newlen));
+184: newp = <void*>newp_s
__pyx_v_newp = ((void *)__pyx_v_newp_s); } __pyx_L17:; } __pyx_L16:;
185:
186: # sysctl has problems with race conditions.
187: # Because of that, unlike the normal system call,
188: # we have to do this in two stages: get old first,
189: # and then set new.
+190: if old:
__pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_old); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 190, __pyx_L5_error) if (__pyx_t_2) { /* … */ goto __pyx_L21; }
191: # We loop on this until we get all the data.
192: # Or until we've tried getting 4mbytes.
+193: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L24; } __pyx_L24:; } }
+194: ret = defs.sysctl(namep, namelen, NULL, &oldlen, NULL, 0)
__pyx_v_ret = sysctl(__pyx_v_namep, __pyx_v_namelen, NULL, (&__pyx_v_oldlen), NULL, 0); }
195:
+196: if ret == -1:
__pyx_t_2 = ((__pyx_v_ret == -1L) != 0); if (unlikely(__pyx_t_2)) { /* … */ }
+197: raise OSError(errno, os.strerror(errno))
__pyx_t_10 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 197, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 197, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_strerror); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 197, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 197, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_7); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_7, function); } } __pyx_t_4 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_7, __pyx_t_11, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_5); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 197, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_10); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4); __pyx_t_10 = 0; __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 197, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 197, __pyx_L5_error)
198:
+199: while True:
while (1) {
+200: oldp = malloc(oldlen)
__pyx_v_oldp = malloc(__pyx_v_oldlen);
+201: if not oldp:
__pyx_t_2 = ((!(__pyx_v_oldp != 0)) != 0); if (unlikely(__pyx_t_2)) { /* … */ }
+202: raise MemoryError()
PyErr_NoMemory(); __PYX_ERR(0, 202, __pyx_L5_error)
203:
+204: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L33; } __pyx_L33:; } }
+205: ret = defs.sysctl(namep, namelen, oldp, &oldlen, NULL, 0)
__pyx_v_ret = sysctl(__pyx_v_namep, __pyx_v_namelen, __pyx_v_oldp, (&__pyx_v_oldlen), NULL, 0); }
206:
+207: if ret == 0:
__pyx_t_2 = ((__pyx_v_ret == 0) != 0); if (__pyx_t_2) { /* … */ }
+208: break
goto __pyx_L27_break;
209:
+210: if errno != ENOMEM or oldlen > (4 * 1024 * 1024):
__pyx_t_3 = ((errno != ENOMEM) != 0); if (!__pyx_t_3) { } else { __pyx_t_2 = __pyx_t_3; goto __pyx_L36_bool_binop_done; } __pyx_t_3 = ((__pyx_v_oldlen > 0x400000) != 0); __pyx_t_2 = __pyx_t_3; __pyx_L36_bool_binop_done:; if (unlikely(__pyx_t_2)) { /* … */ }
+211: free(oldp)
free(__pyx_v_oldp);
+212: raise OSError(errno, os.strerror(errno))
__pyx_t_4 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 212, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_os); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 212, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_strerror); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 212, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_7 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_11, __pyx_t_10) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_10); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 212, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_7); __pyx_t_4 = 0; __pyx_t_7 = 0; __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 212, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_Raise(__pyx_t_7, 0, 0, 0); __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; __PYX_ERR(0, 212, __pyx_L5_error)
213:
+214: free(oldp)
free(__pyx_v_oldp);
+215: oldlen = oldlen * 2
__pyx_v_oldlen = (__pyx_v_oldlen * 2); } __pyx_L27_break:;
216: # This truncates the buffer to oldlen
+217: tmpp = realloc(oldp, oldlen)
__pyx_v_tmpp = realloc(__pyx_v_oldp, __pyx_v_oldlen);
+218: if tmpp:
__pyx_t_2 = (__pyx_v_tmpp != 0); if (__pyx_t_2) { /* … */ }
219: # If realloc failed, we just have extra memory.
+220: oldp = tmpp
__pyx_v_oldp = __pyx_v_tmpp;
+221: if not oldp:
__pyx_t_2 = ((!(__pyx_v_oldp != 0)) != 0); if (unlikely(__pyx_t_2)) { /* … */ }
+222: raise MemoryError()
PyErr_NoMemory(); __PYX_ERR(0, 222, __pyx_L5_error)
223: else:
+224: oldp = NULL
/*else*/ { __pyx_v_oldp = NULL;
+225: oldlen = 0
__pyx_v_oldlen = 0; } __pyx_L21:;
226:
+227: if newp:
__pyx_t_2 = (__pyx_v_newp != 0); if (__pyx_t_2) { /* … */ }
+228: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L43; } __pyx_L43:; } }
+229: ret = defs.sysctl(namep, namelen, NULL, NULL, newp, newlen)
__pyx_v_ret = sysctl(__pyx_v_namep, __pyx_v_namelen, NULL, NULL, __pyx_v_newp, __pyx_v_newlen); }
230:
+231: if ret == -1:
__pyx_t_2 = ((__pyx_v_ret == -1L) != 0); if (unlikely(__pyx_t_2)) { /* … */ }
+232: raise OSError(errno, os.strerror(errno))
__pyx_t_7 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 232, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 232, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strerror); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 232, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 232, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_11 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_10))) { __pyx_t_11 = PyMethod_GET_SELF(__pyx_t_10); if (likely(__pyx_t_11)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_10); __Pyx_INCREF(__pyx_t_11); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_10, function); } } __pyx_t_5 = (__pyx_t_11) ? __Pyx_PyObject_Call2Args(__pyx_t_10, __pyx_t_11, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_10, __pyx_t_4); __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 232, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __pyx_t_10 = PyTuple_New(2); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 232, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_7); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_10, 1, __pyx_t_5); __pyx_t_7 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_10, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 232, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 232, __pyx_L5_error)
233:
+234: if oldp:
__pyx_t_2 = (__pyx_v_oldp != 0); if (__pyx_t_2) { /* … */ } }
+235: if sysctl_type in CTLTYPE_INTEGERS:
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_CTLTYPE_INTEGERS); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 235, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_2 = (__Pyx_PySequence_ContainsTF(__pyx_v_sysctl_type, __pyx_t_5, Py_EQ)); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 235, __pyx_L5_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_3 = (__pyx_t_2 != 0); if (__pyx_t_3) { /* … */ }
+236: return (<int*>oldp)[0]
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = __Pyx_PyInt_From_int((((int *)__pyx_v_oldp)[0])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 236, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L4_return;
+237: elif sysctl_type in CTLTYPE_LONGS:
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_CTLTYPE_LONGS); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 237, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_3 = (__Pyx_PySequence_ContainsTF(__pyx_v_sysctl_type, __pyx_t_5, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 237, __pyx_L5_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_2 = (__pyx_t_3 != 0); if (__pyx_t_2) { /* … */ }
+238: return (<long*>oldp)[0]
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = __Pyx_PyInt_From_long((((long *)__pyx_v_oldp)[0])); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 238, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L4_return;
+239: elif sysctl_type == CTLTYPE_STRING:
__Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_CTLTYPE_STRING); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 239, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_10 = PyObject_RichCompare(__pyx_v_sysctl_type, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_10); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 239, __pyx_L5_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_10); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 239, __pyx_L5_error) __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0; if (__pyx_t_2) { /* … */ }
+240: old_arr = (<char*>oldp)[:oldlen]
__pyx_t_10 = __Pyx_PyBytes_FromStringAndSize(((char *)__pyx_v_oldp) + 0, __pyx_v_oldlen - 0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 240, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __pyx_v_old_arr = ((PyObject*)__pyx_t_10); __pyx_t_10 = 0;
+241: return old_arr.decode('ascii')
__Pyx_XDECREF(__pyx_r); __pyx_t_10 = __Pyx_decode_bytes(__pyx_v_old_arr, 0, PY_SSIZE_T_MAX, NULL, NULL, PyUnicode_DecodeASCII); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 241, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L4_return;
242: else:
+243: return [(<char*>oldp)[i] for i in range(oldlen)]
/*else*/ { __Pyx_XDECREF(__pyx_r); __pyx_t_10 = PyList_New(0); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 243, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_10); __pyx_t_5 = __Pyx_PyInt_FromSize_t(__pyx_v_oldlen); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 243, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_builtin_range, __pyx_t_5); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (likely(PyList_CheckExact(__pyx_t_7)) || PyTuple_CheckExact(__pyx_t_7)) { __pyx_t_5 = __pyx_t_7; __Pyx_INCREF(__pyx_t_5); __pyx_t_1 = 0; __pyx_t_6 = NULL; } else { __pyx_t_1 = -1; __pyx_t_5 = PyObject_GetIter(__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 243, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = Py_TYPE(__pyx_t_5)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 243, __pyx_L5_error) } __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; for (;;) { if (likely(!__pyx_t_6)) { if (likely(PyList_CheckExact(__pyx_t_5))) { if (__pyx_t_1 >= PyList_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyList_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 243, __pyx_L5_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); #endif } else { if (__pyx_t_1 >= PyTuple_GET_SIZE(__pyx_t_5)) break; #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS __pyx_t_7 = PyTuple_GET_ITEM(__pyx_t_5, __pyx_t_1); __Pyx_INCREF(__pyx_t_7); __pyx_t_1++; if (unlikely(0 < 0)) __PYX_ERR(0, 243, __pyx_L5_error) #else __pyx_t_7 = PySequence_ITEM(__pyx_t_5, __pyx_t_1); __pyx_t_1++; if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); #endif } } else { __pyx_t_7 = __pyx_t_6(__pyx_t_5); if (unlikely(!__pyx_t_7)) { PyObject* exc_type = PyErr_Occurred(); if (exc_type) { if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); else __PYX_ERR(0, 243, __pyx_L5_error) } break; } __Pyx_GOTREF(__pyx_t_7); } __Pyx_XDECREF_SET(__pyx_v_i, __pyx_t_7); __pyx_t_7 = 0; __pyx_t_9 = __Pyx_PyIndex_AsSsize_t(__pyx_v_i); if (unlikely((__pyx_t_9 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 243, __pyx_L5_error) __pyx_t_7 = __Pyx_PyInt_From_char((((char *)__pyx_v_oldp)[__pyx_t_9])); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 243, __pyx_L5_error) __Pyx_GOTREF(__pyx_t_7); if (unlikely(__Pyx_ListComp_Append(__pyx_t_10, (PyObject*)__pyx_t_7))) __PYX_ERR(0, 243, __pyx_L5_error) __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; } __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_r = __pyx_t_10; __pyx_t_10 = 0; goto __pyx_L4_return; }
244: finally:
+245: free(buf)
/*finally:*/ { /*normal exit:*/{ free(__pyx_v_buf); /* … */ free(__pyx_v_buf); /* … */ free(__pyx_v_buf);
+246: free(namep)
free(__pyx_v_namep); /* … */ free(__pyx_v_namep); /* … */ free(__pyx_v_namep);
+247: free(namet)
free(__pyx_v_namet); /* … */ free(__pyx_v_namet); /* … */ free(__pyx_v_namet);
+248: free(newp_s)
free(__pyx_v_newp_s); /* … */ free(__pyx_v_newp_s); /* … */ free(__pyx_v_newp_s);
+249: free(oldp)
free(__pyx_v_oldp); goto __pyx_L6; } __pyx_L5_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_8 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename; { /* … */ free(__pyx_v_oldp); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15; goto __pyx_L1_error; } __pyx_L4_return: { __pyx_t_21 = __pyx_r; __pyx_r = 0; /* … */ free(__pyx_v_oldp); __pyx_r = __pyx_t_21; __pyx_t_21 = 0; goto __pyx_L0; } __pyx_L6:; }
250:
251:
+252: def sysctlbyname(name, old=True, new=None):
/* Python wrapper */ static PyObject *__pyx_pw_3bsd_6sysctl_3sysctlbyname(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_3bsd_6sysctl_2sysctlbyname[] = "Wrapper for sysctlbyname(3) API.\n\n :Parameters:\n - name (str): a textual representation of the OID, e.g.\n 'hw.machine'.\n - new (object): new value for sysctl or None if the value isn't\n supposed to be changed.\n - old (bool): a value to note whether or not the old value\n should be queried and returned.\n\n :Raises:\n OSError: the sysctlbyname(3) call failed according to one of the\n ERRORS noted in the manpage.\n ValueError: an invalid value is provided for the 'name'\n parameter.\n\n :Returns:\n a buffer 'array' corresponding to the value returned by when\n querying the textual representation of the sysctl by 'name'.\n\n "; static PyMethodDef __pyx_mdef_3bsd_6sysctl_3sysctlbyname = {"sysctlbyname", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3bsd_6sysctl_3sysctlbyname, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3bsd_6sysctl_2sysctlbyname}; static PyObject *__pyx_pw_3bsd_6sysctl_3sysctlbyname(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_name = 0; PyObject *__pyx_v_old = 0; PyObject *__pyx_v_new = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sysctlbyname (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_old,&__pyx_n_s_new,0}; PyObject* values[3] = {0,0,0}; values[1] = ((PyObject *)Py_True); values[2] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_old); if (value) { values[1] = value; kw_args--; } } CYTHON_FALLTHROUGH; case 2: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_new); if (value) { values[2] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sysctlbyname") < 0)) __PYX_ERR(0, 252, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2); CYTHON_FALLTHROUGH; case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_name = values[0]; __pyx_v_old = values[1]; __pyx_v_new = values[2]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("sysctlbyname", 0, 1, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 252, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("bsd.sysctl.sysctlbyname", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_3bsd_6sysctl_2sysctlbyname(__pyx_self, __pyx_v_name, __pyx_v_old, __pyx_v_new); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_3bsd_6sysctl_2sysctlbyname(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_old, PyObject *__pyx_v_new) { char *__pyx_v_namep; int *__pyx_v_mibp; size_t __pyx_v__size; int __pyx_v_ret; PyObject *__pyx_v_mib = NULL; size_t __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sysctlbyname", 0); __Pyx_INCREF(__pyx_v_name); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("bsd.sysctl.sysctlbyname", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_mib); __Pyx_XDECREF(__pyx_v_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__7 = PyTuple_Pack(9, __pyx_n_s_name, __pyx_n_s_old, __pyx_n_s_new, __pyx_n_s_namep, __pyx_n_s_mibp, __pyx_n_s_size_2, __pyx_n_s_ret, __pyx_n_s_mib, __pyx_n_s_i); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__7); __Pyx_GIVEREF(__pyx_tuple__7); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3bsd_6sysctl_3sysctlbyname, NULL, __pyx_n_s_bsd_sysctl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sysctlbyname, __pyx_t_2) < 0) __PYX_ERR(0, 252, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_bsd_sysctl_pyx, __pyx_n_s_sysctlbyname, 252, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 252, __pyx_L1_error)
253: """Wrapper for sysctlbyname(3) API.
254:
255: :Parameters:
256: - name (str): a textual representation of the OID, e.g.
257: 'hw.machine'.
258: - new (object): new value for sysctl or None if the value isn't
259: supposed to be changed.
260: - old (bool): a value to note whether or not the old value
261: should be queried and returned.
262:
263: :Raises:
264: OSError: the sysctlbyname(3) call failed according to one of the
265: ERRORS noted in the manpage.
266: ValueError: an invalid value is provided for the 'name'
267: parameter.
268:
269: :Returns:
270: a buffer 'array' corresponding to the value returned by when
271: querying the textual representation of the sysctl by 'name'.
272:
273: """
274:
275: cdef:
276: char *namep
277: int *mibp
278: size_t _size
279: int ret
280:
+281: if PY_MAJOR_VERSION == 3 and isinstance(name, str):
__pyx_t_2 = ((PY_MAJOR_VERSION == 3) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_2 = PyString_Check(__pyx_v_name);
__pyx_t_3 = (__pyx_t_2 != 0);
__pyx_t_1 = __pyx_t_3;
__pyx_L4_bool_binop_done:;
if (__pyx_t_1) {
/* … */
}
+282: name = name.encode('ascii')
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_n_s_ascii) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_n_s_ascii); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 282, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_4); __pyx_t_4 = 0;
+283: namep = name
__pyx_t_7 = __Pyx_PyObject_AsWritableString(__pyx_v_name); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 283, __pyx_L1_error) __pyx_v_namep = __pyx_t_7;
+284: _size = CTL_MAXNAME
__Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_CTL_MAXNAME); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_t_4); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 284, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_v__size = __pyx_t_8;
285:
+286: if not name:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 286, __pyx_L1_error) __pyx_t_3 = ((!__pyx_t_1) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+287: raise ValueError("'name' must be a non-zero length iterable object")
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 287, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 287, __pyx_L1_error)
288:
+289: try:
/*try:*/ {
+290: mibp = <int*>malloc(sizeof(int) * (CTL_MAXNAME))
__pyx_t_4 = __Pyx_PyInt_FromSize_t((sizeof(int))); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 290, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_CTL_MAXNAME); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 290, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = PyNumber_Multiply(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 290, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_8 = __Pyx_PyInt_As_size_t(__pyx_t_6); if (unlikely((__pyx_t_8 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 290, __pyx_L8_error) __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_v_mibp = ((int *)malloc(__pyx_t_8));
+291: if not mibp:
__pyx_t_3 = ((!(__pyx_v_mibp != 0)) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+292: raise MemoryError()
PyErr_NoMemory(); __PYX_ERR(0, 292, __pyx_L8_error)
293:
+294: with nogil:
{ #ifdef WITH_THREAD PyThreadState *_save; Py_UNBLOCK_THREADS __Pyx_FastGIL_Remember(); #endif /*try:*/ { /* … */ /*finally:*/ { /*normal exit:*/{ #ifdef WITH_THREAD __Pyx_FastGIL_Forget(); Py_BLOCK_THREADS #endif goto __pyx_L13; } __pyx_L13:; } }
+295: ret = defs.sysctlnametomib(namep, mibp, &_size)
__pyx_v_ret = sysctlnametomib(__pyx_v_namep, __pyx_v_mibp, (&__pyx_v__size)); }
296:
+297: if ret == -1:
__pyx_t_3 = ((__pyx_v_ret == -1L) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+298: raise OSError(errno, os.strerror(errno))
__pyx_t_6 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 298, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_strerror); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 298, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 298, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_5 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_4); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 298, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5); __pyx_t_6 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 298, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 298, __pyx_L8_error)
299:
+300: mib = [mibp[i] for i in range(_size)]
__pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 300, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_8 = __pyx_v__size; __pyx_t_11 = __pyx_t_8; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_i = __pyx_t_12; __pyx_t_9 = __Pyx_PyInt_From_int((__pyx_v_mibp[__pyx_v_i])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 300, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 300, __pyx_L8_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_v_mib = ((PyObject*)__pyx_t_5); __pyx_t_5 = 0;
+301: return sysctl(mib, old, new)
__Pyx_XDECREF(__pyx_r); __Pyx_GetModuleGlobalName(__pyx_t_9, __pyx_n_s_sysctl); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 301, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_9); __pyx_t_6 = NULL; __pyx_t_13 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); __pyx_t_13 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_mib, __pyx_v_old, __pyx_v_new}; __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { PyObject *__pyx_temp[4] = {__pyx_t_6, __pyx_v_mib, __pyx_v_old, __pyx_v_new}; __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_13, 3+__pyx_t_13); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L8_error) __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_GOTREF(__pyx_t_5); } else #endif { __pyx_t_4 = PyTuple_New(3+__pyx_t_13); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 301, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_4); if (__pyx_t_6) { __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; } __Pyx_INCREF(__pyx_v_mib); __Pyx_GIVEREF(__pyx_v_mib); PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_13, __pyx_v_mib); __Pyx_INCREF(__pyx_v_old); __Pyx_GIVEREF(__pyx_v_old); PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_13, __pyx_v_old); __Pyx_INCREF(__pyx_v_new); __Pyx_GIVEREF(__pyx_v_new); PyTuple_SET_ITEM(__pyx_t_4, 2+__pyx_t_13, __pyx_v_new); __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_4, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 301, __pyx_L8_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L7_return; }
302:
303: finally:
+304: free(mibp)
/*finally:*/ { __pyx_L8_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_13 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename; { free(__pyx_v_mibp); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15; goto __pyx_L1_error; } __pyx_L7_return: { __pyx_t_21 = __pyx_r; __pyx_r = 0; free(__pyx_v_mibp); __pyx_r = __pyx_t_21; __pyx_t_21 = 0; goto __pyx_L0; } }
305:
306:
+307: def sysctlnametomib(name, size=CTL_MAXNAME):
/* Python wrapper */ static PyObject *__pyx_pw_3bsd_6sysctl_5sysctlnametomib(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static char __pyx_doc_3bsd_6sysctl_4sysctlnametomib[] = "Wrapper for sysctlnametomib(3) API.\n\n :Parameters:\n - name (str): a textual representation of the OID, e.g.\n 'hw.machine'.\n - size (int): an optional value to pass in to limit the returned OID\n to n elements. Defaults to 'CTL_MAXNAME'.\n\n :Raises:\n OSError: the sysctlnametomib(3) call failed according to one of\n the ERRORS noted in the manpage.\n ValueError: an invalid value is provided for the 'name'\n parameter.\n ValueError: the value provided for 'size' was not greater than 0.\n :Returns:\n A list of integers corresponding to the MIB OID for pointed by\n the parameter, 'name'.\n\n "; static PyMethodDef __pyx_mdef_3bsd_6sysctl_5sysctlnametomib = {"sysctlnametomib", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3bsd_6sysctl_5sysctlnametomib, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3bsd_6sysctl_4sysctlnametomib}; static PyObject *__pyx_pw_3bsd_6sysctl_5sysctlnametomib(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_name = 0; PyObject *__pyx_v_size = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sysctlnametomib (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_size,0}; PyObject* values[2] = {0,0}; values[1] = __pyx_k__2; if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--; else goto __pyx_L5_argtuple_error; CYTHON_FALLTHROUGH; case 1: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_size); if (value) { values[1] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "sysctlnametomib") < 0)) __PYX_ERR(0, 307, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); CYTHON_FALLTHROUGH; case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_name = values[0]; __pyx_v_size = values[1]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("sysctlnametomib", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 307, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("bsd.sysctl.sysctlnametomib", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_3bsd_6sysctl_4sysctlnametomib(__pyx_self, __pyx_v_name, __pyx_v_size); int __pyx_lineno = 0; const char *__pyx_filename = NULL; int __pyx_clineno = 0; /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_3bsd_6sysctl_4sysctlnametomib(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name, PyObject *__pyx_v_size) { char *__pyx_v_namep; int *__pyx_v_mibp; size_t __pyx_v__size; int __pyx_v_ret; size_t __pyx_v_i; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sysctlnametomib", 0); __Pyx_INCREF(__pyx_v_name); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_9); __Pyx_XDECREF(__pyx_t_10); __Pyx_AddTraceback("bsd.sysctl.sysctlnametomib", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF(__pyx_v_name); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_CTL_MAXNAME); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __pyx_k__2 = __pyx_t_2; __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0; /* … */ __pyx_tuple__9 = PyTuple_Pack(7, __pyx_n_s_name, __pyx_n_s_size, __pyx_n_s_namep, __pyx_n_s_mibp, __pyx_n_s_size_2, __pyx_n_s_ret, __pyx_n_s_i); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__9); __Pyx_GIVEREF(__pyx_tuple__9); __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3bsd_6sysctl_5sysctlnametomib, NULL, __pyx_n_s_bsd_sysctl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sysctlnametomib, __pyx_t_2) < 0) __PYX_ERR(0, 307, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_bsd_sysctl_pyx, __pyx_n_s_sysctlnametomib, 307, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 307, __pyx_L1_error)
308: """Wrapper for sysctlnametomib(3) API.
309:
310: :Parameters:
311: - name (str): a textual representation of the OID, e.g.
312: 'hw.machine'.
313: - size (int): an optional value to pass in to limit the returned OID
314: to n elements. Defaults to 'CTL_MAXNAME'.
315:
316: :Raises:
317: OSError: the sysctlnametomib(3) call failed according to one of
318: the ERRORS noted in the manpage.
319: ValueError: an invalid value is provided for the 'name'
320: parameter.
321: ValueError: the value provided for 'size' was not greater than 0.
322: :Returns:
323: A list of integers corresponding to the MIB OID for pointed by
324: the parameter, 'name'.
325:
326: """
327:
328: cdef:
329: char *namep
330: int *mibp
331: size_t _size
332:
+333: if PY_MAJOR_VERSION == 3 and isinstance(name, str):
__pyx_t_2 = ((PY_MAJOR_VERSION == 3) != 0);
if (__pyx_t_2) {
} else {
__pyx_t_1 = __pyx_t_2;
goto __pyx_L4_bool_binop_done;
}
__pyx_t_2 = PyString_Check(__pyx_v_name);
__pyx_t_3 = (__pyx_t_2 != 0);
__pyx_t_1 = __pyx_t_3;
__pyx_L4_bool_binop_done:;
if (__pyx_t_1) {
/* … */
}
+334: name = name.encode('ascii')
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_name, __pyx_n_s_encode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_n_s_ascii) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_n_s_ascii); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 334, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF_SET(__pyx_v_name, __pyx_t_4); __pyx_t_4 = 0;
+335: _size = size
__pyx_t_7 = __Pyx_PyInt_As_size_t(__pyx_v_size); if (unlikely((__pyx_t_7 == (size_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 335, __pyx_L1_error) __pyx_v__size = __pyx_t_7;
+336: namep = name
__pyx_t_8 = __Pyx_PyObject_AsWritableString(__pyx_v_name); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 336, __pyx_L1_error) __pyx_v_namep = __pyx_t_8;
337:
+338: if not name:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 338, __pyx_L1_error) __pyx_t_3 = ((!__pyx_t_1) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+339: raise ValueError("'name' must be a non-zero length iterable object")
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 339, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 339, __pyx_L1_error)
340:
+341: if size <= 0:
__pyx_t_4 = PyObject_RichCompare(__pyx_v_size, __pyx_int_0, Py_LE); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 341, __pyx_L1_error) __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 341, __pyx_L1_error) __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; if (unlikely(__pyx_t_3)) { /* … */ }
+342: raise ValueError("'size' must be greater than or equal to 1")
__pyx_t_4 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_Raise(__pyx_t_4, 0, 0, 0); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __PYX_ERR(0, 342, __pyx_L1_error) /* … */ __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_size_must_be_greater_than_or_eq); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(0, 342, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__3); __Pyx_GIVEREF(__pyx_tuple__3);
343:
+344: mibp = <int*>malloc(sizeof(int) * (_size))
__pyx_v_mibp = ((int *)malloc(((sizeof(int)) * __pyx_v__size)));
+345: if not mibp:
__pyx_t_3 = ((!(__pyx_v_mibp != 0)) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+346: raise MemoryError()
PyErr_NoMemory(); __PYX_ERR(0, 346, __pyx_L1_error)
347:
+348: try:
/*try:*/ {
+349: ret = defs.sysctlnametomib(namep, mibp, &_size)
__pyx_v_ret = sysctlnametomib(__pyx_v_namep, __pyx_v_mibp, (&__pyx_v__size));
+350: if ret == -1:
__pyx_t_3 = ((__pyx_v_ret == -1L) != 0); if (unlikely(__pyx_t_3)) { /* … */ }
+351: raise OSError(errno, os.strerror(errno))
__pyx_t_4 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 351, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 351, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_strerror); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 351, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 351, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_10 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_9); if (likely(__pyx_t_10)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); __Pyx_INCREF(__pyx_t_10); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_9, function); } } __pyx_t_5 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_9, __pyx_t_10, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_6); __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 351, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __pyx_t_9 = PyTuple_New(2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 351, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_t_5); __pyx_t_4 = 0; __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 351, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_5); __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; __Pyx_Raise(__pyx_t_5, 0, 0, 0); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __PYX_ERR(0, 351, __pyx_L10_error)
+352: return [mibp[i] for i in range(_size)]
__Pyx_XDECREF(__pyx_r); __pyx_t_5 = PyList_New(0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 352, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_7 = __pyx_v__size; __pyx_t_11 = __pyx_t_7; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_v_i = __pyx_t_12; __pyx_t_9 = __Pyx_PyInt_From_int((__pyx_v_mibp[__pyx_v_i])); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 352, __pyx_L10_error) __Pyx_GOTREF(__pyx_t_9); if (unlikely(__Pyx_ListComp_Append(__pyx_t_5, (PyObject*)__pyx_t_9))) __PYX_ERR(0, 352, __pyx_L10_error) __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; } __pyx_r = __pyx_t_5; __pyx_t_5 = 0; goto __pyx_L9_return; }
353: finally:
+354: free(mibp)
/*finally:*/ { __pyx_L10_error:; /*exception exit:*/{ __Pyx_PyThreadState_declare __Pyx_PyThreadState_assign __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_19, &__pyx_t_20, &__pyx_t_21); if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_17, &__pyx_t_18); __Pyx_XGOTREF(__pyx_t_16); __Pyx_XGOTREF(__pyx_t_17); __Pyx_XGOTREF(__pyx_t_18); __Pyx_XGOTREF(__pyx_t_19); __Pyx_XGOTREF(__pyx_t_20); __Pyx_XGOTREF(__pyx_t_21); __pyx_t_13 = __pyx_lineno; __pyx_t_14 = __pyx_clineno; __pyx_t_15 = __pyx_filename; { free(__pyx_v_mibp); } if (PY_MAJOR_VERSION >= 3) { __Pyx_XGIVEREF(__pyx_t_19); __Pyx_XGIVEREF(__pyx_t_20); __Pyx_XGIVEREF(__pyx_t_21); __Pyx_ExceptionReset(__pyx_t_19, __pyx_t_20, __pyx_t_21); } __Pyx_XGIVEREF(__pyx_t_16); __Pyx_XGIVEREF(__pyx_t_17); __Pyx_XGIVEREF(__pyx_t_18); __Pyx_ErrRestore(__pyx_t_16, __pyx_t_17, __pyx_t_18); __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0; __pyx_t_20 = 0; __pyx_t_21 = 0; __pyx_lineno = __pyx_t_13; __pyx_clineno = __pyx_t_14; __pyx_filename = __pyx_t_15; goto __pyx_L1_error; } __pyx_L9_return: { __pyx_t_21 = __pyx_r; __pyx_r = 0; free(__pyx_v_mibp); __pyx_r = __pyx_t_21; __pyx_t_21 = 0; goto __pyx_L0; } }
355:
356:
+357: def sysctlmibtoname(mib):
/* Python wrapper */ static PyObject *__pyx_pw_3bsd_6sysctl_7sysctlmibtoname(PyObject *__pyx_self, PyObject *__pyx_v_mib); /*proto*/ static PyMethodDef __pyx_mdef_3bsd_6sysctl_7sysctlmibtoname = {"sysctlmibtoname", (PyCFunction)__pyx_pw_3bsd_6sysctl_7sysctlmibtoname, METH_O, 0}; static PyObject *__pyx_pw_3bsd_6sysctl_7sysctlmibtoname(PyObject *__pyx_self, PyObject *__pyx_v_mib) { PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sysctlmibtoname (wrapper)", 0); __pyx_r = __pyx_pf_3bsd_6sysctl_6sysctlmibtoname(__pyx_self, ((PyObject *)__pyx_v_mib)); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_3bsd_6sysctl_6sysctlmibtoname(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_mib) { arrayobject *__pyx_v_c_mib = 0; int __pyx_v_name[22]; char __pyx_v_ret[0x100]; size_t __pyx_v_l1; size_t __pyx_v_l2; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("sysctlmibtoname", 0); /* … */ /* function exit code */ __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __Pyx_AddTraceback("bsd.sysctl.sysctlmibtoname", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __pyx_L0:; __Pyx_XDECREF((PyObject *)__pyx_v_c_mib); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_3bsd_6sysctl_10generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value); /* proto */ /* … */ __pyx_tuple__11 = PyTuple_Pack(6, __pyx_n_s_mib, __pyx_n_s_c_mib, __pyx_n_s_name, __pyx_n_s_ret, __pyx_n_s_l1, __pyx_n_s_l2); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 357, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__11); __Pyx_GIVEREF(__pyx_tuple__11); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3bsd_6sysctl_7sysctlmibtoname, NULL, __pyx_n_s_bsd_sysctl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 357, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_sysctlmibtoname, __pyx_t_2) < 0) __PYX_ERR(0, 357, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 6, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_bsd_sysctl_pyx, __pyx_n_s_sysctlmibtoname, 357, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 357, __pyx_L1_error)
358: cdef:
359: c_array.array c_mib
360: int name[22]
361: char ret[256]
362: size_t l1
363: size_t l2
364:
+365: name[0] = 0
(__pyx_v_name[0]) = 0;
+366: name[1] = 1
(__pyx_v_name[1]) = 1;
+367: l1 = len(mib) + 2
__pyx_t_1 = PyObject_Length(__pyx_v_mib); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 367, __pyx_L1_error) __pyx_v_l1 = (__pyx_t_1 + 2);
+368: l2 = cython.sizeof(ret)
__pyx_v_l2 = (sizeof(__pyx_v_ret));
369:
+370: c_mib = array('i', mib)
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_4 = NULL; __pyx_t_5 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_5 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_n_s_i, __pyx_v_mib}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_n_s_i, __pyx_v_mib}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_n_s_i); __Pyx_GIVEREF(__pyx_n_s_i); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_n_s_i); __Pyx_INCREF(__pyx_v_mib); __Pyx_GIVEREF(__pyx_v_mib); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_mib); __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 370, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_5array_array))))) __PYX_ERR(0, 370, __pyx_L1_error) __pyx_v_c_mib = ((arrayobject *)__pyx_t_2); __pyx_t_2 = 0;
+371: memcpy(&name[2], c_mib.data.as_voidptr, len(mib) * cython.sizeof(int))
__pyx_t_1 = PyObject_Length(__pyx_v_mib); if (unlikely(__pyx_t_1 == ((Py_ssize_t)-1))) __PYX_ERR(0, 371, __pyx_L1_error) (void)(memcpy((&(__pyx_v_name[2])), __pyx_v_c_mib->data.as_voidptr, (__pyx_t_1 * (sizeof(int)))));
+372: if defs.sysctl(name, l1, ret, &l2, NULL, 0) < 0:
__pyx_t_7 = ((sysctl(__pyx_v_name, __pyx_v_l1, __pyx_v_ret, (&__pyx_v_l2), NULL, 0) < 0) != 0); if (unlikely(__pyx_t_7)) { /* … */ }
+373: raise OSError(errno, os.strerror(errno))
__pyx_t_2 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_strerror); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_8 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); if (likely(__pyx_t_8)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); __Pyx_INCREF(__pyx_t_8); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_4, function); } } __pyx_t_3 = (__pyx_t_8) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_8, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 373, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 373, __pyx_L1_error)
374:
+375: return ret[:l2 - 1]
__Pyx_XDECREF(__pyx_r); __pyx_t_3 = __Pyx_PyUnicode_FromStringAndSize(((const char*)__pyx_v_ret) + 0, (__pyx_v_l2 - 1) - 0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 375, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_r = __pyx_t_3; __pyx_t_3 = 0; goto __pyx_L0;
376:
377:
+378: def filter(name=None):
/* Python wrapper */ static PyObject *__pyx_pw_3bsd_6sysctl_9filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ static PyMethodDef __pyx_mdef_3bsd_6sysctl_9filter = {"filter", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_3bsd_6sysctl_9filter, METH_VARARGS|METH_KEYWORDS, 0}; static PyObject *__pyx_pw_3bsd_6sysctl_9filter(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { PyObject *__pyx_v_name = 0; PyObject *__pyx_r = 0; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("filter (wrapper)", 0); { static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,0}; PyObject* values[1] = {0}; values[0] = ((PyObject *)Py_None); if (unlikely(__pyx_kwds)) { Py_ssize_t kw_args; const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); switch (pos_args) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } kw_args = PyDict_Size(__pyx_kwds); switch (pos_args) { case 0: if (kw_args > 0) { PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_name); if (value) { values[0] = value; kw_args--; } } } if (unlikely(kw_args > 0)) { if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "filter") < 0)) __PYX_ERR(0, 378, __pyx_L3_error) } } else { switch (PyTuple_GET_SIZE(__pyx_args)) { case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); CYTHON_FALLTHROUGH; case 0: break; default: goto __pyx_L5_argtuple_error; } } __pyx_v_name = values[0]; } goto __pyx_L4_argument_unpacking_done; __pyx_L5_argtuple_error:; __Pyx_RaiseArgtupleInvalid("filter", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 378, __pyx_L3_error) __pyx_L3_error:; __Pyx_AddTraceback("bsd.sysctl.filter", __pyx_clineno, __pyx_lineno, __pyx_filename); __Pyx_RefNannyFinishContext(); return NULL; __pyx_L4_argument_unpacking_done:; __pyx_r = __pyx_pf_3bsd_6sysctl_8filter(__pyx_self, __pyx_v_name); /* function exit code */ __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_pf_3bsd_6sysctl_8filter(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_name) { struct __pyx_obj_3bsd_6sysctl___pyx_scope_struct__filter *__pyx_cur_scope; PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("filter", 0); __pyx_cur_scope = (struct __pyx_obj_3bsd_6sysctl___pyx_scope_struct__filter *)__pyx_tp_new_3bsd_6sysctl___pyx_scope_struct__filter(__pyx_ptype_3bsd_6sysctl___pyx_scope_struct__filter, __pyx_empty_tuple, NULL); if (unlikely(!__pyx_cur_scope)) { __pyx_cur_scope = ((struct __pyx_obj_3bsd_6sysctl___pyx_scope_struct__filter *)Py_None); __Pyx_INCREF(Py_None); __PYX_ERR(0, 378, __pyx_L1_error) } else { __Pyx_GOTREF(__pyx_cur_scope); } __pyx_cur_scope->__pyx_v_name = __pyx_v_name; __Pyx_INCREF(__pyx_cur_scope->__pyx_v_name); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_name); { __pyx_CoroutineObject *gen = __Pyx_Generator_New((__pyx_coroutine_body_t) __pyx_gb_3bsd_6sysctl_10generator, __pyx_codeobj__4, (PyObject *) __pyx_cur_scope, __pyx_n_s_filter, __pyx_n_s_filter, __pyx_n_s_bsd_sysctl); if (unlikely(!gen)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_DECREF(__pyx_cur_scope); __Pyx_RefNannyFinishContext(); return (PyObject *) gen; } /* function exit code */ __pyx_L1_error:; __Pyx_AddTraceback("bsd.sysctl.filter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_r = NULL; __Pyx_DECREF(((PyObject *)__pyx_cur_scope)); __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); return __pyx_r; } static PyObject *__pyx_gb_3bsd_6sysctl_10generator(__pyx_CoroutineObject *__pyx_generator, CYTHON_UNUSED PyThreadState *__pyx_tstate, PyObject *__pyx_sent_value) /* generator body */ { PyObject *__pyx_r = NULL; __Pyx_RefNannyDeclarations __Pyx_RefNannySetupContext("filter", 0); __pyx_L3_first_run:; if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 378, __pyx_L1_error) /* … */ /* function exit code */ PyErr_SetNone(PyExc_StopIteration); goto __pyx_L0; __pyx_L1_error:; __Pyx_XDECREF(__pyx_t_2); __Pyx_XDECREF(__pyx_t_3); __Pyx_XDECREF(__pyx_t_4); __Pyx_XDECREF(__pyx_t_5); __Pyx_XDECREF(__pyx_t_6); __Pyx_XDECREF(__pyx_t_19); __Pyx_AddTraceback("filter", __pyx_clineno, __pyx_lineno, __pyx_filename); __pyx_L0:; __Pyx_XDECREF(__pyx_r); __pyx_r = 0; #if !CYTHON_USE_EXC_INFO_STACK __Pyx_Coroutine_ResetAndClearException(__pyx_generator); #endif __pyx_generator->resume_label = -1; __Pyx_Coroutine_clear((PyObject*)__pyx_generator); __Pyx_RefNannyFinishContext(); return __pyx_r; } /* … */ __pyx_tuple__13 = PyTuple_Pack(11, __pyx_n_s_name, __pyx_n_s_mib, __pyx_n_s_name1, __pyx_n_s_name2, __pyx_n_s_l1, __pyx_n_s_l2, __pyx_n_s_j, __pyx_n_s_i, __pyx_n_s_ret, __pyx_n_s_e, __pyx_n_s_x); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_tuple__13); __Pyx_GIVEREF(__pyx_tuple__13); /* … */ __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3bsd_6sysctl_9filter, NULL, __pyx_n_s_bsd_sysctl); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); if (PyDict_SetItem(__pyx_d, __pyx_n_s_filter, __pyx_t_2) < 0) __PYX_ERR(0, 378, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
379: cdef:
380: c_array.array mib
381: int name1[22]
382: int name2[22]
383: size_t l1
384: size_t l2
385:
+386: name1[0] = 0
(__pyx_cur_scope->__pyx_v_name1[0]) = 0;
+387: name1[1] = 2
(__pyx_cur_scope->__pyx_v_name1[1]) = 2;
388:
+389: l1 = 2
__pyx_cur_scope->__pyx_v_l1 = 2;
+390: if name:
__pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_name); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 390, __pyx_L1_error) if (__pyx_t_1) { /* … */ goto __pyx_L4; }
+391: mib = array('i', sysctlnametomib(name))
__Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_sysctlnametomib); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); if (likely(__pyx_t_6)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); __Pyx_INCREF(__pyx_t_6); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_5, function); } } __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_cur_scope->__pyx_v_name) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_cur_scope->__pyx_v_name); __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_4); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_n_s_i, __pyx_t_4}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_n_s_i, __pyx_t_4}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; } else #endif { __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); if (__pyx_t_5) { __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; } __Pyx_INCREF(__pyx_n_s_i); __Pyx_GIVEREF(__pyx_n_s_i); PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_n_s_i); __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_4); __pyx_t_4 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_5array_array))))) __PYX_ERR(0, 391, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_v_mib = ((arrayobject *)__pyx_t_2); __pyx_t_2 = 0;
392: else:
+393: mib = array('i', [])
/*else*/ { __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_array); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_4 = NULL; __pyx_t_7 = 0; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_3, function); __pyx_t_7 = 1; } } #if CYTHON_FAST_PYCALL if (PyFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_n_s_i, __pyx_t_6}; __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif #if CYTHON_FAST_PYCCALL if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_n_s_i, __pyx_t_6}; __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; } else #endif { __pyx_t_5 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); if (__pyx_t_4) { __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; } __Pyx_INCREF(__pyx_n_s_i); __Pyx_GIVEREF(__pyx_n_s_i); PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_7, __pyx_n_s_i); __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_7, __pyx_t_6); __pyx_t_6 = 0; __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (!(likely(((__pyx_t_2) == Py_None) || likely(__Pyx_TypeTest(__pyx_t_2, __pyx_ptype_7cpython_5array_array))))) __PYX_ERR(0, 393, __pyx_L1_error) __Pyx_GIVEREF(__pyx_t_2); __pyx_cur_scope->__pyx_v_mib = ((arrayobject *)__pyx_t_2); __pyx_t_2 = 0; } __pyx_L4:;
394:
+395: memcpy(&name1[2], mib.data.as_voidptr, len(mib) * cython.sizeof(int))
if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_mib) == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 395, __pyx_L1_error) } __pyx_t_8 = Py_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_mib)); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 395, __pyx_L1_error) (void)(memcpy((&(__pyx_cur_scope->__pyx_v_name1[2])), __pyx_cur_scope->__pyx_v_mib->data.as_voidptr, (__pyx_t_8 * (sizeof(int)))));
+396: l1 += len(mib)
if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_mib) == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 396, __pyx_L1_error) } __pyx_t_8 = Py_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_mib)); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 396, __pyx_L1_error) __pyx_cur_scope->__pyx_v_l1 = (__pyx_cur_scope->__pyx_v_l1 + __pyx_t_8);
397:
+398: while True:
while (1) {
+399: l2 = cython.sizeof(name2)
__pyx_cur_scope->__pyx_v_l2 = (sizeof(__pyx_cur_scope->__pyx_v_name2));
+400: j = defs.sysctl(name1, l1, name2, &l2, NULL, 0)
__pyx_cur_scope->__pyx_v_j = sysctl(__pyx_cur_scope->__pyx_v_name1, __pyx_cur_scope->__pyx_v_l1, __pyx_cur_scope->__pyx_v_name2, (&__pyx_cur_scope->__pyx_v_l2), NULL, 0);
+401: if j < 0:
__pyx_t_1 = ((__pyx_cur_scope->__pyx_v_j < 0) != 0); if (__pyx_t_1) { /* … */ }
+402: if errno == ENOENT:
__pyx_t_1 = ((errno == ENOENT) != 0); if (likely(__pyx_t_1)) { /* … */ }
+403: return
__Pyx_XDECREF(__pyx_r);
__pyx_r = NULL;
goto __pyx_L0;
404: else:
+405: raise OSError(errno, os.strerror(errno))
/*else*/ { __pyx_t_2 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_strerror); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __pyx_t_5 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_4)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_4); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_3 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3); __pyx_t_2 = 0; __pyx_t_3 = 0; __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 405, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_Raise(__pyx_t_3, 0, 0, 0); __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __PYX_ERR(0, 405, __pyx_L1_error) }
406:
+407: l2 /= cython.sizeof(int)
__pyx_t_9 = (sizeof(int)); if (unlikely(__pyx_t_9 == 0)) { PyErr_SetString(PyExc_ZeroDivisionError, "integer division or modulo by zero"); __PYX_ERR(0, 407, __pyx_L1_error) } __pyx_cur_scope->__pyx_v_l2 = (__pyx_cur_scope->__pyx_v_l2 / __pyx_t_9);
408:
+409: if name and (len(mib) < 0 or l2 < len(mib)):
__pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_name); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 409, __pyx_L1_error) if (__pyx_t_10) { } else { __pyx_t_1 = __pyx_t_10; goto __pyx_L10_bool_binop_done; } if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_mib) == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 409, __pyx_L1_error) } __pyx_t_8 = Py_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_mib)); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 409, __pyx_L1_error) __pyx_t_10 = ((__pyx_t_8 < 0) != 0); if (!__pyx_t_10) { } else { __pyx_t_1 = __pyx_t_10; goto __pyx_L10_bool_binop_done; } if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_mib) == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 409, __pyx_L1_error) } __pyx_t_8 = Py_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_mib)); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 409, __pyx_L1_error) __pyx_t_10 = ((__pyx_cur_scope->__pyx_v_l2 < __pyx_t_8) != 0); __pyx_t_1 = __pyx_t_10; __pyx_L10_bool_binop_done:; if (__pyx_t_1) { /* … */ }
+410: return
__Pyx_XDECREF(__pyx_r);
__pyx_r = NULL;
goto __pyx_L0;
411:
+412: for i in range(0, len(mib)):
if (unlikely(((PyObject *)__pyx_cur_scope->__pyx_v_mib) == Py_None)) { PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); __PYX_ERR(0, 412, __pyx_L1_error) } __pyx_t_8 = Py_SIZE(((PyObject *)__pyx_cur_scope->__pyx_v_mib)); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 412, __pyx_L1_error) __pyx_t_11 = __pyx_t_8; for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) { __pyx_cur_scope->__pyx_v_i = __pyx_t_12;
+413: if name2[i] != mib[i]:
__pyx_t_3 = __Pyx_PyInt_From_int((__pyx_cur_scope->__pyx_v_name2[__pyx_cur_scope->__pyx_v_i])); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_6 = __Pyx_GetItemInt(((PyObject *)__pyx_cur_scope->__pyx_v_mib), __pyx_cur_scope->__pyx_v_i, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_2 = PyObject_RichCompare(__pyx_t_3, __pyx_t_6, Py_NE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 413, __pyx_L1_error) __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; if (__pyx_t_1) { /* … */ } }
+414: return
__Pyx_XDECREF(__pyx_r);
__pyx_r = NULL;
goto __pyx_L0;
415:
+416: try:
{ /*try:*/ { /* … */ } /* … */ __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L1_error; __pyx_L19_except_return:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); goto __pyx_L0; __pyx_L17_exception_handled:; __Pyx_XGIVEREF(__pyx_t_13); __Pyx_XGIVEREF(__pyx_t_14); __Pyx_XGIVEREF(__pyx_t_15); __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_14, __pyx_t_15); __pyx_L23_try_end:; }
+417: ret = sysctl([x for x in name2[:l2]])
__Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_sysctl); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 417, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 417, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_17 = (__pyx_cur_scope->__pyx_v_name2 + __pyx_cur_scope->__pyx_v_l2); for (__pyx_t_18 = __pyx_cur_scope->__pyx_v_name2; __pyx_t_18 < __pyx_t_17; __pyx_t_18++) { __pyx_t_16 = __pyx_t_18; __pyx_cur_scope->__pyx_v_x = (__pyx_t_16[0]); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_x); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 417, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 417, __pyx_L16_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 417, __pyx_L16_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_ret); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_ret, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2); __pyx_t_2 = 0;
+418: except OSError, e:
__pyx_t_7 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OSError); if (__pyx_t_7) { __Pyx_AddTraceback("bsd.sysctl.filter", __pyx_clineno, __pyx_lineno, __pyx_filename); if (__Pyx_GetException(&__pyx_t_6, &__pyx_t_2, &__pyx_t_3) < 0) __PYX_ERR(0, 418, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GOTREF(__pyx_t_2); __Pyx_GOTREF(__pyx_t_3); __Pyx_INCREF(__pyx_t_2); __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_e); __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_e, __pyx_t_2); __Pyx_GIVEREF(__pyx_t_2);
+419: if e.errno == ENOENT:
__pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_e, __pyx_n_s_errno); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 419, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_5); __pyx_t_4 = __Pyx_PyInt_From_int(ENOENT); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 419, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_4); __pyx_t_19 = PyObject_RichCompare(__pyx_t_5, __pyx_t_4, Py_EQ); __Pyx_XGOTREF(__pyx_t_19); if (unlikely(!__pyx_t_19)) __PYX_ERR(0, 419, __pyx_L18_except_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_19); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 419, __pyx_L18_except_error) __Pyx_DECREF(__pyx_t_19); __pyx_t_19 = 0; if (__pyx_t_1) { /* … */ } __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; goto __pyx_L17_exception_handled; } goto __pyx_L18_except_error; __pyx_L18_except_error:;
+420: return
__Pyx_XDECREF(__pyx_r); __pyx_r = NULL; __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; goto __pyx_L19_except_return;
421:
422: else:
+423: yield (sysctlmibtoname([x for x in name2[:l2]]), ret)
/*else:*/ { __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_sysctlmibtoname); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 423, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_6); __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 423, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_3); __pyx_t_17 = (__pyx_cur_scope->__pyx_v_name2 + __pyx_cur_scope->__pyx_v_l2); for (__pyx_t_18 = __pyx_cur_scope->__pyx_v_name2; __pyx_t_18 < __pyx_t_17; __pyx_t_18++) { __pyx_t_16 = __pyx_t_18; __pyx_cur_scope->__pyx_v_x = (__pyx_t_16[0]); __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_cur_scope->__pyx_v_x); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 423, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_5); if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_5))) __PYX_ERR(0, 423, __pyx_L18_except_error) __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; } __pyx_t_5 = NULL; if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); if (likely(__pyx_t_5)) { PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); __Pyx_INCREF(__pyx_t_5); __Pyx_INCREF(function); __Pyx_DECREF_SET(__pyx_t_6, function); } } __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_3); __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 423, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_2); __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 423, __pyx_L18_except_error) __Pyx_GOTREF(__pyx_t_6); __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __Pyx_INCREF(__pyx_cur_scope->__pyx_v_ret); __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_ret); PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_cur_scope->__pyx_v_ret); __pyx_t_2 = 0; __pyx_r = __pyx_t_6; __pyx_t_6 = 0; __Pyx_XGIVEREF(__pyx_t_13); __pyx_cur_scope->__pyx_t_0 = __pyx_t_13; __Pyx_XGIVEREF(__pyx_t_14); __pyx_cur_scope->__pyx_t_1 = __pyx_t_14; __Pyx_XGIVEREF(__pyx_t_15); __pyx_cur_scope->__pyx_t_2 = __pyx_t_15; __Pyx_XGIVEREF(__pyx_r); __Pyx_RefNannyFinishContext(); __Pyx_Coroutine_ResetAndClearException(__pyx_generator); /* return from generator, yielding value */ __pyx_generator->resume_label = 1; return __pyx_r; __pyx_L28_resume_from_yield:; __pyx_t_13 = __pyx_cur_scope->__pyx_t_0; __pyx_cur_scope->__pyx_t_0 = 0; __Pyx_XGOTREF(__pyx_t_13); __pyx_t_14 = __pyx_cur_scope->__pyx_t_1; __pyx_cur_scope->__pyx_t_1 = 0; __Pyx_XGOTREF(__pyx_t_14); __pyx_t_15 = __pyx_cur_scope->__pyx_t_2; __pyx_cur_scope->__pyx_t_2 = 0; __Pyx_XGOTREF(__pyx_t_15); if (unlikely(!__pyx_sent_value)) __PYX_ERR(0, 423, __pyx_L18_except_error) } __Pyx_XDECREF(__pyx_t_13); __pyx_t_13 = 0; __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0; __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0; goto __pyx_L23_try_end; __pyx_L16_error:; __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0; __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
424:
+425: memcpy(name1+2, name2, l2 * sizeof(int))
(void)(memcpy((__pyx_cur_scope->__pyx_v_name1 + 2), __pyx_cur_scope->__pyx_v_name2, (__pyx_cur_scope->__pyx_v_l2 * (sizeof(int)))));
+426: l1 = 2 + l2
__pyx_cur_scope->__pyx_v_l1 = (2 + __pyx_cur_scope->__pyx_v_l2); } CYTHON_MAYBE_UNUSED_VAR(__pyx_cur_scope);