homepage

This issue tracker has been migrated to GitHub , and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author christopherthemagnificent
Recipients christopherthemagnificent, docs@python
Date 2012年10月17日.15:41:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1350488481.01.0.487550684008.issue16267@psf.upfronthosting.co.za>
In-reply-to
Content
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. :-)
History
Date User Action Args
2012年10月17日 15:41:21christopherthemagnificentsetrecipients: + christopherthemagnificent, docs@python
2012年10月17日 15:41:21christopherthemagnificentsetmessageid: <1350488481.01.0.487550684008.issue16267@psf.upfronthosting.co.za>
2012年10月17日 15:41:20christopherthemagnificentlinkissue16267 messages
2012年10月17日 15:41:20christopherthemagnificentcreate

AltStyle によって変換されたページ (->オリジナル) /