No topic specification for topic 'data' when py2exe'd

23 views
Skip to first unread message

Werner

unread,
Nov 12, 2012, 5:59:29 AM11/12/12
to PyPubSub
Hi,

I am at the point where I like to generate a py2exe'd version of my app.

When I run it I get this traceback:

File "run_cb.py", line 18, in <module>
File "wx\_core.pyo", line 8631, in __init__
File "wx\_core.pyo", line 8196, in _BootstrapApp
File "twcbsrc\app_base.pyo", line 209, in OnInit
File "wx\lib\pubsub\core\publisherbase.pyo", line 141, in subscribe
File "wx\lib\pubsub\core\topicmgr.pyo", line 189, in getOrCreateTopic
File "wx\lib\pubsub\core\topicmgr.pyo", line 323, in __createParentTopics
File "wx\lib\pubsub\core\topicmgr.pyo", line 339, in __createTopic
ListenerSpecIncomplete: No topic specification for topic 'data'. See
pub.getOrCreateTopic(), pub.addTopicDefnProvider(), and/or
pub.setTopicUnspecifiedFatal()

Line 207 - 209 in app_base are:
log.debug("pTopics: %s" % pTopics)
log.debug("pTopics.data: %s" % pTopics.data)
pub.subscribe(self.pubListDataNeedsSaving,
pTopics.data.needsSaving)

The log shows:
2012-11-12 11:43:26,480 - twcbsrc.app_base - DEBUG - app_base.pyo - 207
- pTopics: <module 'twcbsrc.mypub_topics' from
'C:\dev\twcbv4\dist-twcb\lib\library.zip\
twcbsrc\mypub_topics.pyo'>
2012-11-12 11:43:26,494 - twcbsrc.app_base - DEBUG - app_base.pyo - 208
- pTopics.data: twcbsrc.mypub_topics.data

and mypub_topics for data is:

class data:
"""To flag about state of data"""

class needsSaving:
"""there is un-saved data

:param dbparent: parent holding the dbItem
"""

def msgDataSpec(dbparent):
"""params doc on class above"""


Anyone has an idea what is causing the problem with py2exe'd version of
the application?

Werner

Werner

unread,
Nov 12, 2012, 8:05:53 AM11/12/12
to pypu...@googlegroups.com
Did some more debugging but still don't know how to fix it.

When I do this:

import twcbsrc.mypub_topics as pTopics
log.debug("MyPub tree: %s" % dir(pTopics))

#pub.importTopicTree(pTopics, format=pub.TOPIC_TREE_FROM_CLASS)
pub.importTopicTree('twcbsrc.mypub_topics',
format=pub.TOPIC_TREE_FROM_MODULE)
pub.exportTopicTree('MyTopicTree')
pub.setTopicUnspecifiedFatal()

Either of the importTopicTree will create a correct MyTopicTree file
when I run it in WingIDE, but when I run the py2exe'd version the
MyTopicTree is containing the comment entries and no topic definitions.

The log.debug line shows the topic classes "data" etc.

Werner

oliver

unread,
Nov 12, 2012, 8:20:59 AM11/12/12
to PyPubSub
Could it be that py2exe is finding a (old) copy of your topic module somewhere else in the filesystem? Can you clarify "containing the comment entries and no topic definitions"? 




Werner

--
You received this message because you are subscribed to the Google Groups "pypubsub" group.
To post to this group, send email to pypu...@googlegroups.com.
To unsubscribe from this group, send email to pypubsub+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/pypubsub?hl=en.


Werner

unread,
Nov 12, 2012, 9:12:39 AM11/12/12
to pypu...@googlegroups.com
Hi Oliver,

I just narrowed it down.

