I think the doc of Py_CompileStringExFlags has two flaws: 1. Py_CompileStringExFlags should be replaced by Py_CompileStringObject from the context. Py_CompileStringExFlags in the context is meaningless. 2. *filename* is a byte string that should be decoded but not decoded from. It is ... = decode(filename) but not filename = decode(...).
I don't understand the second part of the patch. *filename* is a filesystem encoding (:func:`os.fsdecode`) encoded string [...] Do you want to document that filename should be encoded by using PyUnicode_EncodeFSDefault *before* passing it to Py_CompileStringExFlags (you will probably need to wrap it with something like PyBytes_AsString too)? If so, I think the os.fsdecode() part needs to be changed to os.fsencode(). I think the current wording is saying that filename is going to be decoded inside of Py_CompileStringExFlags (which is also correct.)
> filename is going to be decoded inside of Py_CompileStringExFlags Actually all I want to express is this, *filename* will be decoded inside. But now the wording looks to me is that *filename* is already a decoded string when passed. I don't want to document anything about PyUnicode_EncodeFSDefault. I should remove (:func:`os.fsdecode`). How do you think? I'm Okay if you think the current wording is correct.
I am not a native speaker so I decide not to trap in the minor part. Could you just fix the first point if there is no doubt? I'm okay with the second part staying as now.