[issue22364] Unify error messages of re and regex

Serhiy Storchaka report at bugs.python.org
Thu Sep 11 19:16:40 CEST 2014


Serhiy Storchaka added the comment:

> By the way, which is preferred, "cannot" or "can't"? The regex module always
> uses "can't", but re module uses "cannot" except for "TypeError: can't use
> a bytes pattern on a string-like object", I think.

It's interesting question. Grepping in CPython sources got results:

Cannot  210
cannot  865
Can't   216
can't   796

Lowercase wins uppercase with score 4:1 and short and long forms are 
equivalent.

I left the decision to English speakers.

> Also, you said that one of the re module's messages was better, but didn't
> say which! Did you mean this one?
> > re:    expected bytes, bytearray, or an object with the buffer interface,
> > str found
> > regex: expected bytes instance, str found

Both are not good. re variant is too verbose, but it is more correct.

May be 6, 7, 8, 10, 11, 16, 18 are better in re.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22364>
_______________________________________


More information about the Python-bugs-list mailing list