Merge lp:~cjwatson/storm/py3-raise into lp:storm

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
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://bazaar.launchpad.net/~bellini666/storm/py3/revision/485, with an extra commit where I used six rather than future.

To post a comment you must log in.
Revision history for this message
Simon Poirier (simpoir) wrote :

+1 LGTM

also, thanks for fixing the indentation :)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'storm/schema/patch.py'
--- storm/schema/patch.py 2019-06-05 11:41:07 +0000
+++ storm/schema/patch.py 2019-08-09 13:15:52 +0000
@@ -41,6 +41,8 @@
41import re41import re
42import types42import types
4343
44import six
45
44from storm.locals import StormError, Int46from storm.locals import StormError, Int
4547
4648
@@ -120,10 +122,11 @@
120 except:122 except:
121 type, value, traceback = sys.exc_info()123 type, value, traceback = sys.exc_info()
122 patch_repr = getattr(module, "__file__", version)124 patch_repr = getattr(module, "__file__", version)
123 raise BadPatchError, \125 six.reraise(
124 "Patch %s failed: %s: %s" % \126 BadPatchError,
125 (patch_repr, type.__name__, str(value)), \127 "Patch %s failed: %s: %s" %
126 traceback128 (patch_repr, type.__name__, str(value)),
129 traceback)
127 self._committer.commit()130 self._committer.commit()
128131
129 def apply_all(self):132 def apply_all(self):
130133
=== modified file 'storm/tz.py'
--- storm/tz.py 2019-06-06 09:03:07 +0000
+++ storm/tz.py 2019-08-09 13:15:52 +0000
@@ -215,7 +215,7 @@
215 # of the value is written first).215 # of the value is written first).
216216
217 if fileobj.read(4) != "TZif":217 if fileobj.read(4) != "TZif":
218 raise ValueError, "magic not found"218 raise ValueError("magic not found")
219219
220 fileobj.read(16)220 fileobj.read(16)
221221
@@ -471,7 +471,7 @@
471471
472 def __reduce__(self):472 def __reduce__(self):
473 if not os.path.isfile(self._filename):473 if not os.path.isfile(self._filename):
474 raise ValueError, "Unpickable %s class" % self.__class__.__name__474 raise ValueError("Unpickable %s class" % self.__class__.__name__)
475 return (self.__class__, (self._filename,))475 return (self.__class__, (self._filename,))
476476
477class tzrange(datetime.tzinfo):477class tzrange(datetime.tzinfo):
@@ -563,7 +563,7 @@
563563
564 res = parser._parsetz(s)564 res = parser._parsetz(s)
565 if res is None:565 if res is None:
566 raise ValueError, "unknown string format"566 raise ValueError("unknown string format")
567567
568 # We must initialize it first, since _delta() needs568 # We must initialize it first, since _delta() needs
569 # _std_offset and _dst_offset set. Use False in start/end569 # _std_offset and _dst_offset set. Use False in start/end
@@ -725,7 +725,7 @@
725 def _parse_offset(self, s):725 def _parse_offset(self, s):
726 s = s.strip()726 s = s.strip()
727 if not s:727 if not s:
728 raise ValueError, "empty offset"728 raise ValueError("empty offset")
729 if s[0] in ('+', '-'):729 if s[0] in ('+', '-'):
730 signal = (-1,+1)[s[0]=='+']730 signal = (-1,+1)[s[0]=='+']
731 s = s[1:]731 s = s[1:]
@@ -736,12 +736,12 @@
736 elif len(s) == 6:736 elif len(s) == 6:
737 return (int(s[:2])*3600+int(s[2:4])*60+int(s[4:]))*signal737 return (int(s[:2])*3600+int(s[2:4])*60+int(s[4:]))*signal
738 else:738 else:
739 raise ValueError, "invalid offset: "+s739 raise ValueError("invalid offset: "+s)
740740
741 def _parse_rfc(self, s):741 def _parse_rfc(self, s):
742 lines = s.splitlines()742 lines = s.splitlines()
743 if not lines:743 if not lines:
744 raise ValueError, "empty string"744 raise ValueError("empty string")
745745
746 # Unfold746 # Unfold
747 i = 0747 i = 0
@@ -765,7 +765,7 @@
765 name, value = line.split(':', 1)765 name, value = line.split(':', 1)
766 parms = name.split(';')766 parms = name.split(';')
767 if not parms:767 if not parms:
768 raise ValueError, "empty property name"768 raise ValueError("empty property name")
769 name = parms[0].upper()769 name = parms[0].upper()
770 parms = parms[1:]770 parms = parms[1:]
771 if invtz:771 if invtz:
@@ -774,7 +774,7 @@
774 # Process component774 # Process component
775 pass775 pass
776 else:776 else:
777 raise ValueError, "unknown component: "+value777 raise ValueError("unknown component: "+value)
778 comptype = value778 comptype = value
779 founddtstart = False779 founddtstart = False
780 tzoffsetfrom = None780 tzoffsetfrom = None
@@ -784,27 +784,27 @@
784 elif name == "END":784 elif name == "END":
785 if value == "VTIMEZONE":785 if value == "VTIMEZONE":
786 if comptype:786 if comptype:
787 raise ValueError, \787 raise ValueError(
788 "component not closed: "+comptype788 "component not closed: "+comptype)
789 if not tzid:789 if not tzid:
790 raise ValueError, \790 raise ValueError(
791 "mandatory TZID not found"791 "mandatory TZID not found")
792 if not comps:792 if not comps:
793 raise ValueError, \793 raise ValueError(
794 "at least one component is needed"794 "at least one component is needed")
795 # Process vtimezone795 # Process vtimezone
796 self._vtz[tzid] = _tzicalvtz(tzid, comps)796 self._vtz[tzid] = _tzicalvtz(tzid, comps)
797 invtz = False797 invtz = False
798 elif value == comptype:798 elif value == comptype:
799 if not founddtstart:799 if not founddtstart:
800 raise ValueError, \800 raise ValueError(
801 "mandatory DTSTART not found"801 "mandatory DTSTART not found")
802 if tzoffsetfrom is None:802 if tzoffsetfrom is None:
803 raise ValueError, \803 raise ValueError(
804 "mandatory TZOFFSETFROM not found"804 "mandatory TZOFFSETFROM not found")
805 if tzoffsetto is None:805 if tzoffsetto is None:
806 raise ValueError, \806 raise ValueError(
807 "mandatory TZOFFSETFROM not found"807 "mandatory TZOFFSETFROM not found")
808 # Process component808 # Process component
809 rr = None809 rr = None
810 if rrulelines:810 if rrulelines:
@@ -818,8 +818,8 @@
818 comps.append(comp)818 comps.append(comp)
819 comptype = None819 comptype = None
820 else:820 else:
821 raise ValueError, \821 raise ValueError(
822 "invalid component end: "+value822 "invalid component end: "+value)
823 elif comptype:823 elif comptype:
824 if name == "DTSTART":824 if name == "DTSTART":
825 rrulelines.append(line)825 rrulelines.append(line)
@@ -828,33 +828,33 @@
828 rrulelines.append(line)828 rrulelines.append(line)
829 elif name == "TZOFFSETFROM":829 elif name == "TZOFFSETFROM":
830 if parms:830 if parms:
831 raise ValueError, \831 raise ValueError(
832 "unsupported %s parm: %s "%(name, parms[0])832 "unsupported %s parm: %s "%(name, parms[0]))
833 tzoffsetfrom = self._parse_offset(value)833 tzoffsetfrom = self._parse_offset(value)
834 elif name == "TZOFFSETTO":834 elif name == "TZOFFSETTO":
835 if parms:835 if parms:
836 raise ValueError, \836 raise ValueError(
837 "unsupported TZOFFSETTO parm: "+parms[0]837 "unsupported TZOFFSETTO parm: "+parms[0])
838 tzoffsetto = self._parse_offset(value)838 tzoffsetto = self._parse_offset(value)
839 elif name == "TZNAME":839 elif name == "TZNAME":
840 if parms:840 if parms:
841 raise ValueError, \841 raise ValueError(
842 "unsupported TZNAME parm: "+parms[0]842 "unsupported TZNAME parm: "+parms[0])
843 tzname = value843 tzname = value
844 elif name == "COMMENT":844 elif name == "COMMENT":
845 pass845 pass
846 else:846 else:
847 raise ValueError, "unsupported property: "+name847 raise ValueError("unsupported property: "+name)
848 else:848 else:
849 if name == "TZID":849 if name == "TZID":
850 if parms:850 if parms:
851 raise ValueError, \851 raise ValueError(
852 "unsupported TZID parm: "+parms[0]852 "unsupported TZID parm: "+parms[0])
853 tzid = value853 tzid = value
854 elif name in ("TZURL", "LAST-MODIFIED", "COMMENT"):854 elif name in ("TZURL", "LAST-MODIFIED", "COMMENT"):
855 pass855 pass
856 else:856 else:
857 raise ValueError, "unsupported property: "+name857 raise ValueError("unsupported property: "+name)
858 elif name == "BEGIN" and value == "VTIMEZONE":858 elif name == "BEGIN" and value == "VTIMEZONE":
859 tzid = None859 tzid = None
860 comps = []860 comps = []

Subscribers

People subscribed via source and target branches

to status/vote changes: