New submission from Christopher the Magnificent:

This may be an issue with the interpreter behavior or it may be a documentation 
issue.

Note: I only selected Python 3.3 as the version, but it probably affects MANY 
other Python versions.

Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 01:25:11) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "copyright", "credits" or "license()" for more information.
>>> import abc
>>> help(abc.abstractclassmethod)
Help on class abstractclassmethod in module abc:

class abstractclassmethod(builtins.classmethod)
 |  A decorator indicating abstract classmethods.
 |  
 |  Similar to abstractmethod.
 |  
 |  Usage:
 |  
 |      class C(metaclass=ABCMeta):
 |          @abstractclassmethod
 |          def my_abstract_classmethod(cls, ...):
 |              ...
 |  
 |  'abstractclassmethod' is deprecated. Use 'classmethod' with
 |  'abstractmethod' instead.
. (et cetra)
.
.
>>> # doesn't work
>>> class Demo(metaclass=abc.ABCMeta):
...     @abc.abstractmethod
...     @classmethod
...     def test(cls):
...             pass
... 
Traceback (most recent call last):
  File "<pyshell#26>", line 1, in <module>
    class Demo3(metaclass=abc.ABCMeta):
  File "<pyshell#26>", line 3, in Demo3
    @classmethod
  File 
"/Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/abc.py", line 
24, in abstractmethod
    funcobj.__isabstractmethod__ = True
AttributeError: attribute '__isabstractmethod__' of 'classmethod' objects is 
not writable
>>> # DOES work
>>> class Demo2(metaclass=abc.ABCMeta):
...     @classmethod
...     @abc.abstractmethod
...     def test(cls):
...             pass
...     
>>> Demo2()
Traceback (most recent call last):
  File "<pyshell#33>", line 1, in <module>
    Demo4()
TypeError: Can't instantiate abstract class Demo2 with abstract methods test


Hopefully this is enough documentation to show what the issues is.  If not, 
just chime in.  :-)

----------
assignee: docs@python
components: Documentation, Interpreter Core
messages: 173183
nosy: christopherthemagnificent, docs@python
priority: normal
severity: normal
status: open
title: order of decorators @abstractmethod and @classmethod is significant (is 
not documented to be in @abstractclassmethod which advises their combined use)
type: behavior
versions: Python 3.3

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16267>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to