Message410067
Your functions test1 and test2 are irrelevant to the bug report. The driver code using eval() to pick which function to call is unneeded. The business of simulating a file is complexity for no purpose.
Those ignore, count, unique functions are also irrelevant.
Removing all the irrelevant and extraneous complexity that obfuscates the problem, we get to two lines of simplified code sufficient to demonstrate the issue:
each = "name = "
[code.strip()[0] for func, code in [each.split('=')]]
which sure enough raises IndexError.
The hint was looking at your fix() function, which made it clear that you are getting an IndexError because the string is an empty string. Well of course you do, that is expected behaviour.
Why do you get an empty string? Because you split the line "name = " on the equals sign, giving
func = "name "
code = " "
then you strip the whitespace from code giving:
code = ""
then you try to extract the first character of code using code[0], which raises IndexError, because that's what it is supposed to do.
So there is no bug here, Python is working correctly. |
|
Date |
User |
Action |
Args |
2022-01-08 01:11:35 | steven.daprano | set | recipients:
+ steven.daprano, Stefan Pochmann, NetAlien |
2022-01-08 01:11:35 | steven.daprano | set | messageid: <1641604295.19.0.148339461247.issue46302@roundup.psfhosted.org> |
2022-01-08 01:11:35 | steven.daprano | link | issue46302 messages |
2022-01-08 01:11:35 | steven.daprano | create | |
|