Date: Mon, 18 Sep 2017 10:39:29 +0000 From: bugzilla-noreply@freebsd.org To: python@FreeBSD.org Subject: [Bug 220596] [NEW PORT] shells/xonsh: Python-ish BASH-wards shell Message-ID: <bug-220596-21822-4YUqrLnYX1@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-220596-21822@https.bugs.freebsd.org/bugzilla/> References: <bug-220596-21822@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D220596 Shane <FreeBSD@ShaneWare.Biz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |FreeBSD@ShaneWare.Biz --- Comment #29 from Shane <FreeBSD@ShaneWare.Biz> --- (In reply to Roberto Fernandez Cueto from comment #27) Your example use of find_library is wrong. >From pydocs - > name is the library name without any prefix like lib, suffix like .so, .d= ylib or version number (this is the form used for the posix linker option -= l) sysctlbyname takes a char* as the first arg - in ctypes get that from create_string_buffer(), also prefixing it as bytes works - b'kern.boottime' While it doesn't actually make a difference, using ctypes.c_size_t for sz w= ould be more correct. So for the proper results in 2.7 and 3.x use import ctypes import ctypes.util libc =3D ctypes.CDLL(ctypes.util.find_library('c'), use_errno=3DTrue) sz =3D ctypes.c_size_t(0) Then either sysctl_name =3D ctypes.create_string_buffer(b'kern.boottime') libc.sysctlbyname(sysctl_name, None, ctypes.byref(sz), None, 0) or libc.sysctlbyname(b'kern.boottime', None, ctypes.byref(sz), None, 0) So to get rid of the exception on starting xonsh - You will find in _uptime_bsd() xp.LIBC is None so that points to the first = fix being back in __amalgam__.py:LIBC() Adjust the ON_BSD test to use find_library() - the same as ON_DARWIN elif ON_BSD: try: libc =3D ctypes.CDLL(ctypes.util.find_library("c")) Then in _uptime_bsd() either prefix the sysctlname with b or use create_string_buffer() xp.LIBC.sysctlbyname(b'kern.boottime', None, ctypes.byref(sz), None, 0) --=20 You are receiving this mail because: You are on the CC list for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-220596-21822-4YUqrLnYX1>