ECToo / pymel

Automatically exported from code.google.com/p/pymel
0 stars 0 forks source link

language issubclass simple bug #261

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Describe the problem.
I'm adding mel menuItems and was getting a issubclass error from core.language.

example:
pCore.mel.menuItem(l=menu, c=cmd)

Error

flagInfo :
{'numArgs': 1, 'shortname': 'c', 'args': 'script', 'modes': ['create', 

'edit'], 'longname': 'command'}
# Error: line 4: issubclass() arg 1 must be a class
# Traceback (most recent call last):
#   File "<maya console>", line 1, in <module>
#   File "G:\Maya\Maya_Modules\Achi\ePy\eCore\eUI.py", line 222, in 
buildTriggerMenus
#     m._build(parentMenu, node)
#   File "G:\Maya\Maya_Modules\Achi\ePy\eCore\eUI.py", line 125, in _build
#     pCore.mel.menuItem(l=menu, c=cmd)
#   File 
"G:\Maya\Maya_Modules\Achi\ePy\eInternal\pymel\pymel\core\language.py", line 
724, in _call
#   File 
"G:\Maya\Maya_Modules\Achi\ePy\eInternal\pymel\pymel\core\language.py", line 
114, in pythonToMelCmd
#     if (flagInfo and issubclass(flagInfo.get('args'), bool)
# TypeError: issubclass() arg 1 must be a class # 

The fix is to add the type command:

if (flagInfo and issubclass(type(flagInfo.get('args')), bool)
                         and flagInfo.get('numArgs') == 0):

What Version of Maya are you using?
2011 SAP

On what operating system? (be as specific as possible and include service
packs, 64bit vs 32bit, etc)
Windows 7 x64

What Version of PyMEL are you using?
Git pull from June

What is the expected output? What do you see instead?
NA

If possible, provide a few lines of code to reproduce the problem. It helps
us if your code will reproduce the problem from a new scene.

Does maya.cmds exhibit the same problem?
No

Please provide any additional information below.

Original issue reported on code.google.com by squis...@gmail.com on 5 Oct 2011 at 11:55

GoogleCodeExporter commented 9 years ago
flagInfo['args'] actually often IS a class, so doing type(flagInfo.get('args')) 
isn't the right solution... actually, think we were getting too fancy for our 
own good, and just changed the code to

if (flagInfo and flagInfo.get('args') == bool)
                         and flagInfo.get('numArgs') == 0):

In any case, thanks for the report!

fixed in 02887ab1c79c7d4033c46ab4e4d848694af76470
test added in 2e2860bb47901a4b7e28ea6cab67ed33bcf935a9

Original comment by elron...@gmail.com on 12 Oct 2011 at 8:02