TypeError: __name__ must be set to a string object

Discussion in 'Python' started by Frank Millman, Jan 11, 2010.

  1. Hi all

    This problem is similar to one I posted recently regarding the
    multiprocessing module and unicode.

    However, although this one manifests itself while using the multiprocessing
    module, is caused by Python itself (2.6.2).

    At the top of my program I have 'from __future__ import unicode_literals'.

    The relevant lines from my program read -
    from multiprocessing.managers import BaseManager
    class MyManager(BaseManager): pass
    MyManager.register('my_function', my_function)

    Inside the multiprocessing module, the following lines are executed -
    @classmethod
    def register(cls, typeid, ...)
    [...]
    def temp(...):
    [...]
    temp.__name__ = typeid

    At this point, Python raises the exception 'TypeError: __name__ must be set
    to a string object'.

    I can fix it by changing my last line to -
    MyManager.register(str('my_function'), my_function)

    Is there any reason why __name__ cannot be a unicode object in Python 2.x?
    If so, there is probably little chance of this being changed, so it is
    probably not worth reporting.

    Any thoughts?

    Frank Millman
    Frank Millman, Jan 11, 2010
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Manish Gupta (BBS)
    Replies:
    3
    Views:
    614
    Raymond L. Buvel
    Feb 19, 2005
  2. Fredrik Lundh
    Replies:
    0
    Views:
    512
    Fredrik Lundh
    Feb 17, 2005
  3. Huzaifa Tapal
    Replies:
    0
    Views:
    419
    Huzaifa Tapal
    Apr 26, 2005
  4. gtb
    Replies:
    8
    Views:
    364
    Steven D'Aprano
    May 1, 2007
  5. Eric Snow
    Replies:
    6
    Views:
    467
    Eric Snow
    Aug 10, 2011
Loading...

Share This Page