X7ROOT File Manager
Current Path:
/opt/alt/python37/lib/python3.7/site-packages/libfuturize/fixes
opt
/
alt
/
python37
/
lib
/
python3.7
/
site-packages
/
libfuturize
/
fixes
/
📁
..
📄
__init__.py
(5.02 KB)
📁
__pycache__
📄
fix_UserDict.py
(3.75 KB)
📄
fix_absolute_import.py
(3.07 KB)
📄
fix_add__future__imports_except_unicode_literals.py
(662 B)
📄
fix_basestring.py
(394 B)
📄
fix_bytes.py
(685 B)
📄
fix_cmp.py
(701 B)
📄
fix_division.py
(228 B)
📄
fix_division_safe.py
(3.38 KB)
📄
fix_execfile.py
(921 B)
📄
fix_future_builtins.py
(1.98 KB)
📄
fix_future_standard_library.py
(733 B)
📄
fix_future_standard_library_urllib.py
(1001 B)
📄
fix_metaclass.py
(9.34 KB)
📄
fix_next_call.py
(3.08 KB)
📄
fix_object.py
(407 B)
📄
fix_oldstr_wrap.py
(1.19 KB)
📄
fix_order___future__imports.py
(829 B)
📄
fix_print.py
(3.3 KB)
📄
fix_print_with_import.py
(735 B)
📄
fix_raise.py
(2.12 KB)
📄
fix_remove_old__future__imports.py
(851 B)
📄
fix_unicode_keep_u.py
(779 B)
📄
fix_unicode_literals_import.py
(367 B)
📄
fix_xrange_with_import.py
(479 B)
Editing: fix_raise.py
"""Fixer for 'raise E, V' From Armin Ronacher's ``python-modernize``. raise -> raise raise E -> raise E raise E, V -> raise E(V) raise (((E, E'), E''), E'''), V -> raise E(V) CAVEATS: 1) "raise E, V" will be incorrectly translated if V is an exception instance. The correct Python 3 idiom is raise E from V but since we can't detect instance-hood by syntax alone and since any client code would have to be changed as well, we don't automate this. """ # Author: Collin Winter, Armin Ronacher # Local imports from lib2to3 import pytree, fixer_base from lib2to3.pgen2 import token from lib2to3.fixer_util import Name, Call, is_tuple class FixRaise(fixer_base.BaseFix): BM_compatible = True PATTERN = """ raise_stmt< 'raise' exc=any [',' val=any] > """ def transform(self, node, results): syms = self.syms exc = results["exc"].clone() if exc.type == token.STRING: msg = "Python 3 does not support string exceptions" self.cannot_convert(node, msg) return # Python 2 supports # raise ((((E1, E2), E3), E4), E5), V # as a synonym for # raise E1, V # Since Python 3 will not support this, we recurse down any tuple # literals, always taking the first element. if is_tuple(exc): while is_tuple(exc): # exc.children[1:-1] is the unparenthesized tuple # exc.children[1].children[0] is the first element of the tuple exc = exc.children[1].children[0].clone() exc.prefix = u" " if "val" not in results: # One-argument raise new = pytree.Node(syms.raise_stmt, [Name(u"raise"), exc]) new.prefix = node.prefix return new val = results["val"].clone() if is_tuple(val): args = [c.clone() for c in val.children[1:-1]] else: val.prefix = u"" args = [val] return pytree.Node(syms.raise_stmt, [Name(u"raise"), Call(exc, args)], prefix=node.prefix)
Upload File
Create Folder