Spelling corrections

This commit is contained in:
rocky
2024-07-10 13:31:39 -04:00
parent 51141ad06d
commit 3c6e378cc4
17 changed files with 88 additions and 54 deletions

View File

@@ -29,6 +29,7 @@ storage.
#------------------------------------------------------------------------ #------------------------------------------------------------------------
import sys import sys
absolute_import = (sys.version_info[0] >= 3) absolute_import = (sys.version_info[0] >= 3)
if absolute_import : if absolute_import :
# Because this syntaxis is not valid before Python 2.5 # 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 associate(self, secondaryDB, callback, flags=0):
def _shelf_callback(priKey, priData, realCallback=callback): 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) : if sys.version_info[0] < 3 or isinstance(priData, bytes) :
data = cPickle.loads(priData) data = cPickle.loads(priData)
else : else :
@@ -366,7 +367,7 @@ class DBShelfCursor:
return None return None
else: else:
key, data = rec 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) : if sys.version_info[0] < 3 or isinstance(data, bytes) :
return key, cPickle.loads(data) return key, cPickle.loads(data)
else : else :

View File

@@ -3,10 +3,10 @@
# Grammar allows multiple adjacent 'if's in listcomps and genexps, # Grammar allows multiple adjacent 'if's in listcomps and genexps,
# even though it's silly. Make sure it works (ifelse broke this.) # 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) 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. # but leave dead code or junk around that we have to match on.
# Tests "if_exp_true" rule # Tests "if_exp_true" rule
5 if 1 else 2 5 if 1 else 2

View File

@@ -1,8 +1,8 @@
# From 2.7.17 test_bdb.py # 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 # It must be detected and change'd or else the "from __future__" below
# is invalid. # 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 # will remove the docstring
"""Rational, infinite-precision, real numbers.""" """Rational, infinite-precision, real numbers."""

View File

@@ -1,20 +1,20 @@
# Statements to beef up grammar coverage rules # Statements to beef up grammar coverage rules
# Force "inplace" ops # Force "inplace" ops
# Note this is like simple_source/bug22/01_ops.py # 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 # out around 2.7
y = +10 # UNARY_POSITIVE y = +10 # UNARY_POSITIVE
y /= 1 # INPLACE_DIVIDE y /= 1 # INPLACE_DIVIDE
y %= 4 # INPLACE_MODULO y %= 4 # INPLACE_MODULO
y **= 1 # INPLACE POWER y **= 1 # INPLACE POWER
y >>= 2 # INPLACE_RSHIFT y >>= 2 # INPLACE_RSHIFT
y <<= 2 # INPLACE_LSHIFT y <<= 2 # INPLACE_LSHIFT
y //= 1 # INPLACE_TRUE_DIVIDE y //= 1 # INPLACE_TRUE_DIVIDE
y &= 1 # INPLACE_AND y &= 1 # INPLACE_AND
y ^= 1 # INPLACE_XOR y ^= 1 # INPLACE_XOR
# Beef up aug_assign and STORE_SLICE+3 # 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:1] = 1
x[0:3] += 1, 2, 3 x[0:3] += 1, 2, 3

View File

@@ -1,18 +1,20 @@
# From 3.x test_audiop.py # From 3.x test_audiop.py
# Bug is handling default value after * argument in a lambda. # 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. # hacky fix to the code is even correct.
# #
# FIXME: try and test with more than one default argument. # FIXME: try and test with more than one default argument.
# RUNNABLE # RUNNABLE
def pack(width, data): def pack(width, data):
return (width, data) return (width, data)
packs = {w: (lambda *data, width=w: pack(width, data)) for w in (1, 2, 4)} packs = {w: (lambda *data, width=w: pack(width, data)) for w in (1, 2, 4)}
assert packs[1]('a') == (1, ('a',)) assert packs[1]("a") == (1, ("a",))
assert packs[2]('b') == (2, ('b',)) assert packs[2]("b") == (2, ("b",))
assert packs[4]('c') == (4, ('c',)) assert packs[4]("c") == (4, ("c",))

View File

