Function suddenly became NoneType without any code changes it

Repl link:

Well if you run it you can see an error saying

TypeError: ‘NoneType’ object is not subscriptable

You can run the program multiple time as different code runs with random, but they all leads to the same error, and you can find out the error is related to the function ‘process’.

Well the odd place is that in line 171 and 172 in I checked if the function is NoneType or not, which is no as the print is not triggered, and during the if clauses below there is nothing that changes the variable ‘process’.

Also with the try except, I can print the type of variables in the error line of code, which you can see none of them is a NoneType

So why, and how


The function is not nonetype, it returns NoneType. I see a lot of return … else None. You might want to check for that. (Function process)

1 Like

I am trying to read you code, but honestly it is unreadable with all line breaks and alike.
I agree with @dragonhunter1 that there are tons of ternary operators and return else, this is bound to have a typo somewhere.

But this is for sure a bug

(None if len(char) == 1 else char[1:]))[0] 

As it can lead to None[0]


I forked and used black . before I even attempted to read it XD

1 Like

Well it is just for an argument in the process function so it shouldn’t be a problem
Now I’m trying to tidy up my code

Please do as it is very difficult to give you an hand if the code id not easily readable.

Ok so after some researches and having the entire repl died for days, I think I found out the problem and fixed it. Thanks for all the help

(It seems that the problem is after I found the continuation problem for and gate and or gate, I tried to return a tuple with output and commands left behind, replacing the old output-only return, for potential and/or gates appeared previously.
Which made the second element in the tuple lost to the garbage system and crash those statements that did the ‘update’)

Thx for all the helps btw

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.