Julien Palard added the comment:

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.

----------
nosy: +mdk
Added file: http://bugs.python.org/file45494/28707.patch

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

Reply via email to