@@ -1,16 +1,19 @@
# From python 3.3.7 trace # From python 3.3.7 trace
# Bug was not having not having semantic rule for conditional not # Bug was not having not having semantic rule for conditional not
# RUNNABLE! # RUNNABLE!
def init(modules=None): def init(modules=None):
mods = set() if not modules else set(modules) mods = set() if not modules else set(modules)
return mods return mods
assert init() == set() assert init() == set()
assert init([1, 2, 3]) == set([1, 2, 3]) assert init([1, 2, 3]) == set([1, 2, 3])
# From 3.6 sre_parse # 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): def _escape(a, b, c, d, e):
if a: if a:
if b: if b:
@@ -24,15 +27,16 @@ def _escape(a, b, c, d, e):
return return
raise raise
assert _escape(False, True, True, True, True) is None
assert _escape(True, True, True, False, True) is None assert _escape(False, True, True, True, True) is None
assert _escape(True, True, False, False, True) is None assert _escape(True, True, True, False, True) is None
assert _escape(True, True, False, False, True) is None
for args in ( for args in (
(True, True, True, False, True), (True, True, True, False, True),
(True, False, True, True, True), (True, False, True, True, True),
(True, False, True, True, False), (True, False, True, True, False),
): ):
try: try:
_escape(*args) _escape(*args)
assert False, args assert False, args

View File

@@ -1,8 +1,9 @@
# From Python 3.4 asynchat.py # 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 # SETUP_LOOP testexpr return_stmts POP_BLOCK COME_FROM_LOOP
# Note: that there is no JUMP_BACK because of the return_stmts. # Note: that there is no JUMP_BACK because of the return_stmts.
def initiate_send(a, b, c, num_sent): def initiate_send(a, b, c, num_sent):
while a and b: while a and b:
try: try:
@@ -24,6 +25,7 @@ def initiate_send2(a, b):
return 2 return 2
assert initiate_send(1, 1, 2, False) == 1 assert initiate_send(1, 1, 2, False) == 1
assert initiate_send(1, 2, 3, False) == 3 assert initiate_send(1, 2, 3, False) == 3
assert initiate_send(1, 2, 3, True) == 2 assert initiate_send(1, 2, 3, True) == 2

View File

@@ -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): def foo1(bar, baz=1):
return 1 return 1
def foo2(bar, baz, qux=1): def foo2(bar, baz, qux=1):
return 2 return 2
def foo3(bar, baz=1, qux=2): def foo3(bar, baz=1, qux=2):
return 3 return 3
def foo4(bar, baz, qux=1, quux=2): def foo4(bar, baz, qux=1, quux=2):
return 4 return 4
# From 3.6 compileall. # From 3.6 compileall.
# Bug was in omitting default which when used in an "if" # Bug was in omitting default which when used in an "if"
# are treated as False would be # are treated as False would be

View File

@@ -1,17 +1,23 @@
# From 3.6 test_abc.py # From 3.6 test_abc.py
# Bug was Reciever() class definition # Bug was Receiver() class definition
import abc import abc
import unittest import unittest
class TestABCWithInitSubclass(unittest.TestCase): class TestABCWithInitSubclass(unittest.TestCase):
def test_works_with_init_subclass(self): def test_works_with_init_subclass(self):
class ReceivesClassKwargs: class ReceivesClassKwargs:
def __init_subclass__(cls, **kwargs): def __init_subclass__(cls, **kwargs):
super().__init_subclass__() super().__init_subclass__()
class Receiver(ReceivesClassKwargs, abc.ABC, x=1, y=2, z=3): class Receiver(ReceivesClassKwargs, abc.ABC, x=1, y=2, z=3):
pass pass
def test_abstractmethod_integration(self): def test_abstractmethod_integration(self):
for abstractthing in [abc.abstractmethod]: for abstractthing in [abc.abstractmethod]:
class C(metaclass=abc.ABCMeta): class C(metaclass=abc.ABCMeta):
@abstractthing @abstractthing
def foo(self): pass # abstract def foo(self):
pass # abstract

View File

