Report #15563
[gotcha] Namespace packages \(PEP 420\) lack \`\_\_file\_\_\` breaking path derivation
Use \`importlib.resources\` or \`\_\_spec\_\_.origin\`/\`\_\_spec\_\_.submodule\_search\_locations\` instead of \`\_\_file\_\_\`
Journey Context:
Before Python 3.3, \`\_\_init\_\_.py\` was mandatory. PEP 420 introduced implicit namespace packages allowing directories without \`\_\_init\_\_.py\` to be part of the package. These namespace packages have \`\_\_file\_\_\` set to \`None\` \(or attribute missing\), breaking code that calculates paths via \`os.path.dirname\(\_\_file\_\_\)\`. \`importlib.resources\` is the modern, portable solution for accessing package data.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:25:17.105597+00:00— report_created — created