summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-12-08 23:31:48 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-12-08 23:31:48 (GMT)
commite239d23e8cc66605f548585ad4489a8f12fc070d (patch)
treee165422c11006a4f3595742dd40a7a2095ef59ce /Lib
parent1b2bd3b348d7bb861ae8c92853e5058766ebff80 (diff)
downloadcpython-e239d23e8cc66605f548585ad4489a8f12fc070d.zip
cpython-e239d23e8cc66605f548585ad4489a8f12fc070d.tar.gz
cpython-e239d23e8cc66605f548585ad4489a8f12fc070d.tar.bz2
Issue #6697: Fixed instances of _PyUnicode_AsString() result not checked for NULL
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/datetimetester.py8
-rw-r--r--Lib/test/test_pyexpat.py2
-rw-r--r--Lib/test/test_socket.py2
-rw-r--r--Lib/test/test_syslog.py2
-rw-r--r--Lib/test/test_xml_etree_c.py18
5 files changed, 30 insertions, 2 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 48e5095..dddf0f8 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -2508,11 +2508,17 @@ class TestTimeTZ(TestTime, TZInfoBase, unittest.TestCase):
# Check that an invalid tzname result raises an exception.
class Badtzname(tzinfo):
- def tzname(self, dt): return 42
+ tz = 42
+ def tzname(self, dt): return self.tz
t = time(2, 3, 4, tzinfo=Badtzname())
self.assertEqual(t.strftime("%H:%M:%S"), "02:03:04")
self.assertRaises(TypeError, t.strftime, "%Z")
+ # Issue #6697:
+ if '_Fast' in str(type(self)):
+ Badtzname.tz = '\ud800'
+ self.assertRaises(ValueError, t.strftime, "%Z")
+
def test_hash_edge_cases(self):
# Offsets that overflow a basic time.
t1 = self.theclass(0, 1, 2, 3, tzinfo=FixedOffset(1439, ""))
diff --git a/Lib/test/test_pyexpat.py b/Lib/test/test_pyexpat.py
index 5a193bb..5bb8c97 100644
--- a/Lib/test/test_pyexpat.py
+++ b/Lib/test/test_pyexpat.py
@@ -203,6 +203,8 @@ class ParseTest(unittest.TestCase):
operations = out.out
self._verify_parse_output(operations)
+ # Issue #6697.
+ self.assertRaises(AttributeError, getattr, parser, '\uD800')
def test_parse_file(self):
# Try parsing a file
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
index 32084da..6bdb6c9 100644
--- a/Lib/test/test_socket.py
+++ b/Lib/test/test_socket.py
@@ -667,6 +667,8 @@ class GeneralModuleTests(unittest.TestCase):
type=socket.SOCK_STREAM, proto=0,
flags=socket.AI_PASSIVE)
self.assertEqual(a, b)
+ # Issue #6697.
+ self.assertRaises(UnicodeEncodeError, socket.getaddrinfo, 'localhost', '\uD800')
def test_getnameinfo(self):
# only IP addresses are allowed
diff --git a/Lib/test/test_syslog.py b/Lib/test/test_syslog.py
index 028dcb4..4e7621e5 100644
--- a/Lib/test/test_syslog.py
+++ b/Lib/test/test_syslog.py
@@ -11,6 +11,8 @@ class Test(unittest.TestCase):
def test_openlog(self):
syslog.openlog('python')
+ # Issue #6697.
+ self.assertRaises(UnicodeEncodeError, syslog.openlog, '\uD800')
def test_syslog(self):
syslog.openlog('python')
diff --git a/Lib/test/test_xml_etree_c.py b/Lib/test/test_xml_etree_c.py
index ee270f9..5c0bf6c 100644
--- a/Lib/test/test_xml_etree_c.py
+++ b/Lib/test/test_xml_etree_c.py
@@ -8,10 +8,26 @@ cET = support.import_module('xml.etree.cElementTree')
# cElementTree specific tests
def sanity():
- """
+ r"""
Import sanity.
>>> from xml.etree import cElementTree
+
+ Issue #6697.
+
+ >>> e = cElementTree.Element('a')
+ >>> getattr(e, '\uD800') # doctest: +ELLIPSIS
+ Traceback (most recent call last):
+ ...
+ UnicodeEncodeError: ...
+
+ >>> p = cElementTree.XMLParser()
+ >>> p.version.split()[0]
+ 'Expat'
+ >>> getattr(p, '\uD800')
+ Traceback (most recent call last):
+ ...
+ AttributeError: 'XMLParser' object has no attribute '\ud800'
"""