@@ -1,12 +1,12 @@
# From 3.6 base64.py # 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 # locations
def _85encode(foldnuls, words): def _85encode(foldnuls, words):
return ['z' if foldnuls and word return ["z" if foldnuls and word else "y" for word in words]
else 'y'
for word in words]
# From Python 3.6 enum.py # From Python 3.6 enum.py
def __new__(metacls, cls, bases, classdict): def __new__(metacls, cls, bases, classdict):
{k: classdict[k] for k in classdict._member_names} {k: classdict[k] for k in classdict._member_names}

View File

@@ -14,6 +14,7 @@ assert (
assert "def0" == f"{abc}0" assert "def0" == f"{abc}0"
assert "defdef" == f"{abc}{abc!s}" assert "defdef" == f"{abc}{abc!s}"
# From 3.8 test/test_string.py # From 3.8 test/test_string.py
# We had the precedence of yield vs. lambda incorrect. # We had the precedence of yield vs. lambda incorrect.
def fn(x): def fn(x):
@@ -97,9 +98,10 @@ else:
(x, y, width) = ("foo", 2, 10) (x, y, width) = ("foo", 2, 10)
assert f"x={x*y:{width}}" == "x=foofoo " assert f"x={x*y:{width}}" == "x=foofoo "
# Why the fact that the distinction of docstring versus stmt is a # Why the fact that the distinction of docstring versus stmt is a
# string expression is important academic, but we will decompile an # 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 # instead of a format string
def f(): def f():
f"""Not a docstring""" # noqa f"""Not a docstring""" # noqa

View File

@@ -1,26 +1,27 @@
# From 3.6 _markupbase.py # From 3.6 _markupbase.py
# Bug is that the routine is long enough that POP_JUMP_IF_FALSE instruciton has an # Bug is that the routine is long enough that POP_JUMP_IF_FALSE instruction has an
# EXTENDED_ARG intruction before it and we weren't picking out the jump offset properly # EXTENDED_ARG instruction before it and we weren't picking out the jump offset properly
def parse_declaration(self, i): def parse_declaration(self, i):
if rawdata[j:j] in ("-", ""): if rawdata[j:j] in ("-", ""):
return -1 return -1
n = len(rawdata) n = len(rawdata)
if rawdata[j:j+2] == '-': if rawdata[j : j + 2] == "-":
return self.parse_comment(i) return self.parse_comment(i)
elif rawdata[j] == '[': elif rawdata[j] == "[":
return self.parse_marked_section(i) return self.parse_marked_section(i)
else: else:
decltype, j = self._scan_name(j, i) decltype, j = self._scan_name(j, i)
if j < 0: if j < 0:
return j return j
if decltype == "d": if decltype == "d":
self._decl_otherchars = '' self._decl_otherchars = ""
while j < n: while j < n:
c = rawdata[j] c = rawdata[j]
if c == ">": if c == ">":
data = rawdata[i+2:j] data = rawdata[i + 2 : j]
if decltype == "d": if decltype == "d":
self.handle_decl(data) self.handle_decl(data)
else: else:
@@ -43,8 +44,7 @@ def parse_declaration(self, i):
else: else:
self.error("unexpected '[' char in declaration") self.error("unexpected '[' char in declaration")
else: else:
self.error( self.error("unexpected %r char in declaration" % rawdata[j])
"unexpected %r char in declaration" % rawdata[j])
if j < 0: if j < 0:
return j return j
return -1 return -1

View File

@@ -1,5 +1,5 @@
# Tests custom added grammar rule: # Tests custom added grammar rule:
# expr ::= expr {expr}^n CALL_FUNCTION_n # 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 # expr ::= expr expr expr CALL_FUNCTION_2
max(1, 2) max(1, 2)

View File

@@ -27,7 +27,7 @@ while 1:
else: else:
raise RuntimeError 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 # Suggested in issue #172
while 1: while 1:
pass pass

View File

@@ -1,7 +1,8 @@
# From 3.6.10 test_binascii.py # 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" # and not put into the "ifelsesmt"
# RUNNABLE! # RUNNABLE!
def addnoise(c, noise): def addnoise(c, noise):
while c and noise: while c and noise:
@@ -12,6 +13,7 @@ def addnoise(c, noise):
noise = False noise = False
return c return c
assert addnoise(0, True) == 0 assert addnoise(0, True) == 0
assert addnoise(1, False) == 1 assert addnoise(1, False) == 1
assert addnoise(2, True) == 2 assert addnoise(2, True) == 2
@@ -19,9 +21,10 @@ assert addnoise(3, True) == 3
assert addnoise(4, True) == 3 assert addnoise(4, True) == 3
assert addnoise(5, False) == 5 assert addnoise(5, False) == 5
# From 3.6.10 test_dbm_dumb.py # From 3.6.10 test_dbm_dumb.py
# Bug was getting attaching "else" to the right "if" in the # Bug was getting attaching "else" to the right "if" in the
# presense of a loop. # presence of a loop.
def test_random(a, r): def test_random(a, r):
x = 0 x = 0
for dummy in r: for dummy in r:
@@ -32,11 +35,13 @@ def test_random(a, r):
x += 1 x += 1
return x return x
assert test_random(True, [1]) == 2 assert test_random(True, [1]) == 2
assert test_random(True, [1, 1]) == 4 assert test_random(True, [1, 1]) == 4
assert test_random(False, [1]) == 0 assert test_random(False, [1]) == 0
assert test_random(False, [1, 1]) == 0 assert test_random(False, [1, 1]) == 0
# From 2.7.17 test_frozen.py # From 2.7.17 test_frozen.py
# Bug was getting making sure we have "try" not # Bug was getting making sure we have "try" not
# "try"/"else" # "try"/"else"
@@ -53,11 +58,13 @@ def test_frozen(a, b):
return x return x
assert test_frozen(1, 1) == 4.0 assert test_frozen(1, 1) == 4.0
assert test_frozen(0, 1) == 5.0 assert test_frozen(0, 1) == 5.0
assert test_frozen(0.5, 0) == 6.0 assert test_frozen(0.5, 0) == 6.0
assert test_frozen(0, 0.5) == 8.0 assert test_frozen(0, 0.5) == 8.0
# From 3.6.10 test_binop.py # From 3.6.10 test_binop.py
# Bug was getting "other += 3" outside of "if"/"else. # Bug was getting "other += 3" outside of "if"/"else.
def __floordiv__(a, b): def __floordiv__(a, b):
@@ -70,6 +77,7 @@ def __floordiv__(a, b):
other += 3 other += 3
return other return other
assert __floordiv__(True, True) == 4 assert __floordiv__(True, True) == 4
assert __floordiv__(True, False) == 4 assert __floordiv__(True, False) == 4
assert __floordiv__(False, True) == 3 assert __floordiv__(False, True) == 3

View File

@@ -1,19 +1,19 @@
# Self-checking test. # Self-checking test.
# Mixed boolean expresions # Mixed boolean expressions
b = True b = True
assert b, 'b = True' assert b, "b = True"
c = False c = False
assert not c, 'c = False' assert not c, "c = False"
d = True d = True
a = b and c or d 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 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 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 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 a = b or c and d
assert a assert a
a = b and (c or d) a = b and (c or d)

View File

@@ -1,5 +1,5 @@
# 2.6.9 symbols.py # 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 # "and" in the "if" clause
# RUNNABLE # RUNNABLE
@@ -10,7 +10,7 @@ if __name__:
assert False assert False
# 2.6.9 transformer.py # 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" # of the "or" in the "assert"
# In PyPy the assert is handled via PyPy's unique JUMP_IF_NOT_DEBUG # In PyPy the assert is handled via PyPy's unique JUMP_IF_NOT_DEBUG
@@ -24,6 +24,7 @@ elif __file__:
else: else:
pass pass
# From 3.3.7 test_binop.py # From 3.3.7 test_binop.py
# Bug was in ifelsestmt(c) ensuring b+=5 is not in "else" # Bug was in ifelsestmt(c) ensuring b+=5 is not in "else"
# Also note: ifelsetmtc should not have been used since this # Also note: ifelsetmtc should not have been used since this
@@ -36,6 +37,7 @@ def __floordiv__(a, b):
b += 5 b += 5
return b return b
assert __floordiv__(1, 1) == 7 assert __floordiv__(1, 1) == 7
assert __floordiv__(1, 0) == 6 assert __floordiv__(1, 0) == 6
assert __floordiv__(0, 3) == 8 assert __floordiv__(0, 3) == 8