Whitespace normalization.

This commit is contained in:
Tim Peters 2002-04-16 01:38:40 +00:00
parent c86c1b88f9
commit 863ac44b74
23 changed files with 84 additions and 88 deletions

View file

@ -32,7 +32,7 @@ XXX To do:
# Network Working Group R. Fielding # Network Working Group R. Fielding
# Request for Comments: 2616 et al # Request for Comments: 2616 et al
# Obsoletes: 2068 June 1999 # Obsoletes: 2068 June 1999
# Category: Standards Track # Category: Standards Track
# #
# URL: http://www.faqs.org/rfcs/rfc2616.html # URL: http://www.faqs.org/rfcs/rfc2616.html

View file

@ -66,10 +66,10 @@ class async_chat (asyncore.dispatcher):
def collect_incoming_data(self, data): def collect_incoming_data(self, data):
raise NotImplementedError, "must be implemented in subclass" raise NotImplementedError, "must be implemented in subclass"
def found_terminator(self): def found_terminator(self):
raise NotImplementedError, "must be implemented in subclass" raise NotImplementedError, "must be implemented in subclass"
def set_terminator (self, term): def set_terminator (self, term):
"Set the input delimiter. Can be a fixed string of any length, an integer, or None" "Set the input delimiter. Can be a fixed string of any length, an integer, or None"
self.terminator = term self.terminator = term
@ -291,7 +291,7 @@ class fifo:
# regex: 14035/s # regex: 14035/s
def find_prefix_at_end (haystack, needle): def find_prefix_at_end (haystack, needle):
l = len(needle) - 1 l = len(needle) - 1
while l and not haystack.endswith(needle[:l]): while l and not haystack.endswith(needle[:l]):
l -= 1 l -= 1
return l return l

View file

@ -183,7 +183,7 @@ class FileInput:
if not line: if not line:
raise StopIteration raise StopIteration
return line return line
def __getitem__(self, i): def __getitem__(self, i):
if i != self._lineno: if i != self._lineno:
raise RuntimeError, "accessing lines out of order" raise RuntimeError, "accessing lines out of order"

View file

@ -136,7 +136,7 @@ class GzipFile:
if self.mode != WRITE: if self.mode != WRITE:
import errno import errno
raise IOError(errno.EBADF, "write() on read-only GzipFile object") raise IOError(errno.EBADF, "write() on read-only GzipFile object")
if self.fileobj is None: if self.fileobj is None:
raise ValueError, "write() on closed GzipFile object" raise ValueError, "write() on closed GzipFile object"
if len(data) > 0: if len(data) > 0:
@ -149,7 +149,7 @@ class GzipFile:
if self.mode != READ: if self.mode != READ:
import errno import errno
raise IOError(errno.EBADF, "write() on read-only GzipFile object") raise IOError(errno.EBADF, "write() on read-only GzipFile object")
if self.extrasize <= 0 and self.fileobj is None: if self.extrasize <= 0 and self.fileobj is None:
return '' return ''

View file

@ -1012,7 +1012,7 @@ class IMAP4_SSL(IMAP4):
""" """
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
self.sock.connect((self.host, self.port)) self.sock.connect((self.host, self.port))
self.sslobj = socket.ssl(self.sock,self.keyfile, self.certfile) self.sslobj = socket.ssl(self.sock,self.keyfile, self.certfile)
def read(self, size): def read(self, size):

View file

@ -1,5 +1,5 @@
# Module 'os2emxpath' -- common operations on OS/2 pathnames # Module 'os2emxpath' -- common operations on OS/2 pathnames
"""Common pathname manipulations, OS/2 EMX version. """Common pathname manipulations, OS/2 EMX version.
Instead of importing this module directly, import os and refer to this Instead of importing this module directly, import os and refer to this
module as os.path. module as os.path.

View file

