[issue22364] Improve some re error messages using regex for hints
Changes by Serhiy Storchaka storch...@gmail.com: -- resolution: - fixed stage: patch review - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Roundup Robot added the comment: New changeset 068365acbe73 by Serhiy Storchaka in branch 'default': Issue #22364: Improved some re error messages using regex for hints. https://hg.python.org/cpython/rev/068365acbe73 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Serhiy Storchaka added the comment: Could anyone please make a review? This patch is a prerequisite of other patches. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Serhiy Storchaka added the comment: Messages tend to be abbreviated, so I think that it would be better to just omit the article. I agree, but this is came from standard error messages which are not consistent. I opened a thread on Python-Dev. expected a bytes-like object and expected str instance are standard error messages raised in bytes.join and str.join, not in re. We could change them though. I don't think that the error message bad repeat interval is an improvement (Why is it bad? What is an interval?). I think that saying that the min is greater than the max is clearer. Agree. I'll change this in re. What message is better in case of overflow: the repetition number is too large (in re) or repeat count too big (in regex)? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Serhiy Storchaka added the comment: Here is a patch for regex which makes some error messages be the same as in re with re_errors_2.patch. You could apply it to regex if new error messages look better than old error messages. Otherwise we could change re error messages to match regex, or discuss better variants. -- Added file: http://bugs.python.org/file38171/regex_errors.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Matthew Barnett added the comment: Some error messages use the indefinite article: expected a bytes-like object, %.200s found cannot use a bytes pattern on a string-like object cannot use a string pattern on a bytes-like object but others don't: expected string instance, %.200s found expected str instance, %.200s found Messages tend to be abbreviated, so I think that it would be better to just omit the article. I don't think that the error message bad repeat interval is an improvement (Why is it bad? What is an interval?). I think that saying that the min is greater than the max is clearer. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Serhiy Storchaka added the comment: Updated patch addresses Ezio's comments. -- Added file: http://bugs.python.org/file38080/re_errors_2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Serhiy Storchaka added the comment: Here is a patch which unify and improves re error messages. Added tests for all parsing errors. Now error message always points on the start of affected component, i.e. on the start of bad escape, group name or unterminated subpattern. -- stage: needs patch - patch review Added file: http://bugs.python.org/file38035/re_errors.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Serhiy Storchaka added the comment: re_errors_diff.txt contains differences for all tested error messages. -- Added file: http://bugs.python.org/file38036/re_errors_diff.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Terry J. Reedy added the comment: I already said we should either stick with what we have if better (and gave examples, including sticking with 'cannot') or possibly combine the best of both if we can improve on both. 13 should use 'bytes-like' (already changed?). There is no review button. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Serhiy Storchaka added the comment: Here is a patch which makes re error messages match regex. It doesn't look to me that all these changes are enhancements. -- keywords: +patch Added file: http://bugs.python.org/file37167/re_errors_regex.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Raymond Hettinger added the comment: +1 -- nosy: +rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Changes by Serhiy Storchaka storch...@gmail.com: -- dependencies: +Add additional attributes to re.error, Other mentions of the buffer protocol ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Ezio Melotti added the comment: +1 on the idea. -- stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Serhiy Storchaka added the comment: As for #14, either UNICODE and LOCALE *are* compatible (for re) or this is buggy. This is buggy (issue22407). -- title: Unify error messages of re and regex - Improve some re error messages using regex for hints ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22364] Improve some re error messages using regex for hints
Terry J. Reedy added the comment: Steven and Mark are correct that a tracker patch cannot change a 3rd party module. On the other hand, we are free to improve error messages in new versions. And we are free to borrow ideas from 3rd part modules. I changed the title accordingly. (Back compatibility comes into play in not making message enhancements in bugfix releases even though message details are not part of the documented API. People who write code that depends on those details, and doctexts need not so depend, should expect to revise for new versions. I expect that some of our re tests would need to be changed.) Re and regex are a bit special in that regex is the only re replacement (that I know of) and is (almost) a drop-in replacement. So some people *are*, on their own, replacing re with regex by installing regex (easy with pip) and adding 'import regex as re' at the top of their code. Serhiy suggested either picking the best or writing a new one, I think a new one combining both would be best in many of the cases. As a user, I like name missing terminal '' for #2 (is there an adjective for a name in this context?) and for #4, group name missing terminal ''. (Note that we usually quote literals, as in #8.) For #12, I would like a parallel construction set expression missing terminal ']' if that is possible. But the currently vague re message unexpected end of regular expression might be raised as a point where the specific information is lost and only the general version is correct. As for #14, either UNICODE and LOCALE *are* compatible (for re) or this is buggy. import re re.compile(r'\w', re.UNICODE | re.LOCALE) re.compile('\\w', re.LOCALE|re.UNICODE) -- title: Unify error messages of re and regex - Improve some re error messages using regex for hints ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com