def addDefnFromClassObj(self, pyClassObj):
'''Use pyClassObj as a topic definition written using "Python
classes".
The class name is the topic name, assumed to be a root topic, and
descends recursively down into nested classes. '''
if self.__iterStarted:
raise RuntimeError('addClassObj must be called before
iteration started!')

parentNameTuple = (pyClassObj.__name__, )
print 'parentNameTuple: %s' % parentNameTuple
print 'parentNameTuple 2: %s' % pyClassObj.__doc__
if pyClassObj.__doc__ is not None:
self.__rootTopics.append( (parentNameTuple, pyClassObj) )
if self.__rootDoc is None:
self.__rootDoc = pyClassObj.__doc__
self.__findTopics(pyClassObj, parentNameTuple)


A py2exe'd version with "optimize:2" has NO doc, so __rootTopics is empty.

Any suggestion what I should use for testing instead of __doc__?

Werner

oliver

unread,
Nov 12, 2012, 9:25:35 AM11/12/12
to PyPubSub
Do you really need -OO? All it does is remove doc strings. See the following advice from Python manual: 

Passing two -O flags to the Python interpreter (-OO) will cause the bytecode compiler to perform optimizations that could in some rare cases result in malfunctioning programs. Currently only __doc__ strings are removed from the bytecode, resulting in more compact .pyo files. Since some programs may rely on having these available, you should only use this option if you know what you’re doing.

Sorry, I'm sure this is disappointing answer. 
Oliver




Werner

Werner

unread,
Nov 12, 2012, 9:49:32 AM11/12/12
to pypu...@googlegroups.com
On 12/11/2012 15:25, oliver wrote:
Do you really need -OO? All it does is remove doc strings. See the following advice from Python manual:�

Passing two -O flags to the Python interpreter (-OO) will cause the bytecode compiler to perform optimizations that could in some rare cases result in malfunctioning programs. Currently only __doc__ strings are removed from the bytecode, resulting in more compact .pyo files. Since some programs may rely on having these available, you should only use this option if you know what you�re doing.

Sorry, I'm sure this is disappointing answer.
An o.k. work around and the 1.5MB more space is not really an issue.

FYI, I now use "optimize": 1 instead of "optimize": 2 in the setup.py py2exe options.

I see that __doc__ is used as a check in a few places.� What is the reason to check for the __doc__?� Would you consider something else, e.g. len(dir(pyClassObj)) > 2 in addDefnFromClassObj and something similar in the other cases?� In other words would you accept a patch along those lines?

Have a nice day
Werner

oliver

unread,
Nov 12, 2012, 1:03:03 PM11/12/12
to PyPubSub
The topic tree definition module looks for __doc__ to decide if a topic should be considered "usable"; if no __doc__, it will not generate the topic object so an error would occur in some circumstances (like sendMessage on a topic that hasn't been used yet). From the POV of release, no one is actually going to look at those docs so it should be ok for the __doc__ to be absent. Perhaps instead it could check if the listener method exists, rather than __doc__ exists. Can you generate a patch for that? 
Oliver


On Mon, Nov 12, 2012 at 9:49 AM, Werner <werner...@sfr.fr> wrote:
On 12/11/2012 15:25, oliver wrote:
Do you really need -OO? All it does is remove doc strings. See the following advice from Python manual: 

Passing two -O flags to the Python interpreter (-OO) will cause the bytecode compiler to perform optimizations that could in some rare cases result in malfunctioning programs. Currently only __doc__ strings are removed from the bytecode, resulting in more compact .pyo files. Since some programs may rely on having these available, you should only use this option if you know what you’re doing.

Sorry, I'm sure this is disappointing answer.
An o.k. work around and the 1.5MB more space is not really an issue.

FYI, I now use "optimize": 1 instead of "optimize": 2 in the setup.py py2exe options.

I see that __doc__ is used as a check in a few places.  What is the reason to check for the __doc__?  Would you consider something else, e.g. len(dir(pyClassObj)) > 2 in addDefnFromClassObj and something similar in the other cases?  In other words would you accept a patch along those lines?


Have a nice day
Werner

--
You received this message because you are subscribed to the Google Groups "pypubsub" group.
To post to this group, send email to pypu...@googlegroups.com.
To unsubscribe from this group, send email to pypubsub+u...@googlegroups.com.

Werner

unread,
Nov 13, 2012, 9:35:21 AM11/13/12
to pypu...@googlegroups.com
On 12/11/2012 19:03, oliver wrote:
> The topic tree definition module looks for __doc__ to decide if a
> topic should be considered "usable"; if no __doc__, it will not
> generate the topic object so an error would occur in some
> circumstances (like sendMessage on a topic that hasn't been used yet).
> From the POV of release, no one is actually going to look at those
> docs so it should be ok for the __doc__ to be absent. Perhaps instead
> it could check if the listener method exists, rather than __doc__
> exists. Can you generate a patch for that?
I will give it a try, probably not before next week.

Werner

oliver

unread,
Nov 13, 2012, 11:59:20 AM11/13/12
to PyPubSub
No rush from this end ;) Let me know if you hit any roadblocks. 




Werner

--
You received this message because you are subscribed to the Google Groups "pypubsub" group.
To post to this group, send email to pypu...@googlegroups.com.
To unsubscribe from this group, send email to pypubsub+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages