python / cpython

The Python programming language
https://www.python.org
Other
62.35k stars 29.94k forks source link

cls.__module__ and metaclasses #36090

Closed doerwalter closed 22 years ago

doerwalter commented 22 years ago
BPO 516532
Nosy @doerwalter

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields: ```python assignee = None closed_at = created_at = labels = ['interpreter-core'] title = 'cls.__module__ and metaclasses' updated_at = user = 'https://github.com/doerwalter' ``` bugs.python.org fields: ```python activity = actor = 'jvr' assignee = 'none' closed = True closed_date = None closer = None components = ['Interpreter Core'] creation = creator = 'doerwalter' dependencies = [] files = [] hgrepos = [] issue_num = 516532 keywords = [] message_count = 3.0 messages = ['9255', '9256', '9257'] nosy_count = 3.0 nosy_names = ['doerwalter', 'jvr', 'rengelink'] pr_nums = [] priority = 'normal' resolution = 'duplicate' stage = None status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue516532' versions = ['Python 2.2'] ```

doerwalter commented 22 years ago

In the following the __module__ attribute is incorrect:

file foo.py: ---------------

class foo(object):
  class __metaclass__(type):
    def __new__(cls, name, bases, dict):
      return type.__new__(cls, name, bases, dict)

file bar.py: ---------------

import foo

class bar(foo.foo):
   pass

With these two files the following test prints the wrong result:

>>> import bar
>>> bar.bar.__module__
'foo'
f86a23c4-8f8e-4555-8ad1-51af59a4dcb9 commented 22 years ago

Logged In: YES user_id=302601

I think this is a duplicate of bpo-503837

0aa1c2b5-8e64-4988-b25b-7db15cdc7c29 commented 22 years ago

Logged In: YES user_id=92689

I think so, too: can't reproduce in CVS Python.