Skip to content

Commit

Permalink
Merge pull request #56 from zopefoundation/metadata-parse-error-master
Browse files Browse the repository at this point in the history
When metadata.xml parsing fails, show the filename in the ExpatError. [master]
  • Loading branch information
mauritsvanrees committed Mar 15, 2018
2 parents a6745a2 + f40b9ef commit 5cdc2a2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ Changelog
1.10.1 (unreleased)
-------------------

- When ``metadata.xml`` parsing fails, show the filename in the ``ExpatError``.
Fixes `Plone issue 2303 <https://github.com/plone/Products.CMFPlone/issues/2303>`_.

- Prevent AttributeError 'NoneType' object has no attribute 'decode'.
[maurits]

Expand Down
6 changes: 5 additions & 1 deletion Products/GenericSetup/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"""

import os
from xml.parsers.expat import ExpatError

from Products.GenericSetup.utils import _getProductPath
from Products.GenericSetup.utils import CONVERTER
Expand Down Expand Up @@ -53,7 +54,10 @@ def __call__( self ):
return {}

file = open( full_path, 'r' )
return self.parseXML( file.read() )
try:
return self.parseXML( file.read() )
except ExpatError as e:
raise ExpatError('%s: %s' % (full_path, e))

def _getImportMapping( self ):

Expand Down

0 comments on commit 5cdc2a2

Please sign in to comment.