Update: this can now be handled automatically (and more selectively) via an option. See http://wiki.cython.org/DifferencesFromPyrex
Imagine this simple file:
The generated code is slow though, because range() is slow. I can either manually change all ranges to the "from 1 <= i <= dim -1" idiom, but that's annoying. I prefer Cython to do it automatically (for example by providing a switch "--convertrange" or something, it doesn't have to be default).
Here is a simple script which does that:
--> -->
ImportError
cannot import name wiki
If you want to report a bug, please save this page and attach it to your bug report.
Traceback
A problem occurred in a Python script. Here is the sequence of function calls leading up to the error, in the order they occurred.
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/request/__init__.py in run (self=<MoinMoin.request.request_twisted.Request object at 0x44b7250>)
- 1305 self.page.send_page()
- 1306 else:
- 1307 handler(self.page.page_name, self)
- 1308
- 1309 # every action that didn't use to raise MoinMoinFinish must call this now:
- handler = <function do_show at 0x256b320>
- self = <MoinMoin.request.request_twisted.Request object at 0x44b7250>
- self.page = <MoinMoin.Page.Page object at 0x3d07d10>
- self.page.page_name = u'RangeFromConverting'
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/action/__init__.py in do_show (pagename=u'RangeFromConverting', request=<MoinMoin.request.request_twisted.Request object at 0x44b7250>, content_only=0, count_hit=1, cacheable=1, print_mode=0)
- 251 count_hit=count_hit,
- 252 print_mode=print_mode,
- 253 content_only=content_only,
- 254 )
- 255
- content_only = 0
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/Page.py in send_page (self=<MoinMoin.Page.Page object at 0x3d07b50>, **keywords={'content_only': 0, 'count_hit': 1, 'print_mode': 0})
- 1195 format_args=pi['formatargs'],
- 1196 do_cache=do_cache,
- 1197 start_line=pi['lines'])
- 1198
- 1199 # check for pending footnotes
- start_line undefined
- pi = {'acl': <MoinMoin.security.AccessControlList instance at 0x3a9d368>, 'format': 'jsmath', 'formatargs': '', 'language': 'en', 'lines': 0}
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/Page.py in send_page_content (self=<MoinMoin.Page.Page object at 0x3d07b50>, request=<MoinMoin.request.request_twisted.Request object at 0x44b7250>, body=u'Update: this can now be handled automatically (a...yx\n}}}\n\nproduces:\n\n{{attachment:exampleOut.pyx}}\n', format='jsmath', format_args='', do_cache=1, **kw={'start_line': 0})
- 1283 try:
- 1284 code = self.loadCache(request)
- 1285 self.execute(request, parser, code)
- 1286 except Exception, e:
- 1287 if not is_cache_exception(e):
- self = <MoinMoin.Page.Page object at 0x3d07b50>
- self.execute = <bound method Page.execute of <MoinMoin.Page.Page object at 0x3d07b50>>
- request = <MoinMoin.request.request_twisted.Request object at 0x44b7250>
- parser = <wikiconfig.plugin.parser.jsmath.Parser instance at 0x41ad248>
- code = <code object <module> at 0x4af17b0, file "RangeFromConverting", line 2>
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/Page.py in execute (self=<MoinMoin.Page.Page object at 0x3d07b50>, request=<MoinMoin.request.request_twisted.Request object at 0x44b7250>, parser=<wikiconfig.plugin.parser.jsmath.Parser instance at 0x41ad248>, code=<code object <module> at 0x4af17b0, file "RangeFromConverting", line 2>)
- 1314 __file__ = os.path.join(MoinMoin.__loader__.archive, 'dummy')
- 1315 try:
- 1316 exec code
- 1317 except "CacheNeedsUpdate": # convert the exception
- 1318 raise Exception("CacheNeedsUpdate")
- code = <code object <module> at 0x4af17b0, file "RangeFromConverting", line 2>
/home/sage/wiki/cython/sage_wiki/RangeFromConverting in
() /home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/formatter/__init__.py in attachment_inlined (self=<MoinMoin.formatter.text_html.Formatter instance at 0x3a9d248>, url=u'convertRange.py', text=u'convertRange.py', **kw={})
- 133 fpath = AttachFile.getFilename(self.request, pagename, fname)
- 134 ext = os.path.splitext(filename)[1]
- 135 Parser = wikiutil.getParserForExtension(self.request.cfg, ext)
- 136 if Parser is not None:
- 137 try:
- Parser undefined
- global wikiutil = <module 'MoinMoin.wikiutil' from '/home/sage/sag...b/python2.5/site-packages/MoinMoin/wikiutil.pyc'>
- wikiutil.getParserForExtension = <function getParserForExtension at 0x23ab938>
- self = <MoinMoin.formatter.text_html.Formatter instance at 0x3a9d248>
- self.request = <MoinMoin.request.request_twisted.Request object at 0x44b7250>
- self.request.cfg = <wikiconfig.Config object at 0x24b9c10>
- ext = u'.py'
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/wikiutil.py in getParserForExtension (cfg=<wikiconfig.Config object at 0x24b9c10>, extension=u'.py')
- 1250 for pname in getPlugins('parser', cfg):
- 1251 try:
- 1252 Parser = importPlugin(cfg, 'parser', pname, 'Parser')
- 1253 except PluginMissingError:
- 1254 continue
- Parser = <class MoinMoin.parser.text_xslt.Parser at 0x3182dd0>
- global importPlugin = <function importPlugin at 0x23ab140>
- cfg = <wikiconfig.Config object at 0x24b9c10>
- pname = 'inline_latex'
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/wikiutil.py in importPlugin (cfg=<wikiconfig.Config object at 0x24b9c10>, kind='parser', name='inline_latex', function='Parser')
- 1105 """
- 1106 try:
- 1107 return importWikiPlugin(cfg, kind, name, function)
- 1108 except PluginMissingError:
- 1109 return importBuiltinPlugin(kind, name, function)
- global importWikiPlugin = <function importWikiPlugin at 0x23ab5f0>
- cfg = <wikiconfig.Config object at 0x24b9c10>
- kind = 'parser'
- name = 'inline_latex'
- function = 'Parser'
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/wikiutil.py in importWikiPlugin (cfg=<wikiconfig.Config object at 0x24b9c10>, kind='parser', name='inline_latex', function='Parser')
- 1118 raise PluginMissingError
- 1119 moduleName = '%s.plugin.%s.%s' % (cfg.siteid, kind, name)
- 1120 return importNameFromPlugin(moduleName, function)
- 1121
- 1122
- global importNameFromPlugin = <function importNameFromPlugin at 0x23ab6e0>
- moduleName = 'wikiconfig.plugin.parser.inline_latex'
- function = 'Parser'
/home/sage/sage_install/new/local/lib/python2.5/site-packages/MoinMoin/wikiutil.py in importNameFromPlugin (moduleName='wikiconfig.plugin.parser.inline_latex', name='Parser')
- 1142 else:
- 1143 fromlist = [name]
- 1144 module = __import__(moduleName, globals(), {}, fromlist)
- 1145 if fromlist:
- 1146 # module has the obj for module <moduleName>
- module undefined
- builtin __import__ = <built-in function __import__>
- moduleName = 'wikiconfig.plugin.parser.inline_latex'
- builtin globals = <built-in function globals>
- fromlist = ['Parser']
/home/sage/wiki/cython/sage_wiki/data/plugin/parser/inline_latex.py in
() - 13 """
- 14
- 15 from MoinMoin.parser import wiki
- 16 from MoinMoin import wikiutil
- 17
- MoinMoin undefined
- wiki undefined
ImportError
cannot import name wiki
- args = ('cannot import name wiki',)
- message = 'cannot import name wiki'
System Details
- Date: Mon, 22 Mar 2010 02:48:30 +0000
- Platform: Linux sagemath 2.6.28-18-server #59-Ubuntu SMP Thu Jan 28 02:25:03 UTC 2010 x86_64
- Python: Python 2.5.2 (/home/sage/sage_install/new/local/bin/python)
- MoinMoin: Release 1.7.2 (release)
