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: Document exceptions raised by fnmtach
Type: Stage:
Components: Documentation, Library (Lib), Regular Expressions Versions: Python 3.11
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: DimitriPapadopoulosOrfanos, docs@python, ezio.melotti, mrabarnett
Priority: normal Keywords:

Created on 2021-11-16 10:46 by DimitriPapadopoulosOrfanos, last changed 2022-04-11 14:59 by admin.

Files
File name Uploaded Description Edit
sre_constants.error_stderr.txt DimitriPapadopoulosOrfanos, 2021-11-16 10:46 Last part of the stderr output of a Python script that calls fnmatch() on a bad glob
Messages (1)
msg406396 - (view) Author: Dimitri Papadopoulos Orfanos (DimitriPapadopoulosOrfanos) * Date: 2021-11-16 10:46
The fnmatch documentation should explicitly mention the type of exceptions raised by fnmatch.fnmatch():
https://docs.python.org/3/library/fnmatch.html

In my case it raised sre_constants.error, and it took some time to understand that the proper way to catch this type of exceptions is to catch the re.error superclass, by reading https://bugs.python.org/issue795379.

Actually that would be the case for any module using the re module under the hood, possibly passing an ill-formed regex to a re function.
History
Date User Action Args
2022-04-11 14:59:52adminsetgithub: 89973
2021-11-16 10:46:44DimitriPapadopoulosOrfanoscreate