[Zope-CVS] CVS: Packages/ZConfig - Interpolation.py:1.3
Fred L. Drake, Jr.
fdrake@acm.org
Wed, 9 Oct 2002 12:42:03 -0400
Update of /cvs-repository/Packages/ZConfig
In directory cvs.zope.org:/tmp/cvs-serv6660
Modified Files:
Interpolation.py
Log Message:
Refactor the exception constructors.
=== Packages/ZConfig/Interpolation.py 1.2 => 1.3 ===
--- Packages/ZConfig/Interpolation.py:1.2 Wed Oct 9 12:30:31 2002
+++ Packages/ZConfig/Interpolation.py Wed Oct 9 12:42:02 2002
@@ -6,26 +6,26 @@
class InterpolationError(Exception):
"""Base exception for string interpolation errors."""
+ def __init__(self, msg, context):
+ self.message = msg
+ self.context = context
+
class InterpolationSyntaxError(InterpolationError):
"""Raised when interpolation source text contains syntactical errors."""
def __init__(self, msg, context):
- self.message = msg
- if context is None:
- self.context = context
- else:
- self.context = context[:]
- InterpolationError.__init__(self, msg, self.context)
+ if context is not None:
+ context = context[:]
+ InterpolationError.__init__(self, msg, context)
class InterpolationRecursionError(InterpolationError):
"""Raised when a nested interpolation is recursive."""
def __init__(self, name, context):
self.name = name
- self.context = context[:]
- self.message = ("recursion on %s; current context:\n%s"
- % (repr(name), ", ".join(context)))
- InterpolationError.__init__(self, name, self.context)
+ msg = ("recursion on %s; current context:\n%s"
+ % (repr(name), ", ".join(context)))
+ InterpolationError.__init__(self, msg, context[:])
def get(section, name, default=None):