CHasTraits type name

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

CHasTraits type name

Christopher Burns-2
We're getting a pickling error when building our docs using Sphinx.
It appears the pickling is unable to find the CHasTraits type and is
therefore looking in the __builtins__ for it.  I was able to fix this
by fully qualifying the type name in the tp_name field of the
PyTypeObject in ctraits.c.

Unfortunately I have not been able to come up with a simple example
that recreates this error.  But below is the traceback and the mro of
the classes to show the type names.

# Sphinx version: 0.6.3
# Docutils version: 0.5 release
Traceback (most recent call last):
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/cmdline.py",
line 172, in main
    app.build(all_files, filenames)
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/application.py",
line 130, in build
    self.builder.build_update()
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 265, in build_update
    'out of date' % len(to_build))
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 285, in build
    purple, length):
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 131, in status_iterator
    for item in iterable:
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/environment.py",
line 513, in update_generator
    self.read_doc(docname, app=app)
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/environment.py",
line 656, in read_doc
    pickle.dump(doctree, f, pickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <type 'CHasTraits'>: attribute lookup
__builtin__.CHasTraits failed


Here we can see the type names of HasTraits and its base classes:

In [2]: traits.HasTraits.__mro__
Out[2]:
(<class 'enthought.traits.has_traits.HasTraits'>,
 <type 'CHasTraits'>,
 <type 'object'>)


CTrait has the same issue:
In [4]: traits.CTrait.__mro__
Out[4]:
(<class 'enthought.traits.traits.CTrait'>,
 <type 'cTrait'>,
 <type 'object'>)


CHasTraits with complete type name:

In [10]: traits.HasTraits.__mro__
Out[10]:
(<class 'enthought.traits.has_traits.HasTraits'>,
 <type 'enthought.traits.ctraits.CHasTraits'>,
 <type 'object'>)


I've attached a patch that fixed the problem for me.  Is this the
correct solution or am I on the wrong path?

Thanks,
Chris

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev

traits_type_name.diff (988 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: CHasTraits type name

Robert Kern

This is probably the right fix.

On May 4, 2010 1:26 PM, "Christopher Burns" <[hidden email]> wrote:

We're getting a pickling error when building our docs using Sphinx.
It appears the pickling is unable to find the CHasTraits type and is
therefore looking in the __builtins__ for it.  I was able to fix this
by fully qualifying the type name in the tp_name field of the
PyTypeObject in ctraits.c.

Unfortunately I have not been able to come up with a simple example
that recreates this error.  But below is the traceback and the mro of
the classes to show the type names.

# Sphinx version: 0.6.3
# Docutils version: 0.5 release
Traceback (most recent call last):
 File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/cmdline.py",
line 172, in main
   app.build(all_files, filenames)
 File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/application.py",
line 130, in build
   self.builder.build_update()
 File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 265, in build_update
   'out of date' % len(to_build))
 File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 285, in build
   purple, length):
 File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 131, in status_iterator
   for item in iterable:
 File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/environment.py",
line 513, in update_generator
   self.read_doc(docname, app=app)
 File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/environment.py",
line 656, in read_doc
   pickle.dump(doctree, f, pickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <type 'CHasTraits'>: attribute lookup
__builtin__.CHasTraits failed


Here we can see the type names of HasTraits and its base classes:

In [2]: traits.HasTraits.__mro__
Out[2]:
(<class 'enthought.traits.has_traits.HasTraits'>,
 <type 'CHasTraits'>,
 <type 'object'>)


CTrait has the same issue:
In [4]: traits.CTrait.__mro__
Out[4]:
(<class 'enthought.traits.traits.CTrait'>,
 <type 'cTrait'>,
 <type 'object'>)


CHasTraits with complete type name:

In [10]: traits.HasTraits.__mro__
Out[10]:
(<class 'enthought.traits.has_traits.HasTraits'>,
 <type 'enthought.traits.ctraits.CHasTraits'>,
 <type 'object'>)


I've attached a patch that fixed the problem for me.  Is this the
correct solution or am I on the wrong path?

Thanks,
Chris

_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: CHasTraits type name

bryce hendrix-2
In reply to this post by Christopher Burns-2
Chris,

I've committed your patch, thanks.

Bryce

On 05/04/2010 12:26 PM, Christopher Burns wrote:
We're getting a pickling error when building our docs using Sphinx.
It appears the pickling is unable to find the CHasTraits type and is
therefore looking in the __builtins__ for it.  I was able to fix this
by fully qualifying the type name in the tp_name field of the
PyTypeObject in ctraits.c.

Unfortunately I have not been able to come up with a simple example
that recreates this error.  But below is the traceback and the mro of
the classes to show the type names.

# Sphinx version: 0.6.3
# Docutils version: 0.5 release
Traceback (most recent call last):
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/cmdline.py",
line 172, in main
    app.build(all_files, filenames)
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/application.py",
line 130, in build
    self.builder.build_update()
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 265, in build_update
    'out of date' % len(to_build))
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 285, in build
    purple, length):
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/builders/__init__.py",
line 131, in status_iterator
    for item in iterable:
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/environment.py",
line 513, in update_generator
    self.read_doc(docname, app=app)
  File "/Users/cburns/local/lib/python2.5/site-packages/Sphinx-0.6.3-py2.5.egg/sphinx/environment.py",
line 656, in read_doc
    pickle.dump(doctree, f, pickle.HIGHEST_PROTOCOL)
PicklingError: Can't pickle <type 'CHasTraits'>: attribute lookup
__builtin__.CHasTraits failed


Here we can see the type names of HasTraits and its base classes:

In [2]: traits.HasTraits.__mro__
Out[2]:
(<class 'enthought.traits.has_traits.HasTraits'>,
 <type 'CHasTraits'>,
 <type 'object'>)


CTrait has the same issue:
In [4]: traits.CTrait.__mro__
Out[4]:
(<class 'enthought.traits.traits.CTrait'>,
 <type 'cTrait'>,
 <type 'object'>)


CHasTraits with complete type name:

In [10]: traits.HasTraits.__mro__
Out[10]:
(<class 'enthought.traits.has_traits.HasTraits'>,
 <type 'enthought.traits.ctraits.CHasTraits'>,
 <type 'object'>)


I've attached a patch that fixed the problem for me.  Is this the
correct solution or am I on the wrong path?

Thanks,
Chris
  
_______________________________________________ Enthought-Dev mailing list [hidden email] https://mail.enthought.com/mailman/listinfo/enthought-dev


_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev
Reply | Threaded
Open this post in threaded view
|

Re: CHasTraits type name

Christopher Burns-2
Cool.  Thanks Bryce.  Is there a plan/date for the next traits release?

Chris

On Wed, May 5, 2010 at 4:19 PM, bryce hendrix <[hidden email]> wrote:
> Chris,
>
> I've committed your patch, thanks.
>
> Bryce
>
_______________________________________________
Enthought-Dev mailing list
[hidden email]
https://mail.enthought.com/mailman/listinfo/enthought-dev