mirror of
https://github.com/django/django.git
synced 2025-04-04 13:36:42 +00:00
Added note to TypeError exceptions in GEOS WKTReader and WKBReader.
This commit is contained in:
parent
40bfd7b09a
commit
968a5f9eb4
@ -156,7 +156,7 @@ class _WKTReader(IOBase):
|
||||
|
||||
def read(self, wkt):
|
||||
if not isinstance(wkt, (bytes, str)):
|
||||
raise TypeError
|
||||
raise TypeError("'wkt' must be bytes or str.")
|
||||
return wkt_reader_read(self.ptr, force_bytes(wkt))
|
||||
|
||||
|
||||
@ -176,7 +176,7 @@ class _WKBReader(IOBase):
|
||||
wkb_s = wkb.encode()
|
||||
return wkb_reader_read_hex(self.ptr, wkb_s, len(wkb_s))
|
||||
else:
|
||||
raise TypeError
|
||||
raise TypeError("'wkb' must be bytes, str or memoryview.")
|
||||
|
||||
|
||||
def default_trim_value():
|
||||
|
@ -28,9 +28,10 @@ class GEOSIOTest(SimpleTestCase):
|
||||
self.assertEqual(ref, geom)
|
||||
|
||||
# Should only accept string objects.
|
||||
with self.assertRaises(TypeError):
|
||||
msg = "'wkt' must be bytes or str."
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
wkt_r.read(1)
|
||||
with self.assertRaises(TypeError):
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
wkt_r.read(memoryview(b"foo"))
|
||||
|
||||
def test02_wktwriter(self):
|
||||
|
Loading…
x
Reference in New Issue
Block a user