Opened 15 years ago
Closed 15 years ago
#8730 closed defect (fixed)
r8496 Breaks "Environment needs to be upgraded" Message
Reported by: | John Hampton | Owned by: | John Hampton |
---|---|---|---|
Priority: | high | Milestone: | 0.12 |
Component: | general | Version: | devel |
Severity: | major | Keywords: | |
Cc: | Branch: | ||
Release Notes: | |||
API Changes: | |||
Internal Changes: |
Description
r8496 breaks Trac when accessing a site whose environment needs to be upgraded.
The problem is due to line 434 in source:trunk/trac/web/main.py.
If an environment needs an upgrade, then env
will be None
and thus the access to env.path
is invalid.
A simple solution would be:
-
trac/web/main.py
431 431 env_error = e 432 432 433 433 req = Request(environ, start_response) 434 translation.make_activable(lambda: req.locale, env .path)434 translation.make_activable(lambda: req.locale, env and env.path or None) 435 435 try: 436 436 return _dispatch_request(req, env, env_error) 437 437 finally: … … 489 489 message = e.detail 490 490 else: 491 491 message = to_unicode(e.detail) 492 data = {'title': title, 'type': 'TracError', 'message': message,492 data = {'title': title, 'type': 'TracError', 'message': str(message), 493 493 'frames': [], 'traceback': None} 494 494 if e.code == 403 and req.authname == 'anonymous': 495 495 # TRANSLATOR: ... not logged in, you may want to 'do so' now (link)
Note, the second line changed where wrapping the message
in sstr()
was done because otherwise the exception in Request.write() is triggered. I'm not sure that this is actually correct, but don't understand where better to put it.
Suggestions, anyone?
Attachments (0)
Change History (3)
comment:1 by , 15 years ago
follow-up: 3 comment:2 by , 15 years ago
Severity: | critical → major |
---|
Right, I already had the first chunk in a patch, but was unsure about the exact circumstance triggering the problem.
Instead of the second chunk in your patch, we should do what Remy proposed.
John, can you commit the two changes or should one of us take care of it?
(and the problem is not that critical ;-) )
comment:3 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Replying to cboos:
Instead of the second chunk in your patch, we should do what Remy proposed.
Yeah, I definitely like Remy's patch better. Mine was just a quick hack to prove the first line.
John, can you commit the two changes or should one of us take care of it?
Fixed in [8658]
(and the problem is not that critical ;-) )
Perhaps, though breaking every upgrade from 0.11 and any installation of any plugin that requires an env upgrade seems pretty critical to me ;)
For the second part of the patch, rather than converting to string at that location, we should fix
Request.send_error()
and ensuredata
is always a UTF-8 string before callingwrite()
. Something like (untested):trac/web/api.py