- Python Home
- About
- News
- Documentation
- Downloads
- Community
- Foundation
- Developer's Guide
- Issue Tracker
- Issues
- Summaries
- User
- Administration
- Help
➜
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 | aronacher |
|---|---|
| Recipients | aronacher |
| Date | 2009-02-19.20:34:22 |
| SpamBayes Score | 2.6682733e-07 |
| Marked as misclassified | No |
| Message-id | <1235075665.37.0.301694124748.issue5322@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
|---|
In 2.6 a deprecation warning was added if `object.__new__` was called
with arguments. Per se this is fine, but the detection seems to be faulty.
The following code shows the problem:
>>> class A(object):
... def __new__(self):
... raise TypeError('i do not exist')
...
>>> class B(A):
... __new__ = object.__new__
... def __init__(self, x):
... self.x = x
...
>>> B(1)
__main__:1: DeprecationWarning: object.__new__() takes no parameters
<__main__.B object at 0x88dd0>
In the `B` case `__new__` is not overridden (in the sense that it
differs from object.__new__) but `__init__` is. Which is the default
behaviour. Nonetheless a warning is raised.
I used the pattern with the "__new__ switch" to achieve a
cStringIO.StringIO behavior that supports typechecks: IterIO() returns
either a IterI or IterO object, both instances of IterIO so that
typechecks can be performed.
Real-world use case here:
http://dev.pocoo.org/projects/werkzeug/browser/werkzeug/contrib/iterio.py |
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2009-02-19 20:34:25 | aronacher | set | recipients: + aronacher |
| 2009-02-19 20:34:25 | aronacher | set | messageid: <1235075665.37.0.301694124748.issue5322@psf.upfronthosting.co.za> |
| 2009-02-19 20:34:23 | aronacher | link | issue5322 messages |
| 2009-02-19 20:34:22 | aronacher | create |
Powered by Roundup Copyright © 1990-2022, Python Software Foundation
Legal Statements
