[issue46285] protocol_version in http.server.test can be ignored
Hugo Almeida added the comment: Hi Éric, thank you so much. I know only a little usage of closure and functools.partial but not the historical/relative knowledge of their design/feature, I mean this issue have 2 visual, the partical object not working as it expected or we are not calling the partical as it expected: 1) partial is not working as its feature or design said, assume I guessed right, thus partial object behaviors should be totally equal to its wrapper/inside class called with properties applied in a standalone/outside way which we usually used, the use of partical at http.server.test should be okey. """ import functools class Obj: pass obj = Obj(); obj.foo = bar # usually used jbo = functools.partial(Obj, foo=bar) # if jbo totally equal to obj in anywhere # (the so called Duck Type or # maybe the LSP rule, Liskov # Substitution Principle) # the use of partical in http.server # should also be ok # # I used the partical times the same # as http.server's author did # and I told myself I know its usage # but now I do not think so """ 2) solve this issue itself, to pass handler class directly to ignore partial object caused problem, this is a coding logic shelter/fixing because the way we used functools.partical is not as it expected. This is what cpython@github PR30701 already done. (so the use of partical in http.server is not ok, not welcome at least, so based what I said above, the feature/design of partical now confused me, unless its a bug of partical itself which I am not sure.) -- ___ Python tracker <https://bugs.python.org/issue46285> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46285] http/server.py wont respect its protocol_version
Hugo Almeida added the comment: Hi, buddy, there is no problem if invoke the http.server.test function as its designed, I mean the function iteself is okay, thus http/server.py invoked it via the functools.partial wrapper (handler_class) only will case this issue, which technically ignored its protocol parameter's specify. User of http/server.py::test should specify a handler class directly. If this is a bug, maybe it is about the usage/desire of `functools.partial` ... I am not sure, closure model programming (the lambda etc.) is not eary for me and I closed this issue by courtesy yesterday, if reopen this issue will help/valueable a bit, please tell me. Improve my English seems too nessary, thank you so much for your warm hearted. -- ___ Python tracker <https://bugs.python.org/issue46285> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46285] http/server.py wont respect its protocol_version
Hugo Almeida added the comment: The short story is, everything is okay, its my bad to taken the test function out of context, sorry about that of issue report. # just for details review (related file attached): # # check line 1277 to line 1278 (main branch of Python currently): # https://github.com/python/cpython/blob/17b16e1/Lib/http/server.py#L1277-L1278 # # thus, `functools.partial` (closure/wrapper) will # make the parameter `protocol` of the function `test` useless. # So, specify a handler class directly. -- resolution: remind -> not a bug stage: -> resolved status: open -> closed Added file: https://bugs.python.org/file50551/my_http.py ___ Python tracker <https://bugs.python.org/issue46285> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46285] http/server.py wont respect its protocol_version
Hugo Almeida added the comment: update == It seems I've found the problem, http/server.py#L1277-L1288: ``` handler_class = partial(SimpleHTTPRequestHandler, directory=args.directory) ``` Because of `partial` (provide by the functools module), there comes a closure like stuff ? -- resolution: -> remind ___ Python tracker <https://bugs.python.org/issue46285> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46285] http/server.py wont respect its protocol_version
New submission from Hugo Almeida : Hi, Sorry for my poor English, this is not a spam issue. How to reproduce File about `http/server.py`, line 1235 at main branch. 1st, change `protocol_version`, e.g. from "HTTP/1.0" to "HTTP/1.1": --- protocol="HTTP/1.0", port=8000, ... +++ protocol="HTTP/1.1", port=8000, ... 2ed, run with `python -m http.server` and test by: `curl http://127.0.0.1:8000 2>/dev/null| head -n 1` Result == The response head line will always been a fixed HTTP Version refer to `BaseHTTPRequestHandler.protocol_version` defined, thus "HTTP/1.0 200 OK" currently. Expected It should equal to `http.server.test(protocol="...")` which specified like above, for this issue, it is expected to be "HTTP/1.1 200 OK". P.S. I know it is just locate in a test code area (http.servers::test), but what I submit here is about a Python Variable Scope issue maybe. -- components: Library (Lib) messages: 409894 nosy: openalmeida priority: normal severity: normal status: open title: http/server.py wont respect its protocol_version type: enhancement versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue46285> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com