Created
February 10, 2017 15:10
-
-
Save thombashi/5be8a602df933851d2fd1af73cb1bb0e to your computer and use it in GitHub Desktop.
voluptuous_python25.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -u org_voluptuous-0.8.8/voluptuous-0.8.8/setup.py modified_voluptuous-0.8.8/voluptuous-0.8.8/setup.py | |
--- org_voluptuous-0.8.8/voluptuous-0.8.8/setup.py 2015-12-15 23:10:46.000000000 +0900 | |
+++ modified_voluptuous-0.8.8/voluptuous-0.8.8/setup.py 2016-01-01 15:50:05.766400230 +0900 | |
@@ -1,3 +1,4 @@ | |
+from __future__ import with_statement | |
try: | |
from setuptools import setup | |
except ImportError: | |
diff -u org_voluptuous-0.8.8/voluptuous-0.8.8/voluptuous.py modified_voluptuous-0.8.8/voluptuous-0.8.8/voluptuous.py | |
--- org_voluptuous-0.8.8/voluptuous-0.8.8/voluptuous.py 2015-12-15 23:10:46.000000000 +0900 | |
+++ modified_voluptuous-0.8.8/voluptuous-0.8.8/voluptuous.py 2016-01-02 01:30:34.000000000 +0900 | |
@@ -115,7 +115,7 @@ | |
def raises(exc, msg=None, regex=None): | |
try: | |
yield | |
- except exc as e: | |
+ except exc, e: | |
if msg is not None: | |
assert str(e) == msg, '%r != %r' % (str(e), msg) | |
if regex is not None: | |
@@ -337,7 +337,7 @@ | |
return self._compiled([], data) | |
except MultipleInvalid: | |
raise | |
- except Invalid as e: | |
+ except Invalid, e: | |
raise MultipleInvalid([e]) | |
# return self.validate([], self.schema, data) | |
@@ -346,7 +346,7 @@ | |
return lambda _, v: v | |
if isinstance(schema, Object): | |
return self._compile_object(schema) | |
- if isinstance(schema, collections.Mapping): | |
+ if isinstance(schema, dict): | |
return self._compile_dict(schema) | |
elif isinstance(schema, list): | |
return self._compile_list(schema) | |
@@ -399,7 +399,7 @@ | |
for skey, (ckey, cvalue) in candidates: | |
try: | |
new_key = ckey(key_path, key) | |
- except Invalid as e: | |
+ except Invalid, e: | |
if len(e.path) > len(key_path): | |
raise | |
if not error or len(e.path) > len(error.path): | |
@@ -418,9 +418,9 @@ | |
else: | |
remove_key = True | |
continue | |
- except MultipleInvalid as e: | |
+ except MultipleInvalid, e: | |
exception_errors.extend(e.errors) | |
- except Invalid as e: | |
+ except Invalid, e: | |
exception_errors.append(e) | |
if exception_errors: | |
@@ -673,7 +673,7 @@ | |
if cval is not Remove: # do not include Remove values | |
out.append(cval) | |
break | |
- except Invalid as e: | |
+ except Invalid, e: | |
if len(e.path) > len(index_path): | |
raise | |
invalid = e | |
@@ -772,13 +772,13 @@ | |
def validate_callable(path, data): | |
try: | |
return schema(data) | |
- except ValueError as e: | |
+ except ValueError, e: | |
raise ValueInvalid('not a valid value', path) | |
- except MultipleInvalid as e: | |
+ except MultipleInvalid, e: | |
for error in e.errors: | |
error.path = path + error.path | |
raise | |
- except Invalid as e: | |
+ except Invalid, e: | |
e.path = path + e.path | |
raise | |
return validate_callable | |
@@ -884,7 +884,7 @@ | |
def __call__(self, v): | |
try: | |
return self._schema(v) | |
- except Invalid as e: | |
+ except Invalid, e: | |
if not self.msg or len(e.path) > 1: | |
raise | |
raise Invalid(self.msg) | |
@@ -1099,7 +1099,7 @@ | |
def f(v): | |
try: | |
return schema(v) | |
- except Invalid as e: | |
+ except Invalid, e: | |
if len(e.path) > 1: | |
raise e | |
else: | |
@@ -1316,7 +1316,7 @@ | |
for schema in schemas: | |
try: | |
return schema(v) | |
- except Invalid as e: | |
+ except Invalid, e: | |
if error is None or len(e.path) > len(error.path): | |
error = e | |
else: | |
@@ -1349,7 +1349,7 @@ | |
try: | |
for schema in schemas: | |
v = schema(v) | |
- except Invalid as e: | |
+ except Invalid, e: | |
raise e if msg is None else AllInvalid(msg) | |
return v | |
return f | |
@@ -1689,7 +1689,7 @@ | |
raise ExactSequenceInvalid(msg) | |
try: | |
v = type(v)(schema(x) for x, schema in zip(v, schemas)) | |
- except Invalid as e: | |
+ except Invalid, e: | |
raise e if msg is None else ExactSequenceInvalid(msg) | |
return v | |
return f | |
@@ -1743,7 +1743,7 @@ | |
def f(v): | |
try: | |
set_v = set(v) | |
- except TypeError as e: | |
+ except TypeError, e: | |
raise TypeInvalid(msg or 'contains unhashable elements: {0}'.format(e)) | |
if len(set_v) != len(v): | |
@@ -1770,7 +1770,7 @@ | |
def f(v): | |
try: | |
set_v = set(v) | |
- except Exception as e: | |
+ except Exception, e: | |
raise TypeInvalid(msg or 'cannot be presented as set: {0}'.format(e)) | |
return set_v |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment