Repository: mitmproxy/pdoc

Issue:
TypeError: argument of type '_SentinelObject' is not iterable (`unittest.mock`)
#### Problem Description

`pdoc` fails to generate API documentation for the `unittest.mock` module.

#### Steps to reproduce the behavior:

```sh
pdoc --output-directory /tmp/docs unittest.mock
```
```py
Traceback (most recent call last):
  File "/private/tmp/pdoc/.venv/bin/pdoc", line 8, in <module>
    ...
  File "/Users/bf/.pyenv/versions/3.13.0/lib/python3.13/functools.py", line 1037, in __get__
    val = self.func(instance)
  File "/private/tmp/pdoc/.venv/lib/python3.13/site-packages/pdoc/doc.py", line 259, in members
    taken_from = self._taken_from(name, obj)
  File "/private/tmp/pdoc/.venv/lib/python3.13/site-packages/pdoc/doc.py", line 448, in _taken_from
    if mod and qual and "<locals>" not in qual:
                        ^^^^^^^^^^^^^^^^^^^^^^
TypeError: argument of type '_SentinelObject' is not iterable
```

#### System Information

```sh
❯ pdoc --version
pdoc: 15.0.0
Python: 3.13.0
Platform: macOS-14.6.1-arm64-arm-64bit-Mach-O
```

Hints from issue comments:

Solution patch:
diff --git a/pdoc/doc.py b/pdoc/doc.py
index 51468dd..752cd17 100644
--- a/pdoc/doc.py
+++ b/pdoc/doc.py
@@ -445,7 +445,7 @@ class Module(Namespace[types.ModuleType]):
 
         mod = _safe_getattr(obj, "__module__", None)
         qual = _safe_getattr(obj, "__qualname__", None)
-        if mod and qual and "<locals>" not in qual:
+        if mod and isinstance(qual, str) and "<locals>" not in qual:
             return mod, qual
         else:
             # This might be wrong, but it's the best guess we have.


Test patch:
diff --git a/test/test_smoke.py b/test/test_smoke.py
index 60f1041..f8c67c4 100644
--- a/test/test_smoke.py
+++ b/test/test_smoke.py
@@ -12,7 +12,7 @@ modules = [
     m.name
     for m in pkgutil.iter_modules()
     if not m.name.startswith("_") and m.name not in ("test", "idlelib", "py")
-]
+] + ["unittest.mock"]
 
 
 @pytest.mark.slow