[Zope3-checkins] SVN: Zope3/trunk/src/zope/ Massive style cleanup:
Move to new raise exception style; for motivation, see:
Martijn Pieters
mj at zopatista.com
Tue Aug 30 17:50:20 EDT 2005
Log message for revision 38178:
Massive style cleanup: Move to new raise exception style; for motivation, see:
http://permalink.gmane.org/gmane.comp.web.zope.zope3/13884
Changed:
U Zope3/trunk/src/zope/app/annotation/attribute.py
U Zope3/trunk/src/zope/app/apidoc/utilities.py
U Zope3/trunk/src/zope/app/authentication/principalfolder.py
U Zope3/trunk/src/zope/app/basicskin/standardmacros.py
U Zope3/trunk/src/zope/app/broken/broken.py
U Zope3/trunk/src/zope/app/catalog/attribute.py
U Zope3/trunk/src/zope/app/component/__init__.py
U Zope3/trunk/src/zope/app/component/contentdirective.py
U Zope3/trunk/src/zope/app/component/fields.py
U Zope3/trunk/src/zope/app/component/registration.py
U Zope3/trunk/src/zope/app/component/site.py
U Zope3/trunk/src/zope/app/component/vocabulary.py
U Zope3/trunk/src/zope/app/container/tests/test_find.py
U Zope3/trunk/src/zope/app/container/traversal.py
U Zope3/trunk/src/zope/app/datetimeutils.py
U Zope3/trunk/src/zope/app/dav/widget.py
U Zope3/trunk/src/zope/app/demo/itemvocabulary/__init__.py
U Zope3/trunk/src/zope/app/demo/jobboard/job.py
U Zope3/trunk/src/zope/app/demo/passwdauth/__init__.py
U Zope3/trunk/src/zope/app/folder/filerepresentation.py
U Zope3/trunk/src/zope/app/form/browser/addwizard.py
U Zope3/trunk/src/zope/app/form/browser/editwizard.py
U Zope3/trunk/src/zope/app/form/browser/itemswidgets.py
U Zope3/trunk/src/zope/app/i18n/filters.py
U Zope3/trunk/src/zope/app/location/location.py
U Zope3/trunk/src/zope/app/locking/tests.py
U Zope3/trunk/src/zope/app/pagetemplate/engine.py
U Zope3/trunk/src/zope/app/pagetemplate/talesapi.py
U Zope3/trunk/src/zope/app/pluggableauth/__init__.py
U Zope3/trunk/src/zope/app/preference/default.py
U Zope3/trunk/src/zope/app/preference/preference.py
U Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py
U Zope3/trunk/src/zope/app/publication/traversers.py
U Zope3/trunk/src/zope/app/publication/zopepublication.py
U Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py
U Zope3/trunk/src/zope/app/publisher/browser/fields.py
U Zope3/trunk/src/zope/app/publisher/browser/i18nfileresource.py
U Zope3/trunk/src/zope/app/publisher/browser/tests/test_menudirectives.py
U Zope3/trunk/src/zope/app/rdb/__init__.py
U Zope3/trunk/src/zope/app/rdb/gadflyda.py
U Zope3/trunk/src/zope/app/schema/browser/traversal.py
U Zope3/trunk/src/zope/app/schema/schema.py
U Zope3/trunk/src/zope/app/schemacontent/browser/__init__.py
U Zope3/trunk/src/zope/app/schemacontent/content.py
U Zope3/trunk/src/zope/app/schemacontent/instance.py
U Zope3/trunk/src/zope/app/security/browser/principalterms.py
U Zope3/trunk/src/zope/app/sqlexpr/sqlexpr.py
U Zope3/trunk/src/zope/app/sqlscript/dtml.py
U Zope3/trunk/src/zope/app/sqlscript/sqlscript.py
U Zope3/trunk/src/zope/app/testing/setup.py
U Zope3/trunk/src/zope/app/traversing/api.py
U Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py
U Zope3/trunk/src/zope/app/undo/__init__.py
U Zope3/trunk/src/zope/app/workflow/stateful/definition.py
U Zope3/trunk/src/zope/app/workflow/stateful/instance.py
U Zope3/trunk/src/zope/app/workflow/stateful/xmlimportexport.py
U Zope3/trunk/src/zope/component/__init__.py
U Zope3/trunk/src/zope/component/bbb/adapter.py
U Zope3/trunk/src/zope/component/bbb/tests/test_api.py
U Zope3/trunk/src/zope/component/bbb/utility.py
U Zope3/trunk/src/zope/configuration/config.py
U Zope3/trunk/src/zope/configuration/xmlconfig.py
U Zope3/trunk/src/zope/dependencytool/finddeps.py
U Zope3/trunk/src/zope/documenttemplate/dt_html.py
U Zope3/trunk/src/zope/documenttemplate/dt_if.py
U Zope3/trunk/src/zope/documenttemplate/dt_in.py
U Zope3/trunk/src/zope/documenttemplate/dt_insv.py
U Zope3/trunk/src/zope/documenttemplate/dt_let.py
U Zope3/trunk/src/zope/documenttemplate/dt_raise.py
U Zope3/trunk/src/zope/documenttemplate/dt_string.py
U Zope3/trunk/src/zope/documenttemplate/dt_try.py
U Zope3/trunk/src/zope/documenttemplate/dt_util.py
U Zope3/trunk/src/zope/documenttemplate/dt_var.py
U Zope3/trunk/src/zope/documenttemplate/pdocumenttemplate.py
U Zope3/trunk/src/zope/exceptions/tests/test_exceptionformatter.py
U Zope3/trunk/src/zope/fssync/metadata.py
U Zope3/trunk/src/zope/fssync/server/entryadapter.py
U Zope3/trunk/src/zope/i18n/format.py
U Zope3/trunk/src/zope/i18n/gettextmessagecatalog.py
U Zope3/trunk/src/zope/i18n/locales/__init__.py
U Zope3/trunk/src/zope/i18n/locales/inheritance.py
U Zope3/trunk/src/zope/i18n/locales/provider.py
U Zope3/trunk/src/zope/i18n/locales/tests/test_docstrings.py
U Zope3/trunk/src/zope/i18nmessageid/message.py
U Zope3/trunk/src/zope/index/keyword/index.py
U Zope3/trunk/src/zope/index/text/parsetree.py
U Zope3/trunk/src/zope/index/text/queryparser.py
U Zope3/trunk/src/zope/index/text/ricecode.py
U Zope3/trunk/src/zope/index/topic/index.py
U Zope3/trunk/src/zope/interface/adapter.py
U Zope3/trunk/src/zope/interface/declarations.py
U Zope3/trunk/src/zope/interface/interface.py
U Zope3/trunk/src/zope/interface/tests/odd.py
U Zope3/trunk/src/zope/pagetemplate/tests/batch.py
U Zope3/trunk/src/zope/pagetemplate/tests/util.py
U Zope3/trunk/src/zope/publisher/base.py
U Zope3/trunk/src/zope/publisher/browser.py
U Zope3/trunk/src/zope/publisher/http.py
U Zope3/trunk/src/zope/publisher/publish.py
U Zope3/trunk/src/zope/publisher/tests/test_ipublication.py
U Zope3/trunk/src/zope/publisher/tests/test_requestdataproperty.py
U Zope3/trunk/src/zope/schema/_field.py
U Zope3/trunk/src/zope/schema/fieldproperty.py
U Zope3/trunk/src/zope/security/checker.py
U Zope3/trunk/src/zope/security/untrustedpython/builtins.py
U Zope3/trunk/src/zope/server/buffers.py
U Zope3/trunk/src/zope/server/ftp/publisher.py
U Zope3/trunk/src/zope/server/ftp/server.py
U Zope3/trunk/src/zope/server/http/httprequestparser.py
U Zope3/trunk/src/zope/server/http/tests/test_httprequestparser.py
U Zope3/trunk/src/zope/server/serverchannelbase.py
U Zope3/trunk/src/zope/server/taskthreads.py
U Zope3/trunk/src/zope/server/trigger.py
U Zope3/trunk/src/zope/tal/ndiff.py
U Zope3/trunk/src/zope/tal/talinterpreter.py
U Zope3/trunk/src/zope/tales/expressions.py
U Zope3/trunk/src/zope/tales/tales.py
U Zope3/trunk/src/zope/wfmc/xpdl.py
U Zope3/trunk/src/zope/xmlpickle/ppml.py
-=-
Modified: Zope3/trunk/src/zope/app/annotation/attribute.py
===================================================================
--- Zope3/trunk/src/zope/app/annotation/attribute.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/annotation/attribute.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -50,7 +50,7 @@
def __getitem__(self, key):
annotations = getattr(self.obj, '__annotations__', None)
if annotations is None:
- raise KeyError, key
+ raise KeyError(key)
return annotations[key]
@@ -75,6 +75,6 @@
try:
annotation = self.obj.__annotations__
except AttributeError:
- raise KeyError, key
+ raise KeyError(key)
del annotation[key]
Modified: Zope3/trunk/src/zope/app/apidoc/utilities.py
===================================================================
--- Zope3/trunk/src/zope/app/apidoc/utilities.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/apidoc/utilities.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -67,7 +67,7 @@
default = object()
obj = self.get(key, default)
if obj is default:
- raise KeyError, key
+ raise KeyError(key)
return obj
def __contains__(self, key):
Modified: Zope3/trunk/src/zope/app/authentication/principalfolder.py
===================================================================
--- Zope3/trunk/src/zope/app/authentication/principalfolder.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/authentication/principalfolder.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -171,7 +171,7 @@
"""
# A user with the new login already exists
if principal.login in self.__id_by_login:
- raise ValueError, 'Principal Login already taken!'
+ raise ValueError('Principal Login already taken!')
del self.__id_by_login[oldLogin]
self.__id_by_login[principal.login] = principal.__name__
@@ -204,7 +204,7 @@
"""
# A user with the new login already exists
if principal.login in self.__id_by_login:
- raise DuplicateIDError, 'Principal Login already taken!'
+ raise DuplicateIDError('Principal Login already taken!')
super(PrincipalFolder, self).__setitem__(id, principal)
self.__id_by_login[principal.login] = id
Modified: Zope3/trunk/src/zope/app/basicskin/standardmacros.py
===================================================================
--- Zope3/trunk/src/zope/app/basicskin/standardmacros.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/basicskin/standardmacros.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -45,7 +45,7 @@
pass
else:
return v
- raise KeyError, key
+ raise KeyError(key)
class StandardMacros(BrowserView, Macros):
macro_pages = ('view_macros', 'dialog_macros')
Modified: Zope3/trunk/src/zope/app/broken/broken.py
===================================================================
--- Zope3/trunk/src/zope/app/broken/broken.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/broken/broken.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -55,7 +55,7 @@
annotations = self.__getAnnotations()
if annotations:
return annotations[key]
- raise KeyError, key
+ raise KeyError(key)
def __setitem__(self, key, value):
raise ZODB.broken.BrokenModified("Can't modify broken objects")
Modified: Zope3/trunk/src/zope/app/catalog/attribute.py
===================================================================
--- Zope3/trunk/src/zope/app/catalog/attribute.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/catalog/attribute.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -112,7 +112,7 @@
*args, **kwargs):
super(AttributeIndex, self).__init__(*args, **kwargs)
if field_name is None and self.default_field_name is None:
- raise ValueError, "Must pass a field_name"
+ raise ValueError("Must pass a field_name")
if field_name is None:
self.field_name = self.default_field_name
else:
Modified: Zope3/trunk/src/zope/app/component/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/component/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/component/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -30,8 +30,8 @@
"""Get the next site manager."""
sm = queryNextSiteManager(context, _marker)
if sm is _marker:
- raise zope.component.interfaces.ComponentLookupError, \
- "No more site managers have been found."
+ raise zope.component.interfaces.ComponentLookupError(
+ "No more site managers have been found.")
return sm
@@ -56,9 +56,9 @@
"""
util = queryNextUtility(context, interface, name, _marker)
if util is _marker:
- raise zope.component.interfaces.ComponentLookupError, \
- "No more utilities for %s, '%s' have been found." %(interface,
- name)
+ raise zope.component.interfaces.ComponentLookupError(
+ "No more utilities for %s, '%s' have been found." % (
+ interface, name))
return util
Modified: Zope3/trunk/src/zope/app/component/contentdirective.py
===================================================================
--- Zope3/trunk/src/zope/app/component/contentdirective.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/component/contentdirective.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -217,12 +217,12 @@
def __init__(self, _context, class_):
if not ILocation.implementedBy(class_) and \
not hasattr(class_, '__parent__'):
- raise ConfigurationError, \
- 'Class `%s` does not implement `ILocation`.' %class_.__name__
+ raise ConfigurationError('Class `%s` does not implement '
+ '`ILocation`.' % class_.__name__)
if not IPersistent.implementedBy(class_):
- raise ConfigurationError, \
- 'Class `%s` does not implement `IPersistent`.' %class_.__name__
+ raise ConfigurationError('Class `%s` does not implement '
+ '`IPersistent`.' % class_.__name__)
classImplements(class_, IAttributeAnnotatable)
classImplements(class_, ILocalUtility)
Modified: Zope3/trunk/src/zope/app/component/fields.py
===================================================================
--- Zope3/trunk/src/zope/app/component/fields.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/component/fields.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -50,7 +50,7 @@
... path == 'zope.app.component.fields.layer1' or
... path == '.fields.layer1'):
... return layer1
- ... raise ConfigurationError, 'layer1'
+ ... raise ConfigurationError('layer1')
>>> field = LayerField()
>>> field = field.bind(Resolver())
Modified: Zope3/trunk/src/zope/app/component/registration.py
===================================================================
--- Zope3/trunk/src/zope/app/component/registration.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/component/registration.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -67,7 +67,7 @@
registration = inst
registry = registration.getRegistry()
if registry is None:
- raise ValueError, 'No registry found.'
+ raise ValueError('No registry found.')
if value == interfaces.ActiveStatus:
if not registry.registered(registration):
@@ -79,7 +79,7 @@
registry.unregister(registration)
zope.event.notify(RegistrationDeactivatedEvent(registration))
else:
- raise ValueError, value
+ raise ValueError(value)
class SimpleRegistration(Persistent, Contained):
Modified: Zope3/trunk/src/zope/app/component/site.py
===================================================================
--- Zope3/trunk/src/zope/app/component/site.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/component/site.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -213,10 +213,10 @@
return self.utilities
elif interfaces.IAdapterRegistration.providedBy(registration):
return self.adapters
- raise ValueError, \
- ("Unable to detect registration type or registration "
- "type is not supported. The registration object must provide "
- "`IAdapterRegistration` or `IUtilityRegistration`.")
+ raise ValueError("Unable to detect registration type or registration "
+ "type is not supported. The registration object must "
+ "provide `IAdapterRegistration` or "
+ "`IUtilityRegistration`.")
def register(self, registration):
"""See zope.app.component.interfaces.registration.IRegistry"""
Modified: Zope3/trunk/src/zope/app/component/vocabulary.py
===================================================================
--- Zope3/trunk/src/zope/app/component/vocabulary.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/component/vocabulary.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -195,14 +195,14 @@
return [term for name, term in self._terms.items()
if term.value == value][0]
except IndexError:
- raise LookupError, value
+ raise LookupError(value)
def getTermByToken(self, token):
"""See zope.schema.interfaces.IVocabularyTokenized"""
try:
return self._terms[token]
except KeyError:
- raise LookupError, token
+ raise LookupError(token)
def __iter__(self):
"""See zope.schema.interfaces.IIterableVocabulary"""
Modified: Zope3/trunk/src/zope/app/container/tests/test_find.py
===================================================================
--- Zope3/trunk/src/zope/app/container/tests/test_find.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/container/tests/test_find.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -41,7 +41,7 @@
for object in self._objects:
if object._id == id:
return object
- raise KeyError, "Could not find %s" % id
+ raise KeyError("Could not find %s" % id)
def get(self, id, default=None):
for object in self._objects:
Modified: Zope3/trunk/src/zope/app/container/traversal.py
===================================================================
--- Zope3/trunk/src/zope/app/container/traversal.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/container/traversal.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -97,6 +97,6 @@
if v is _marker:
v = getattr(container, name, _marker)
if v is _marker:
- raise TraversalError, name
+ raise TraversalError(name)
return v
Modified: Zope3/trunk/src/zope/app/datetimeutils.py
===================================================================
--- Zope3/trunk/src/zope/app/datetimeutils.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/datetimeutils.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -521,7 +521,7 @@
will raise a DateTimeError.
"""
if not isinstance(arg, StringTypes):
- raise TypeError, 'Expected a string argument'
+ raise TypeError('Expected a string argument')
if not arg:
raise SyntaxError(arg)
Modified: Zope3/trunk/src/zope/app/dav/widget.py
===================================================================
--- Zope3/trunk/src/zope/app/dav/widget.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/dav/widget.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -76,7 +76,7 @@
return self._data
def __str__(self):
- raise ValueError, "xmldavwidget is not a string."
+ raise ValueError("xmldavwidget is not a string.")
def __call__(self):
return self._data
Modified: Zope3/trunk/src/zope/app/demo/itemvocabulary/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/itemvocabulary/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/demo/itemvocabulary/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -82,7 +82,7 @@
def getTerm(self, value):
"""See zope.schema.interfaces.IBaseVocabulary"""
if value not in self.context.keys():
- raise LookupError, value
+ raise LookupError(value)
return ItemTerm(value)
def getTermByToken(self, token):
Modified: Zope3/trunk/src/zope/app/demo/jobboard/job.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/jobboard/job.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/demo/jobboard/job.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -109,7 +109,7 @@
try:
jobid = int(jobid)
except ValueError:
- raise KeyError, jobid
+ raise KeyError(jobid)
del self._jobs[jobid]
def query(self, state):
@@ -126,7 +126,7 @@
try:
jobid = int(jobid)
except ValueError:
- raise KeyError, jobid
+ raise KeyError(jobid)
return self._jobs[jobid]
def getPendingIds(self):
Modified: Zope3/trunk/src/zope/app/demo/passwdauth/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/demo/passwdauth/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/demo/passwdauth/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -58,7 +58,7 @@
for p in self.readPrincipals():
if p._id == id:
return p
- raise PrincipalLookupError, id
+ raise PrincipalLookupError(id)
def getPrincipals(self, name):
"""See `IPrincipalSource`."""
Modified: Zope3/trunk/src/zope/app/folder/filerepresentation.py
===================================================================
--- Zope3/trunk/src/zope/app/folder/filerepresentation.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/folder/filerepresentation.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -54,7 +54,7 @@
def __getitem__(self, key):
v = self.get(key, self)
if v is self:
- raise KeyError, key
+ raise KeyError(key)
return v
def values(self):
Modified: Zope3/trunk/src/zope/app/form/browser/addwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/addwizard.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/form/browser/addwizard.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -44,7 +44,7 @@
def _setUpWidgets(self):
if self.use_session:
# Need session for File upload fields
- raise NotImplementedError, 'Need a working ISessionDataManager'
+ raise NotImplementedError('Need a working ISessionDataManager')
else:
self.storage = WizardStorage(self.fieldNames, None)
Modified: Zope3/trunk/src/zope/app/form/browser/editwizard.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/editwizard.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/form/browser/editwizard.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -50,7 +50,7 @@
try:
return self[key]
except KeyError:
- raise AttributeError, key
+ raise AttributeError(key)
def __setattr__(self, key, value):
self[key] = value
@@ -63,8 +63,8 @@
if self.use_session:
# Need session for File upload fields
- raise NotImplementedError, \
- 'Cannot be implemented until we have an ISessionDataManager'
+ raise NotImplementedError('Cannot be implemented until we have an '
+ 'ISessionDataManager')
else:
self.storage = WizardStorage(self.fieldNames, self.adapted)
@@ -196,7 +196,7 @@
# doesn't conflict with other wizards in progress in other
# browser windows.
# Otherwise, no more state to propagate
- raise NotImplementedError, 'use_session'
+ raise NotImplementedError('use_session')
else:
current_fields = self.currentPane().names
Modified: Zope3/trunk/src/zope/app/form/browser/itemswidgets.py
===================================================================
--- Zope3/trunk/src/zope/app/form/browser/itemswidgets.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/form/browser/itemswidgets.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -128,8 +128,7 @@
try:
term = self.vocabulary.getTermByToken(token)
except LookupError, error:
- raise InvalidValue, \
- "token %r not found in vocabulary" %token
+ raise InvalidValue("token %r not found in vocabulary" % token)
else:
values.append(term.value)
return values
Modified: Zope3/trunk/src/zope/app/i18n/filters.py
===================================================================
--- Zope3/trunk/src/zope/app/i18n/filters.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/i18n/filters.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -53,8 +53,8 @@
elif len(languages) == 1:
language = languages[0]
else:
- raise TypeError, \
- 'Only one language at a time is supported for gettext export.'
+ raise TypeError(
+ 'Only one language at a time is supported for gettext export.')
dt = time.time()
dt = time.localtime(dt)
@@ -89,8 +89,8 @@
elif len(languages) == 1:
language = languages[0]
else:
- raise TypeError, \
- 'Only one language at a time is supported for gettext export.'
+ raise TypeError(
+ 'Only one language at a time is supported for gettext export.')
result = parseGetText(file.readlines())[3]
headers = parserHeaders(''.join(result[('',)][1]))
Modified: Zope3/trunk/src/zope/app/location/location.py
===================================================================
--- Zope3/trunk/src/zope/app/location/location.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/location/location.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -162,7 +162,7 @@
self.__name__ = name
def __reduce__(self, proto=None):
- raise TypeError, "Not picklable"
+ raise TypeError("Not picklable")
__doc__ = ClassAndInstanceDescr(
Modified: Zope3/trunk/src/zope/app/locking/tests.py
===================================================================
--- Zope3/trunk/src/zope/app/locking/tests.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/locking/tests.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -31,7 +31,7 @@
try:
return self.__dict[name]
except KeyError:
- raise AttributeError, name
+ raise AttributeError(name)
name = 'zope.app.locking.README'
Modified: Zope3/trunk/src/zope/app/pagetemplate/engine.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/engine.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/pagetemplate/engine.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -118,10 +118,10 @@
def evaluateCode(self, lang, code):
if not self.evaluateInlineCode:
- raise InlineCodeError, \
+ raise InlineCodeError(
_('Inline Code Evaluation is deactivated, which means that '
'you cannot have inline code snippets in your Page '
- 'Template. Activate Inline Code Evaluation and try again.')
+ 'Template. Activate Inline Code Evaluation and try again.'))
# TODO This is only needed when self.evaluateInlineCode is true,
# so should only be needed for zope.app.pythonpage.
@@ -130,7 +130,7 @@
if interpreter is None:
error = _('No interpreter named "${lang_name}" was found.')
error.mapping = {'lang_name': lang}
- raise InlineCodeError, error
+ raise InlineCodeError(error)
globals = self.vars.copy()
result = interpreter.evaluateRawCode(code, globals)
@@ -198,7 +198,7 @@
try:
return zapi.getAdapter(object, IPathAdapter, name)
except ComponentLookupError:
- raise KeyError, name
+ raise KeyError(name)
self.namespaces[name] = namespace
return namespace
Modified: Zope3/trunk/src/zope/app/pagetemplate/talesapi.py
===================================================================
--- Zope3/trunk/src/zope/app/pagetemplate/talesapi.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/pagetemplate/talesapi.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -40,28 +40,28 @@
def title(self):
a = IZopeDublinCore(self.context, None)
if a is None:
- raise AttributeError, 'title'
+ raise AttributeError('title')
return a.title
title = property(title)
def description(self):
a = IZopeDublinCore(self.context, None)
if a is None:
- raise AttributeError, 'description'
+ raise AttributeError('description')
return a.description
description = property(description)
def created(self):
a = IZopeDublinCore(self.context, None)
if a is None:
- raise AttributeError, 'created'
+ raise AttributeError('created')
return a.created
created = property(created)
def modified(self):
a = IZopeDublinCore(self.context, None)
if a is None:
- raise AttributeError, 'modified'
+ raise AttributeError('modified')
return a.modified
modified = property(modified)
@@ -77,5 +77,5 @@
def size(self):
a = ISized(self.context, None)
if a is None:
- raise AttributeError, 'created'
+ raise AttributeError('created')
return a.sizeForDisplay()
Modified: Zope3/trunk/src/zope/app/pluggableauth/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/pluggableauth/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/pluggableauth/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -138,7 +138,7 @@
source = self.get(principal_src_id)
if source is None:
- raise PrincipalLookupError, principal_src_id
+ raise PrincipalLookupError(principal_src_id)
return source.getPrincipal(id)
def getPrincipals(self, name):
@@ -460,7 +460,7 @@
try:
return self._principals_by_number[id]
except KeyError:
- raise PrincipalLookupError, id
+ raise PrincipalLookupError(id)
def getPrincipals(self, name):
""" See `IPrincipalSource`.
Modified: Zope3/trunk/src/zope/app/preference/default.py
===================================================================
--- Zope3/trunk/src/zope/app/preference/default.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/preference/default.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -103,7 +103,7 @@
return getattr(nextGroup, key, self.__schema__[key].default)
# Nothing found, raise an attribute error
- raise AttributeError, "'%s' is not a preference or sub-group." %key
+ raise AttributeError("'%s' is not a preference or sub-group." % key)
def data(self):
if self.__id__ not in self.provider.data:
Modified: Zope3/trunk/src/zope/app/preference/preference.py
===================================================================
--- Zope3/trunk/src/zope/app/preference/preference.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/preference/preference.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -106,7 +106,7 @@
default = object()
obj = self.get(key, default)
if obj is default:
- raise KeyError, key
+ raise KeyError(key)
return obj
def __contains__(self, key):
@@ -150,7 +150,7 @@
return value
# Nothing found, raise an attribute error
- raise AttributeError, "'%s' is not a preference or sub-group." %key
+ raise AttributeError("'%s' is not a preference or sub-group." % key)
def __setattr__(self, key, value):
if self.__schema__ and key in self.__schema__:
Modified: Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/publication/tests/test_browserpublication.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -53,7 +53,7 @@
def publishTraverse(self, request, name):
if name == 'bruce':
return foo
- raise KeyError, name
+ raise KeyError(name)
def browserDefault(self, request):
return self, ['bruce']
Modified: Zope3/trunk/src/zope/app/publication/traversers.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/traversers.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/publication/traversers.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -89,7 +89,7 @@
return zapi.getMultiAdapter((ob, request), name=name[6:])
if name.startswith('_'):
- raise Unauthorized, name
+ raise Unauthorized(name)
subob = getattr(ob, name, self) # self is marker here
if subob is self:
Modified: Zope3/trunk/src/zope/app/publication/zopepublication.py
===================================================================
--- Zope3/trunk/src/zope/app/publication/zopepublication.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/publication/zopepublication.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -156,7 +156,7 @@
app = root.get(self.root_name, None)
if app is None:
- raise SystemError, "Zope Application Not Found"
+ raise SystemError("Zope Application Not Found")
return ProxyFactory(app)
Modified: Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/publisher/browser/directoryresource.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -74,7 +74,7 @@
def __getitem__(self, name):
res = self.get(name, None)
if res is None:
- raise KeyError, name
+ raise KeyError(name)
return res
def get(self, name, default=_marker):
Modified: Zope3/trunk/src/zope/app/publisher/browser/fields.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/fields.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/publisher/browser/fields.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -48,7 +48,7 @@
... hasattr(menus, 'menu1') or \
... path == 'zope.app.component.menus.menu1':
... return menu1
- ... raise ConfigurationError, 'menu1'
+ ... raise ConfigurationError('menu1')
>>> field = MenuField()
>>> field = field.bind(Resolver())
Modified: Zope3/trunk/src/zope/app/publisher/browser/i18nfileresource.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/i18nfileresource.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/publisher/browser/i18nfileresource.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -67,8 +67,8 @@
def setDefaultLanguage(self, language):
'See II18nAware'
if not self._data.has_key(language):
- raise ValueError, \
- 'cannot set nonexistent language (%s) as default' % language
+ raise ValueError(
+ 'cannot set nonexistent language (%s) as default' % language)
self.defaultLanguage = language
def getAvailableLanguages(self):
Modified: Zope3/trunk/src/zope/app/publisher/browser/tests/test_menudirectives.py
===================================================================
--- Zope3/trunk/src/zope/app/publisher/browser/tests/test_menudirectives.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/publisher/browser/tests/test_menudirectives.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -54,9 +54,9 @@
def publishTraverse(self, request, name):
if name[:1] == 'f':
- raise Forbidden, name
+ raise Forbidden(name)
if name[:1] == 'u':
- raise Unauthorized, name
+ raise Unauthorized(name)
return self.f
class IMyLayer(Interface):
Modified: Zope3/trunk/src/zope/app/rdb/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/rdb/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -157,7 +157,7 @@
# issues at this point, so that we can convert it to a
# DatabaseException.
except Exception, error:
- raise DatabaseException, str(error)
+ raise DatabaseException(str(error))
def disconnect(self):
if self.isConnected():
Modified: Zope3/trunk/src/zope/app/rdb/gadflyda.py
===================================================================
--- Zope3/trunk/src/zope/app/rdb/gadflyda.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/rdb/gadflyda.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -49,7 +49,7 @@
conn_info['parameters'].get('dir', connection))
if not os.path.isdir(dir):
- raise DatabaseAdapterError, 'Not a directory ' + dir
+ raise DatabaseAdapterError('Not a directory ' + dir)
if not os.path.exists(os.path.join(dir, connection + ".gfd")):
db = gadfly.gadfly()
Modified: Zope3/trunk/src/zope/app/schema/browser/traversal.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/browser/traversal.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/schema/browser/traversal.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -69,6 +69,6 @@
def traverse(self, name, furtherPath):
subobj = self._context.get(name, _marker)
if subobj is _marker:
- raise TraversalError, name
+ raise TraversalError(name)
return subobj
Modified: Zope3/trunk/src/zope/app/schema/schema.py
===================================================================
--- Zope3/trunk/src/zope/app/schema/schema.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/schema/schema.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -63,7 +63,7 @@
field_names = [n for n, f in fields]
fields = [f for n, f in fields]
if name in field_names:
- raise KeyError, "Field %s already exists." % name
+ raise KeyError("Field %s already exists." % name)
if fields:
field.order = fields[-1].order + 1
self[name] = field
@@ -72,16 +72,16 @@
"""See zope.app.interfaces.utilities.IMutableSchema"""
fields = getFieldNamesInOrder(self)
if name not in fields:
- raise KeyError, "Field %s does not exists." % name
+ raise KeyError("Field %s does not exists." % name)
del self[name]
def renameField(self, orig_name, target_name):
"""See zope.app.interfaces.utilities.IMutableSchema"""
fields = getFieldNamesInOrder(self)
if orig_name not in fields:
- raise KeyError, "Field %s does not exists." % orig_name
+ raise KeyError("Field %s does not exists." % orig_name)
if target_name in fields:
- raise KeyError, "Field %s already exists." % target_name
+ raise KeyError("Field %s already exists." % target_name)
field = self[orig_name]
del self[orig_name]
field.__name__ = None
@@ -93,9 +93,9 @@
field_names = [n for n, f in fields]
fields = [f for n, f in fields]
if name in field_names:
- raise KeyError, "Field %s already exists." % name
+ raise KeyError("Field %s already exists." % name)
if not 0 <= position <= len(field_names):
- raise IndexError, "Position %s out of range." % position
+ raise IndexError("Position %s out of range." % position)
fields.insert(position, field)
for p, f in enumerate(fields):
if not f.order == p:
@@ -108,9 +108,9 @@
field_names = [n for n, f in fields]
fields = [f for n, f in fields]
if name not in field_names:
- raise KeyError, "Field %s does not exist." % name
+ raise KeyError("Field %s does not exist." % name)
if not 0 <= position <= len(field_names):
- raise IndexError, "Position %s out of range." % position
+ raise IndexError("Position %s out of range." % position)
index = field_names.index(name)
if index == position: return
field = fields[index]
@@ -188,7 +188,7 @@
if r is not None:
return r
- raise KeyError, name
+ raise KeyError(name)
__getitem__ = getDescriptionFor
Modified: Zope3/trunk/src/zope/app/schemacontent/browser/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/browser/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/schemacontent/browser/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -147,8 +147,8 @@
if name == type_name]
if not matching:
- raise ComponentLookupError, \
- "No Content Component Definition named '%s' found" %type_name
+ raise ComponentLookupError("No Content Component Definition named "
+ "'%s' found" % type_name)
self.definition = matching[0]
self.schema = self.definition.schema
Modified: Zope3/trunk/src/zope/app/schemacontent/content.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/content.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/schemacontent/content.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -94,7 +94,7 @@
if is_schema_field:
super(ContentComponentInstance, self).__setattr__(key, value)
else:
- raise AttributeError, 'Attribute "%s" not available' %key
+ raise AttributeError('Attribute "%s" not available' % key)
def getSchema(self):
Modified: Zope3/trunk/src/zope/app/schemacontent/instance.py
===================================================================
--- Zope3/trunk/src/zope/app/schemacontent/instance.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/schemacontent/instance.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -83,7 +83,7 @@
if is_schema_field:
super(ContentComponentInstance, self).__setattr__(key, value)
else:
- raise AttributeError, 'Attribute not available'
+ raise AttributeError('Attribute not available')
def getSchema(self):
Modified: Zope3/trunk/src/zope/app/security/browser/principalterms.py
===================================================================
--- Zope3/trunk/src/zope/app/security/browser/principalterms.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/security/browser/principalterms.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -40,13 +40,13 @@
def getTerm(self, principal_id):
if principal_id not in self.context:
- raise LookupError, principal_id
+ raise LookupError(principal_id)
auth = zapi.principals()
principal = auth.getPrincipal(principal_id)
if principal is None:
- raise LookupError, principal_id
+ raise LookupError(principal_id)
return Term(principal_id.encode('base64').strip().replace('=', '_'),
principal.title)
Modified: Zope3/trunk/src/zope/app/sqlexpr/sqlexpr.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlexpr/sqlexpr.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/sqlexpr/sqlexpr.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -38,26 +38,24 @@
conn_name = econtext.vars['sql_conn']
adapter = zapi.queryUtility(IZopeDatabaseAdapter, conn_name)
if adapter is None:
- raise ConnectionError, \
- ("The RDB DA name, '%s' you specified is not "
- "valid." %conn_name)
+ raise ConnectionError("The RDB DA name, '%s' you specified is "
+ "not valid." % conn_name)
elif econtext.vars.has_key('rdb') and econtext.vars.has_key('dsn'):
rdb = econtext.vars['rdb']
dsn = econtext.vars['dsn']
try:
adapter = zapi.createObject(rdb, dsn)
except ComponentLookupError:
- raise ConnectionError, \
- ("The factory id, '%s', you specified in the `rdb` "
- "attribute did not match any registered factory." %rdb)
+ raise ConnectionError("The factory id, '%s', you specified in "
+ "the `rdb` attribute did not match any "
+ "registered factory." % rdb)
if not IZopeDatabaseAdapter.providedBy(adapter):
- raise ConnectionError, \
- ("The factory id, '%s', you specifed did not create a "
- "Zope Database Adapter component." %rdb)
+ raise ConnectionError("The factory id, '%s', you specifed did "
+ "not create a Zope Database Adapter "
+ "component." % rdb)
else:
- raise ConnectionError, \
- 'You did not specify a RDB connection.'
+ raise ConnectionError('You did not specify a RDB connection.')
connection = adapter()
vvals = []
Modified: Zope3/trunk/src/zope/app/sqlscript/dtml.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlscript/dtml.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/sqlscript/dtml.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -47,10 +47,10 @@
self.__name__ = name_param(context, args, 'sqlvar')
has_key=args.has_key
if not has_key('type'):
- raise ParseError, ('the type attribute is required', 'sqltest')
+ raise ParseError('the type attribute is required', 'sqltest')
self.type = t = args['type']
if not valid_type(t):
- raise ParseError, ('invalid type, %s' % t, 'sqltest')
+ raise ParseError('invalid type, %s' % t, 'sqltest')
if has_key('optional'):
self.optional = args['optional']
if has_key('multiple'):
@@ -76,7 +76,7 @@
except KeyError, key:
if key[0] == name and self.optional:
return ''
- raise KeyError, key, sys.exc_info()[2]
+ raise KeyError(key), None, sys.exc_info()[2]
if (list in v.__class__.__mro__ # isinstance doesn't work w
or # security proxies, so we use
@@ -101,8 +101,7 @@
else:
v = str(int(v))
except ValueError:
- raise ValueError, (
- 'Invalid integer value for **%s**' %name)
+ raise ValueError('Invalid integer value for **%s**' % name)
elif t == 'float':
if not v and isinstance(v, str):
@@ -113,8 +112,8 @@
else:
v = str(float(v))
except ValueError:
- raise ValueError, (
- 'Invalid floating-point value for **%s**' %name)
+ raise ValueError(
+ 'Invalid floating-point value for **%s**' % name)
else:
v = str(v)
v = self.sql_quote__(v)
@@ -124,7 +123,7 @@
if not vs:
if self.optional:
return ''
- raise MissingInput, 'No input was provided for **%s**' %name
+ raise MissingInput('No input was provided for **%s**' % name)
if len(vs) > 1:
vs = ', '.join(map(str, vs))
@@ -208,11 +207,11 @@
self.args = args
if not args.has_key('type'):
- raise ParseError, ('the type attribute is required', 'dtvar')
+ raise ParseError('the type attribute is required', 'dtvar')
t = args['type']
if not valid_type(t):
- raise ParseError, ('invalid type, %s' % t, 'dtvar')
+ raise ParseError('invalid type, %s' % t, 'dtvar')
def render(self, md):
@@ -230,7 +229,7 @@
return 'null'
if not isinstance(expr, StringTypes):
raise
- raise MissingInput, 'Missing input variable, **%s**' %name
+ raise MissingInput('Missing input variable, **%s**' % name)
# TODO: Shrug, should these tyoes be really hard coded? What about
# Dates and other types a DB supports; I think we should make this
@@ -244,8 +243,7 @@
except:
if not v and args.has_key('optional') and args['optional']:
return 'null'
- raise ValueError, (
- 'Invalid integer value for **%s**' % name)
+ raise ValueError('Invalid integer value for **%s**' % name)
elif t == 'float':
try:
@@ -256,7 +254,7 @@
except ValueError:
if not v and args.has_key('optional') and args['optional']:
return 'null'
- raise ValueError, (
+ raise ValueError(
'Invalid floating-point value for **%s**' % name)
else:
@@ -266,7 +264,7 @@
if args.has_key('optional') and args['optional']:
return 'null'
else:
- raise ValueError, (
+ raise ValueError(
'Invalid empty string value for **%s**' % name)
v = self.sql_quote__(v)
Modified: Zope3/trunk/src/zope/app/sqlscript/sqlscript.py
===================================================================
--- Zope3/trunk/src/zope/app/sqlscript/sqlscript.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/sqlscript/sqlscript.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -133,9 +133,8 @@
try:
connection = self.getConnection()
except KeyError:
- raise AttributeError, (
- "The database connection '%s' cannot be found." % (
- self.connectionName))
+ raise AttributeError("The database connection '%s' cannot be "
+ "found." % (self.connectionName))
query = apply(self.template, (), arg_values)
cache = getCacheForObject(self)
@@ -189,7 +188,7 @@
# We are done parsing
if not text or not text.strip():
return Arguments(result)
- raise InvalidParameter, text
+ raise InvalidParameter(text)
# Find type of argument (int, float, string, ...)
lt = name.find(':')
@@ -198,7 +197,7 @@
value['type'] = name[lt+1:]
name = name[:lt]
else:
- raise InvalidParameter, text
+ raise InvalidParameter(text)
result[name] = value
Modified: Zope3/trunk/src/zope/app/testing/setup.py
===================================================================
--- Zope3/trunk/src/zope/app/testing/setup.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/testing/setup.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -250,7 +250,7 @@
try:
return self.__dict[name]
except KeyError:
- raise AttributeError, name
+ raise AttributeError(name)
def setUpTestAsModule(test, name=None):
Modified: Zope3/trunk/src/zope/app/traversing/api.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/api.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/traversing/api.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -189,7 +189,7 @@
if parents and IContainmentRoot.providedBy(parents[-1]):
return parents
- raise TypeError, "Not enough context information to get all parents"
+ raise TypeError("Not enough context information to get all parents")
def _normalizePath(path):
Modified: Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py
===================================================================
--- Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/traversing/browser/absoluteurl.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -53,13 +53,13 @@
container = getattr(context, '__parent__', None)
if container is None:
- raise TypeError, _insufficientContext
+ raise TypeError(_insufficientContext)
url = str(zope.component.getMultiAdapter((container, request),
name='absolute_url'))
name = self._getContextName(context)
if name is None:
- raise TypeError, _insufficientContext
+ raise TypeError(_insufficientContext)
if name:
url += '/' + urllib.quote(name.encode('utf-8'), _safe)
@@ -78,7 +78,7 @@
# We do this here do maintain the rule that we must be wrapped
container = getattr(context, '__parent__', None)
if container is None:
- raise TypeError, _insufficientContext
+ raise TypeError(_insufficientContext)
if sameProxiedObjects(context, request.getVirtualHostRoot()) or \
isinstance(context, Exception):
@@ -89,7 +89,7 @@
name = getattr(context, '__name__', None)
if name is None:
- raise TypeError, _insufficientContext
+ raise TypeError(_insufficientContext)
if name:
base += ({'name': name,
Modified: Zope3/trunk/src/zope/app/undo/__init__.py
===================================================================
--- Zope3/trunk/src/zope/app/undo/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/undo/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -113,7 +113,7 @@
first=0, last=-20):
"""See zope.app.undo.interfaces.IPrincipal"""
if not IPrincipal.providedBy(principal):
- raise TypeError, "Invalid principal: %s" % principal
+ raise TypeError("Invalid principal: %s" % principal)
return self._getUndoInfo(context, principal, first, last)
def _getUndoInfo(self, context, principal, first, last):
@@ -176,7 +176,7 @@
def undoPrincipalTransactions(self, principal, ids):
"""See zope.app.undo.interfaces.IPrincipal"""
if not IPrincipal.providedBy(principal):
- raise TypeError, "Invalid principal: %s" % principal
+ raise TypeError("Invalid principal: %s" % principal)
# Make sure we only undo the transactions initiated by our
# principal
@@ -191,9 +191,9 @@
first += batch_size
txns = self._getUndoInfo(None, principal, first, -batch_size)
if left_overs:
- raise UndoError, ("You are trying to undo a transaction that "
- "either does not exist or was not initiated "
- "by the principal.")
+ raise UndoError("You are trying to undo a transaction that "
+ "either does not exist or was not initiated "
+ "by the principal.")
self._undo(ids)
def _undo(self, ids):
Modified: Zope3/trunk/src/zope/app/workflow/stateful/definition.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/definition.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/workflow/stateful/definition.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -46,6 +46,10 @@
implements(IStatefulStatesContainer)
+class NoLocalProcessDefinition(Exception):
+ """No local process definition found"""
+
+
class StateNamesVocabulary(SimpleVocabulary):
"""Vocabulary providing the names of states in a local process definition.
"""
@@ -61,7 +65,7 @@
for obj in zapi.getParents(context):
if IStatefulProcessDefinition.providedBy(obj):
return obj.getStateNames()
- raise 'NoLocalProcessDefinition', 'No local process definition found.'
+ raise NoLocalProcessDefinition('No local process definition found.')
class Transition(Persistent, Contained):
@@ -142,7 +146,7 @@
def addState(self, name, state):
"""See workflow.stateful.IStatefulProcessDefinition"""
if name in self.states:
- raise KeyError, name
+ raise KeyError(name)
self.states[name] = state
def getState(self, name):
@@ -164,7 +168,7 @@
def addTransition(self, name, transition):
"""See workflow.stateful.IStatefulProcessDefinition"""
if name in self.transitions:
- raise KeyError, name
+ raise KeyError(name)
self.transitions[name] = transition
def getTransition(self, name):
Modified: Zope3/trunk/src/zope/app/workflow/stateful/instance.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/instance.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/workflow/stateful/instance.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -200,7 +200,7 @@
pd = self.getProcessDefinition()
clean_pd = removeAllProxies(pd)
if not id in self._outgoingTransitions(clean_pd):
- raise KeyError, 'Invalid Transition Id: %s' % id
+ raise KeyError('Invalid Transition Id: %s' % id)
transition = clean_pd.transitions[id]
# Get the object whose status is being changed.
obj = getParent(self)
Modified: Zope3/trunk/src/zope/app/workflow/stateful/xmlimportexport.py
===================================================================
--- Zope3/trunk/src/zope/app/workflow/stateful/xmlimportexport.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/app/workflow/stateful/xmlimportexport.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -60,7 +60,7 @@
def startElement(self, name, attrs):
handler = getattr(self, 'start' + name.title().replace('-', ''), None)
if not handler:
- raise ValueError, 'Unknown element %s' % name
+ raise ValueError('Unknown element %s' % name)
handler(attrs)
Modified: Zope3/trunk/src/zope/component/__init__.py
===================================================================
--- Zope3/trunk/src/zope/component/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/component/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -193,7 +193,7 @@
def __get__(self, inst, cls):
if inst is None:
return self.interfaces
- raise AttributeError, '__component_adapts__'
+ raise AttributeError('__component_adapts__')
class adapter:
Modified: Zope3/trunk/src/zope/component/bbb/adapter.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/adapter.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/component/bbb/adapter.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -71,7 +71,7 @@
attr = getattr(self.sm.adapters, name)
if attr is not None:
return attr
- raise AttributeError, name
+ raise AttributeError(name)
class GlobalAdapterService(AdapterService, GlobalService):
Modified: Zope3/trunk/src/zope/component/bbb/tests/test_api.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/tests/test_api.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/component/bbb/tests/test_api.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -88,7 +88,7 @@
try:
return self.services[name]
except KeyError:
- raise ComponentLookupError, name
+ raise ComponentLookupError(name)
class ConformsToIServiceService(object):
Modified: Zope3/trunk/src/zope/component/bbb/utility.py
===================================================================
--- Zope3/trunk/src/zope/component/bbb/utility.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/component/bbb/utility.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -52,7 +52,7 @@
if attr is not None:
return attr
- raise AttributeError, name
+ raise AttributeError(name)
class GlobalUtilityService(UtilityService, GlobalService):
Modified: Zope3/trunk/src/zope/configuration/config.py
===================================================================
--- Zope3/trunk/src/zope/configuration/config.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/configuration/config.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -183,9 +183,8 @@
try:
mod = __import__(mname, *_import_chickens)
except ImportError, v:
- raise ConfigurationError, (
- "Couldn't import %s, %s" % (mname, v)
- ), sys.exc_info()[2]
+ raise ConfigurationError(
+ "Couldn't import %s, %s" % (mname, v)), None, sys.exc_info()[2]
if not oname:
# see not mname case above
@@ -623,10 +622,8 @@
except:
if testing:
raise
- t, v = sys.exc_info()[:2]
- v = ConfigurationExecutionError(t, v, info)
- t = ConfigurationExecutionError
- raise t, v, sys.exc_info()[2]
+ t, v, tb = sys.exc_info()
+ raise ConfigurationExecutionError(t, v, info), None, tb
finally:
if clear:
del self.actions[:]
@@ -1392,8 +1389,8 @@
try:
args[str(name)] = field.fromUnicode(s)
except zope.schema.ValidationError, v:
- raise ConfigurationError, (
- "Invalid value for", n, str(v)), sys.exc_info()[2]
+ raise ConfigurationError(
+ "Invalid value for", n, str(v)), None, sys.exc_info()[2]
elif field.required:
# if the default is valid, we can use that:
default = field.default
Modified: Zope3/trunk/src/zope/configuration/xmlconfig.py
===================================================================
--- Zope3/trunk/src/zope/configuration/xmlconfig.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/configuration/xmlconfig.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -222,9 +222,8 @@
except:
if self.testing:
raise
- raise ZopeXMLConfigurationError, (
- info, sys.exc_info()[0], sys.exc_info()[1]
- ), sys.exc_info()[2]
+ raise ZopeXMLConfigurationError(info, sys.exc_info()[0],
+ sys.exc_info()[1]), None, sys.exc_info()[2]
self.context.setInfo(info)
@@ -327,9 +326,8 @@
except:
if self.testing:
raise
- raise ZopeXMLConfigurationError, (
- info, sys.exc_info()[0], sys.exc_info()[1]
- ), sys.exc_info()[2]
+ raise ZopeXMLConfigurationError(info, sys.exc_info()[0],
+ sys.exc_info()[1]), None, sys.exc_info()[2]
def processxmlfile(file, context, testing=False):
@@ -345,7 +343,7 @@
try:
parser.parse(src)
except SAXParseException:
- raise ZopeSAXParseException, sys.exc_info()[1], sys.exc_info()[2]
+ raise ZopeSAXParseException(sys.exc_info()[1]), None, sys.exc_info()[2]
def openInOrPlain(filename):
Modified: Zope3/trunk/src/zope/dependencytool/finddeps.py
===================================================================
--- Zope3/trunk/src/zope/dependencytool/finddeps.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/dependencytool/finddeps.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -98,7 +98,7 @@
if path.startswith(syspath):
return path[len(syspath):].replace(os.sep, ".")
- raise ValueError, 'Cannot create dotted name for %r' % path
+ raise ValueError('Cannot create dotted name for %r' % path)
def getDependenciesOfPythonFile(path, packages):
Modified: Zope3/trunk/src/zope/documenttemplate/dt_html.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_html.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_html.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -159,7 +159,7 @@
args=args.strip()
if end:
if not command or name != command.name:
- raise ParseError, ('unexpected end tag', tag)
+ raise ParseError('unexpected end tag', tag)
return tag, args, None, None
if command and name in command.blockContinuations:
@@ -176,7 +176,7 @@
try: return tag, args, self.commands[name], None
except KeyError:
- raise ParseError, ('Unexpected tag', tag)
+ raise ParseError('Unexpected tag', tag)
def SubTemplate(self, name):
Modified: Zope3/trunk/src/zope/documenttemplate/dt_if.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_if.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_if.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -103,13 +103,13 @@
if args:
ename,expr=name_param(context, args,'else',1)
if ename != name:
- raise ParseError, ('name in else does not match if', 'in')
+ raise ParseError('name in else does not match if', 'in')
elses=section.blocks
else: elses = None
for tname, args, section in blocks[1:]:
if tname == 'else':
- raise ParseError, (
+ raise ParseError(
'more than one else tag for a single if tag', 'in')
args = parse_params(args, name='', expr='')
name,expr = name_param(context, args, 'elif', 1)
Modified: Zope3/trunk/src/zope/documenttemplate/dt_in.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_in.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_in.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -336,6 +336,9 @@
In = InFactory()
+class InError(Exception):
+ """Strings are not allowed as input to the in tag"""
+
class InClass:
elses = None
expr = sort = batch = mapping = None
@@ -374,7 +377,7 @@
for n in 'orphan','overlap','previous','next':
if has_key(n) and not self.batch:
- raise ParseError, (
+ raise ParseError(
"""
The %s attribute was used but neither of the
<code>start</code>, <code>end</code>, or <code>size</code>
@@ -397,14 +400,14 @@
self.__name__, self.expr = name, expr
self.section = section.blocks
if len(blocks) > 1:
- if len(blocks) != 2: raise ParseError, (
+ if len(blocks) != 2: raise ParseError(
'too many else blocks', 'in')
tname, args, section = blocks[1]
args=parse_params(args, name='')
if args:
ename = name_param(context, args)
if ename != name:
- raise ParseError, (
+ raise ParseError(
'name in else does not match in', 'in')
self.elses = section.blocks
@@ -425,8 +428,7 @@
return ''
if isinstance(sequence, StringType):
- raise 'InError', (
- 'Strings are not allowed as input to the in tag.')
+ raise InError('Strings are not allowed as input to the in tag.')
section = self.section
@@ -572,7 +574,7 @@
if index == first:
kw['sequence-start'] = 0
continue
- raise ValidationError, index
+ raise ValidationError(index)
kw['sequence-index'] = index
if isinstance(client, TupleType) and len(client) == 2:
@@ -617,8 +619,7 @@
return ''
if isinstance(sequence, StringType):
- raise 'InError', (
- 'Strings are not allowed as input to the in tag.')
+ raise InError('Strings are not allowed as input to the in tag.')
section = self.section
mapping = self.mapping
@@ -669,7 +670,7 @@
if index == 1:
kw['sequence-start'] = 0
continue
- raise ValidationError, index
+ raise ValidationError(index)
kw['sequence-index'] = index
if isinstance(client, TupleType) and len(client) == 2:
Modified: Zope3/trunk/src/zope/documenttemplate/dt_insv.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_insv.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_insv.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -143,7 +143,7 @@
def query(self, *ignored):
if self.start_name_re is None:
- raise KeyError, 'sequence-query'
+ raise KeyError('sequence-query')
query_string = self.query_string
while query_string and query_string[:1] in '?&':
query_string = query_string[1:]
@@ -270,7 +270,7 @@
def next_batches(self, suffix='batches', key=''):
if suffix != 'batches':
- raise KeyError, key
+ raise KeyError(key)
data = self.data
sequence = self.items
try:
@@ -300,7 +300,7 @@
def previous_batches(self, suffix='batches', key=''):
if suffix != 'batches':
- raise KeyError, key
+ raise KeyError(key)
data = self.data
sequence = self.items
try:
@@ -352,7 +352,7 @@
l = key.rfind('-')
if l < 0:
- raise KeyError, key
+ raise KeyError(key)
suffix = key[l+1:]
prefix = key[:l]
@@ -378,7 +378,7 @@
if key == 'sequence-query':
return self.query()
- raise KeyError, key
+ raise KeyError(key)
Modified: Zope3/trunk/src/zope/documenttemplate/dt_let.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_let.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_let.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -65,7 +65,7 @@
args[i] = name, Eval(context, expr).eval
except SyntaxError, v:
m,(huh,l,c,src) = v
- raise ParseError, (
+ raise ParseError(
'<strong>Expression (Python) Syntax error</strong>:'
'\n<pre>\n%s\n</pre>\n' % v[0],
'let')
@@ -112,7 +112,7 @@
else:
if not text or not text.strip():
return result
- raise ParseError, ('invalid parameter: "%s"' % text, tag)
+ raise ParseError('invalid parameter: "%s"' % text, tag)
result.append((name,value))
Modified: Zope3/trunk/src/zope/documenttemplate/dt_raise.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_raise.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_raise.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -57,6 +57,6 @@
except:
v = 'Invalid Error Value'
- raise t, v
+ raise t(v)
__call__ = render
Modified: Zope3/trunk/src/zope/documenttemplate/dt_string.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_string.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_string.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -57,9 +57,9 @@
return s
def parse_error(self, mess, tag, text, start):
- raise ParseError, "%s, for tag %s, on line %s of %s<p>" % (
+ raise ParseError("%s, for tag %s, on line %s of %s<p>" % (
mess, self.errQuote(tag), len(text[:start].split('\n')),
- self.errQuote(self.__name__))
+ self.errQuote(self.__name__)))
commands={
'var': Var,
@@ -124,7 +124,7 @@
if fmt == ']':
if not command or name != command.name:
- raise ParseError, ('unexpected end tag', tag)
+ raise ParseError('unexpected end tag', tag)
return tag, args, None, None
elif fmt == '[' or fmt == '!':
if command and name in command.blockContinuations:
@@ -142,7 +142,7 @@
try:
return tag, args, self.commands[name], None
except KeyError:
- raise ParseError, ('Unexpected tag', tag)
+ raise ParseError('Unexpected tag', tag)
else:
# Var command
args = args and ("%s %s" % (name, args)) or name
@@ -456,7 +456,7 @@
level = md.level
if level > 200:
- raise SystemError, ('infinite recursion in document template')
+ raise SystemError('infinite recursion in document template')
md.level = level+1
if client is not None:
Modified: Zope3/trunk/src/zope/documenttemplate/dt_try.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_try.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_try.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -115,20 +115,20 @@
for tname, nargs, nsection in blocks[1:]:
if tname == 'else':
if not self.elseBlock is None:
- raise ParseError, (
+ raise ParseError(
'No more than one else block is allowed',
self.name)
self.elseBlock = nsection.blocks
elif tname == 'finally':
- raise ParseError, (
+ raise ParseError(
'A try..finally combination cannot contain '
'any other else, except or finally blocks',
self.name)
else:
if not self.elseBlock is None:
- raise ParseError, (
+ raise ParseError(
'The else block should be the last block '
'in a try tag', self.name)
@@ -136,7 +136,7 @@
self.handlers.append((errname, nsection.blocks))
if nargs.strip() == '':
if defaultHandlerFound:
- raise ParseError, (
+ raise ParseError(
'Only one default exception handler '
'is allowed', self.name)
else:
Modified: Zope3/trunk/src/zope/documenttemplate/dt_util.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_util.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_util.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -106,39 +106,39 @@
if v[:1] == '"' and v[-1:] == '"' and len(v) > 1: # expr shorthand
if used(attr):
- raise ParseError, (u'%s and expr given' % attr, tag)
+ raise ParseError(u'%s and expr given' % attr, tag)
if expr:
if used('expr'):
- raise ParseError, (u'two exprs given', tag)
+ raise ParseError(u'two exprs given', tag)
v = v[1:-1]
try:
expr=Eval(context, v)
except SyntaxError, v:
- raise ParseError, (
+ raise ParseError(
u'<strong>Expression (Python) Syntax error</strong>:'
u'\n<pre>\n%s\n</pre>\n' % v[0],
tag)
return v, expr
else:
- raise ParseError, (
+ raise ParseError(
u'The "..." shorthand for expr was used in a tag '
u'that doesn\'t support expr attributes.',
tag)
else: # name shorthand
if used(attr):
- raise ParseError, (u'Two %s values were given' % attr, tag)
+ raise ParseError(u'Two %s values were given' % attr, tag)
if expr:
if used('expr'):
# raise 'Waaaaaa', 'waaa'
- raise ParseError, (u'%s and expr given' % attr, tag)
+ raise ParseError(u'%s and expr given' % attr, tag)
return params[''],None
return params['']
elif used(attr):
if expr:
if used('expr'):
- raise ParseError, (u'%s and expr given' % attr, tag)
+ raise ParseError(u'%s and expr given' % attr, tag)
return params[attr],None
return params[attr]
elif expr and used('expr'):
@@ -146,7 +146,7 @@
expr = Eval(context, name)
return name, expr
- raise ParseError, (u'No %s given' % attr, tag)
+ raise ParseError(u'No %s given' % attr, tag)
Expr_doc = u"""
@@ -258,11 +258,11 @@
l = len(mo_unp.group(1))
if result:
if parms.has_key(name):
- if parms[name] is None: raise ParseError, (
+ if parms[name] is None: raise ParseError(
u'Attribute %s requires a value' % name, tag)
result[name] = parms[name]
- else: raise ParseError, (
+ else: raise ParseError(
u'Invalid attribute name, "%s"' % name, tag)
else:
result[''] = name
@@ -271,22 +271,22 @@
name = mo_unq.group(2)
l = len(mo_unq.group(1))
if result:
- raise ParseError, (u'Invalid attribute name, "%s"' % name, tag)
+ raise ParseError(u'Invalid attribute name, "%s"' % name, tag)
else:
result[''] = name
return apply(parse_params, (text[l:], result), parms)
else:
if not text or not text.strip():
return result
- raise ParseError, (u'invalid parameter: "%s"' % text, tag)
+ raise ParseError(u'invalid parameter: "%s"' % text, tag)
if not parms.has_key(name):
- raise ParseError, (u'Invalid attribute name, "%s"' % name, tag)
+ raise ParseError(u'Invalid attribute name, "%s"' % name, tag)
if result.has_key(name):
p = parms[name]
if type(p) is not ListType or p:
- raise ParseError, (
+ raise ParseError(
u'Duplicate values for attribute "%s"' % name, tag)
result[name] = value
Modified: Zope3/trunk/src/zope/documenttemplate/dt_var.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/dt_var.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/dt_var.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -204,7 +204,7 @@
if have_arg('missing'):
return args['missing']
else:
- raise KeyError, name
+ raise KeyError(name)
else:
val = val.eval(md)
if have_arg('url'):
@@ -233,7 +233,7 @@
t, v = sys.exc_info()[:2]
if val is None or not str(val):
return args['null']
- raise t, v
+ raise t(v)
else:
# We duplicate the code here to avoid exception handler
Modified: Zope3/trunk/src/zope/documenttemplate/pdocumenttemplate.py
===================================================================
--- Zope3/trunk/src/zope/documenttemplate/pdocumenttemplate.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/documenttemplate/pdocumenttemplate.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -57,7 +57,7 @@
try:
r = getattr(inst, key)
except AttributeError:
- raise KeyError, key
+ raise KeyError(key)
self.cache[key] = r
return r
@@ -77,7 +77,7 @@
return d[key]
except (KeyError, AttributeError):
pass
- raise KeyError, key
+ raise KeyError(key)
def push(self,d):
self.dicts.insert(0, d)
@@ -103,7 +103,7 @@
try:
return self.__d[name]
except KeyError:
- raise AttributeError, name
+ raise AttributeError(name)
class TemplateDict:
@@ -186,19 +186,19 @@
elif len(args) == 2:
iStart, iEnd, iStep = iFirst, args[0], args[1]
else:
- raise AttributeError, u'range() requires 1-3 int arguments'
+ raise AttributeError(u'range() requires 1-3 int arguments')
if iStep == 0:
- raise ValueError, u'zero step for range()'
+ raise ValueError(u'zero step for range()')
iLen = int((iEnd - iStart) / iStep)
if iLen < 0:
iLen = 0
if iLen >= RANGELIMIT:
- raise ValueError, u'range() too large'
+ raise ValueError(u'range() too large')
return range(iStart, iEnd, iStep)
def pow(self, x, y, z):
if not z:
- raise ValueError, 'pow(x, y, z) with z==0'
+ raise ValueError('pow(x, y, z) with z==0')
return pow(x,y,z)
def test(self, *args):
@@ -298,7 +298,7 @@
except KeyError, v:
v = v[0]
if n != v:
- raise KeyError, v, sys.exc_traceback
+ raise KeyError(v), None, sys.exc_traceback
cond=None
else:
cond = cond(md)
Modified: Zope3/trunk/src/zope/exceptions/tests/test_exceptionformatter.py
===================================================================
--- Zope3/trunk/src/zope/exceptions/tests/test_exceptionformatter.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/exceptions/tests/test_exceptionformatter.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -135,7 +135,7 @@
def testQuoteLastLine(self):
class C(object): pass
- try: raise TypeError, C()
+ try: raise TypeError(C())
except:
s = tb(1)
else:
Modified: Zope3/trunk/src/zope/fssync/metadata.py
===================================================================
--- Zope3/trunk/src/zope/fssync/metadata.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/fssync/metadata.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -81,7 +81,7 @@
if len(errors) == 1:
raise
else:
- raise IOError, tuple(errors)
+ raise IOError(tuple(errors))
class DirectoryManager(object):
Modified: Zope3/trunk/src/zope/fssync/server/entryadapter.py
===================================================================
--- Zope3/trunk/src/zope/fssync/server/entryadapter.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/fssync/server/entryadapter.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -36,7 +36,7 @@
def __getitem__(self, name):
if name in self.attrs:
return getattr(self.context, name)
- raise KeyError, name
+ raise KeyError(name)
def get(self, name, default=None):
if name in self.attrs:
@@ -50,13 +50,13 @@
if name in self.attrs:
delattr(self.context, name)
return
- raise KeyError, name
+ raise KeyError(name)
def __setitem__(self, name, value):
if name in self.attrs:
setattr(self.context, name, value)
return
- raise KeyError, name
+ raise KeyError(name)
def __iter__(self):
return iter(self.attrs)
Modified: Zope3/trunk/src/zope/i18n/format.py
===================================================================
--- Zope3/trunk/src/zope/i18n/format.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/i18n/format.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -113,8 +113,8 @@
hour = int(results[bin_pattern.index(hour_entry[0])])
ampm_entry = _findFormattingCharacterInPattern('a', bin_pattern)
if not ampm_entry:
- raise DateTimeParseError, \
- 'Cannot handle 12-hour format without am/pm marker.'
+ raise DateTimeParseError(
+ 'Cannot handle 12-hour format without am/pm marker.')
ampm = self.calendar.pm == results[bin_pattern.index(ampm_entry[0])]
if hour == 12:
ampm = not ampm
@@ -270,7 +270,7 @@
num_str = num_res[1].groups()[0]
sign = -1
else:
- raise NumberParseError, 'Not a valid number for this pattern.'
+ raise NumberParseError('Not a valid number for this pattern.')
# Remove possible grouping separators
num_str = num_str.replace(self.symbols['group'], '')
# Extract number
@@ -494,11 +494,11 @@
# Some cleaning up
if state == IN_QUOTE:
if quote_start == -1:
- raise DateTimePatternParseError, \
- 'Waaa: state = IN_QUOTE and quote_start = -1!'
+ raise DateTimePatternParseError(
+ 'Waaa: state = IN_QUOTE and quote_start = -1!')
else:
- raise DateTimePatternParseError, \
- ('The quote starting at character %i is not closed.' %
+ raise DateTimePatternParseError(
+ 'The quote starting at character %i is not closed.' %
quote_start)
elif state == IN_DATETIMEFIELD:
result.append((helper[0], len(helper)))
@@ -526,7 +526,7 @@
elif entry[1] == 4:
info[entry] = r'([0-9]{4})'
else:
- raise DateTimePatternParseError, "Only 'yy' and 'yyyy' allowed."
+ raise DateTimePatternParseError("Only 'yy' and 'yyyy' allowed." )
# am/pm marker (Text)
for entry in _findFormattingCharacterInPattern('a', pattern):
@@ -732,8 +732,8 @@
state = READ_INTEGER
helper += char
else:
- raise NumberPatternParseError, \
- 'Wrong syntax at beginning of pattern.'
+ raise NumberPatternParseError(
+ 'Wrong syntax at beginning of pattern.')
elif state == READ_PADDING_1:
padding_1 = char
Modified: Zope3/trunk/src/zope/i18n/gettextmessagecatalog.py
===================================================================
--- Zope3/trunk/src/zope/i18n/gettextmessagecatalog.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/i18n/gettextmessagecatalog.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -22,7 +22,7 @@
class _KeyErrorRaisingFallback(object):
def ugettext(self, message):
- raise KeyError, message
+ raise KeyError(message)
class GettextMessageCatalog(object):
Modified: Zope3/trunk/src/zope/i18n/locales/__init__.py
===================================================================
--- Zope3/trunk/src/zope/i18n/locales/__init__.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/i18n/locales/__init__.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -653,4 +653,4 @@
return locales.getLocale(None, None, None)
else:
# Well, this is bad; we are already at the root locale
- raise NoParentException, 'Cannot find a more general locale.'
+ raise NoParentException('Cannot find a more general locale.')
Modified: Zope3/trunk/src/zope/i18n/locales/inheritance.py
===================================================================
--- Zope3/trunk/src/zope/i18n/locales/inheritance.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/i18n/locales/inheritance.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -45,7 +45,7 @@
def getInheritedSelf(self):
"""See zope.i18n.interfaces.locales.ILocaleInheritance"""
if self.__parent__ is None:
- raise NoParentException, 'No parent was specified.'
+ raise NoParentException('No parent was specified.')
parent = self.__parent__.getInheritedSelf()
if isinstance(parent, dict):
return parent[self.__name__]
@@ -117,9 +117,9 @@
except NoParentException:
# There was simply no parent anymore, so let's raise an error
# for good
- raise AttributeError, \
- "'%s' object (or any of its parents) has no attribute '%s'" %(
- self.__class__.__name__, name)
+ raise AttributeError("'%s' object (or any of its parents) has no "
+ "attribute '%s'" % (self.__class__.__name__,
+ name))
else:
value = getattr(selfUp, name)
# Since a locale hierarchy never changes after startup, we can
Modified: Zope3/trunk/src/zope/i18n/locales/provider.py
===================================================================
--- Zope3/trunk/src/zope/i18n/locales/provider.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/i18n/locales/provider.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -53,8 +53,8 @@
# Making sure we have this locale
path = os.path.join(self._locale_dir, filename)
if not os.path.exists(path):
- raise LoadLocaleError, \
- 'The desired locale is not available.\nPath: %s' %path
+ raise LoadLocaleError(
+ 'The desired locale is not available.\nPath: %s' % path)
# Import here to avoid circular imports
from zope.i18n.locales.xmlfactory import LocaleFactory
Modified: Zope3/trunk/src/zope/i18n/locales/tests/test_docstrings.py
===================================================================
--- Zope3/trunk/src/zope/i18n/locales/tests/test_docstrings.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/i18n/locales/tests/test_docstrings.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -26,7 +26,7 @@
def getInheritedSelf(self):
if self.__nextLocale__ is None:
- raise NoParentException, 'No parent was specified.'
+ raise NoParentException('No parent was specified.')
return self.__nextLocale__
Modified: Zope3/trunk/src/zope/i18nmessageid/message.py
===================================================================
--- Zope3/trunk/src/zope/i18nmessageid/message.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/i18nmessageid/message.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -161,7 +161,7 @@
It cannot be changed once the message id is created.
"""
if getattr(self, '_readonly', False):
- raise TypeError, 'readonly attribute'
+ raise TypeError('readonly attribute')
else:
return unicode.__setattr__(self, key, value)
Modified: Zope3/trunk/src/zope/index/keyword/index.py
===================================================================
--- Zope3/trunk/src/zope/index/keyword/index.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/index/keyword/index.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -62,7 +62,7 @@
def index_doc(self, docid, seq):
if not isinstance(seq, (TupleType, ListType)):
- raise TypeError, 'seq argument must be a list/tuple of strings'
+ raise TypeError('seq argument must be a list/tuple of strings')
if not seq: return
if self.normalize:
@@ -125,7 +125,7 @@
if isinstance(query, StringTypes): query = [query]
if not isinstance(query, (TupleType, ListType)):
- raise TypeError, 'query argument must be a list/tuple of strings'
+ raise TypeError('query argument must be a list/tuple of strings')
if self.normalize:
query = [w.lower() for w in query]
Modified: Zope3/trunk/src/zope/index/text/parsetree.py
===================================================================
--- Zope3/trunk/src/zope/index/text/parsetree.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/index/text/parsetree.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -64,7 +64,7 @@
return []
def executeQuery(self, index):
- raise QueryError, "NOT parse tree node cannot be executed directly"
+ raise QueryError("NOT parse tree node cannot be executed directly")
class AndNode(ParseTreeNode):
Modified: Zope3/trunk/src/zope/index/text/queryparser.py
===================================================================
--- Zope3/trunk/src/zope/index/text/queryparser.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/index/text/queryparser.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -143,7 +143,7 @@
if not self._check(tokentype):
t = self._tokens[self._index]
msg = "Token %r required, %r found" % (tokentype, t)
- raise parsetree.ParseError, msg
+ raise parsetree.ParseError(msg)
def _check(self, tokentype):
if self._tokentypes[self._index] is tokentype:
Modified: Zope3/trunk/src/zope/index/text/ricecode.py
===================================================================
--- Zope3/trunk/src/zope/index/text/ricecode.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/index/text/ricecode.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -86,7 +86,7 @@
def __init__(self, m):
"""Constructor a RiceCode for m-bit values."""
if not (0 <= m <= 16):
- raise ValueError, "m must be between 0 and 16"
+ raise ValueError("m must be between 0 and 16")
self.init(m)
self.bits = BitArray()
self.len = 0
@@ -99,7 +99,7 @@
def append(self, val):
"""Append an item to the list."""
if val < 1:
- raise ValueError, "value >= 1 expected, got %s" % `val`
+ raise ValueError("value >= 1 expected, got %s" % `val`)
val -= 1
# emit the unary part of the code
q = val >> self.m
Modified: Zope3/trunk/src/zope/index/topic/index.py
===================================================================
--- Zope3/trunk/src/zope/index/topic/index.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/index/topic/index.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -61,7 +61,7 @@
if isinstance(query, StringTypes): query = [query]
if not isinstance(query, (TupleType, ListType)):
- raise TypeError, 'query argument must be a list/tuple of filter ids'
+ raise TypeError('query argument must be a list/tuple of filter ids')
f = {'and' : intersection, 'or' : union}[operator]
Modified: Zope3/trunk/src/zope/interface/adapter.py
===================================================================
--- Zope3/trunk/src/zope/interface/adapter.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/interface/adapter.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -274,8 +274,8 @@
def _subscriptionAdaptTo(self, specification, object, with=()):
if object is None:
- raise TypeError, ("Unregistering subscription adapters"
- " isn't implemented")
+ raise TypeError("Unregistering subscription adapters isn't "
+ "implemented")
key = (True, tuple(with), '', specification)
self.adapters[key] = self.adapters.get(key, ()) + (object, )
Modified: Zope3/trunk/src/zope/interface/declarations.py
===================================================================
--- Zope3/trunk/src/zope/interface/declarations.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/interface/declarations.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -688,7 +688,7 @@
# being called on the same class that we were defined for:
return self
- raise AttributeError, '__provides__'
+ raise AttributeError('__provides__')
ProvidesClass = Provides
@@ -951,7 +951,7 @@
return self._implements
- raise AttributeError, '__provides__'
+ raise AttributeError('__provides__')
ClassProvidesBase = ClassProvidesBasePy
Modified: Zope3/trunk/src/zope/interface/interface.py
===================================================================
--- Zope3/trunk/src/zope/interface/interface.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/interface/interface.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -438,7 +438,7 @@
for base in bases:
if not isinstance(base, InterfaceClass):
- raise TypeError, 'Expected base interfaces'
+ raise TypeError('Expected base interfaces')
Specification.__init__(self, bases)
@@ -526,7 +526,7 @@
if r is not None:
return r
- raise KeyError, name
+ raise KeyError(name)
__getitem__ = getDescriptionFor
Modified: Zope3/trunk/src/zope/interface/tests/odd.py
===================================================================
--- Zope3/trunk/src/zope/interface/tests/odd.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/interface/tests/odd.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -92,7 +92,7 @@
v = getattr(b, name, self)
if v is not self:
return v
- raise AttributeError, name
+ raise AttributeError(name)
def __repr__(self):
return "<odd class %s at %s>" % (self.__name__, hex(id(self)))
Modified: Zope3/trunk/src/zope/pagetemplate/tests/batch.py
===================================================================
--- Zope3/trunk/src/zope/pagetemplate/tests/batch.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/pagetemplate/tests/batch.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -85,7 +85,7 @@
else: return 1
def __getitem__(self, index):
- if index > self._last: raise IndexError, index
+ if index > self._last: raise IndexError(index)
return self._sequence[index+self._first]
def opt(start,end,size,orphan,sequence):
Modified: Zope3/trunk/src/zope/pagetemplate/tests/util.py
===================================================================
--- Zope3/trunk/src/zope/pagetemplate/tests/util.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/pagetemplate/tests/util.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -31,12 +31,12 @@
def __len__(self): return 7
def __getitem__(self,index):
if ininstance(index, int) and (index < 0 or index > 6):
- raise IndexError, index
+ raise IndexError(index)
return self
isDocTemp = 0
def __getattr__(self,name):
if name.startswith('_'):
- raise AttributeError, name
+ raise AttributeError(name)
return self
bruce = Bruce()
Modified: Zope3/trunk/src/zope/publisher/base.py
===================================================================
--- Zope3/trunk/src/zope/publisher/base.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/publisher/base.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -145,7 +145,7 @@
return self.__gettr_class(request)
def __set__(*args):
- raise AttributeError, 'Unassignable attribute'
+ raise AttributeError('Unassignable attribute')
class RequestEnvironment(RequestDataMapper):
@@ -362,7 +362,7 @@
'See Interface.Common.Mapping.IReadMapping'
result = self.get(key, _marker)
if result is _marker:
- raise KeyError, key
+ raise KeyError(key)
else:
return result
@@ -467,7 +467,7 @@
def traverseName(self, request, ob, name, check_auth=1):
if name.startswith('_'):
- raise Unauthorized, name
+ raise Unauthorized(name)
if hasattr(ob, name):
subob = getattr(ob, name)
else:
Modified: Zope3/trunk/src/zope/publisher/browser.py
===================================================================
--- Zope3/trunk/src/zope/publisher/browser.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/publisher/browser.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -66,7 +66,7 @@
def field2required(v):
v = field2string(v)
if not v.strip():
- raise ValueError, 'No input for required field<p>'
+ raise ValueError('No input for required field<p>')
return v
def field2int(v):
@@ -74,25 +74,24 @@
return map(field2int, v)
v = field2string(v)
if not v:
- raise ValueError, 'Empty entry when <strong>integer</strong> expected'
+ raise ValueError('Empty entry when <strong>integer</strong> expected')
try:
return int(v)
except ValueError:
- raise ValueError, "An integer was expected in the value '%s'" % v
+ raise ValueError("An integer was expected in the value '%s'" % v)
def field2float(v):
if isinstance(v, __ArrayTypes):
return map(field2float, v)
v = field2string(v)
if not v:
- raise ValueError, (
+ raise ValueError(
'Empty entry when <strong>floating-point number</strong> expected')
try:
return float(v)
except ValueError:
- raise ValueError, (
- "A floating-point number was expected in the value '%s'" % v
- )
+ raise ValueError(
+ "A floating-point number was expected in the value '%s'" % v)
def field2long(v):
if isinstance(v, __ArrayTypes):
@@ -103,11 +102,11 @@
if v and v[-1].upper() == 'L':
v = v[:-1]
if not v:
- raise ValueError, 'Empty entry when <strong>integer</strong> expected'
+ raise ValueError('Empty entry when <strong>integer</strong> expected')
try:
return long(v)
except ValueError:
- raise ValueError, "A long integer was expected in the value '%s'" % v
+ raise ValueError("A long integer was expected in the value '%s'" % v)
def field2tokens(v):
return field2string(v).split()
@@ -143,7 +142,7 @@
existing = type_converters.get(field_type)
if existing is not None and not replace:
- raise KeyError, 'Existing converter for field_type: %s' % field_type
+ raise KeyError('Existing converter for field_type: %s' % field_type)
type_converters[field_type] = converter
@@ -182,7 +181,7 @@
if key in ('get', 'keys', 'items', 'values', 'copy',
'has_key', '__contains__'):
return getattr(self.__dict__, key)
- raise AttributeError, key
+ raise AttributeError(key)
def __getitem__(self, key):
return self.__dict__[key]
Modified: Zope3/trunk/src/zope/publisher/http.py
===================================================================
--- Zope3/trunk/src/zope/publisher/http.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/publisher/http.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -151,7 +151,7 @@
def __getitem__(self, name):
url = self.get(name, None)
if url is None:
- raise KeyError, name
+ raise KeyError(name)
return url
def get(self, name, default=None):
@@ -450,7 +450,7 @@
names = self._app_names + self._traversed_names
if level:
if level > len(names):
- raise IndexError, level
+ raise IndexError(level)
names = names[:-level]
# See: http://www.ietf.org/rfc/rfc2718.txt, Section 2.2.5
names = [quote(name.encode("utf-8"), safe='/+@') for name in names]
@@ -469,7 +469,7 @@
if depth:
names = self._traversed_names
if depth > len(names):
- raise IndexError, depth
+ raise IndexError(depth)
names = self._app_names + names[:depth]
else:
names = self._app_names
Modified: Zope3/trunk/src/zope/publisher/publish.py
===================================================================
--- Zope3/trunk/src/zope/publisher/publish.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/publisher/publish.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -37,7 +37,7 @@
for i in range(10):
bases = getattr(unwrapped, '__bases__', None)
if bases is not None:
- raise TypeError, "mapply() can not call class constructors"
+ raise TypeError("mapply() can not call class constructors")
im_func = getattr(unwrapped, 'im_func', None)
if im_func is not None:
@@ -53,7 +53,7 @@
if __call__ is not None:
unwrapped = unwrapped.__call__
else:
- raise TypeError, "mapply() can not call %s" % `object`
+ raise TypeError("mapply() can not call %s" % `object`)
else:
raise TypeError(
@@ -82,7 +82,7 @@
given = len(args)
if wrapperCount:
given = given + wrapperCount
- raise TypeError, (
+ raise TypeError(
'%s() takes at most %d argument%s(%d given)' % (
getattr(unwrapped, '__name__', repr(object)), code.co_argcount,
(code.co_argcount > 1 and 's ' or ' '), given))
@@ -101,8 +101,8 @@
if name == 'REQUEST':
v = request
elif index < nrequired:
- raise TypeError, 'Missing argument to %s(): %s' % (
- getattr(unwrapped, '__name__', repr(object)), name)
+ raise TypeError('Missing argument to %s(): %s' % (
+ getattr(unwrapped, '__name__', repr(object)), name))
else:
v = defaults[index-nrequired]
args.append(v)
Modified: Zope3/trunk/src/zope/publisher/tests/test_ipublication.py
===================================================================
--- Zope3/trunk/src/zope/publisher/tests/test_ipublication.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/publisher/tests/test_ipublication.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -89,7 +89,7 @@
def test_handleException(self):
try:
- raise ValueError, 1
+ raise ValueError(1)
except:
exc_info = sys.exc_info()
Modified: Zope3/trunk/src/zope/publisher/tests/test_requestdataproperty.py
===================================================================
--- Zope3/trunk/src/zope/publisher/tests/test_requestdataproperty.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/publisher/tests/test_requestdataproperty.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -36,7 +36,7 @@
if default is not _marker:
return default
- raise KeyError, name
+ raise KeyError(name)
something = RequestDataProperty(TestDataGettr)
somedata = RequestDataProperty(TestDataMapper)
Modified: Zope3/trunk/src/zope/schema/_field.py
===================================================================
--- Zope3/trunk/src/zope/schema/_field.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/schema/_field.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -261,7 +261,7 @@
except VocabularyRegistryError:
raise ValueError("Can't validate value without vocabulary")
if value not in vocabulary:
- raise ConstraintNotSatisfied, value
+ raise ConstraintNotSatisfied(value)
class InterfaceField(Field):
__doc__ = IInterfaceField.__doc__
@@ -317,7 +317,7 @@
temp_values = []
for item in value:
if item in temp_values:
- raise NotUnique, item
+ raise NotUnique(item)
temp_values.append(item)
@@ -329,7 +329,7 @@
super(AbstractCollection, self).__init__(**kw)
# whine if value_type is not a field
if value_type is not None and not IField.providedBy(value_type):
- raise ValueError, "'value_type' must be field instance."
+ raise ValueError("'value_type' must be field instance.")
self.value_type = value_type
self.unique = unique
@@ -346,7 +346,7 @@
super(AbstractCollection, self)._validate(value)
errors = _validate_sequence(self.value_type, value)
if errors:
- raise WrongContainedType, errors
+ raise WrongContainedType(errors)
if self.unique:
_validate_uniqueness(value)
@@ -423,9 +423,9 @@
super(Dict, self).__init__(**kw)
# whine if key_type or value_type is not a field
if key_type is not None and not IField.providedBy(key_type):
- raise ValueError, "'key_type' must be field instance."
+ raise ValueError("'key_type' must be field instance.")
if value_type is not None and not IField.providedBy(value_type):
- raise ValueError, "'value_type' must be field instance."
+ raise ValueError("'value_type' must be field instance.")
self.key_type = key_type
self.value_type = value_type
@@ -439,7 +439,7 @@
errors = _validate_sequence(self.key_type, value, errors)
if errors:
- raise WrongContainedType, errors
+ raise WrongContainedType(errors)
finally:
errors = None
@@ -470,7 +470,7 @@
if _isuri(value):
return
- raise InvalidURI, value
+ raise InvalidURI(value)
def fromUnicode(self, value):
"""
@@ -525,7 +525,7 @@
if _isdotted(value) and "." in value:
return
- raise InvalidId, value
+ raise InvalidId(value)
def fromUnicode(self, value):
"""
@@ -642,12 +642,11 @@
raise InvalidDottedName(value)
dots = value.count(".")
if dots < self.min_dots:
- raise InvalidDottedName, \
- ("too few dots; %d required" % self.min_dots, value)
+ raise InvalidDottedName("too few dots; %d required" % self.min_dots,
+ value)
if self.max_dots is not None and dots > self.max_dots:
- raise InvalidDottedName, \
- ("too many dots; no more than %d allowed" % self.max_dots,
- value)
+ raise InvalidDottedName("too many dots; no more than %d allowed" %
+ self.max_dots, value)
def fromUnicode(self, value):
v = str(value.strip())
Modified: Zope3/trunk/src/zope/schema/fieldproperty.py
===================================================================
--- Zope3/trunk/src/zope/schema/fieldproperty.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/schema/fieldproperty.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -43,7 +43,7 @@
field = self.__field.bind(inst)
value = getattr(field, 'default', _marker)
if value is _marker:
- raise AttributeError, self.__name
+ raise AttributeError(self.__name)
return value
Modified: Zope3/trunk/src/zope/security/checker.py
===================================================================
--- Zope3/trunk/src/zope/security/checker.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/security/checker.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -172,7 +172,7 @@
raise Unauthorized(object, name, permission)
__traceback_supplement__ = (TracebackSupplement, object)
- raise ForbiddenAttribute, (name, object)
+ raise ForbiddenAttribute(name, object)
def check(self, object, name):
'See IChecker'
@@ -190,7 +190,7 @@
if name != '__iter__' or hasattr(object, name):
__traceback_supplement__ = (TracebackSupplement, object)
- raise ForbiddenAttribute, (name, object)
+ raise ForbiddenAttribute(name, object)
def proxy(self, value):
'See IChecker'
Modified: Zope3/trunk/src/zope/security/untrustedpython/builtins.py
===================================================================
--- Zope3/trunk/src/zope/security/untrustedpython/builtins.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/security/untrustedpython/builtins.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -117,10 +117,10 @@
self.__dict__.update(kw)
def __setattr__(self, name, v):
- raise AttributeError, name
+ raise AttributeError(name)
def __delattr__(self, name):
- raise AttributeError, name
+ raise AttributeError(name)
SafeBuiltins = ImmutableModule(**SafeBuiltins())
Modified: Zope3/trunk/src/zope/server/buffers.py
===================================================================
--- Zope3/trunk/src/zope/server/buffers.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/server/buffers.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -75,9 +75,8 @@
def skip(self, bytes, allow_prune=0):
if self.remain < bytes:
- raise ValueError, (
- "Can't skip %d bytes in buffer of %d bytes" %
- (bytes, self.remain))
+ raise ValueError("Can't skip %d bytes in buffer of %d bytes" % (
+ bytes, self.remain))
self.file.seek(bytes, 1)
self.remain = self.remain - bytes
Modified: Zope3/trunk/src/zope/server/ftp/publisher.py
===================================================================
--- Zope3/trunk/src/zope/server/ftp/publisher.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/server/ftp/publisher.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -128,7 +128,7 @@
dump anything into it."""
def write(self, data):
- raise RuntimeError, "Not a writable stream"
+ raise RuntimeError("Not a writable stream")
def flush(self):
pass
Modified: Zope3/trunk/src/zope/server/ftp/server.py
===================================================================
--- Zope3/trunk/src/zope/server/ftp/server.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/server/ftp/server.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -896,7 +896,7 @@
def write(self, data):
if self.control_channel is None:
- raise IOError, 'Client FTP connection closed'
+ raise IOError('Client FTP connection closed')
if not self.opened:
self._open()
FTPDataChannel.write(self, data)
Modified: Zope3/trunk/src/zope/server/http/httprequestparser.py
===================================================================
--- Zope3/trunk/src/zope/server/http/httprequestparser.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/server/http/httprequestparser.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -196,7 +196,7 @@
def split_uri(self):
m = self.path_regex.match (self.uri)
if m.end() != len(self.uri):
- raise ValueError, "Broken URI"
+ raise ValueError("Broken URI")
else:
path, query, self.fragment = m.groups()
if path and '%' in path:
Modified: Zope3/trunk/src/zope/server/http/tests/test_httprequestparser.py
===================================================================
--- Zope3/trunk/src/zope/server/http/tests/test_httprequestparser.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/server/http/tests/test_httprequestparser.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -34,7 +34,7 @@
data = data[consumed:]
if parser.completed:
return
- raise ValueError, 'Looping'
+ raise ValueError('Looping')
def testSimpleGET(self):
data = """\
Modified: Zope3/trunk/src/zope/server/serverchannelbase.py
===================================================================
--- Zope3/trunk/src/zope/server/serverchannelbase.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/server/serverchannelbase.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -149,7 +149,7 @@
"""
t, v = sys.exc_info()[:2]
if t is SystemExit or t is KeyboardInterrupt:
- raise t, v
+ raise t(v)
asyncore.dispatcher.handle_error(self)
def handle_comm_error(self):
Modified: Zope3/trunk/src/zope/server/taskthreads.py
===================================================================
--- Zope3/trunk/src/zope/server/taskthreads.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/server/taskthreads.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -87,7 +87,7 @@
def addTask(self, task):
"""See zope.server.interfaces.ITaskDispatcher"""
if task is None:
- raise ValueError, "No task passed to addTask()."
+ raise ValueError("No task passed to addTask().")
# assert ITask.providedBy(task)
try:
task.defer()
Modified: Zope3/trunk/src/zope/server/trigger.py
===================================================================
--- Zope3/trunk/src/zope/server/trigger.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/server/trigger.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -152,7 +152,7 @@
else:
break
else:
- raise RuntimeError, 'Cannot bind trigger!'
+ raise RuntimeError('Cannot bind trigger!')
a.listen(1)
w.setblocking(0)
Modified: Zope3/trunk/src/zope/tal/ndiff.py
===================================================================
--- Zope3/trunk/src/zope/tal/ndiff.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/tal/ndiff.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -514,7 +514,7 @@
atags = atags + ' ' * la
btags = btags + ' ' * lb
else:
- raise ValueError, 'unknown tag ' + `tag`
+ raise ValueError('unknown tag ' + `tag`)
printq(aelt, belt, atags, btags)
else:
# the synch pair is identical
@@ -588,7 +588,7 @@
elif tag == 'equal':
dump(' ', a, alo, ahi)
else:
- raise ValueError, 'unknown tag ' + `tag`
+ raise ValueError('unknown tag ' + `tag`)
return 1
Modified: Zope3/trunk/src/zope/tal/talinterpreter.py
===================================================================
--- Zope3/trunk/src/zope/tal/talinterpreter.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/tal/talinterpreter.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -1026,4 +1026,4 @@
def _write_ValueError(s):
- raise ValueError, "I/O operation on closed file"
+ raise ValueError("I/O operation on closed file")
Modified: Zope3/trunk/src/zope/tales/expressions.py
===================================================================
--- Zope3/trunk/src/zope/tales/expressions.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/tales/expressions.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -37,7 +37,7 @@
elif hasattr(object, '__getitem__'):
object = object[name]
else:
- raise NameError, name
+ raise NameError(name)
return object
Modified: Zope3/trunk/src/zope/tales/tales.py
===================================================================
--- Zope3/trunk/src/zope/tales/tales.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/tales/tales.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -560,13 +560,11 @@
def registerType(self, name, handler):
if not _valid_name(name):
- raise RegistrationError, (
- 'Invalid expression type name "%s".' % name)
+ raise RegistrationError('Invalid expression type name "%s".' % name)
types = self.types
if name in types:
- raise RegistrationError, (
- 'Multiple registrations for Expression type "%s".' %
- name)
+ raise RegistrationError(
+ 'Multiple registrations for Expression type "%s".' % name)
types[name] = handler
def getTypes(self):
@@ -574,10 +572,10 @@
def registerBaseName(self, name, object):
if not _valid_name(name):
- raise RegistrationError, 'Invalid base name "%s".' % name
+ raise RegistrationError('Invalid base name "%s".' % name)
base_names = self.base_names
if name in base_names:
- raise RegistrationError, (
+ raise RegistrationError(
'Multiple registrations for base name "%s".' % name)
base_names[name] = object
@@ -595,8 +593,7 @@
try:
handler = self.types[type]
except KeyError:
- raise CompilerError, (
- 'Unrecognized expression type "%s".' % type)
+ raise CompilerError('Unrecognized expression type "%s".' % type)
return handler(type, expr, self)
def getContext(self, contexts=None, **kwcontexts):
Modified: Zope3/trunk/src/zope/wfmc/xpdl.py
===================================================================
--- Zope3/trunk/src/zope/wfmc/xpdl.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/wfmc/xpdl.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -76,9 +76,8 @@
try:
result = handler(self, attrs)
except:
- raise HandlerError, (
- sys.exc_info()[1], name[1], self.locator
- ), sys.exc_info()[2]
+ raise HandlerError(sys.exc_info()[1], name[1], self.locator
+ ), None, sys.exc_info()[2]
else:
result = None
@@ -96,9 +95,8 @@
try:
handler(self, last)
except:
- raise HandlerError, (
- sys.exc_info()[1], name[1], self.locator
- ), sys.exc_info()[2]
+ raise HandlerError(sys.exc_info()[1], name[1], self.locator
+ ), None, sys.exc_info()[2]
self.text = u''
Modified: Zope3/trunk/src/zope/xmlpickle/ppml.py
===================================================================
--- Zope3/trunk/src/zope/xmlpickle/ppml.py 2005-08-30 21:36:02 UTC (rev 38177)
+++ Zope3/trunk/src/zope/xmlpickle/ppml.py 2005-08-30 21:50:19 UTC (rev 38178)
@@ -284,7 +284,7 @@
class Collection(Base):
def value(self, write, indent):
- raise AttributeError, 'value'
+ raise AttributeError('value')
def output(self, write, indent=0):
if self.id:
More information about the Zope3-Checkins
mailing list