Opened 18 years ago
Closed 17 years ago
#5339 closed defect (fixed)
GeneratorExit thrown in trac/wiki/macros.py
Reported by: | Owned by: | Tim Hatch | |
---|---|---|---|
Priority: | normal | Milestone: | 0.10.5 |
Component: | wiki system | Version: | 0.10.4 |
Severity: | normal | Keywords: | python25 |
Cc: | dluke@… | Branch: | |
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description (last modified by )
Class UserMacroProvider throws an annoying error in method get_macros (with python 2.5). Simple (2 line) fix, where the GeneratorExit exception is ignored.
snippet from trac/wiki/macros.py
def get_macros(self): found = [] for path in (self.env_macros, self.site_macros): if not os.path.exists(path): continue for filename in [filename for filename in os.listdir(path) if filename.lower().endswith('.py') and not filename.startswith('__')]: try: module = self._load_macro(filename[:-3]) name = module.__name__ if name in found: continue found.append(name) yield name except GeneratorExit: pass except Exception, e: self.log.error('Failed to load wiki macro %s (%s)', filename, e, exc_info=True)
Attachments (0)
Change History (9)
comment:1 by , 17 years ago
follow-up: 3 comment:2 by , 17 years ago
Description: | modified (diff) |
---|---|
Keywords: | python25 verify added; generator GeneratorExit yield exception removed |
Milestone: | → 0.10.5 |
Summary: | trac/wiki/macros.py and python 2.5 → GeneratorExit thrown in trac/wiki/macros.py |
Sorry, this report went unnoticed.
comment:3 by , 17 years ago
Replying to cboos:
Sorry, this report went unnoticed.
May have been my fault… my first (official) bug report ever! I'm glad it turns out not to have been a waste of time/effort.
I still use trac, though I haven't given it much scrutiny now that it/s up and running stably on my server. I'll be pleased to participate in the trac community, though.
comment:4 by , 17 years ago
My reading suggests this is likely caused by Python 2.5's close function for generators. If Trac isn't calling this itself then I guess it must be the garbage collector. The correct behaviour seems to be to not catch the exception:
--- trac/wiki/macros.py 2007-04-20 14:41:49.000000000 +0100 +++ trac/wiki/macros.py 2007-10-03 17:24:41.347073000 +0100 @@ -446,6 +446,9 @@ continue found.append(name) yield name + except GeneratorExit: + # never catch GeneratorExit + raise except Exception, e: self.log.error('Failed to load wiki macro %s (%s)', filename, e, exc_info=True)
From a google search of the docs:
close()
Raises a GeneratorExit at the point where the generator function was paused. If the generator function then raises StopIteration (by exiting normally, or due to already being closed) or GeneratorExit (by not catching the exception), close returns to its caller. If the generator yields a value, a RuntimeError is raised. If the generator raises any other exception, it is propagated to the caller. close does nothing if the generator has already exited due to an exception or normal exit.
I hope that helps.
comment:6 by , 17 years ago
Milestone: | 0.10.5 → 0.11.1 |
---|---|
Priority: | low → normal |
comment:7 by , 17 years ago
Cc: | added |
---|
comment:8 by , 17 years ago
Keywords: | verify removed |
---|---|
Milestone: | 0.11.1 → 0.10.5 |
Owner: | changed from | to
Severity: | minor → normal |
Status: | new → assigned |
Version: | 0.10-stable → 0.10.4 |
This error kept phaidros
on IRC from being able to view any of the TracGuide pages. This seems to happen mainly to Ubuntu Gutsy users. I'm not able to reproduce this issue (though I can reproduce #4026) on my 64-bit machine, and the patch silences those as well.
phaidros
confirms that the patch above makes the TracGuide pages viewable once again. Here is the error, for posterity:
2008-04-03 23:49:18,919 Trac[macros] ERROR: Failed to load wiki macro TracGuideToc.py () Traceback (most recent call last): File "/var/lib/python-support/python2.5/trac/wiki/macros.py", line 448, in get_macros yield name GeneratorExit 2008-04-03 23:49:18,920 Trac[formatter] DEBUG: Executing Wiki macro TracGuideToc by provider <trac.wiki.macros.UserMacroProvider object at 0x85a858c>
This bug is filed downstream as https://bugs.launchpad.net/ubuntu/+source/trac/+bug/199306
I can confirm this on 0.10.4. This ticket has been fallow for 4 months - is it likely to be fixed?