pdoc3 / pdoc3/pdoc

TypeError on namespace package while working in server mode

Open
#461 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
Python
Stars
1.2k
Forks
146
PR merge metrics
No merged PRs in 30d

Description

Steps to Reproduce
  1. Recreate the following structure (creating namespace package):
    extendable_service/
       extensions/# <--- no __init__.py here!
          core/
             __init__.py
             some_code.py
       __init__.py
    
  2. Run pdoc's server:
    pdoc3 ./extendable_service --http localhost:8080
    
  3. Navigate to extendable_service.extensions
Expected:
  • List of submodules is displayed
Actual:
  • Page returns stacktrace
  • Status code is 404
  • Server still working
Stacktrace here
Error importing module pdoc_issues.extensions:

Traceback (most recent call last):
  File "D:\Projects\test\.venv-312\Lib\site-packages\pdoc\cli.py", line 236, in do_GET
    out = self.html()
          ^^^^^^^^^^^
  File "D:\Projects\test\.venv-312\Lib\site-packages\pdoc\cli.py", line 268, in html
    return pdoc.html(self.import_path_from_req_url,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\test\.venv-312\Lib\site-packages\pdoc\__init__.py", line 178, in html
    return mod.html(**kwargs)
           ^^^^^^^^^^^^^^^^^^
  File "D:\Projects\test\.venv-312\Lib\site-packages\pdoc\__init__.py", line 905, in html
    html = _render_template('/html.mako', module=self, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\test\.venv-312\Lib\site-packages\pdoc\__init__.py", line 157, in _render_template
    return t.render(**config).strip()
           ^^^^^^^^^^^^^^^^^^
  File "D:\Projects\test\.venv-312\Lib\site-packages\mako\template.py", line 434, in render
    return runtime._render(self, self.callable_, args, data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Projects\test\.venv-312\Lib\site-packages\mako\runtime.py", line 874, in _render
    _render_context(
  File "D:\Projects\test\.venv-312\Lib\site-packages\mako\runtime.py", line 916, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "D:\Projects\test\.venv-312\Lib\site-packages\mako\runtime.py", line 943, in _exec_template
    callable_(context, *args, **kwargs)
  File "_html_mako", line 156, in render_body
TypeError: stat: path should be string, bytes, os.PathLike or integer, not NoneType
Meta
  • pdoc version: 0.11.6
  • OS: Windows 10 64bit: 19045.5965
  • Python version: 3.12.1, 3.13.5

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the namespace-package layout and running pdoc3 ./extendable_service --http localhost:8080, then trace the request through pdoc/cli.py, pdoc/__init__.py, and the /html.mako template shown in the stacktrace. Done means visiting extendable_service.extensions displays its submodules without a TypeError or 404 while the server remains usable.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, documentation
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.