Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
ecc18276
Commit
ecc18276
authored
Sep 12, 2016
by
Hanno Schlichting
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid bare except's.
parent
ca5312b4
Changes
35
Hide whitespace changes
Inline
Side-by-side
Showing
35 changed files
with
51 additions
and
58 deletions
+51
-58
src/App/Extensions.py
src/App/Extensions.py
+2
-2
src/App/ImageFile.py
src/App/ImageFile.py
+1
-1
src/OFS/DTMLDocument.py
src/OFS/DTMLDocument.py
+1
-1
src/OFS/DTMLMethod.py
src/OFS/DTMLMethod.py
+1
-1
src/OFS/Lockable.py
src/OFS/Lockable.py
+1
-1
src/OFS/ObjectManager.py
src/OFS/ObjectManager.py
+3
-3
src/OFS/SimpleItem.py
src/OFS/SimpleItem.py
+5
-5
src/OFS/Traversable.py
src/OFS/Traversable.py
+1
-1
src/OFS/role.py
src/OFS/role.py
+2
-2
src/OFS/subscribers.py
src/OFS/subscribers.py
+1
-1
src/OFS/tests/testAcquisition.py
src/OFS/tests/testAcquisition.py
+1
-1
src/OFS/tests/testCopySupport.py
src/OFS/tests/testCopySupport.py
+1
-1
src/OFS/tests/testCopySupportEvents.py
src/OFS/tests/testCopySupportEvents.py
+1
-1
src/OFS/tests/testCopySupportHooks.py
src/OFS/tests/testCopySupportHooks.py
+1
-1
src/OFS/tests/testFileAndImage.py
src/OFS/tests/testFileAndImage.py
+2
-6
src/OFS/tests/testRanges.py
src/OFS/tests/testRanges.py
+1
-1
src/OFS/tests/testSimpleItem.py
src/OFS/tests/testSimpleItem.py
+1
-1
src/OFS/userfolder.py
src/OFS/userfolder.py
+2
-2
src/Products/Five/browser/metaconfigure.py
src/Products/Five/browser/metaconfigure.py
+1
-1
src/Products/PageTemplates/PageTemplate.py
src/Products/PageTemplates/PageTemplate.py
+2
-2
src/Products/PageTemplates/PageTemplateFile.py
src/Products/PageTemplates/PageTemplateFile.py
+1
-1
src/Products/PageTemplates/ZopePageTemplate.py
src/Products/PageTemplates/ZopePageTemplate.py
+1
-1
src/Products/PageTemplates/unicodeconflictresolver.py
src/Products/PageTemplates/unicodeconflictresolver.py
+1
-1
src/Testing/ZopeTestCase/PortalTestCase.py
src/Testing/ZopeTestCase/PortalTestCase.py
+1
-1
src/Testing/ZopeTestCase/ZopeTestCase.py
src/Testing/ZopeTestCase/ZopeTestCase.py
+1
-1
src/Testing/ZopeTestCase/base.py
src/Testing/ZopeTestCase/base.py
+2
-2
src/Testing/ZopeTestCase/testBaseTestCase.py
src/Testing/ZopeTestCase/testBaseTestCase.py
+2
-2
src/Testing/ZopeTestCase/testPortalTestCase.py
src/Testing/ZopeTestCase/testPortalTestCase.py
+1
-1
src/ZPublisher/HTTPRequest.py
src/ZPublisher/HTTPRequest.py
+2
-2
src/ZPublisher/HTTPResponse.py
src/ZPublisher/HTTPResponse.py
+1
-1
src/Zope2/App/ClassFactory.py
src/Zope2/App/ClassFactory.py
+1
-1
src/Zope2/App/startup.py
src/Zope2/App/startup.py
+1
-1
src/Zope2/Startup/starter.py
src/Zope2/Startup/starter.py
+2
-2
src/Zope2/utilities/copyzopeskel.py
src/Zope2/utilities/copyzopeskel.py
+2
-2
src/Zope2/utilities/mkwsgiinstance.py
src/Zope2/utilities/mkwsgiinstance.py
+1
-4
No files found.
src/App/Extensions.py
View file @
ecc18276
...
...
@@ -35,7 +35,7 @@ class FuncCode:
try
:
return
cmp
((
self
.
co_argcount
,
self
.
co_varnames
),
(
other
.
co_argcount
,
other
.
co_varnames
))
except
:
except
Exception
:
return
1
...
...
@@ -182,7 +182,7 @@ def getObject(module, name, reload=0,
else
:
try
:
execsrc
=
open
(
path
)
except
:
except
Exception
:
raise
NotFound
(
"The specified module, '%s', "
"couldn't be opened."
%
module
)
module_dict
=
{}
...
...
src/App/ImageFile.py
View file @
ecc18276
...
...
@@ -107,7 +107,7 @@ class ImageFile(Explicit):
# of the way they parse it).
try
:
mod_since
=
int
(
DateTime
(
header
).
timeTime
())
except
:
except
Exception
:
mod_since
=
None
if
mod_since
is
not
None
:
if
getattr
(
self
,
'lmt'
,
None
):
...
...
src/OFS/DTMLDocument.py
View file @
ecc18276
...
...
@@ -146,7 +146,7 @@ def addDTMLDocument(self, id, title='', file='', REQUEST=None, submit=None):
if
REQUEST
is
not
None
:
try
:
u
=
self
.
DestinationURL
()
except
:
except
Exception
:
u
=
REQUEST
[
'URL1'
]
if
submit
==
" Add and Edit "
:
u
=
"%s/%s"
%
(
u
,
quote
(
id
))
...
...
src/OFS/DTMLMethod.py
View file @
ecc18276
...
...
@@ -306,7 +306,7 @@ def addDTMLMethod(self, id, title='', file='', REQUEST=None, submit=None):
if REQUEST is not None:
try:
u = self.DestinationURL()
except:
except
Exception
:
u = REQUEST['URL1']
if submit == "
Add
and
Edit
":
u = "
%
s
/%
s
" % (u, quote(id))
...
...
src/OFS/Lockable.py
View file @
ecc18276
...
...
@@ -118,7 +118,7 @@ class LockableItem(EtagSupport):
try
:
locks
=
self
.
wl_lockmapping
()
locks
.
clear
()
except
:
except
Exception
:
# The locks may be totally messed up, so we'll just delete
# and replace.
if
hasattr
(
self
,
'_dav_writelocks'
):
...
...
src/OFS/ObjectManager.py
View file @
ecc18276
...
...
@@ -396,7 +396,7 @@ class ObjectManager(CopyContainer,
# on Broken objects.
try
:
ob
.
_v__object_deleted__
=
1
except
:
except
Exception
:
pass
if
not
suppress_events
:
...
...
@@ -524,7 +524,7 @@ class ObjectManager(CopyContainer,
raise
BadRequest
(
'No items specified'
)
try
:
p
=
self
.
_reserved_names
except
:
except
Exception
:
p
=
()
for
n
in
ids
:
if
n
in
p
:
...
...
@@ -645,7 +645,7 @@ class ObjectManager(CopyContainer,
# the error.
try
:
stat
=
marshal
.
loads
(
v
.
manage_FTPstat
(
REQUEST
))
except
:
except
Exception
:
LOG
.
error
(
"Failed to stat file '%s'"
%
k
,
exc_info
=
sys
.
exc_info
())
stat
=
None
...
...
src/OFS/SimpleItem.py
View file @
ecc18276
...
...
@@ -202,7 +202,7 @@ class Item(Base,
if
not
error_message
:
try
:
s
=
ustr
(
error_value
)
except
:
except
Exception
:
s
=
error_value
try
:
match
=
tagSearch
(
s
)
...
...
@@ -236,14 +236,14 @@ class Item(Base,
v
=
s
(
**
kwargs
)
else
:
v
=
HTML
.
__call__
(
s
,
client
,
REQUEST
,
**
kwargs
)
except
:
except
Exception
:
logger
.
error
(
'Exception while rendering an error message'
,
exc_info
=
True
)
try
:
strv
=
repr
(
error_value
)
# quotes tainted strings
except
:
except
Exception
:
strv
=
(
'<unprintable %s object>'
%
str
(
type
(
error_value
).
__name__
))
v
=
strv
+
(
...
...
@@ -360,7 +360,7 @@ class Item(Base,
"""
try
:
path
=
'/'
.
join
(
self
.
getPhysicalPath
())
except
:
except
Exception
:
return
Base
.
__repr__
(
self
)
context_path
=
None
context
=
aq_parent
(
self
)
...
...
@@ -368,7 +368,7 @@ class Item(Base,
if
aq_base
(
context
)
is
not
aq_base
(
container
):
try
:
context_path
=
'/'
.
join
(
context
.
getPhysicalPath
())
except
:
except
Exception
:
context_path
=
None
res
=
'<%s'
%
self
.
__class__
.
__name__
res
+=
' at %s'
%
path
...
...
src/OFS/Traversable.py
View file @
ecc18276
...
...
@@ -346,7 +346,7 @@ class Traversable:
except
ConflictError
:
raise
except
:
except
Exception
:
if
default
is
not
_marker
:
return
default
else
:
...
...
src/OFS/role.py
View file @
ecc18276
...
...
@@ -118,7 +118,7 @@ class RoleManager(BaseRoleManager):
if
not
have
(
'acquire_%s'
%
permission_hash
):
roles
=
tuple
(
roles
)
p
.
setRoles
(
roles
)
except
:
except
Exception
:
fails
.
append
(
name
)
if
fails
:
...
...
@@ -196,7 +196,7 @@ class RoleManager(BaseRoleManager):
for
role
in
roles
:
try
:
data
.
remove
(
role
)
except
:
except
Exception
:
pass
self
.
__ac_roles__
=
tuple
(
data
)
if
REQUEST
is
not
None
:
...
...
src/OFS/subscribers.py
View file @
ecc18276
...
...
@@ -163,7 +163,7 @@ def callManageBeforeDelete(ob, item, container):
raise
except
ConflictError
:
raise
except
:
except
Exception
:
LOG
.
error
(
'_delObject() threw'
,
exc_info
=
True
)
# In debug mode when non-Manager, let exceptions propagate.
if
getConfiguration
().
debug_mode
:
...
...
src/OFS/tests/testAcquisition.py
View file @
ecc18276
...
...
@@ -80,7 +80,7 @@ class TestGetAttr(unittest.TestCase):
self
.
folder
.
_setObject
(
'denied'
,
DeniedItem
())
self
.
folder
.
_setObject
(
'protected'
,
ProtectedItem
())
except
:
except
Exception
:
self
.
tearDown
()
raise
...
...
src/OFS/tests/testCopySupport.py
View file @
ecc18276
...
...
@@ -76,7 +76,7 @@ class CopySupportTestBase(unittest.TestCase):
# has one. We use a subtransaction, which means we can rollback
# later and pretend we didn't touch the ZODB.
transaction
.
commit
()
except
:
except
Exception
:
self
.
connection
.
close
()
raise
transaction
.
begin
()
...
...
src/OFS/tests/testCopySupportEvents.py
View file @
ecc18276
...
...
@@ -84,7 +84,7 @@ class EventTest(unittest.TestCase):
uf
.
_doAddUser
(
'manager'
,
'secret'
,
[
'Manager'
],
[])
user
=
uf
.
getUserById
(
'manager'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
except
:
except
Exception
:
self
.
tearDown
()
raise
...
...
src/OFS/tests/testCopySupportHooks.py
View file @
ecc18276
...
...
@@ -94,7 +94,7 @@ class HookTest(unittest.TestCase):
uf
.
_doAddUser
(
'manager'
,
'secret'
,
[
'Manager'
],
[])
user
=
uf
.
getUserById
(
'manager'
).
__of__
(
uf
)
newSecurityManager
(
None
,
user
)
except
:
except
Exception
:
self
.
tearDown
()
raise
...
...
src/OFS/tests/testFileAndImage.py
View file @
ecc18276
...
...
@@ -24,11 +24,7 @@ from zope.component import adapter
from
zope.lifecycleevent.interfaces
import
IObjectModifiedEvent
from
zope.lifecycleevent.interfaces
import
IObjectCreatedEvent
try
:
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
except
:
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
sys
.
argv
[
0
]))
here
=
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
))
imagedata
=
os
.
path
.
join
(
here
,
'test.gif'
)
filedata
=
os
.
path
.
join
(
here
,
'test.gif'
)
...
...
@@ -107,7 +103,7 @@ class FileTests(unittest.TestCase):
# Hack, we need a _p_mtime for the file, so we make sure that it
# has one.
transaction
.
commit
()
except
:
except
Exception
:
self
.
connection
.
close
()
raise
transaction
.
begin
()
...
...
src/OFS/tests/testRanges.py
View file @
ecc18276
...
...
@@ -78,7 +78,7 @@ class TestRequestRange(unittest.TestCase):
# has one. We use a subtransaction, which means we can rollback
# later and pretend we didn't touch the ZODB.
transaction
.
commit
()
except
:
except
Exception
:
self
.
connection
.
close
()
raise
...
...
src/OFS/tests/testSimpleItem.py
View file @
ecc18276
...
...
@@ -111,7 +111,7 @@ class TestSimpleItem(unittest.TestCase):
try
:
raise
BadRequest
(
"1"
)
except
:
except
Exception
:
item
.
raise_standardErrorMessage
(
client
=
item
,
REQUEST
=
REQUEST
())
...
...
src/OFS/userfolder.py
View file @
ecc18276
...
...
@@ -241,7 +241,7 @@ class BasicUserFolder(Navigation, Tabs, Item, RoleManager,
if
item
is
self
:
try
:
del
container
.
__allow_groups__
except
:
except
Exception
:
pass
def
manage_afterAdd
(
self
,
item
,
container
):
...
...
@@ -290,7 +290,7 @@ class UserFolder(accesscontrol_userfolder.UserFolder, BasicUserFolder):
cfg
=
App
.
config
.
getConfiguration
()
try
:
os
.
remove
(
os
.
path
.
join
(
cfg
.
instancehome
,
'inituser'
))
except
:
except
Exception
:
pass
InitializeClass
(
UserFolder
)
...
...
src/Products/Five/browser/metaconfigure.py
View file @
ecc18276
...
...
@@ -278,7 +278,7 @@ class view(zope.browserpage.metaconfigure.view):
try
:
cname
=
str
(
name
)
except
:
except
Exception
:
cname
=
"GeneratedClass"
cdict
[
'__name__'
]
=
name
...
...
src/Products/PageTemplates/PageTemplate.py
View file @
ecc18276
...
...
@@ -92,7 +92,7 @@ class PageTemplate(ExtensionClass.Base,
return
err
try
:
self
.
pt_render
(
source
=
True
,
extra_context
=
namespace
)
except
:
except
Exception
:
return
(
'Macro expansion failed'
,
'%s: %s'
%
sys
.
exc_info
()[:
2
])
def
__call__
(
self
,
*
args
,
**
kwargs
):
...
...
@@ -107,7 +107,7 @@ class PageTemplate(ExtensionClass.Base,
return
self
.
_text
try
:
return
self
.
pt_render
(
source
=
True
)
except
:
except
Exception
:
return
(
'%s
\
n
Macro expansion failed
\
n
%s
\
n
-->
\
n
%s'
%
(
self
.
_error_start
,
"%s: %s"
%
sys
.
exc_info
()[:
2
],
self
.
_text
))
...
...
src/Products/PageTemplates/PageTemplateFile.py
View file @
ecc18276
...
...
@@ -154,7 +154,7 @@ class PageTemplateFile(SimpleItem, Script, PageTemplate, Traversable):
f
=
open
(
self
.
filename
,
"rb"
)
try
:
text
=
f
.
read
(
XML_PREFIX_MAX_LENGTH
)
except
:
except
Exception
:
f
.
close
()
raise
t
=
sniff_type
(
text
)
...
...
src/Products/PageTemplates/ZopePageTemplate.py
View file @
ecc18276
...
...
@@ -328,7 +328,7 @@ class ZopePageTemplate(Script, PageTemplate, Cacheable,
"""Returns a file name to be compiled into the TAL code."""
try
:
return
'/'
.
join
(
self
.
getPhysicalPath
())
except
:
except
Exception
:
# This page template is being compiled without an
# acquisition context, so we don't know where it is. :-(
return
None
...
...
src/Products/PageTemplates/unicodeconflictresolver.py
View file @
ecc18276
...
...
@@ -29,7 +29,7 @@ default_encoding = sys.getdefaultencoding()
class
DefaultUnicodeEncodingConflictResolver
(
object
):
""" This resolver implements the old-style behavior and will
raise an exception in case of the string 'text' can't be converted
proper
t
ly to unicode.
properly to unicode.
"""
implements
(
IUnicodeEncodingConflictResolver
)
...
...
src/Testing/ZopeTestCase/PortalTestCase.py
View file @
ecc18276
...
...
@@ -59,7 +59,7 @@ class PortalTestCase(base.TestCase):
self
.
portal
=
self
.
_portal
()
self
.
_setup
()
self
.
afterSetUp
()
except
:
except
Exception
:
self
.
_clear
()
raise
...
...
src/Testing/ZopeTestCase/ZopeTestCase.py
View file @
ecc18276
...
...
@@ -85,7 +85,7 @@ class ZopeTestCase(base.TestCase):
try
:
if
connections
.
contains
(
self
.
app
):
self
.
app
.
_delObject
(
folder_name
)
except
:
except
Exception
:
pass
base
.
TestCase
.
_clear
(
self
,
call_close_hook
)
...
...
src/Testing/ZopeTestCase/base.py
View file @
ecc18276
...
...
@@ -90,7 +90,7 @@ class TestCase(unittest.TestCase, object):
self
.
app
=
self
.
_app
()
self
.
_setup
()
self
.
afterSetUp
()
except
:
except
Exception
:
self
.
_clear
()
raise
...
...
@@ -101,7 +101,7 @@ class TestCase(unittest.TestCase, object):
try
:
self
.
beforeTearDown
()
self
.
_clear
(
1
)
except
:
except
Exception
:
self
.
_clear
()
raise
...
...
src/Testing/ZopeTestCase/testBaseTestCase.py
View file @
ecc18276
...
...
@@ -191,7 +191,7 @@ class TestTestCase(HookTest):
class
TestSetUpRaises
(
HookTest
):
class
Error
:
class
Error
(
Exception
)
:
pass
def
setUp
(
self
):
...
...
@@ -212,7 +212,7 @@ class TestSetUpRaises(HookTest):
class
TestTearDownRaises
(
HookTest
):
class
Error
:
class
Error
(
Exception
)
:
pass
def
tearDown
(
self
):
...
...
src/Testing/ZopeTestCase/testPortalTestCase.py
View file @
ecc18276
...
...
@@ -493,7 +493,7 @@ class HookTest(ZopeTestCase.PortalTestCase):
class
TestSetUpRaises
(
HookTest
):
class
Error
:
class
Error
(
Exception
)
:
pass
def
getPortal
(
self
):
...
...
src/ZPublisher/HTTPRequest.py
View file @
ecc18276
...
...
@@ -678,7 +678,7 @@ class HTTPRequest(BaseRequest):
if
not
is_tainted
:
tainted
=
None
except
:
except
Exception
:
if
(
not
item
and
not
(
flags
&
DEFAULT
)
and
key
in
defaults
):
item
=
defaults
[
key
]
...
...
@@ -1605,7 +1605,7 @@ def sane_environment(env):
dict
[
'HTTP_AUTHORIZATION'
]
=
dict
[
'HTTP_CGI_AUTHORIZATION'
]
try
:
del
dict
[
'HTTP_CGI_AUTHORIZATION'
]
except
:
except
Exception
:
pass
return
dict
...
...
src/ZPublisher/HTTPResponse.py
View file @
ecc18276
...
...
@@ -876,7 +876,7 @@ class HTTPResponse(HTTPBaseResponse):
b = str(b)
except UnicodeEncodeError:
b = self._encode_unicode(unicode(b))
except:
except
Exception
:
b = '
<
unprintable
%
s
object
>
' % type(b).__name__
if fatal and t is SystemExit and v.code == 0:
...
...
src/Zope2/App/ClassFactory.py
View file @
ecc18276
...
...
@@ -18,5 +18,5 @@ def ClassFactory(jar, module, name, _silly=('__doc__',), _globals={}):
try
:
m
=
__import__
(
module
,
_globals
,
_globals
,
_silly
)
return
getattr
(
m
,
name
)
except
:
except
Exception
:
return
OFS
.
Uninstalled
.
Broken
(
jar
,
None
,
(
module
,
name
))
src/Zope2/App/startup.py
View file @
ecc18276
...
...
@@ -87,7 +87,7 @@ def startup():
# Try to use custom storage
try
:
m
=
imp
.
find_module
(
'custom_zodb'
,
[
configuration
.
testinghome
])
except
:
except
Exception
:
m
=
imp
.
find_module
(
'custom_zodb'
,
[
configuration
.
instancehome
])
except
Exception
:
# if there is no custom_zodb, use the config file specified databases
...
...
src/Zope2/Startup/starter.py
View file @
ecc18276
...
...
@@ -61,7 +61,7 @@ class WSGIStarter(object):
if
locale_id
is
not
None
:
try
:
import
locale
except
:
except
Exception
:
raise
ConfigurationError
(
'The locale module could not be imported.
\
n
'
'To use localization options, you must ensure
\
n
'
...
...
@@ -69,7 +69,7 @@ class WSGIStarter(object):
'Python installation.'
)
try
:
locale
.
setlocale
(
locale
.
LC_ALL
,
locale_id
)
except
:
except
Exception
:
raise
ConfigurationError
(
'The specified locale "%s" is not supported by your'
'system.
\
n
See your operating system documentation for '
...
...
src/Zope2/utilities/copyzopeskel.py
View file @
ecc18276
...
...
@@ -110,7 +110,7 @@ def main():
sys
.
exit
(
2
)
try
:
uid
=
int
(
arg
)
except
:
except
Exception
:
try
:
import
pwd
uid
=
pwd
.
getpwnam
(
arg
)[
2
]
...
...
@@ -135,7 +135,7 @@ def main():
sys
.
exit
(
2
)
try
:
gid
=
int
(
arg
)
except
:
except
Exception
:
try
:
import
pwd
gid
=
pwd
.
getpwnam
(
arg
)[
3
]
...
...
src/Zope2/utilities/mkwsgiinstance.py
View file @
ecc18276
...
...
@@ -186,10 +186,7 @@ def get_inituser():
def
write_inituser
(
fn
,
user
,
password
):
import
binascii
try
:
from
hashlib
import
sha1
as
sha
except
:
from
sha
import
new
as
sha
from
hashlib
import
sha1
as
sha
fp
=
open
(
fn
,
"w"
)
pw
=
binascii
.
b2a_base64
(
sha
(
password
).
digest
())[:
-
1
]
fp
.
write
(
'%s:{SHA}%s
\
n
'
%
(
user
,
pw
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment