Repository: r1chardj0n3s/parse

Issue:
Unmatched brace can still result in a match
Certain patterns can still result in a match even when there are unmatched braces. For example:
```
>>> parse("{who.txt", "hello")
<Result () {'who.tx': 'hello'}>
```
Even though there is no closing `}`, `parse` assumes the final character is the closing brace and matches the pattern accordingly. In this case, I'd expect `parse` to return `None` since there is no direct match.

Discussion:

Patch:
diff --git a/README.rst b/README.rst
index 59f1018..3665905 100644
--- a/README.rst
+++ b/README.rst
@@ -345,6 +345,7 @@ the pattern, the actual match represents the shortest successful match for
 
 **Version history (in brief)**:
 
+- 1.12.0 Do not assume closing brace when an opening one is found (thanks @mattsep)
 - 1.11.1 Revert having unicode char in docstring, it breaks Bamboo builds(?!)
 - 1.11.0 Implement `__contains__` for Result instances.
 - 1.10.0 Introduce a "letters" matcher, since "w" matches numbers
diff --git a/parse.py b/parse.py
index b5d543f..bff5f7f 100644
--- a/parse.py
+++ b/parse.py
@@ -345,6 +345,7 @@ the pattern, the actual match represents the shortest successful match for
 
 **Version history (in brief)**:
 
+- 1.12.0 Do not assume closing brace when an opening one is found (thanks @mattsep)
 - 1.11.1 Revert having unicode char in docstring, it breaks Bamboo builds(?!)
 - 1.11.0 Implement `__contains__` for Result instances.
 - 1.10.0 Introduce a "letters" matcher, since "w" matches numbers
@@ -415,7 +416,7 @@ See the end of the source file for the license of use.
 '''
 
 from __future__ import absolute_import
-__version__ = '1.11.1'
+__version__ = '1.12.0'
 
 # yes, I now have two problems
 import re
@@ -885,7 +886,7 @@ class Parser(object):
                 e.append(r'\{')
             elif part == '}}':
                 e.append(r'\}')
-            elif part[0] == '{':
+            elif part[0] == '{' and part[-1] == '}':
                 # this will be a braces-delimited field to handle
                 e.append(self._handle_field(part))
             else:


Test patch:
diff --git a/test_parse.py b/test_parse.py
index d48159a..7ebe378 100755
--- a/test_parse.py
+++ b/test_parse.py
@@ -771,6 +771,10 @@ class TestBugs(unittest.TestCase):
         self.assertEqual(r[0], 'ALICE')
         self.assertEqual(r[1], 42)
 
+    def test_unmatched_brace_doesnt_match(self):
+        r = parse.parse("{who.txt", "hello")
+        self.assertIsNone(r)
+
 
 # -----------------------------------------------------------------------------
 # TEST SUPPORT FOR: TestParseType
@@ -793,7 +797,6 @@ class TestParseType(unittest.TestCase):
         result = parser.parse(text)
         self.assertEqual(result, None)
 
-
     def test_pattern_should_be_used(self):
         def parse_number(text):
             return int(text)