Merge lp:~cjwatson/storm/py3-raise into lp:storm
- py3-raise
- Merge into trunk
Proposed by
Colin Watson
Status: | Merged |
---|---|
Merged at revision: | 510 |
Proposed branch: | lp:~cjwatson/storm/py3-raise |
Merge into: | lp:storm |
Diff against target: |
196 lines (+39/-36) 2 files modified
storm/schema/patch.py (+7/-4) storm/tz.py (+32/-32) |
To merge this branch: | bzr merge lp:~cjwatson/storm/py3-raise |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Simon Poirier (community) | Approve | ||
Review via email: mp+371121@code.launchpad.net |
Commit message
Use Python 3-compatible raise syntax.
Description of the change
Mostly extracted from https:/
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'storm/schema/patch.py' | |||
2 | --- storm/schema/patch.py 2019-06-05 11:41:07 +0000 | |||
3 | +++ storm/schema/patch.py 2019-08-09 13:15:52 +0000 | |||
4 | @@ -41,6 +41,8 @@ | |||
5 | 41 | import re | 41 | import re |
6 | 42 | import types | 42 | import types |
7 | 43 | 43 | ||
8 | 44 | import six | ||
9 | 45 | |||
10 | 44 | from storm.locals import StormError, Int | 46 | from storm.locals import StormError, Int |
11 | 45 | 47 | ||
12 | 46 | 48 | ||
13 | @@ -120,10 +122,11 @@ | |||
14 | 120 | except: | 122 | except: |
15 | 121 | type, value, traceback = sys.exc_info() | 123 | type, value, traceback = sys.exc_info() |
16 | 122 | patch_repr = getattr(module, "__file__", version) | 124 | patch_repr = getattr(module, "__file__", version) |
21 | 123 | raise BadPatchError, \ | 125 | six.reraise( |
22 | 124 | "Patch %s failed: %s: %s" % \ | 126 | BadPatchError, |
23 | 125 | (patch_repr, type.__name__, str(value)), \ | 127 | "Patch %s failed: %s: %s" % |
24 | 126 | traceback | 128 | (patch_repr, type.__name__, str(value)), |
25 | 129 | traceback) | ||
26 | 127 | self._committer.commit() | 130 | self._committer.commit() |
27 | 128 | 131 | ||
28 | 129 | def apply_all(self): | 132 | def apply_all(self): |
29 | 130 | 133 | ||
30 | === modified file 'storm/tz.py' | |||
31 | --- storm/tz.py 2019-06-06 09:03:07 +0000 | |||
32 | +++ storm/tz.py 2019-08-09 13:15:52 +0000 | |||
33 | @@ -215,7 +215,7 @@ | |||
34 | 215 | # of the value is written first). | 215 | # of the value is written first). |
35 | 216 | 216 | ||
36 | 217 | if fileobj.read(4) != "TZif": | 217 | if fileobj.read(4) != "TZif": |
38 | 218 | raise ValueError, "magic not found" | 218 | raise ValueError("magic not found") |
39 | 219 | 219 | ||
40 | 220 | fileobj.read(16) | 220 | fileobj.read(16) |
41 | 221 | 221 | ||
42 | @@ -471,7 +471,7 @@ | |||
43 | 471 | 471 | ||
44 | 472 | def __reduce__(self): | 472 | def __reduce__(self): |
45 | 473 | if not os.path.isfile(self._filename): | 473 | if not os.path.isfile(self._filename): |
47 | 474 | raise ValueError, "Unpickable %s class" % self.__class__.__name__ | 474 | raise ValueError("Unpickable %s class" % self.__class__.__name__) |
48 | 475 | return (self.__class__, (self._filename,)) | 475 | return (self.__class__, (self._filename,)) |
49 | 476 | 476 | ||
50 | 477 | class tzrange(datetime.tzinfo): | 477 | class tzrange(datetime.tzinfo): |
51 | @@ -563,7 +563,7 @@ | |||
52 | 563 | 563 | ||
53 | 564 | res = parser._parsetz(s) | 564 | res = parser._parsetz(s) |
54 | 565 | if res is None: | 565 | if res is None: |
56 | 566 | raise ValueError, "unknown string format" | 566 | raise ValueError("unknown string format") |
57 | 567 | 567 | ||
58 | 568 | # We must initialize it first, since _delta() needs | 568 | # We must initialize it first, since _delta() needs |
59 | 569 | # _std_offset and _dst_offset set. Use False in start/end | 569 | # _std_offset and _dst_offset set. Use False in start/end |
60 | @@ -725,7 +725,7 @@ | |||
61 | 725 | def _parse_offset(self, s): | 725 | def _parse_offset(self, s): |
62 | 726 | s = s.strip() | 726 | s = s.strip() |
63 | 727 | if not s: | 727 | if not s: |
65 | 728 | raise ValueError, "empty offset" | 728 | raise ValueError("empty offset") |
66 | 729 | if s[0] in ('+', '-'): | 729 | if s[0] in ('+', '-'): |
67 | 730 | signal = (-1,+1)[s[0]=='+'] | 730 | signal = (-1,+1)[s[0]=='+'] |
68 | 731 | s = s[1:] | 731 | s = s[1:] |
69 | @@ -736,12 +736,12 @@ | |||
70 | 736 | elif len(s) == 6: | 736 | elif len(s) == 6: |
71 | 737 | return (int(s[:2])*3600+int(s[2:4])*60+int(s[4:]))*signal | 737 | return (int(s[:2])*3600+int(s[2:4])*60+int(s[4:]))*signal |
72 | 738 | else: | 738 | else: |
74 | 739 | raise ValueError, "invalid offset: "+s | 739 | raise ValueError("invalid offset: "+s) |
75 | 740 | 740 | ||
76 | 741 | def _parse_rfc(self, s): | 741 | def _parse_rfc(self, s): |
77 | 742 | lines = s.splitlines() | 742 | lines = s.splitlines() |
78 | 743 | if not lines: | 743 | if not lines: |
80 | 744 | raise ValueError, "empty string" | 744 | raise ValueError("empty string") |
81 | 745 | 745 | ||
82 | 746 | # Unfold | 746 | # Unfold |
83 | 747 | i = 0 | 747 | i = 0 |
84 | @@ -765,7 +765,7 @@ | |||
85 | 765 | name, value = line.split(':', 1) | 765 | name, value = line.split(':', 1) |
86 | 766 | parms = name.split(';') | 766 | parms = name.split(';') |
87 | 767 | if not parms: | 767 | if not parms: |
89 | 768 | raise ValueError, "empty property name" | 768 | raise ValueError("empty property name") |
90 | 769 | name = parms[0].upper() | 769 | name = parms[0].upper() |
91 | 770 | parms = parms[1:] | 770 | parms = parms[1:] |
92 | 771 | if invtz: | 771 | if invtz: |
93 | @@ -774,7 +774,7 @@ | |||
94 | 774 | # Process component | 774 | # Process component |
95 | 775 | pass | 775 | pass |
96 | 776 | else: | 776 | else: |
98 | 777 | raise ValueError, "unknown component: "+value | 777 | raise ValueError("unknown component: "+value) |
99 | 778 | comptype = value | 778 | comptype = value |
100 | 779 | founddtstart = False | 779 | founddtstart = False |
101 | 780 | tzoffsetfrom = None | 780 | tzoffsetfrom = None |
102 | @@ -784,27 +784,27 @@ | |||
103 | 784 | elif name == "END": | 784 | elif name == "END": |
104 | 785 | if value == "VTIMEZONE": | 785 | if value == "VTIMEZONE": |
105 | 786 | if comptype: | 786 | if comptype: |
108 | 787 | raise ValueError, \ | 787 | raise ValueError( |
109 | 788 | "component not closed: "+comptype | 788 | "component not closed: "+comptype) |
110 | 789 | if not tzid: | 789 | if not tzid: |
113 | 790 | raise ValueError, \ | 790 | raise ValueError( |
114 | 791 | "mandatory TZID not found" | 791 | "mandatory TZID not found") |
115 | 792 | if not comps: | 792 | if not comps: |
118 | 793 | raise ValueError, \ | 793 | raise ValueError( |
119 | 794 | "at least one component is needed" | 794 | "at least one component is needed") |
120 | 795 | # Process vtimezone | 795 | # Process vtimezone |
121 | 796 | self._vtz[tzid] = _tzicalvtz(tzid, comps) | 796 | self._vtz[tzid] = _tzicalvtz(tzid, comps) |
122 | 797 | invtz = False | 797 | invtz = False |
123 | 798 | elif value == comptype: | 798 | elif value == comptype: |
124 | 799 | if not founddtstart: | 799 | if not founddtstart: |
127 | 800 | raise ValueError, \ | 800 | raise ValueError( |
128 | 801 | "mandatory DTSTART not found" | 801 | "mandatory DTSTART not found") |
129 | 802 | if tzoffsetfrom is None: | 802 | if tzoffsetfrom is None: |
132 | 803 | raise ValueError, \ | 803 | raise ValueError( |
133 | 804 | "mandatory TZOFFSETFROM not found" | 804 | "mandatory TZOFFSETFROM not found") |
134 | 805 | if tzoffsetto is None: | 805 | if tzoffsetto is None: |
137 | 806 | raise ValueError, \ | 806 | raise ValueError( |
138 | 807 | "mandatory TZOFFSETFROM not found" | 807 | "mandatory TZOFFSETFROM not found") |
139 | 808 | # Process component | 808 | # Process component |
140 | 809 | rr = None | 809 | rr = None |
141 | 810 | if rrulelines: | 810 | if rrulelines: |
142 | @@ -818,8 +818,8 @@ | |||
143 | 818 | comps.append(comp) | 818 | comps.append(comp) |
144 | 819 | comptype = None | 819 | comptype = None |
145 | 820 | else: | 820 | else: |
148 | 821 | raise ValueError, \ | 821 | raise ValueError( |
149 | 822 | "invalid component end: "+value | 822 | "invalid component end: "+value) |
150 | 823 | elif comptype: | 823 | elif comptype: |
151 | 824 | if name == "DTSTART": | 824 | if name == "DTSTART": |
152 | 825 | rrulelines.append(line) | 825 | rrulelines.append(line) |
153 | @@ -828,33 +828,33 @@ | |||
154 | 828 | rrulelines.append(line) | 828 | rrulelines.append(line) |
155 | 829 | elif name == "TZOFFSETFROM": | 829 | elif name == "TZOFFSETFROM": |
156 | 830 | if parms: | 830 | if parms: |
159 | 831 | raise ValueError, \ | 831 | raise ValueError( |
160 | 832 | "unsupported %s parm: %s "%(name, parms[0]) | 832 | "unsupported %s parm: %s "%(name, parms[0])) |
161 | 833 | tzoffsetfrom = self._parse_offset(value) | 833 | tzoffsetfrom = self._parse_offset(value) |
162 | 834 | elif name == "TZOFFSETTO": | 834 | elif name == "TZOFFSETTO": |
163 | 835 | if parms: | 835 | if parms: |
166 | 836 | raise ValueError, \ | 836 | raise ValueError( |
167 | 837 | "unsupported TZOFFSETTO parm: "+parms[0] | 837 | "unsupported TZOFFSETTO parm: "+parms[0]) |
168 | 838 | tzoffsetto = self._parse_offset(value) | 838 | tzoffsetto = self._parse_offset(value) |
169 | 839 | elif name == "TZNAME": | 839 | elif name == "TZNAME": |
170 | 840 | if parms: | 840 | if parms: |
173 | 841 | raise ValueError, \ | 841 | raise ValueError( |
174 | 842 | "unsupported TZNAME parm: "+parms[0] | 842 | "unsupported TZNAME parm: "+parms[0]) |
175 | 843 | tzname = value | 843 | tzname = value |
176 | 844 | elif name == "COMMENT": | 844 | elif name == "COMMENT": |
177 | 845 | pass | 845 | pass |
178 | 846 | else: | 846 | else: |
180 | 847 | raise ValueError, "unsupported property: "+name | 847 | raise ValueError("unsupported property: "+name) |
181 | 848 | else: | 848 | else: |
182 | 849 | if name == "TZID": | 849 | if name == "TZID": |
183 | 850 | if parms: | 850 | if parms: |
186 | 851 | raise ValueError, \ | 851 | raise ValueError( |
187 | 852 | "unsupported TZID parm: "+parms[0] | 852 | "unsupported TZID parm: "+parms[0]) |
188 | 853 | tzid = value | 853 | tzid = value |
189 | 854 | elif name in ("TZURL", "LAST-MODIFIED", "COMMENT"): | 854 | elif name in ("TZURL", "LAST-MODIFIED", "COMMENT"): |
190 | 855 | pass | 855 | pass |
191 | 856 | else: | 856 | else: |
193 | 857 | raise ValueError, "unsupported property: "+name | 857 | raise ValueError("unsupported property: "+name) |
194 | 858 | elif name == "BEGIN" and value == "VTIMEZONE": | 858 | elif name == "BEGIN" and value == "VTIMEZONE": |
195 | 859 | tzid = None | 859 | tzid = None |
196 | 860 | comps = [] | 860 | comps = [] |
+1 LGTM
also, thanks for fixing the indentation :)