Skip to content

Commit

Permalink
fix: Bottle.__setattr__ breaks data descriptors
Browse files Browse the repository at this point in the history
  • Loading branch information
defnull committed Sep 7, 2024
1 parent c925160 commit 7a53615
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
3 changes: 1 addition & 2 deletions bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -1122,8 +1122,7 @@ def __exit__(self, exc_type, exc_value, traceback):
def __setattr__(self, name, value):
if name in self.__dict__:
raise AttributeError("Attribute %s already defined. Plugin conflict?" % name)
self.__dict__[name] = value

object.__setattr__(self, name, value)

###############################################################################
# HTTP and WSGI Tools ##########################################################
Expand Down
2 changes: 1 addition & 1 deletion docs/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ Bottle catches all Exceptions raised in your app code to prevent your WSGI serve

import bottle
app = bottle.Bottle()
app.catchall = False #Now most exceptions are re-raised within bottle.
app.catchall = False # Now most exceptions are re-raised within bottle.
myapp = DebuggingMiddleware(app) #Replace this with a middleware of your choice (see below)
bottle.run(app=myapp)

Expand Down
5 changes: 4 additions & 1 deletion test/test_exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ def test_noncatched_error(self):
@bottle.route('/')
def test(): raise SomeError
bottle.request.environ['exc_info'] = None
bottle.catchall = False
self.app.catchall = False
with self.assertRaises(SomeError):
self.urlopen("/")
self.app.catchall = True
self.assertStatus(500, '/')
self.assertInBody('SomeError')

0 comments on commit 7a53615

Please sign in to comment.