Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'causing': 0.04; 'static': 0.04; 'subject:Python': 0.06; 'compiler': 0.07; 'debug': 0.07; "subject:' ": 0.07; 'arguments': 0.09; 'meaningful': 0.09; 'null,': 0.09; 'subject:using': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '11:09': 0.16; 'cc:name:python list': 0.16; 'linux).': 0.16; 'luck,': 0.16; 'subject:library': 0.16; 'symbols': 0.16; 'traceback.': 0.16; 'wrote:': 0.18; 'obviously': 0.18; '(but': 0.19; '3.0': 0.19; 'basically': 0.19; '>>>': 0.22; 'import': 0.22; 'aug': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'switched': 0.24; 'cc:2**0': 0.24; 'somewhere': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; "doesn't": 0.30; 'message-id:@mail.gmail.com': 0.30; '(on': 0.31; '3.2': 0.31; 'flags': 0.31; 'gcc': 0.31; 'problem': 0.35; 'subject:with': 0.35; "can't": 0.35; 'problem.': 0.35; 'received:google.com': 0.35; 'add': 0.35; 'subject:one': 0.36; 'doing': 0.36; 'skip:& 10': 0.38; 'jason': 0.38; 'nov': 0.38; 'files': 0.38; 'skip:& 20': 0.39; 'does': 0.39; 'bad': 0.39; 'sure': 0.39; 'university': 0.39; 'tell': 0.60; "you're": 0.61; 'field': 0.63; '8bit%:10': 0.64; 'more': 0.64; 'to:addr:gmail.com': 0.65; 'world': 0.66; '8bit%:21': 0.69; 'subject:hello': 0.83; '2014,': 0.84; '4.7': 0.84; 'lying': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=SR3COWtOUtQx1FEKE9iqP7eNsY6iuE5VV6FUSpvlsdo=; b=PojmmgRj6BeW8pBsti+hbSRFaqOSlDda2aVGYuClNU0nUx0wxMquXCe71Y8gRHOPy6 qmp7X8pB7OHAs6EETQ8AllDV1xKxlH+FqKwEPTRN90gKzlenmJY5S2LT4Tg7Z1tHlMDQ ozL/dIZRJysx6RAdDACo4cMPJXj3H+e56V8JSHZsNM7X07j7J9ReiD+LB/aag4YJgEy7 SfdNBrNhyXvHvHBdoWLr69nBJhWNslrP6iCfnUyIfHyaIyl510POdbYHs0AtvZZyhLfM L2EwLFSVG9+p+oR7r3Zga9hQ2gg+D3i7MYUxbDHIO/pZH9HOuy1SNtnGjc7OUQ1ZLjvM XpPg== MIME-Version: 1.0 X-Received: by 10.236.30.33 with SMTP id j21mr8867587yha.157.1415122084601; Tue, 04 Nov 2014 09:28:04 -0800 (PST) In-Reply-To: References: Date: Tue, 4 Nov 2014 12:28:04 -0500 Subject: Re: Python extension using a C library with one 'hello' function From: Jason Swails To: Veek M Content-Type: multipart/alternative; boundary=089e0116085c2aa6c505070bc991 Cc: python list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 119 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415122451 news.xs4all.nl 2937 [2001:888:2000:d::a6]:60787 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80209 --089e0116085c2aa6c505070bc991 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Nov 4, 2014 at 11:09 AM, Veek M wrote: > static PyMethodDef hellomethods[] =3D { > {"hello", py_hello, METH_VARARGS, py_hello_doc}, > {NULL, NULL, 0, NULL}, > }; > > It's basically the METH_VARARGS field that's giving the problem. Switchin= g > it to NULL gives, > SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longe= r > supported! > =E2=80=8BYes, I got that problem too, which is why I switched it to METH_NO= ARGS. =E2=80=8B > and METH_NOARGS doesn't work in 3.2 > I =E2=80=8Bt does for me: =E2=80=8B Python 3.2.5 (default, Aug 24 2014, 10:06:23) [GCC 4.7.4] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import hello >>> hello.hello() hello world 0 >>> =E2=80=8BAs you can see -- this is a Python 3.2 built with GCC 4.7 (On Gent= oo Linux). It also works on Python 3.1 and 3.0 (but obviously doesn't work for Python 2.X). I can't tell why you're having so many problems...=E2=80= =8B Try doing a "git clean -fxd" to make sure you don't have leftover files lying around somewhere that are causing grief. Also, you need to add "-g" to the compiler arguments to make sure you build with debug symbols if you want a meaningful traceback. Good luck, Jason --=20 Jason M. Swails BioMaPS, Rutgers University Postdoctoral Researcher --089e0116085c2aa6c505070bc991 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

On Tue, N= ov 4, 2014 at 11:09 AM, Veek M <vek.m1234@gmail.com> wrote= :
static PyMethodDef hellomethods[] =3D {
=C2=A0 =C2=A0 {"hello", py_hello, METH_VARARGS, py_hello_doc}, =C2=A0 =C2=A0 {NULL, NULL, 0, NULL},
};

It's basically the METH_VARARGS field that's giving the problem. Sw= itching
it to NULL gives,
SystemError: Bad call flags in PyCFunction_Call. METH_OLDARGS is no longer<= br> supported!

=E2=80=8BYes, I got that problem= too, which is why I switched it to METH_NOARGS.
=E2=80=8B
and METH_NOARGS doesn't work in 3.2

I
=E2=80=8Bt does for me:

=E2=80=8BPython 3.2.5 (default, Aug 24 2014, 10:06:23)=C2=A0
[GCC 4.7.4] on linux2
Type "help", "copyright", "credits" o= r "license" for more information.
>>> import hello
>>> hello.hello()
hello= world
0
>>>=C2=A0

=E2=80=8BAs you can see -- = this is a Python 3.2 built with GCC 4.7 (On Gentoo Linux).=C2=A0 It also wo= rks on Python 3.1 and 3.0 (but obviously doesn't work for Python 2.X).= =C2=A0 I can't tell why you're having so many problems...=E2=80=8B = =C2=A0Try doing a "git clean -fxd" to make sure you don't hav= e leftover files lying around somewhere that are causing grief.

Also, you need to add "-g&quo= t; to the compiler arguments to make sure you build with debug symbols if y= ou want a meaningful traceback.

Good luck,
Jason

--
Jason M. Swails
BioMaPS,
Rutgers University
Postdocto= ral Researcher
--089e0116085c2aa6c505070bc991--