Deprecating Python2 and adding type-annotations to the python API

As a user of the lldb python scripting API I would love to see type annotations on the scripting APIs. I posted this diff the other day - Pavel commented that this would require deprecating python2 and that the recent 11.0 branch cut might make this a good time to do this. So how do people feel about removing python2 support and moving the APIs more towards modern python3?

Hi Nathan,

Thanks for bringing this up. I’ve been expecting this question for a while now.

Python 2 is end-of-life and we should move to Python 3. I’m pretty sure nobody here disagrees with that. Unfortunately though, we still have consumers, both internally and externally, that still rely on it. We’re actively making an effort to change that, but we’re not quite there yet.

That said, I think we should continue moving in that direction. In line with the rest of LLVM moving to Python 3 by the end of the year, we’ve already made it the default. All our bots on GreenDragon are also building against Python 3.

As a first step, for the next release, I propose we remove the fallback to Python 2 and make it the only supported configuration. At the same time we can convert any scripts and tools (I’m thinking of the lit configurations, the lldb-dotest and lldb-repro wrappers, etc) to be Python 3 only. During this time however, we’d ask that the bindings and the test suite remain compatible with Python 2. Given that Python 3 is the only supported configuration for developers, we’d take on the burden of maintaining Python 2 compatibility in the test suite and correcting (accidental) incompatibilities.

When the 12.0 release is cut, we can reconsider the situation. If we’re still not ready by then to drop Python 2 support, I propose another intermediate step where we remove Python 2 support from the upstream repository, but ask the community to not actively modernize the test suite and the bindings. In this situation we’d be dealing with the merge conflicts in our downstream fork and this would avoid an endless number of conflicts in the test suite.

Finally, presumably after the 13.0 release, we’d drop that last requirement.

Please let me know if you think that sounds like a reasonable timeline.


This sounds like a good plan to me. If lldb is supposed to remain
buildable with python2, then I also don't see a problem with keeping the
cmake bits which enable that. We could make it harder to build with
python2 accidentally by requiring the user to set a variable similar to