@ -92,7 +92,7 @@ from pcre import *
import warnings as _warnings import warnings as _warnings
_warnings.warn("Please use the 're' module, not the 'pre' module", _warnings.warn("Please use the 're' module, not the 'pre' module",
DeprecationWarning) DeprecationWarning)
__all__ = ["match","search","sub","subn","split","findall","escape","compile", __all__ = ["match","search","sub","subn","split","findall","escape","compile",
"I","L","M","S","X","IGNORECASE","LOCALE","MULTILINE","DOTALL", "I","L","M","S","X","IGNORECASE","LOCALE","MULTILINE","DOTALL",
"VERBOSE","error"] "VERBOSE","error"]

View file

@ -18,4 +18,3 @@
from sre import * from sre import *
from sre import __all__ from sre import __all__

View file

@ -60,7 +60,7 @@ class Completer:
readline.set_completer(Completer(my_namespace).complete) readline.set_completer(Completer(my_namespace).complete)
""" """
if namespace and not isinstance(namespace, dict): if namespace and not isinstance(namespace, dict):
raise TypeError,'namespace must be a dictionary' raise TypeError,'namespace must be a dictionary'
@ -82,7 +82,7 @@ class Completer:
""" """
if self.use_main_ns: if self.use_main_ns:
self.namespace = __main__.__dict__ self.namespace = __main__.__dict__
if state == 0: if state == 0:
if "." in text: if "." in text:
self.matches = self.attr_matches(text) self.matches = self.attr_matches(text)

View file

@ -227,8 +227,8 @@ class SMTP:
connect. If specified, `port' specifies the port to which to connect. connect. If specified, `port' specifies the port to which to connect.
By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised By default, smtplib.SMTP_PORT is used. An SMTPConnectError is raised
if the specified `host' doesn't respond correctly. If specified, if the specified `host' doesn't respond correctly. If specified,
`local_hostname` is used as the FQDN of the local host. By default, `local_hostname` is used as the FQDN of the local host. By default,
the local hostname is found using socket.getfqdn(). the local hostname is found using socket.getfqdn().
""" """
self.esmtp_features = {} self.esmtp_features = {}

View file

@ -253,7 +253,7 @@ class AbstractPickleTests(unittest.TestCase):
t = time.localtime() t = time.localtime()
s = self.dumps(t) s = self.dumps(t)
u = self.loads(s) u = self.loads(s)
self.assertEqual(t, u) self.assertEqual(t, u)
import os import os
if hasattr(os, "stat"): if hasattr(os, "stat"):
t = os.stat(os.curdir) t = os.stat(os.curdir)

View file

