Skip to content

Commit 295c13d

Browse files
author
Daniel Neuhäuser
committed
Nicer TypeErrors
1 parent d9ac484 commit 295c13d

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Version 0.2.1
55
=============
66

77
- Fix issue with named groups.
8+
- Nicer `TypeError`\s, if pattern types are unequal.
89

910
Version 0.2.0
1011
=============

oore.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ def __add__(self, other):
5757
if isinstance(other, r):
5858
if self.pattern.__class__ != other.pattern.__class__:
5959
raise TypeError(
60-
'incompatible pattern types: {} and {}'.format(
61-
self.pattern.__class__, other.pattern.__class__
60+
'incompatible pattern types: {!r} and {!r}'.format(
61+
self.pattern, other.pattern
6262
)
6363
)
6464
elif isinstance(self.pattern, bytes):
@@ -76,9 +76,9 @@ def __or__(self, other):
7676
if isinstance(other, r):
7777
if self.pattern.__class__ != other.pattern.__class__:
7878
raise TypeError(
79-
'incompatible pattern types: {} and {}'.format(
80-
self.pattern.__class__,
81-
other.pattern.__class__
79+
'incompatible pattern types: {!r} and {!r}'.format(
80+
self.pattern,
81+
other.pattern
8282
)
8383
)
8484
elif isinstance(self.pattern, bytes):

0 commit comments

Comments
 (0)