Skip to content

Commit

Permalink
Allow for non-string 'message' argument, as in a failed attempt to ac…
Browse files Browse the repository at this point in the history
…cess

an element of a sequence.
  • Loading branch information
Evan Simpson committed Nov 13, 2001
1 parent 5f5cfe4 commit 4351125
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions unauthorized.py
Expand Up @@ -83,9 +83,11 @@
#
##############################################################################
"""
$Id: unauthorized.py,v 1.2 2001/10/19 15:12:28 shane Exp $
$Id: unauthorized.py,v 1.3 2001/11/13 19:22:37 evan Exp $
"""

from types import StringType

class Unauthorized(Exception):
"""Some user wasn't allowed to access a resource"""

Expand All @@ -103,7 +105,8 @@ def __init__(self, message=None, value=None, needed=None, name=None, **kw):
(e.g. {'permission': 'add spam'}). Any extra keyword arguments
provides are added to needed.
"""
if name is None and message is not None and len(message.split()) <= 1:
if name is None and (
not isinstance(message, StringType) or len(message.split()) <= 1):
# First arg is a name, not a message
name=message
message=None
Expand Down

0 comments on commit 4351125

Please sign in to comment.