From owner-freebsd-python@freebsd.org Mon Sep 18 10:39:30 2017 Return-Path: Delivered-To: freebsd-python@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 22EBBE06EED for ; Mon, 18 Sep 2017 10:39:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mailman.ysv.freebsd.org (unknown [127.0.1.3]) by mx1.freebsd.org (Postfix) with ESMTP id 0A4B83DFC for ; Mon, 18 Sep 2017 10:39:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: by mailman.ysv.freebsd.org (Postfix) id 053E8E06EEC; Mon, 18 Sep 2017 10:39:30 +0000 (UTC) Delivered-To: python@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 04CE0E06EEB for ; Mon, 18 Sep 2017 10:39:30 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2001:1900:2254:206a::16:76]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id E6A7B3DFB for ; Mon, 18 Sep 2017 10:39:29 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from bugs.freebsd.org ([127.0.1.118]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id v8IAdTEg048788 for ; Mon, 18 Sep 2017 10:39:29 GMT (envelope-from bugzilla-noreply@freebsd.org) From: bugzilla-noreply@freebsd.org To: python@FreeBSD.org Subject: [Bug 220596] [NEW PORT] shells/xonsh: Python-ish BASH-wards shell Date: Mon, 18 Sep 2017 10:39:29 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Ports & Packages X-Bugzilla-Component: Individual Port(s) X-Bugzilla-Version: Latest X-Bugzilla-Keywords: feature, needs-patch, needs-qa X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: FreeBSD@ShaneWare.Biz X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: matthew@FreeBSD.org X-Bugzilla-Flags: maintainer-feedback? X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: freebsd-python@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: FreeBSD-specific Python issues List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 Sep 2017 10:39:30 -0000 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D220596 Shane changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |FreeBSD@ShaneWare.Biz --- Comment #29 from Shane --- (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.=