@ -239,7 +239,7 @@ def run_method_tests(test):
test('zfill', '', '000', 3) test('zfill', '', '000', 3)
test('zfill', '34', '34', 1) test('zfill', '34', '34', 1)
test('zfill', '34', '0034', 4) test('zfill', '34', '0034', 4)
# Encoding/decoding # Encoding/decoding
codecs = [('rot13', 'uryyb jbeyq'), codecs = [('rot13', 'uryyb jbeyq'),
('base64', 'aGVsbG8gd29ybGQ=\n'), ('base64', 'aGVsbG8gd29ybGQ=\n'),

View file

@ -67,7 +67,7 @@ foo = another very
foo = this line is much, much longer than my editor foo = this line is much, much longer than my editor
likes it. likes it.
""") """)
def case_sensitivity(): def case_sensitivity():
print "Testing case sensitivity..." print "Testing case sensitivity..."
cf = ConfigParser.ConfigParser() cf = ConfigParser.ConfigParser()

View file

@ -313,7 +313,7 @@ class TestMessageAPI(TestEmailBase):
msg.del_param("report-type") msg.del_param("report-type")
eq(msg.get_params(), eq(msg.get_params(),
[('multipart/report', ''), [('multipart/report', ''),
('boundary', 'D1690A7AC1.996856090/mail.example.com')]) ('boundary', 'D1690A7AC1.996856090/mail.example.com')])
msg.set_param("report-type", old_val) msg.set_param("report-type", old_val)
eq(msg.get_params(), eq(msg.get_params(),
[('multipart/report', ''), [('multipart/report', ''),
@ -331,7 +331,7 @@ class TestMessageAPI(TestEmailBase):
msg.set_type('text/html') msg.set_type('text/html')
eq(msg['content-type'], 'text/html; charset="us-ascii"') eq(msg['content-type'], 'text/html; charset="us-ascii"')
# Test the email.Encoders module # Test the email.Encoders module
class TestEncoders(unittest.TestCase): class TestEncoders(unittest.TestCase):
@ -409,7 +409,7 @@ Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0 MIME-Version: 1.0
Content-Transfer-Encoding: 7bit Content-Transfer-Encoding: 7bit
X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals"; X-Foobar-Spoink-Defrobnit: wasnipoop; giraffes="very-long-necked-animals";
spooge="yummy"; hippos="gargantuan"; marshmallows="gooey" spooge="yummy"; hippos="gargantuan"; marshmallows="gooey"
''') ''')
@ -450,22 +450,22 @@ Test""")
msg = Message() msg = Message()
msg['Received'] = """\ msg['Received'] = """\
from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST) from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST) from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST) from babylon.socal-raves.org (localhost [127.0.0.1]); by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; for <mailman-admin@babylon.socal-raves.org>; Sat, 2 Feb 2002 17:00:06 -0800 (PST)
""" """
self.assertEqual(msg.as_string(), """\ self.assertEqual(msg.as_string(), """\
Received: from babylon.socal-raves.org (localhost [127.0.0.1]); Received: from babylon.socal-raves.org (localhost [127.0.0.1]);
by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
for <mailman-admin@babylon.socal-raves.org>; for <mailman-admin@babylon.socal-raves.org>;
Sat, 2 Feb 2002 17:00:06 -0800 (PST) Sat, 2 Feb 2002 17:00:06 -0800 (PST)
from babylon.socal-raves.org (localhost [127.0.0.1]); from babylon.socal-raves.org (localhost [127.0.0.1]);
by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
for <mailman-admin@babylon.socal-raves.org>; for <mailman-admin@babylon.socal-raves.org>;
Sat, 2 Feb 2002 17:00:06 -0800 (PST) Sat, 2 Feb 2002 17:00:06 -0800 (PST)
from babylon.socal-raves.org (localhost [127.0.0.1]); from babylon.socal-raves.org (localhost [127.0.0.1]);
by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81; by babylon.socal-raves.org (Postfix) with ESMTP id B570E51B81;
for <mailman-admin@babylon.socal-raves.org>; for <mailman-admin@babylon.socal-raves.org>;
Sat, 2 Feb 2002 17:00:06 -0800 (PST) Sat, 2 Feb 2002 17:00:06 -0800 (PST)
""") """)
@ -721,7 +721,7 @@ From: bperson@dom.ain
--BOUNDARY-- --BOUNDARY--
''') ''')
def test_one_part_in_a_multipart(self): def test_one_part_in_a_multipart(self):
outer = MIMEBase('multipart', 'mixed') outer = MIMEBase('multipart', 'mixed')
@ -748,7 +748,7 @@ Content-Transfer-Encoding: 7bit
hello world hello world
--BOUNDARY-- --BOUNDARY--
''') ''')
def test_seq_parts_in_a_multipart(self): def test_seq_parts_in_a_multipart(self):
outer = MIMEBase('multipart', 'mixed') outer = MIMEBase('multipart', 'mixed')
@ -775,7 +775,7 @@ Content-Transfer-Encoding: 7bit
hello world hello world
--BOUNDARY-- --BOUNDARY--
''') ''')
@ -1163,11 +1163,11 @@ class TestMiscellaneous(unittest.TestCase):
module = __import__('email') module = __import__('email')
all = module.__all__ all = module.__all__
all.sort() all.sort()
self.assertEqual(all, ['Charset', 'Encoders', 'Errors', 'Generator', self.assertEqual(all, ['Charset', 'Encoders', 'Errors', 'Generator',
'Header', 'Iterators', 'MIMEAudio', 'Header', 'Iterators', 'MIMEAudio',
'MIMEBase', 'MIMEImage', 'MIMEMessage', 'MIMEBase', 'MIMEImage', 'MIMEMessage',
'MIMEText', 'Message', 'Parser', 'MIMEText', 'Message', 'Parser',
'Utils', 'base64MIME', 'Utils', 'base64MIME',
'message_from_file', 'message_from_string', 'message_from_file', 'message_from_string',
'quopriMIME']) 'quopriMIME'])
@ -1313,7 +1313,7 @@ class TestParsers(unittest.TestCase):
From: aperson@dom.ain From: aperson@dom.ain
To: bperson@dom.ain To: bperson@dom.ain
Subject: the next line has a space on it Subject: the next line has a space on it
Date: Mon, 8 Apr 2002 15:09:19 -0400 Date: Mon, 8 Apr 2002 15:09:19 -0400
Message-ID: spam Message-ID: spam
@ -1367,7 +1367,7 @@ eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r eHh4eCB4eHh4IHh4eHggeHh4eCB4eHh4IHh4eHgg\r
eHh4eCB4eHh4IA==\r eHh4eCB4eHh4IA==\r
""") """)
def test_header_encode(self): def test_header_encode(self):
eq = self.assertEqual eq = self.assertEqual
he = base64MIME.header_encode he = base64MIME.header_encode
@ -1504,7 +1504,7 @@ two line"""), """\
one line one line
two line""") two line""")
# Test the Charset class # Test the Charset class

View file

@ -6,9 +6,9 @@ from test_support import TestFailed, TestSkipped
REPS = 65580 REPS = 65580
if sys.platform == 'mac': if sys.platform == 'mac':
import gestalt import gestalt
if gestalt.gestalt('sysv') > 0x9ff: if gestalt.gestalt('sysv') > 0x9ff:
raise TestSkipped, 'Triggers pathological malloc slowdown on OSX MacPython' raise TestSkipped, 'Triggers pathological malloc slowdown on OSX MacPython'
if sys.platform == "os2emx": if sys.platform == "os2emx":
raise TestFailed, "OS/2+EMX port has malloc problems with long expressions" raise TestFailed, "OS/2+EMX port has malloc problems with long expressions"
else: else:

View file

@ -87,4 +87,3 @@ else: raise TestFailed, 'gcdext(10, 10.) should raise a TypeError'
try: mpz.mpz(-10).binary() try: mpz.mpz(-10).binary()
except ValueError: pass except ValueError: pass
else: raise TestFailed, 'mpz(-10).binary() should raise a ValueError' else: raise TestFailed, 'mpz(-10).binary() should raise a ValueError'

View file

@ -12,7 +12,7 @@ macdef macro2
line3 line3
line4 line4
default login log2 password pass2 default login log2 password pass2
""" """
@ -25,7 +25,7 @@ class NetrcTestCase(unittest.TestCase):
fp.write(TEST_NETRC) fp.write(TEST_NETRC)
fp.close() fp.close()
self.netrc = netrc.netrc(temp_filename) self.netrc = netrc.netrc(temp_filename)
def tearDown (self): def tearDown (self):
del self.netrc del self.netrc
os.unlink(temp_filename) os.unlink(temp_filename)
@ -36,8 +36,7 @@ class NetrcTestCase(unittest.TestCase):
) )
self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1')) self.assert_(self.netrc.hosts['foo'] == ('log1', 'acct1', 'pass1'))
self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2')) self.assert_(self.netrc.hosts['default'] == ('log2', None, 'pass2'))
if __name__ == "__main__": if __name__ == "__main__":
test_support.run_unittest(NetrcTestCase) test_support.run_unittest(NetrcTestCase)

View file

@ -30,14 +30,14 @@ tests = unittest.TestSuite()
def RobotTest(index, robots_txt, good_urls, bad_urls, def RobotTest(index, robots_txt, good_urls, bad_urls,
agent="test_robotparser"): agent="test_robotparser"):
lines = StringIO.StringIO(robots_txt).readlines() lines = StringIO.StringIO(robots_txt).readlines()
parser = robotparser.RobotFileParser() parser = robotparser.RobotFileParser()
parser.parse(lines) parser.parse(lines)
for url in good_urls: for url in good_urls:
tests.addTest(RobotTestCase(index, parser, url, 1, agent)) tests.addTest(RobotTestCase(index, parser, url, 1, agent))
for url in bad_urls: for url in bad_urls:
tests.addTest(RobotTestCase(index, parser, url, 0, agent)) tests.addTest(RobotTestCase(index, parser, url, 0, agent))
# Examples from http://www.robotstxt.org/wc/norobots.html (fetched 2002) # Examples from http://www.robotstxt.org/wc/norobots.html (fetched 2002)
@ -116,7 +116,7 @@ Disallow: /%7ejoe/index.html
good = ['/tmp',] # XFAIL: '/a%2fb.html' good = ['/tmp',] # XFAIL: '/a%2fb.html'
bad = ['/tmp/','/tmp/a.html', bad = ['/tmp/','/tmp/a.html',
'/a%3cd.html','/a%3Cd.html',"/a/b.html", '/a%3cd.html','/a%3Cd.html',"/a/b.html",
'/%7Ejoe/index.html'] '/%7Ejoe/index.html']
RobotTest(6, doc, good, bad) RobotTest(6, doc, good, bad)

View file

@ -494,7 +494,7 @@ else: raise TestFailed, "{}.pop(k) doesn't raise KeyError when dictionary is emp
d[1] = 1 d[1] = 1
try: try:
for i in d: for i in d:
d[i+1] = 1 d[i+1] = 1
except RuntimeError: except RuntimeError:
pass pass
else: else:

View file

@ -523,7 +523,7 @@ verify(u'\u6b63\u78ba\u306b\u8a00\u3046\u3068\u7ffb\u8a33\u306f'
u'\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c' u'\u90e8\u306f\u30c9\u30a4\u30c4\u8a9e\u3067\u3059\u304c'
u'\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067' u'\u3001\u3042\u3068\u306f\u3067\u305f\u3089\u3081\u3067'
u'\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das' u'\u3059\u3002\u5b9f\u969b\u306b\u306f\u300cWenn ist das'
u' Nunstuck git und'.encode('utf-8') == u' Nunstuck git und'.encode('utf-8') ==
'\xe6\xad\xa3\xe7\xa2\xba\xe3\x81\xab\xe8\xa8\x80\xe3\x81' '\xe6\xad\xa3\xe7\xa2\xba\xe3\x81\xab\xe8\xa8\x80\xe3\x81'
'\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3\xe3\x81\xaf\xe3' '\x86\xe3\x81\xa8\xe7\xbf\xbb\xe8\xa8\xb3\xe3\x81\xaf\xe3'
'\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3\x81\xbe' '\x81\x95\xe3\x82\x8c\xe3\x81\xa6\xe3\x81\x84\xe3\x81\xbe'

View file

@ -5,11 +5,11 @@ import os
import sys import sys
DATA_TEMPLATE=[ DATA_TEMPLATE=[
"line1=1", "line1=1",
"line2='this is a very long line designed to go past the magic " + "line2='this is a very long line designed to go past the magic " +
"hundred character limit that is inside fileobject.c and which " + "hundred character limit that is inside fileobject.c and which " +
"is meant to speed up the common case, but we also want to test " + "is meant to speed up the common case, but we also want to test " +
"the uncommon case, naturally.'", "the uncommon case, naturally.'",
"def line3():pass" "def line3():pass"
] ]
DATA_LF = "\n".join(DATA_TEMPLATE) + "\n" DATA_LF = "\n".join(DATA_TEMPLATE) + "\n"
@ -40,13 +40,13 @@ class TestGenericUnivNewlines(unittest.TestCase):
os.unlink(test_support.TESTFN) os.unlink(test_support.TESTFN)
except: except:
pass pass
def test_read(self): def test_read(self):
fp = open(test_support.TESTFN, self.READMODE) fp = open(test_support.TESTFN, self.READMODE)
data = fp.read() data = fp.read()
self.assertEqual(data, DATA_LF) self.assertEqual(data, DATA_LF)
self.assertEqual(`fp.newlines`, `self.NEWLINE`) self.assertEqual(`fp.newlines`, `self.NEWLINE`)
def test_readlines(self): def test_readlines(self):
fp = open(test_support.TESTFN, self.READMODE) fp = open(test_support.TESTFN, self.READMODE)
data = fp.readlines() data = fp.readlines()
@ -62,7 +62,7 @@ class TestGenericUnivNewlines(unittest.TestCase):
d = fp.readline() d = fp.readline()
self.assertEqual(data, DATA_SPLIT) self.assertEqual(data, DATA_SPLIT)
self.assertEqual(`fp.newlines`, `self.NEWLINE`) self.assertEqual(`fp.newlines`, `self.NEWLINE`)
def test_seek(self): def test_seek(self):
fp = open(test_support.TESTFN, self.READMODE) fp = open(test_support.TESTFN, self.READMODE)
fp.readline() fp.readline()
@ -72,36 +72,36 @@ class TestGenericUnivNewlines(unittest.TestCase):
fp.seek(pos) fp.seek(pos)
data = fp.readlines() data = fp.readlines()
self.assertEqual(data, DATA_SPLIT[1:]) self.assertEqual(data, DATA_SPLIT[1:])
def test_execfile(self): def test_execfile(self):
dict = {} dict = {}
execfile(test_support.TESTFN, dict) execfile(test_support.TESTFN, dict)
func = dict['line3'] func = dict['line3']
self.assertEqual(func.func_code.co_firstlineno, 3) self.assertEqual(func.func_code.co_firstlineno, 3)
class TestNativeNewlines(TestGenericUnivNewlines): class TestNativeNewlines(TestGenericUnivNewlines):
NEWLINE=None NEWLINE=None
DATA=DATA_LF DATA=DATA_LF
READMODE='r' READMODE='r'
WRITEMODE='w' WRITEMODE='w'
class TestCRNewlines(TestGenericUnivNewlines): class TestCRNewlines(TestGenericUnivNewlines):
NEWLINE='\r' NEWLINE='\r'
DATA=DATA_CR DATA=DATA_CR
class TestLFNewlines(TestGenericUnivNewlines): class TestLFNewlines(TestGenericUnivNewlines):
NEWLINE='\n' NEWLINE='\n'
DATA=DATA_LF DATA=DATA_LF
class TestCRLFNewlines(TestGenericUnivNewlines): class TestCRLFNewlines(TestGenericUnivNewlines):
NEWLINE='\r\n' NEWLINE='\r\n'
DATA=DATA_CRLF DATA=DATA_CRLF
class TestMixedNewlines(TestGenericUnivNewlines): class TestMixedNewlines(TestGenericUnivNewlines):
NEWLINE=('\r', '\n') NEWLINE=('\r', '\n')
DATA=DATA_MIXED DATA=DATA_MIXED
def test_main(): def test_main():
test_support.run_unittest(TestNativeNewlines) test_support.run_unittest(TestNativeNewlines)

View file

@ -123,4 +123,3 @@ def test_main():
if __name__ == "__main__": if __name__ == "__main__":
test_main() test_main()

View file

@ -13,7 +13,7 @@ def warn(message, category=None, stacklevel=1):
"""Issue a warning, or maybe ignore it or raise an exception.""" """Issue a warning, or maybe ignore it or raise an exception."""
# Check if message is already a Warning object # Check if message is already a Warning object
if isinstance(message, Warning): if isinstance(message, Warning):
category = message.__class__ category = message.__class__
# Check category argument # Check category argument
if category is None: if category is None:
category = UserWarning category = UserWarning
@ -53,11 +53,11 @@ def warn_explicit(message, category, filename, lineno,
if registry is None: if registry is None:
registry = {} registry = {}
if isinstance(message, Warning): if isinstance(message, Warning):
text = str(message) text = str(message)
category = message.__class__ category = message.__class__
else: else:
text = message text = message
message = category(message) message = category(message)
key = (text, category, lineno) key = (text, category, lineno)
# Quick test for common case # Quick test for common case
if registry.get(key): if registry.get(key):