Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
struct has no member 'None' when accessing a list-derived type from a cdef function
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Saúl Ibarra Corretgé  
View profile  
 More options May 27 2011, 6:22 am
From: Saúl Ibarra Corretgé <sag...@gmail.com>
Date: Fri, 27 May 2011 10:22:12 +0000
Local: Fri, May 27 2011 6:22 am
Subject: [cython-users] struct has no member 'None' when accessing a list-derived type from a cdef function
Hi,

Sorry if this has been posted already, I didn't quite know how to
phrase the problem, hence the weird title of this email.

In the following example (using Cython 0.14.1):

# ------------------------ #
cdef class MyList(list):
    def foo(self):
        print "foo"

cdef class Bar(object):
    cdef MyList _attributes

    def __init__(self, list attributes=None):
        self.attributes = attributes if attributes is not None else []

    property attributes:
        def __get__(self):
            return self._attributes

        def __set__(self, list attributes not None):
            self._attributes = attributes

    cdef int _test(self):
        self._attributes.append('foo')
# ------------------------ #

I'm getting th following error:

t.c: In function ‘__pyx_f_5hello_3Bar__test’:
t.c:1148:7: warning: comparison of distinct pointer types lacks a cast
t.c:1155:56: error: ‘struct __pyx_obj_5hello_MyList’ has no member named ‘None’

However, if I declare list as an explicit extern type:

cdef extern from "listobject.h":
    ctypedef class __builtin__.list [object PyListObject]:
        pass

It works. Am I doing something wrong here or is this a bug?

Kind regards,

--
/Saúl
http://saghul.net | http://sipdoc.net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Bradshaw  
View profile  
 More options May 27 2011, 7:37 pm
From: Robert Bradshaw <rober...@math.washington.edu>
Date: Fri, 27 May 2011 16:37:39 -0700
Local: Fri, May 27 2011 7:37 pm
Subject: Re: [cython-users] struct has no member 'None' when accessing a list-derived type from a cdef function
On Fri, May 27, 2011 at 3:22 AM, Saúl Ibarra Corretgé <sag...@gmail.com> wrote:

This is a bug. However, note that the cython builtin "list" means
exactly a list (no subclasses allowed), otherwise we can't safely
optimize it (or, at least, we'd have to re-work our optimizations to
include dispatches to generic code, in which case there's little
benefit to typing it something other than "object."

- Robert


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Saúl Ibarra Corretgé  
View profile  
 More options May 30 2011, 5:28 am
From: Saúl Ibarra Corretgé <sag...@gmail.com>
Date: Mon, 30 May 2011 11:28:49 +0200
Local: Mon, May 30 2011 5:28 am
Subject: Re: [cython-users] struct has no member 'None' when accessing a list-derived type from a cdef function
Hi Robert,

> This is a bug. However, note that the cython builtin "list" means
> exactly a list (no subclasses allowed), otherwise we can't safely
> optimize it (or, at least, we'd have to re-work our optimizations to
> include dispatches to generic code, in which case there's little
> benefit to typing it something other than "object."

Ok, thanks for the explanation! Is there a ticket created for this?

Regards,

--
/Saúl
http://saghul.net | http://sipdoc.net


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Robert Bradshaw  
View profile  
 More options May 31 2011, 12:35 am
From: Robert Bradshaw <rober...@math.washington.edu>
Date: Mon, 30 May 2011 21:35:18 -0700
Local: Tues, May 31 2011 12:35 am
Subject: Re: [cython-users] struct has no member 'None' when accessing a list-derived type from a cdef function
On Mon, May 30, 2011 at 2:28 AM, Saúl Ibarra Corretgé <sag...@gmail.com> wrote:

> Hi Robert,

>> This is a bug. However, note that the cython builtin "list" means
>> exactly a list (no subclasses allowed), otherwise we can't safely
>> optimize it (or, at least, we'd have to re-work our optimizations to
>> include dispatches to generic code, in which case there's little
>> benefit to typing it something other than "object."

> Ok, thanks for the explanation! Is there a ticket created for this?

I don't think so (short of the fact that I tagged this email as "bug"
to not forget it :), feel free to file one.

- Robert


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »