Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: workaround potencial valueerror form importlib_metadata #8069

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions ddtrace/internal/packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,19 @@ def _package_file_mapping():
mapping = {}

for ilmd_d in il_md.distributions():
if ilmd_d is not None and ilmd_d.files is not None:
d = Distribution(name=ilmd_d.metadata["name"], version=ilmd_d.version, path=None)
for f in ilmd_d.files:
if _is_python_source_file(f):
# mapping[fspath(f.locate())] = d
_path = fspath(f.locate())
mapping[_path] = d
_realp = os.path.realpath(_path)
if _realp != _path:
mapping[_realp] = d
try:
if ilmd_d is not None and ilmd_d.files is not None:
d = Distribution(name=ilmd_d.metadata["name"], version=ilmd_d.version, path=None)
for f in ilmd_d.files:
if _is_python_source_file(f):
# mapping[fspath(f.locate())] = d
_path = fspath(f.locate())
mapping[_path] = d
_realp = os.path.realpath(_path)
if _realp != _path:
mapping[_realp] = d
except ValueError:
continue

return mapping

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fixes:
- |
Handle potencial ValueError on importlib_metadata. Fixes #8068.
Loading