Function and modules recognized as "NoneType" when not part of the Operator Class namespace #23346

Closed
opened 2010-08-17 07:27:25 +02:00 by Dalai Felinto · 11 comments

%%%This bug report shows a strange bevahiour in Blender bpy introduced after rev.26569 .My guess is that it's related to namespace.

  1. Global functions are recognizes as being "NoneType" therefore can't be called
  • solution to move them to inside the Operator Class [Not handy for big scripts though]
  1. Imported modules have to be re-imported to be accessed from an Operator class.

To test it go to bug.blend and run the scripts. The file is self-explanatory (I hope).

It's probably something I'm doing wrong, dunno. I've been away for one month, so I may have missed some important API change.

Tested in Windows 64 (blender 32) with rev. 31365 (after 2.5Beta3). Using Python from lib/windows/

Thanks,
Dalai%%%

%%%This bug report shows a strange bevahiour in Blender bpy introduced after rev.26569 .My guess is that it's related to namespace. 1) Global functions are recognizes as being "NoneType" therefore can't be called - solution to move them to inside the Operator Class [Not handy for big scripts though] 2) Imported modules have to be re-imported to be accessed from an Operator class. To test it go to bug.blend and run the scripts. The file is self-explanatory (I hope). It's probably something I'm doing wrong, dunno. I've been away for one month, so I may have missed some important API change. Tested in Windows 64 (blender 32) with rev. 31365 (after 2.5Beta3). Using Python from lib/windows/ Thanks, Dalai%%%
Author
Owner

Changed status to: 'Open'

Changed status to: 'Open'

%%%I think this is the issue that we discussed on IRC a while ago, this didn't work with python 3.1.0 and does work with python 3.1.2. Probably Nathan has upgrading the python version on his todo list?%%%

%%%I think this is the issue that we discussed on IRC a while ago, this didn't work with python 3.1.0 and does work with python 3.1.2. Probably Nathan has upgrading the python version on his todo list?%%%
Member

%%%Indeed, is on the todolist.%%%

%%%Indeed, is on the todolist.%%%

%%%these two problems seemed to begin after auto-registration. In addition to whats listed above, there is also a problem with on-the-fly class generation. If you generate classes they appear to get registered (ie you can find them in the operator search) but you can't call them. The workaround is to unregister each class after generation then register it again eg...

def gen_class(...):

 opclass = type(..., (bpy.types.Operator,), dict(
    bl_idname=...,
    bl_label=...,
    bl_description = ...,
    bl_options={'REGISTER', 'UNDO'},
    dialog_width=250,
    ....,
    ....))
 setattr(opclass,'execute',gen_exec_func())
 return opclass

new_class=gen_class(...)
unregister(new_class)
register(new_class)

I'm not sure if this is related to the python version problem or simply to the auto registration code?
hope this helps, josh

%%%

%%%these two problems seemed to begin after auto-registration. In addition to whats listed above, there is also a problem with on-the-fly class generation. If you generate classes they appear to get registered (ie you can find them in the operator search) but you can't call them. The workaround is to unregister each class after generation then register it again eg... def gen_class(...): ``` opclass = type(..., (bpy.types.Operator,), dict( bl_idname=..., bl_label=..., bl_description = ..., bl_options={'REGISTER', 'UNDO'}, dialog_width=250, ...., ....)) setattr(opclass,'execute',gen_exec_func()) return opclass ``` new_class=gen_class(...) unregister(new_class) register(new_class) I'm not sure if this is related to the python version problem or simply to the auto registration code? hope this helps, josh %%%
Author
Owner

%%%Hey Josh, do you think you can put your problem in a example .blend file. Just so when Nathan updates the Python all the 3 bugs can be tested (in case the 3rd one is not related with that, otherwise the bug report can end up closed with still remaining issues). %%%

%%%Hey Josh, do you think you can put your problem in a example .blend file. Just so when Nathan updates the Python all the 3 bugs can be tested (in case the 3rd one is not related with that, otherwise the bug report can end up closed with still remaining issues). %%%
Author
Owner

%%%argh this bug is even worse. Another test for it:
Go to Console Editor:
$ import urllib
$ urllib.<Ctrl+Tab>
you should see 4 modules, however only parse is available

With Python 3.1.2 (or importing the modules from an addon):
http://www.pasteall.org/pic/show.php?id=5241
%%%

%%%argh this bug is even worse. Another test for it: Go to Console Editor: $ import urllib $ urllib.<Ctrl+Tab> you should see 4 modules, however only parse is available With Python 3.1.2 (or importing the modules from an addon): http://www.pasteall.org/pic/show.php?id=5241 %%%
Member

%%%I have updated the Python libraries in lib/windows and lib/win64. Please update and rebuild against those.

All the scripts in bug.blend give a nice "It worked!"

Please verify and report back. Builds with the new python can be retrieved at http://www.letworyinteractive.com/b/ top part of right sidebar.%%%

%%%I have updated the Python libraries in lib/windows and lib/win64. Please update and rebuild against those. All the scripts in bug.blend give a nice "It worked!" Please verify and report back. Builds with the new python can be retrieved at http://www.letworyinteractive.com/b/ top part of right sidebar.%%%

%%%Very nice, works great!%%%

%%%Very nice, works great!%%%
Author
Owner

%%%Hm strange. The reported file really works well, but the urllib test still fails here. (even though the submodules are accessible from an addon (e.g. - https://svn.blender.org/svnroot/bf-extensions/contrib/py/scripts/addons/text_editor_pasteall.py ))

Do you want me to open a new report for that?

Windows 7 Pro, CMake+MSVC - Python 3.1.2
%%%

%%%Hm strange. The reported file really works well, but the urllib test still fails here. (even though the submodules are accessible from an addon (e.g. - https://svn.blender.org/svnroot/bf-extensions/contrib/py/scripts/addons/text_editor_pasteall.py )) Do you want me to open a new report for that? Windows 7 Pro, CMake+MSVC - Python 3.1.2 %%%
Author
Owner

%%%closing. moving the urllib problem for another bugreport.%%%

%%%closing. moving the urllib problem for another bugreport.%%%
Author
Owner

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#23346
No description provided.