You've already forked python-uncompyle6
mirror of
https://github.com/rocky/python-uncompyle6.git
synced 2025-08-02 16:44:46 +08:00
Spelling corrections
This commit is contained in:
@@ -29,6 +29,7 @@ storage.
|
||||
#------------------------------------------------------------------------
|
||||
|
||||
import sys
|
||||
|
||||
absolute_import = (sys.version_info[0] >= 3)
|
||||
if absolute_import :
|
||||
# Because this syntaxis is not valid before Python 2.5
|
||||
@@ -229,7 +230,7 @@ class DBShelf(MutableMapping):
|
||||
|
||||
def associate(self, secondaryDB, callback, flags=0):
|
||||
def _shelf_callback(priKey, priData, realCallback=callback):
|
||||
# Safe in Python 2.x because expresion short circuit
|
||||
# Safe in Python 2.x because expression short circuit
|
||||
if sys.version_info[0] < 3 or isinstance(priData, bytes) :
|
||||
data = cPickle.loads(priData)
|
||||
else :
|
||||
@@ -366,7 +367,7 @@ class DBShelfCursor:
|
||||
return None
|
||||
else:
|
||||
key, data = rec
|
||||
# Safe in Python 2.x because expresion short circuit
|
||||
# Safe in Python 2.x because expression short circuit
|
||||
if sys.version_info[0] < 3 or isinstance(data, bytes) :
|
||||
return key, cPickle.loads(data)
|
||||
else :
|
||||
|
@@ -3,10 +3,10 @@
|
||||
# Grammar allows multiple adjacent 'if's in listcomps and genexps,
|
||||
# even though it's silly. Make sure it works (ifelse broke this.)
|
||||
|
||||
[ x for x in range(10) if x % 2 if x % 3 ]
|
||||
[x for x in range(10) if x % 2 if x % 3]
|
||||
list(x for x in range(10) if x % 2 if x % 3)
|
||||
|
||||
# expresion which evaluates True unconditionally,
|
||||
# expression which evaluates True unconditionally,
|
||||
# but leave dead code or junk around that we have to match on.
|
||||
# Tests "if_exp_true" rule
|
||||
5 if 1 else 2
|
||||
|
@@ -1,8 +1,8 @@
|
||||
# From 2.7.17 test_bdb.py
|
||||
# The problem was detecting a docstring at the begining of the module
|
||||
# The problem was detecting a docstring at the beginning of the module
|
||||
# It must be detected and change'd or else the "from __future__" below
|
||||
# is invalid.
|
||||
# Note that this has to be compiled with optimation < 2 or else optimization
|
||||
# Note that this has to be compiled with optimization < 2 or else optimization
|
||||
# will remove the docstring
|
||||
"""Rational, infinite-precision, real numbers."""
|
||||
|
||||
|
@@ -1,20 +1,20 @@
|
||||
# Statements to beef up grammar coverage rules
|
||||
# Force "inplace" ops
|
||||
# Note this is like simple_source/bug22/01_ops.py
|
||||
# But we don't ahve the UNARY_CONVERT which dropped
|
||||
# But we don't have the UNARY_CONVERT which dropped
|
||||
# out around 2.7
|
||||
y = +10 # UNARY_POSITIVE
|
||||
y /= 1 # INPLACE_DIVIDE
|
||||
y %= 4 # INPLACE_MODULO
|
||||
y /= 1 # INPLACE_DIVIDE
|
||||
y %= 4 # INPLACE_MODULO
|
||||
y **= 1 # INPLACE POWER
|
||||
y >>= 2 # INPLACE_RSHIFT
|
||||
y <<= 2 # INPLACE_LSHIFT
|
||||
y //= 1 # INPLACE_TRUE_DIVIDE
|
||||
y &= 1 # INPLACE_AND
|
||||
y ^= 1 # INPLACE_XOR
|
||||
y &= 1 # INPLACE_AND
|
||||
y ^= 1 # INPLACE_XOR
|
||||
|
||||
# Beef up aug_assign and STORE_SLICE+3
|
||||
x = [1,2,3,4,5]
|
||||
x = [1, 2, 3, 4, 5]
|
||||
x[0:1] = 1
|
||||
x[0:3] += 1, 2, 3
|
||||
|
||||
|
@@ -1,18 +1,20 @@
|
||||
# From 3.x test_audiop.py
|
||||
|
||||
# Bug is handling default value after * argument in a lambda.
|
||||
# That's a mouthful of desciption; I am not sure if the really
|
||||
# That's a mouthful of description; I am not sure if the really
|
||||
# hacky fix to the code is even correct.
|
||||
|
||||
#
|
||||
# FIXME: try and test with more than one default argument.
|
||||
|
||||
|
||||
# RUNNABLE
|
||||
def pack(width, data):
|
||||
return (width, data)
|
||||
|
||||
|
||||
packs = {w: (lambda *data, width=w: pack(width, data)) for w in (1, 2, 4)}
|
||||
|
||||
assert packs[1]('a') == (1, ('a',))
|
||||
assert packs[2]('b') == (2, ('b',))
|
||||
assert packs[4]('c') == (4, ('c',))
|
||||
assert packs[1]("a") == (1, ("a",))
|
||||
assert packs[2]("b") == (2, ("b",))
|
||||
assert packs[4]("c") == (4, ("c",))
|
||||
|
@@ -1,16 +1,19 @@
|
||||
# From python 3.3.7 trace
|
||||
# Bug was not having not having semantic rule for conditional not
|
||||
|
||||
|
||||
# RUNNABLE!
|
||||
def init(modules=None):
|
||||
mods = set() if not modules else set(modules)
|
||||
return mods
|
||||
|
||||
|
||||
assert init() == set()
|
||||
assert init([1, 2, 3]) == set([1, 2, 3])
|
||||
|
||||
|
||||
# From 3.6 sre_parse
|
||||
# Bug was in handling multple COME_FROMS from nested if's
|
||||
# Bug was in handling multiple COME_FROMS from nested if's
|
||||
def _escape(a, b, c, d, e):
|
||||
if a:
|
||||
if b:
|
||||
@@ -24,15 +27,16 @@ def _escape(a, b, c, d, e):
|
||||
return
|
||||
raise
|
||||
|
||||
assert _escape(False, True, True, True, True) is None
|
||||
assert _escape(True, True, True, False, True) is None
|
||||
assert _escape(True, True, False, False, True) is None
|
||||
|
||||
assert _escape(False, True, True, True, True) is None
|
||||
assert _escape(True, True, True, False, True) is None
|
||||
assert _escape(True, True, False, False, True) is None
|
||||
|
||||
for args in (
|
||||
(True, True, True, False, True),
|
||||
(True, False, True, True, True),
|
||||
(True, False, True, True, False),
|
||||
):
|
||||
(True, True, True, False, True),
|
||||
(True, False, True, True, True),
|
||||
(True, False, True, True, False),
|
||||
):
|
||||
try:
|
||||
_escape(*args)
|
||||
assert False, args
|
||||
|
@@ -1,8 +1,9 @@
|
||||
# From Python 3.4 asynchat.py
|
||||
# Tests presence or absense of
|
||||
# Tests presence or absence of
|
||||
# SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM_LOOP
|
||||
# Note: that there is no JUMP_BACK because of the return_stmts.
|
||||
|
||||
|
||||
def initiate_send(a, b, c, num_sent):
|
||||
while a and b:
|
||||
try:
|
||||
@@ -24,6 +25,7 @@ def initiate_send2(a, b):
|
||||
|
||||
return 2
|
||||
|
||||
|
||||
assert initiate_send(1, 1, 2, False) == 1
|
||||
assert initiate_send(1, 2, 3, False) == 3
|
||||
assert initiate_send(1, 2, 3, True) == 2
|
||||
|
@@ -1,13 +1,20 @@
|
||||
# Python 3.6 changes, yet again, the way deafult pairs are handled
|
||||
# Python 3.6 changes, yet again, the way default pairs are handled
|
||||
def foo1(bar, baz=1):
|
||||
return 1
|
||||
|
||||
|
||||
def foo2(bar, baz, qux=1):
|
||||
return 2
|
||||
|
||||
|
||||
def foo3(bar, baz=1, qux=2):
|
||||
return 3
|
||||
|
||||
|
||||
def foo4(bar, baz, qux=1, quux=2):
|
||||
return 4
|
||||
|
||||
|
||||
# From 3.6 compileall.
|
||||
# Bug was in omitting default which when used in an "if"
|
||||
# are treated as False would be
|
||||
|
@@ -1,17 +1,23 @@
|
||||
# From 3.6 test_abc.py
|
||||
# Bug was Reciever() class definition
|
||||
# Bug was Receiver() class definition
|
||||
import abc
|
||||
import unittest
|
||||
|
||||
|
||||
class TestABCWithInitSubclass(unittest.TestCase):
|
||||
def test_works_with_init_subclass(self):
|
||||
class ReceivesClassKwargs:
|
||||
def __init_subclass__(cls, **kwargs):
|
||||
super().__init_subclass__()
|
||||
|
||||
class Receiver(ReceivesClassKwargs, abc.ABC, x=1, y=2, z=3):
|
||||
pass
|
||||
|
||||
|
||||
def test_abstractmethod_integration(self):
|
||||
for abstractthing in [abc.abstractmethod]:
|
||||
|
||||
class C(metaclass=abc.ABCMeta):
|
||||
@abstractthing
|
||||
def foo(self): pass # abstract
|
||||
def foo(self):
|
||||
pass # abstract
|
||||
|
@@ -1,12 +1,12 @@
|
||||
# From 3.6 base64.py
|
||||
# Bug was handling "and" condition in the presense of POP_JUMP_IF_FALSE
|
||||
# Bug was handling "and" condition in the presence of POP_JUMP_IF_FALSE
|
||||
# locations
|
||||
def _85encode(foldnuls, words):
|
||||
return ['z' if foldnuls and word
|
||||
else 'y'
|
||||
for word in words]
|
||||
return ["z" if foldnuls and word else "y" for word in words]
|
||||
|
||||
|
||||
# From Python 3.6 enum.py
|
||||
|
||||
|
||||
def __new__(metacls, cls, bases, classdict):
|
||||
{k: classdict[k] for k in classdict._member_names}
|
||||
|
@@ -14,6 +14,7 @@ assert (
|
||||
assert "def0" == f"{abc}0"
|
||||
assert "defdef" == f"{abc}{abc!s}"
|
||||
|
||||
|
||||
# From 3.8 test/test_string.py
|
||||
# We had the precedence of yield vs. lambda incorrect.
|
||||
def fn(x):
|
||||
@@ -97,9 +98,10 @@ else:
|
||||
(x, y, width) = ("foo", 2, 10)
|
||||
assert f"x={x*y:{width}}" == "x=foofoo "
|
||||
|
||||
|
||||
# Why the fact that the distinction of docstring versus stmt is a
|
||||
# string expression is important academic, but we will decompile an
|
||||
# equivalent thing. For compatiblity with older Python we'll use "%"
|
||||
# equivalent thing. For compatibility with older Python we'll use "%"
|
||||
# instead of a format string
|
||||
def f():
|
||||
f"""Not a docstring""" # noqa
|
||||
|
@@ -1,26 +1,27 @@
|
||||
# From 3.6 _markupbase.py
|
||||
|
||||
# Bug is that the routine is long enough that POP_JUMP_IF_FALSE instruciton has an
|
||||
# EXTENDED_ARG intruction before it and we weren't picking out the jump offset properly
|
||||
# Bug is that the routine is long enough that POP_JUMP_IF_FALSE instruction has an
|
||||
# EXTENDED_ARG instruction before it and we weren't picking out the jump offset properly
|
||||
|
||||
|
||||
def parse_declaration(self, i):
|
||||
if rawdata[j:j] in ("-", ""):
|
||||
return -1
|
||||
n = len(rawdata)
|
||||
if rawdata[j:j+2] == '-':
|
||||
if rawdata[j : j + 2] == "-":
|
||||
return self.parse_comment(i)
|
||||
elif rawdata[j] == '[':
|
||||
elif rawdata[j] == "[":
|
||||
return self.parse_marked_section(i)
|
||||
else:
|
||||
decltype, j = self._scan_name(j, i)
|
||||
if j < 0:
|
||||
return j
|
||||
if decltype == "d":
|
||||
self._decl_otherchars = ''
|
||||
self._decl_otherchars = ""
|
||||
while j < n:
|
||||
c = rawdata[j]
|
||||
if c == ">":
|
||||
data = rawdata[i+2:j]
|
||||
data = rawdata[i + 2 : j]
|
||||
if decltype == "d":
|
||||
self.handle_decl(data)
|
||||
else:
|
||||
@@ -43,8 +44,7 @@ def parse_declaration(self, i):
|
||||
else:
|
||||
self.error("unexpected '[' char in declaration")
|
||||
else:
|
||||
self.error(
|
||||
"unexpected %r char in declaration" % rawdata[j])
|
||||
self.error("unexpected %r char in declaration" % rawdata[j])
|
||||
if j < 0:
|
||||
return j
|
||||
return -1
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# Tests custom added grammar rule:
|
||||
# expr ::= expr {expr}^n CALL_FUNCTION_n
|
||||
# which in the specifc case below is:
|
||||
# which in the specific case below is:
|
||||
# expr ::= expr expr expr CALL_FUNCTION_2
|
||||
max(1, 2)
|
||||
|
@@ -27,7 +27,7 @@ while 1:
|
||||
else:
|
||||
raise RuntimeError
|
||||
|
||||
# Degenerate case. Note: we can't run becase this causes an infinite loop.
|
||||
# Degenerate case. Note: we can't run because this causes an infinite loop.
|
||||
# Suggested in issue #172
|
||||
while 1:
|
||||
pass
|
||||
|
@@ -1,7 +1,8 @@
|
||||
# From 3.6.10 test_binascii.py
|
||||
# Bug was getting "while c and noise" parsed correclty
|
||||
# Bug was getting "while c and noise" parsed correctly
|
||||
# and not put into the "ifelsesmt"
|
||||
|
||||
|
||||
# RUNNABLE!
|
||||
def addnoise(c, noise):
|
||||
while c and noise:
|
||||
@@ -12,6 +13,7 @@ def addnoise(c, noise):
|
||||
noise = False
|
||||
return c
|
||||
|
||||
|
||||
assert addnoise(0, True) == 0
|
||||
assert addnoise(1, False) == 1
|
||||
assert addnoise(2, True) == 2
|
||||
@@ -19,9 +21,10 @@ assert addnoise(3, True) == 3
|
||||
assert addnoise(4, True) == 3
|
||||
assert addnoise(5, False) == 5
|
||||
|
||||
|
||||
# From 3.6.10 test_dbm_dumb.py
|
||||
# Bug was getting attaching "else" to the right "if" in the
|
||||
# presense of a loop.
|
||||
# presence of a loop.
|
||||
def test_random(a, r):
|
||||
x = 0
|
||||
for dummy in r:
|
||||
@@ -32,11 +35,13 @@ def test_random(a, r):
|
||||
x += 1
|
||||
return x
|
||||
|
||||
|
||||
assert test_random(True, [1]) == 2
|
||||
assert test_random(True, [1, 1]) == 4
|
||||
assert test_random(False, [1]) == 0
|
||||
assert test_random(False, [1, 1]) == 0
|
||||
|
||||
|
||||
# From 2.7.17 test_frozen.py
|
||||
# Bug was getting making sure we have "try" not
|
||||
# "try"/"else"
|
||||
@@ -53,11 +58,13 @@ def test_frozen(a, b):
|
||||
|
||||
return x
|
||||
|
||||
|
||||
assert test_frozen(1, 1) == 4.0
|
||||
assert test_frozen(0, 1) == 5.0
|
||||
assert test_frozen(0.5, 0) == 6.0
|
||||
assert test_frozen(0, 0.5) == 8.0
|
||||
|
||||
|
||||
# From 3.6.10 test_binop.py
|
||||
# Bug was getting "other += 3" outside of "if"/"else.
|
||||
def __floordiv__(a, b):
|
||||
@@ -70,6 +77,7 @@ def __floordiv__(a, b):
|
||||
other += 3
|
||||
return other
|
||||
|
||||
|
||||
assert __floordiv__(True, True) == 4
|
||||
assert __floordiv__(True, False) == 4
|
||||
assert __floordiv__(False, True) == 3
|
||||
|
@@ -1,19 +1,19 @@
|
||||
# Self-checking test.
|
||||
# Mixed boolean expresions
|
||||
# Mixed boolean expressions
|
||||
|
||||
b = True
|
||||
assert b, 'b = True'
|
||||
assert b, "b = True"
|
||||
c = False
|
||||
assert not c, 'c = False'
|
||||
assert not c, "c = False"
|
||||
d = True
|
||||
a = b and c or d
|
||||
assert a, 'b and c or d'
|
||||
assert a, "b and c or d"
|
||||
a = (b or c) and d
|
||||
assert a, '(b or c) and d'
|
||||
assert a, "(b or c) and d"
|
||||
a = b or c or d
|
||||
assert a, 'b or c or d'
|
||||
assert a, "b or c or d"
|
||||
a = b and c and d
|
||||
assert not a, 'b and c and d'
|
||||
assert not a, "b and c and d"
|
||||
a = b or c and d
|
||||
assert a
|
||||
a = b and (c or d)
|
||||
|
@@ -1,5 +1,5 @@
|
||||
# 2.6.9 symbols.py
|
||||
# Bug in 2.6 is having multple COME_FROMs due to the
|
||||
# Bug in 2.6 is having multiple COME_FROMs due to the
|
||||
# "and" in the "if" clause
|
||||
|
||||
# RUNNABLE
|
||||
@@ -10,7 +10,7 @@ if __name__:
|
||||
assert False
|
||||
|
||||
# 2.6.9 transformer.py
|
||||
# Bug in 2.6 is multple COME_FROMs as a result
|
||||
# Bug in 2.6 is multiple COME_FROMs as a result
|
||||
# of the "or" in the "assert"
|
||||
|
||||
# In PyPy the assert is handled via PyPy's unique JUMP_IF_NOT_DEBUG
|
||||
@@ -24,6 +24,7 @@ elif __file__:
|
||||
else:
|
||||
pass
|
||||
|
||||
|
||||
# From 3.3.7 test_binop.py
|
||||
# Bug was in ifelsestmt(c) ensuring b+=5 is not in "else"
|
||||
# Also note: ifelsetmtc should not have been used since this
|
||||
@@ -36,6 +37,7 @@ def __floordiv__(a, b):
|
||||
b += 5
|
||||
return b
|
||||
|
||||
|
||||
assert __floordiv__(1, 1) == 7
|
||||
assert __floordiv__(1, 0) == 6
|
||||
assert __floordiv__(0, 3) == 8
|
||||
|
Reference in New Issue
Block a user