Mercurial > hg
view mercurial/templates/gitweb/notfound.tmpl @ 25561:50a6c3c55db1 stable
parsers: do not cache RevlogError type (issue4451)
Index lookups raise RevlogError when the lookup fails. The previous
implementation was caching a reference to the RevlogError type in a
static variable. This assumed that the "mercurial.error" module was
only loaded once and there was only a single copy of it floating
around in memory. Unfortunately, in some situations - including
certain mod_wsgi configurations - this was not the case: the
"mercurial.error" module could be reloaded. It was possible for a
"RevlogError" reference from the first interpreter to be used by
a second interpreter. While the underlying thing was a
"mercurial.error.RevlogError," the object IDs were different, so
the Python code in revlog.py was failing to catch the exception! This
error has existed since the C index lookup code was implemented in
changeset e8d37b78acfb, which was first released in Mercurial 2.2 in
2012.
http://emptysqua.re/blog/python-c-extensions-and-mod-wsgi/#static-variables-are-shared
contains more details.
This patch removes the caching of the RevlogError type from the
function.
Since pretty much the entire function was refactored and the return
value of the function wasn't used, I changed the function signature
to not return anything.
For reasons unknown to me, we were calling PyErr_SetObject()
with the type of RevlogError and an instance of RevlogError. This
was equivalent to the Python code "raise RevlogError(RevlogError)".
This seemed wonky and completely unnecessary. The Python code only
cares about the type of the exception, not its contents. So I got
rid of this complexity.
This is my first Python C extension patch. Please give extra scrutiny
to it during review.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 12 Jun 2015 14:43:59 -0700 |
parents | 9409aeaafdc1 |
children |
line wrap: on
line source
{header} <title>Mercurial repository not found</title> </head> <body> <div class="page_header"> <a href="{logourl}" title="Mercurial" style="float: right;">Mercurial</a> Not found: {repo|escape} </div> <div class="page_body"> The specified repository "{repo|escape}" is unknown, sorry. <br/> <br/> Please go back to the <a href="{url|urlescape}">main repository list page</a>. </div> {footer}