LumaPictures / pymel

Python in Maya Done Right
Other
490 stars 131 forks source link

language issubclass simple bug #295

Closed pmolodo closed 9 years ago

pmolodo commented 9 years ago

From squis...@gmail.com on October 05, 2011 04:55:11

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 "", line 1, in

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: http://code.google.com/p/pymel/issues/detail?id=261

pmolodo commented 9 years ago

From elron...@gmail.com on October 12, 2011 01:02:17

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

Status: Fixed