[Maya] Strange Maya Error

I’ve been seeing this error pop up from time to time, across multiple of versions of maya, including 2016.

I can’t make any sense of it… anyone got any insight into what this might be a symptom of?


selection = cmds.ls(sl=True, l=True, o=True)
TypeError: Flag 'l' must be passed a boolean argument

No error on maya 2015.

So I was able to recreate the error by running the command in a thread. So I would double check to see if that is what is happening, and you can always wrap the cmd in maya.utils.executeDeferred or maya.utils.executeInMainThreadWithResult to push it back onto the main thread if this turns out to be the culprit.


import maya.cmds as cmds
import threading

def no_error():
    print(cmds.ls(sl=True, l=True, o=True))

def error_time():
    print(cmds.ls(sl=True, l=True, o=True))

no_error()
t = threading.Thread(target=error_time)
t.start()

that is interesting and good to know, but the script that threw that error doesn’t use threading, although the ls command is getting called when a UI needs to update itself based on a scriptjob.

I have also seen Maya throw errors when you use the True term. I have no idea why. If you replace True with a 1, what happens?

Weird. I’ve had some of my MSceneMessage callbacks cause some errors similar to threading ones, event when I wasn’t explicitly using threading.
So I wonder if scriptJobs sometimes pull the same crap without telling us.

Also looks like folks have bumped into this before link.

Might be worth wrapping it in one of the defer execution functions to see if it avoids the error.

it doesn’t happen all the time, in fact, it rarely ever happens. every time it does, I shrug and try again and the problem goes away…

Well that certainly sounds frustrating.

ive hit this before, but never found a good solution. It had to do with threading, but i think there was an error above it and this was just what happened to leak through. Just empathy from me :confused:

I see everybody caught it already, but it’s almost certainly a cross-thread UI access producing a bogus error