Debugging in Python, part 7: Bugs in third-party libraries
MP 146: What happens when the bug actually is in one of your project's dependencies?
Note: This post is part of an ongoing series about debugging in Python. The posts in this series will only be available to paid subscribers for the first 6 weeks. After that they will be available to everyone. Thank you to everyone who supports my ongoing work on Mostly Python.
Most of the time when our code fails to run, the bug is in code that we've written. There are times, however, when the bug actually does come from one of the project's dependencies. Most dependencies are pretty well-tested, and end up not being the cause of the problem. But no code is perfect, and sometimes the dependency really is the source of the problem. In this post we'll see what it looks like when a bug appears in third-party code.
An interesting traceback
Let's use the same strat_players.py project from the last post. I generated a bug in a .py file within the virtual environment, that I knew would affect the execution path. Consider the resulting traceback:
$ python strat_players.py Traceback (most recent call last): File "strat_players.py", line 5, in <module> import player_data File "player_data.py", line 3, in <module> import pandas as pd File ".venv/lib/python3.12/site-packages/pandas/__init__.py", line 49, in <module> from pandas.core.api import ( File ".venv/lib/python3.12/site-packages/pandas/core/api.py", line 9, in <module> from pandas.core.dtypes.dtypes import ( File ".venv/lib/python3.12/site-packages/pandas/core/dtypes/dtypes.py", line 60, in <module> from pandas.core.dtypes.inference import ( File ".venv/lib/python3.12/site-packages/pandas/core/dtypes/inference.py", line 335 """ ^ IndentationError: expected an indented block after function definition on line 334
Just like the last post, which focused on a bug in our own code, this traceback includes references to some code we've written and some third-party code.
This post is only available to paid subscribers at the moment. It will be available to everyone 6 weeks after posting. If you'd like to continue reading now, please support my work by signing up for a paid subscription.