classification
Title: SocketServer.BaseRequestHandler not a new-style class?
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: eric.araujo, eric.smith, phf
Priority: normal Keywords:

Created on 2010-07-02 04:53 by phf, last changed 2010-07-02 13:33 by phf. This issue is now closed.

Messages (4)
msg109089 - (view) Author: Peter Froehlich (phf) Date: 2010-07-02 04:53
I tried to do this:

class Handler(SimpleHTTPRequestHandler):
  def do_GET(self):
    super(Handler, self).do_GET()
    print self.path

However super fails:

TypeError: super() argument 1 must be type, not classobj

Looking up the chain of base classes, I found that SocketServer.BaseRequestHandler is defined as follows:

class BaseRequestHandler:

No "(object)" there to make it a new-style class. I think that's wrong? BTW, in the 3.1 library it's defined the same way, but I'd assume that all classes are "new-style" in 3.1?
msg109105 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2010-07-02 12:48
We can't change this for 2.6 since it's not a bug fix, and it's too late for 2.7. I doubt we would ever change it for 2.x, since it's likely to break other code is subtle ways.

In 3.x all classes are new-style, so it's not at issue there.
msg109106 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-07-02 12:50
To address the OP’s problem, super can be removed:

-    super(Handler, self).do_GET()
+    Handler.do_GET(self)
msg109108 - (view) Author: Peter Froehlich (phf) Date: 2010-07-02 13:33
On Fri, Jul 2, 2010 at 8:50 AM, Éric Araujo <report@bugs.python.org> wrote:
> -    super(Handler, self).do_GET()
> +    Handler.do_GET(self)

Yep, that's how I solved it. :-D
History
Date User Action Args
2010-07-02 13:33:17phfsetmessages: + msg109108
2010-07-02 12:50:27eric.araujosetnosy: + eric.araujo
messages: + msg109106
2010-07-02 12:48:44eric.smithsetstatus: open -> closed

type: behavior -> enhancement
versions: + Python 2.7, - Python 2.6
nosy: + eric.smith

messages: + msg109105
resolution: wont fix
stage: resolved
2010-07-02 04:53:40phfcreate