Commit b053cd8f authored by Guido van Rossum's avatar Guido van Rossum

Killed the <> operator. You must now use !=.

Opportunistically also fixed one or two places where '<> None' should be
'is not None' and where 'type(x) <> y' should be 'not isinstance(x, y)'.
parent 01c77c66
......@@ -90,7 +90,7 @@ or_test: and_test ('or' and_test)*
and_test: not_test ('and' not_test)*
not_test: 'not' not_test | comparison
comparison: expr (comp_op expr)*
comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not'
expr: xor_expr ('|' xor_expr)*
xor_expr: and_expr ('^' and_expr)*
and_expr: shift_expr ('&' shift_expr)*
......
......@@ -453,7 +453,7 @@ class bsdTableDB :
# error
dataitem = None
dataitem = mappings[column](dataitem)
if dataitem <> None:
if dataitem != None:
self.db.put(
_data_key(table, column, rowid),
dataitem, txn=txn)
......
......@@ -120,7 +120,7 @@ class CompatibilityTestCase(unittest.TestCase):
try:
rec = f.next()
except KeyError:
assert rec == f.last(), 'Error, last <> last!'
assert rec == f.last(), 'Error, last != last!'
f.previous()
break
if verbose:
......
......@@ -30,7 +30,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
try:
os.remove(self.filename)
except OSError, e:
if e.errno <> errno.EEXIST: raise
if e.errno != errno.EEXIST: raise
def test01_basic(self):
d = db.DB()
......
......@@ -58,7 +58,7 @@ class BaseThreadedTestCase(unittest.TestCase):
try:
os.mkdir(homeDir)
except OSError, e:
if e.errno <> errno.EEXIST: raise
if e.errno != errno.EEXIST: raise
self.env = db.DBEnv()
self.setEnvOpts()
self.env.open(homeDir, self.envflags | db.DB_CREATE)
......
......@@ -618,7 +618,7 @@ class Transformer:
for i in range(2, len(nodelist), 2):
nl = nodelist[i-1]
# comp_op: '<' | '>' | '=' | '>=' | '<=' | '<>' | '!=' | '=='
# comp_op: '<' | '>' | '=' | '>=' | '<=' | '!=' | '=='
# | 'in' | 'not' 'in' | 'is' | 'is' 'not'
n = nl[1]
if n[0] == token.NAME:
......@@ -1396,7 +1396,7 @@ _doc_nodes = [
symbol.power,
]
# comp_op: '<' | '>' | '=' | '>=' | '<=' | '<>' | '!=' | '=='
# comp_op: '<' | '>' | '=' | '>=' | '<=' | '!=' | '=='
# | 'in' | 'not' 'in' | 'is' | 'is' 'not'
_cmp_types = {
token.LESS : '<',
......
......@@ -146,7 +146,7 @@ def encode(s, binary=True, maxlinelen=76, eol=NL):
# BAW: should encode() inherit b2a_base64()'s dubious behavior in
# adding a newline to the encoded string?
enc = b2a_base64(s[i:i + max_unencoded])
if enc.endswith(NL) and eol <> NL:
if enc.endswith(NL) and eol != NL:
enc = enc[:-1] + eol
encvec.append(enc)
return EMPTYSTRING.join(encvec)
......
......@@ -250,7 +250,7 @@ class Charset:
Returns "base64" if self.body_encoding is BASE64.
Returns "7bit" otherwise.
"""
assert self.body_encoding <> SHORTEST
assert self.body_encoding != SHORTEST
if self.body_encoding == QP:
return 'quoted-printable'
elif self.body_encoding == BASE64:
......@@ -260,7 +260,7 @@ class Charset:
def convert(self, s):
"""Convert a string from the input_codec to the output_codec."""
if self.input_codec <> self.output_codec:
if self.input_codec != self.output_codec:
return unicode(s, self.input_codec).encode(self.output_codec)
else:
return s
......
......@@ -211,7 +211,7 @@ class Generator:
# doesn't preserve newlines/continuations in headers. This is no big
# deal in practice, but turns out to be inconvenient for the unittest
# suite.
if msg.get_boundary() <> boundary:
if msg.get_boundary() != boundary:
msg.set_boundary(boundary)
# If there's a preamble, write it out, with a trailing CRLF
if msg.preamble is not None:
......
......@@ -248,7 +248,7 @@ class Header:
elif not isinstance(charset, Charset):
charset = Charset(charset)
# If the charset is our faux 8bit charset, leave the string unchanged
if charset <> '8bit':
if charset != '8bit':
# We need to test that the string can be converted to unicode and
# back to a byte string, given the input and output codecs of the
# charset.
......@@ -454,7 +454,7 @@ def _split_ascii(s, firstlen, restlen, continuation_ws, splitchars):
# If this part is longer than maxlen and we aren't already
# splitting on whitespace, try to recursively split this line
# on whitespace.
if partlen > maxlen and ch <> ' ':
if partlen > maxlen and ch != ' ':
subl = _split_ascii(part, maxlen, restlen,
continuation_ws, ' ')
lines.extend(subl[:-1])
......
......@@ -252,7 +252,7 @@ class Message:
charset=charset.get_output_charset())
else:
self.set_param('charset', charset.get_output_charset())
if str(charset) <> charset.get_output_charset():
if str(charset) != charset.get_output_charset():
self._payload = charset.body_encode(self._payload)
if 'Content-Transfer-Encoding' not in self:
cte = charset.get_body_encoding()
......@@ -301,7 +301,7 @@ class Message:
name = name.lower()
newheaders = []
for k, v in self._headers:
if k.lower() <> name:
if k.lower() != name:
newheaders.append((k, v))
self._headers = newheaders
......@@ -438,7 +438,7 @@ class Message:
return self.get_default_type()
ctype = paramre.split(value)[0].lower().strip()
# RFC 2045, section 5.2 says if its invalid, use text/plain
if ctype.count('/') <> 1:
if ctype.count('/') != 1:
return 'text/plain'
return ctype
......@@ -601,7 +601,7 @@ class Message:
ctype = append_param
else:
ctype = SEMISPACE.join([ctype, append_param])
if ctype <> self.get(header):
if ctype != self.get(header):
del self[header]
self[header] = ctype
......@@ -617,13 +617,13 @@ class Message:
return
new_ctype = ''
for p, v in self.get_params(header=header, unquote=requote):
if p.lower() <> param.lower():
if p.lower() != param.lower():
if not new_ctype:
new_ctype = _formatparam(p, v, requote)
else:
new_ctype = SEMISPACE.join([new_ctype,
_formatparam(p, v, requote)])
if new_ctype <> self.get(header):
if new_ctype != self.get(header):
del self[header]
self[header] = new_ctype
......
......@@ -287,7 +287,7 @@ def decode(encoded, eol=NL):
n = len(line)
while i < n:
c = line[i]
if c <> '=':
if c != '=':
decoded += c
i += 1
# Otherwise, c == "=". Are we at the end of the line? If so, add
......
......@@ -51,7 +51,7 @@ def openfile(filename, mode='r'):
class TestEmailBase(unittest.TestCase):
def ndiffAssertEqual(self, first, second):
"""Like failUnlessEqual except use ndiff for readable output."""
if first <> second:
if first != second:
sfirst = str(first)
ssecond = str(second)
diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines())
......@@ -2726,7 +2726,7 @@ class TestCharset(unittest.TestCase):
# Try a charset with None body encoding
c = Charset('us-ascii')
eq('hello world', c.body_encode('hello world'))
# Try the convert argument, where input codec <> output codec
# Try the convert argument, where input codec != output codec
c = Charset('euc-jp')
# With apologies to Tokio Kikuchi ;)
try:
......
......@@ -52,7 +52,7 @@ def openfile(filename, mode='r'):
class TestEmailBase(unittest.TestCase):
def ndiffAssertEqual(self, first, second):
"""Like failUnlessEqual except use ndiff for readable output."""
if first <> second:
if first != second:
sfirst = str(first)
ssecond = str(second)
diff = difflib.ndiff(sfirst.splitlines(), ssecond.splitlines())
......@@ -2732,7 +2732,7 @@ class TestCharset(unittest.TestCase):
# Try a charset with None body encoding
c = Charset('us-ascii')
eq('hello world', c.body_encode('hello world'))
# Try the convert argument, where input codec <> output codec
# Try the convert argument, where input codec != output codec
c = Charset('euc-jp')
# With apologies to Tokio Kikuchi ;)
try:
......
......@@ -912,7 +912,8 @@ class Manager:
"""
#for c in ph.loggers:
for c in ph.loggerMap.keys():
if string.find(c.parent.name, alogger.name) <> 0:
# XXX Is the following correct? Shouldn't it be >= 0?
if string.find(c.parent.name, alogger.name) != 0:
alogger.parent = c.parent
c.parent = alogger
......
......@@ -602,7 +602,7 @@ class Menu:
def dispatch(self, id, item, window, event):
title, shortcut, callback, mtype = self.items[item-1]
if callback:
if not self.bar.parent or type(callback) <> types.StringType:
if not self.bar.parent or not isinstance(callback, str):
menuhandler = callback
else:
# callback is string
......@@ -748,7 +748,7 @@ class Window:
self.parent = parent
def open(self, bounds=(40, 40, 400, 400), resid=None):
if resid <> None:
if resid is not None:
self.wid = GetNewWindow(resid, -1)
else:
self.wid = NewWindow(bounds, self.__class__.__name__, 1,
......@@ -826,7 +826,7 @@ class Window:
# If we're not frontmost, select ourselves and wait for
# the activate event.
#
if MyFrontWindow() <> window:
if MyFrontWindow() != window:
window.SelectWindow()
return
# We are. Handle the event.
......@@ -875,7 +875,7 @@ class ControlsWindow(Window):
if DEBUG: print "control hit in", window, "on", control, "; pcode =", pcode
def do_inContent(self, partcode, window, event):
if MyFrontWindow() <> window:
if MyFrontWindow() != window:
window.SelectWindow()
return
(what, message, when, where, modifiers) = event
......
......@@ -192,7 +192,7 @@ def process_common(template, progress, code, rsrcname, destname, is_update,
'icl8', 'ics4', 'ics8', 'ICN#', 'ics#']
if not copy_codefragment:
skiptypes.append('cfrg')
## skipowner = (ownertype <> None)
## skipowner = (ownertype != None)
# Copy the resources from the template
......
......@@ -73,7 +73,7 @@ class CfrgResource:
Res.CloseResFile(resref)
Res.UseResFile(currentresref)
self.parse(data)
if self.version <> 1:
if self.version != 1:
raise error, "unknown 'cfrg' resource format"
def parse(self, data):
......@@ -143,7 +143,7 @@ class FragmentDescriptor:
return data
def getfragment(self):
if self.where <> 1:
if self.where != 1:
raise error, "can't read fragment, unsupported location"
f = open(self.path, "rb")
f.seek(self.offset)
......@@ -155,7 +155,7 @@ class FragmentDescriptor:
return frag
def copydata(self, outfile):
if self.where <> 1:
if self.where != 1:
raise error, "can't read fragment, unsupported location"
infile = open(self.path, "rb")
if self.length == 0:
......
......@@ -169,7 +169,7 @@ def processfile_fromresource(fullname, output=None, basepkgname=None,
aete = decode(data, verbose)
aetelist.append((aete, res.GetResInfo()))
finally:
if rf <> cur:
if rf != cur:
CloseResFile(rf)
UseResFile(cur)
# switch back (needed for dialogs in Python)
......@@ -332,7 +332,7 @@ def getpstr(f, *args):
def getalign(f):
if f.tell() & 1:
c = f.read(1)
##if c <> '\0':
##if c != '\0':
## print align:', repr(c)
def getlist(f, description, getitem):
......@@ -779,7 +779,7 @@ class SuiteCompiler:
if is_enum(a[2]):
kname = a[1]
ename = a[2][0]
if ename <> '****':
if ename != '****':
fp.write(" aetools.enumsubst(_arguments, %r, _Enum_%s)\n" %
(kname, identify(ename)))
self.enumsneeded[ename] = 1
......@@ -810,7 +810,7 @@ class SuiteCompiler:
for a in arguments:
if is_enum(a[2]):
ename = a[2][0]
if ename <> '****':
if ename != '****':
self.enumsneeded[ename] = 1
#
......
......@@ -1574,7 +1574,7 @@ smFHBlkDispErr = -311 #Error occurred during _sDisposePtr (Dispose of FHea
smFHBlockRdErr = -310 #Error occurred during _sGetFHeader.
smBLFieldBad = -309 #ByteLanes field was bad.
smUnExBusErr = -308 #Unexpected BusError
smResrvErr = -307 #Fatal reserved error. Resreved field <> 0.
smResrvErr = -307 #Fatal reserved error. Resreved field != 0.
smNosInfoArray = -306 #No sInfoArray. Memory Mgr error.
smDisabledSlot = -305 #This slot is disabled (-305 use to be smLWTstBad)
smNoDir = -304 #Directory offset is Nil
......
......@@ -55,12 +55,10 @@ __eq__: (1,)
__lt__: (1,)
__gt__: (1,)
__ne__: (1,)
__ne__: (1,)
__eq__: (1,)
__gt__: (1,)
__lt__: (1,)
__ne__: (1,)
__ne__: (1,)
__del__: ()
__getattr__: ('spam',)
__setattr__: ('eggs', 'spam, spam, spam and ham')
......
......@@ -108,11 +108,11 @@ test_tokenize
37,0-37,1: NL '\n'
38,0-38,20: COMMENT '# Ordinary integers\n'
39,0-39,4: NUMBER '0xff'
39,5-39,7: OP '<>'
39,5-39,7: OP '!='
39,8-39,11: NUMBER '255'
39,11-39,12: NEWLINE '\n'
40,0-40,4: NUMBER '0377'
40,5-40,7: OP '<>'
40,5-40,7: OP '!='
40,8-40,11: NUMBER '255'
40,11-40,12: NEWLINE '\n'
41,0-41,10: NUMBER '2147483647'
......@@ -484,7 +484,7 @@ test_tokenize
149,2-149,3: OP ','
149,4-149,5: NAME 'y'
149,5-149,6: OP ')'
149,7-149,9: OP '<>'
149,7-149,9: OP '!='
149,10-149,11: OP '('
149,11-149,12: OP '{'
149,12-149,15: STRING "'a'"
......@@ -513,7 +513,7 @@ test_tokenize
152,21-152,22: NUMBER '1'
152,23-152,25: OP '<='
152,26-152,27: NUMBER '1'
152,28-152,30: OP '<>'
152,28-152,30: OP '!='
152,31-152,32: NUMBER '1'
152,33-152,35: OP '!='
152,36-152,37: NUMBER '1'
......
......@@ -8,7 +8,7 @@ from test.test_support import requires, verbose, run_suite, unlink
# When running as a script instead of within the regrtest framework, skip the
# requires test, since it's obvious we want to run them.
if __name__ <> '__main__':
if __name__ != '__main__':
requires('bsddb')
verbose = False
......
......@@ -244,12 +244,10 @@ str(testme)
testme == 1
testme < 1
testme > 1
testme <> 1
testme != 1
1 == testme
1 < testme
1 > testme
1 <> testme
1 != testme
# This test has to be last (duh.)
......
......@@ -19,16 +19,16 @@ try:
except AttributeError: pass
else: raise TestFailed, 'expected AttributeError'
if b.__dict__ <> {}:
if b.__dict__ != {}:
raise TestFailed, 'expected unassigned func.__dict__ to be {}'
b.publish = 1
if b.publish <> 1:
if b.publish != 1:
raise TestFailed, 'function attribute not set to expected value'
docstring = 'its docstring'
b.__doc__ = docstring
if b.__doc__ <> docstring:
if b.__doc__ != docstring:
raise TestFailed, 'problem with setting __doc__ attribute'
if 'publish' not in dir(b):
......@@ -49,7 +49,7 @@ d = {'hello': 'world'}
b.__dict__ = d
if b.func_dict is not d:
raise TestFailed, 'func.__dict__ assignment to dictionary failed'
if b.hello <> 'world':
if b.hello != 'world':
raise TestFailed, 'attribute after func.__dict__ assignment failed'
f1 = F()
......@@ -75,13 +75,13 @@ else: raise TestFailed, 'expected AttributeError or TypeError'
# But setting it explicitly on the underlying function object is okay.
F.a.im_func.publish = 1
if F.a.publish <> 1:
if F.a.publish != 1:
raise TestFailed, 'unbound method attribute not set to expected value'
if f1.a.publish <> 1:
if f1.a.publish != 1:
raise TestFailed, 'bound method attribute access did not work'
if f2.a.publish <> 1:
if f2.a.publish != 1:
raise TestFailed, 'bound method attribute access did not work'
if 'publish' not in dir(F.a):
......@@ -117,7 +117,7 @@ else: raise TestFailed, 'expected TypeError or AttributeError'
F.a.im_func.__dict__ = {'one': 11, 'two': 22, 'three': 33}
if f1.a.two <> 22:
if f1.a.two != 22:
raise TestFailed, 'setting __dict__'
from UserDict import UserDict
......@@ -128,7 +128,7 @@ try:
except (AttributeError, TypeError): pass
else: raise TestFailed
if f2.a.one <> f1.a.one <> F.a.one <> 11:
if f2.a.one != f1.a.one != F.a.one != 11:
raise TestFailed
# im_func may not be a Python method!
......@@ -136,7 +136,7 @@ import new
F.id = new.instancemethod(id, None, F)
eff = F()
if eff.id() <> id(eff):
if eff.id() != id(eff):
raise TestFailed
try:
......
......@@ -412,7 +412,7 @@ def test_break_continue_loop(extra_burning_oil = 1, count=0):
continue
except:
raise
if count > 2 or big_hippo <> 1:
if count > 2 or big_hippo != 1:
print "continue then break in try/except in loop broken!"
test_break_continue_loop()
......@@ -586,12 +586,11 @@ if 1 and 1 or 1 and 1 and 1 or not 1 and 1: pass
print 'comparison'
### comparison: expr (comp_op expr)*
### comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'|'is' 'not'
### comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'|'is' 'not'
if 1: pass
x = (1 == 1)
if 1 == 1: pass
if 1 != 1: pass
if 1 <> 1: pass
if 1 < 1: pass
if 1 > 1: pass
if 1 <= 1: pass
......@@ -600,7 +599,7 @@ if 1 is 1: pass
if 1 is not 1: pass
if 1 in (): pass
if 1 not in (): pass
if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1: pass
if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 in 1 not in 1 is 1 is not 1: pass
print 'binary mask ops'
x = 1 & 1
......
......@@ -285,7 +285,7 @@ class GeneralModuleTests(unittest.TestCase):
orig = sys.getrefcount(__name__)
socket.getnameinfo(__name__,0)
except SystemError:
if sys.getrefcount(__name__) <> orig:
if sys.getrefcount(__name__) != orig:
self.fail("socket.getnameinfo loses a reference")
def testInterpreterCrash(self):
......
......@@ -515,7 +515,7 @@ class HandlerTests(TestCase):
"Content-Length: %d\r\n"
"\r\n%s" % (h.error_status,len(h.error_body),h.error_body))
self.failUnless(h.stderr.getvalue().find("AssertionError")<>-1)
self.failUnless("AssertionError" in h.stderr.getvalue())
def testErrorAfterOutput(self):
MSG = "Some output has been sent"
......@@ -528,7 +528,7 @@ class HandlerTests(TestCase):
self.assertEqual(h.stdout.getvalue(),
"Status: 200 OK\r\n"
"\r\n"+MSG)
self.failUnless(h.stderr.getvalue().find("AssertionError")<>-1)
self.failUnless("AssertionError" in h.stderr.getvalue())
def testHeaderFormats(self):
......
......@@ -36,8 +36,8 @@ x = 1 \
x = 0
# Ordinary integers
0xff <> 255
0377 <> 255
0xff != 255
0377 != 255
2147483647 != 017777777777
-2147483647-1 != 020000000000
037777777777 != -1
......@@ -146,10 +146,10 @@ if 0:
def d22(a, b, c=1, d=2): pass
def d01v(a=1, *restt, **restd): pass
(x, y) <> ({'a':1}, {'b':2})
(x, y) != ({'a':1}, {'b':2})
# comparison
if 1 < 1 > 1 == 1 >= 1 <= 1 <> 1 != 1 in 1 not in 1 is 1 is not 1: pass
if 1 < 1 > 1 == 1 >= 1 <= 1 != 1 != 1 in 1 not in 1 is 1 is not 1: pass
# binary
x = 1 & 1
......
......@@ -77,7 +77,7 @@ String = group(r"[uU]?[rR]?'[^\n'\\]*(?:\\.[^\n'\\]*)*'",
# Because of leftmost-then-longest match semantics, be sure to put the
# longest operators first (e.g., if = came before ==, == would get
# recognized as two instances of =).
Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"<>", r"!=",
Operator = group(r"\*\*=?", r">>=?", r"<<=?", r"!=",
r"//=?",
r"[+\-*/%&|^=<>]=?",
r"~")
......
......@@ -627,7 +627,7 @@ def main():
for o, a in opts:
if o == '-n': new_win = 1
elif o == '-t': new_win = 2
if len(args) <> 1:
if len(args) != 1:
print >>sys.stderr, usage
sys.exit(1)
......
......@@ -63,7 +63,7 @@ class Headers:
Does *not* raise an exception if the header is missing.
"""
name = name.lower()
self._headers[:] = [kv for kv in self._headers if kv[0].lower()<>name]
self._headers[:] = [kv for kv in self._headers if kv[0].lower() != name]
def __getitem__(self,name):
"""Get the first header value for 'name'
......
......@@ -98,7 +98,7 @@ def shift_path_info(environ):
return None
path_parts = path_info.split('/')
path_parts[1:-1] = [p for p in path_parts[1:-1] if p and p<>'.']
path_parts[1:-1] = [p for p in path_parts[1:-1] if p and p != '.']
name = path_parts[1]
del path_parts[1]
......
......@@ -982,7 +982,6 @@ PyToken_TwoChars(int c1, int c2)
break;
case '<':
switch (c2) {
case '>': return NOTEQUAL;
case '=': return LESSEQUAL;
case '<': return LEFTSHIFT;
}
......
......@@ -478,7 +478,7 @@ ast_for_augassign(const node *n)
static cmpop_ty
ast_for_comp_op(const node *n)
{
/* comp_op: '<'|'>'|'=='|'>='|'<='|'<>'|'!='|'in'|'not' 'in'|'is'
/* comp_op: '<'|'>'|'=='|'>='|'<='|'!='|'in'|'not' 'in'|'is'
|'is' 'not'
*/
REQ(n, comp_op);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment