Given comment #1, would it be an option to invert the getattr logic instead, so that it tries readfp first and fallback to read_file, i.e. reader = getattr(parser, "readfp", parser.read_file)?
I think that would maintain compatibility when readfp is available and would fallback to read_file in 3.12, where only that is available.
Given comment #1, would it be an option to invert the getattr logic instead, so that it tries readfp first and fallback to read_file, i.e. reader = getattr(parser, "readfp", parser.read_file)?
I think that would maintain compatibility when readfp is available and would fallback to read_file in 3.12, where only that is available.
I can submit a merge proposal.