Zhixu Liu <zhixu.liu@xxxxxxxxx> writes: > Hi Jonathan, > > How about the v3 patch? I still think try/except is more robust, > but I can switch to version comparison if you prefer, e.g.: > > if docutils.__version_info__ >= (0, 22): > ... > else: > ... > > My preference for try/except: > > 1. Reflects the actual runtime environment, while version checks can > be broken by backported patches. > 2. Avoids parsing non-standard version strings (e.g. 0.21a1, > 0.21.dev0); try/except is simpler and has no extra dependencies. > (__version_info__ mitigates this somewhat.) > 3. More Pythonic and straightforward. > > I’m fine with either approach—please let me know which you’d like me to go with. I've already been fairly clear on that, I think. Exceptions mask bugs, so I really don't want to spread random exception-handling code around. A version check says exactly what we need to know, and lets us know when the older code can be removed. That said: I dug into this a bit and concluded that this approach is not right. ErrorString and SafeString() are old Python 2 compatibility stuff; there really seems to be no need for them with Python >= 3.6. So the right fix is to do away with that import entirely. I've put together a patch with that approach, will post shortly. (Incidentally, Sphinx has not caught up with this change, so how did you test your change?) Thanks, jon