Author mdk
Recipients matrixise, mdk, vstinner
Date 2016-11-15.23:46:11
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Hi Stéphane,

Your patch is simple and elegant, but I'm asking myself a question about the idea to pass a class instead of an instance to the TCPServer ctor (I know that's not your choice).

If we were able to pass an instance of SimpleHTTPRequestHandler instead of its class, we'd be able to give the `directory` to the handler during the `main()`, instead of using with `chdir` and `getcwd` to pass the information in a kind of hidden/side channel.

I think that relying on `chdir` and `getcwd` to pass a parameter is not the most pretty or most testable way to do so. Also, having an `os.getcwd()` hardcoded in `SimpleHTTPRequestHandler` does not looks right (again, not your fault, it was here before…) typically for testability, but also when used in a concurrent environment, when cwd may be changed by other "coroutines".

I tried to provide a patch fixing all those condiderations, here it is. still, I can't write a patch as KISS as yours, so I'm probably in the wrong way, at least I tried.
Date User Action Args
2016-11-15 23:46:12mdksetrecipients: + mdk, vstinner, matrixise
2016-11-15 23:46:12mdksetmessageid: <>
2016-11-15 23:46:12mdklinkissue28707 messages
2016-11-15 23:46:12mdkcreate