Skip to content

Commit

Permalink
Merged r72753:72754 from 2.9 branch.
Browse files Browse the repository at this point in the history
Raise SyntaxError when encountering invalid PythonScript headers.
  • Loading branch information
stefanholek committed Feb 22, 2007
2 parents 0109dab + 9c5fd81 commit 7436bab
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion PythonScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ def write(self, text):
k = k.strip().lower()
v = v.strip()
if not mdata.has_key(k):
SyntaxError, 'Unrecognized header line "%s"' % line
raise SyntaxError, 'Unrecognized header line "%s"' % line
if v == mdata[k]:
# Unchanged value
continue
Expand Down
3 changes: 3 additions & 0 deletions tests/testPythonScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ def testNSBind(self):
bound = f.__render_with_namespace__({'yes': 1, 'no': self.fail})
self.assertEqual(bound, 1)

def testNSBindInvalidHeader(self):
self.assertRaises(SyntaxError, self._filePS, 'ns_bind_invalid')

def testBooleanMap(self):
res = self._filePS('boolean_map')()
self.failUnless(res)
Expand Down
Binary file added tests/tscripts/ns_bind_invalid.ps
Binary file not shown.

0 comments on commit 7436bab

Please sign in to comment.