This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: better message for re.search TypeError ("expected string or bytes-like object")
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.11
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Ido Michael, ZackerySpytz, chris.jerdonek, zihengcat
Priority: normal Keywords: patch

Created on 2020-05-22 21:12 by chris.jerdonek, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 23312 merged ZackerySpytz, 2020-11-16 05:26
Messages (4)
msg369652 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2020-05-22 21:12
This TypeError could be a bit better:

"/Users/runner/runners/2.262.1/work/cpython/cpython/Lib/test/test_nntplib.py", line 293, in test_with_statement
    if re.search(r'(?i)KEY.TOO.SMALL', ssl_err.reason):
  File "/Users/runner/runners/2.262.1/work/cpython/cpython/Lib/re.py", line 201, in search
    return _compile(pattern, flags).search(string)
TypeError: expected string or bytes-like object

It just says "expected string or bytes-like object" but could include what type it found.
msg369884 - (view) Author: Ido Michael (Ido Michael) * Date: 2020-05-25 14:58
I agree it should be more informative and have the same standard as the rest of the Errors messages.

Can I start a PR?
msg369926 - (view) Author: Chris Jerdonek (chris.jerdonek) * (Python committer) Date: 2020-05-25 21:51
I already started one actually. But if I don't get to it in a week, I'll make a note here and you can take it up.
msg369945 - (view) Author: zihengCat (zihengcat) * Date: 2020-05-26 06:07
Does it mean modify `cpython/Modules/_sre.c` and add `PyObject` information to PyError string ?

https://github.com/python/cpython/blob/master/Modules/_sre.c#L376
History
Date User Action Args
2022-04-11 14:59:31adminsetgithub: 84913
2021-05-21 21:03:01iritkatrielsetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-05-21 18:33:31iritkatrielsetversions: + Python 3.11, - Python 3.10
2020-11-16 05:26:40ZackerySpytzsetkeywords: + patch
nosy: + ZackerySpytz

pull_requests: + pull_request22203
stage: patch review
2020-05-26 06:07:30zihengcatsetnosy: + zihengcat
messages: + msg369945
2020-05-25 21:51:17chris.jerdoneksetmessages: + msg369926
2020-05-25 14:58:04Ido Michaelsetnosy: + Ido Michael
messages: + msg369884
2020-05-22 21:12:55chris.jerdonekcreate