Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a5e0eaf

Browse files
committed
Fix 5931 - Python runtime hardcoded in wsgiref.simple_server - Now it specifies an implementation specific term.
1 parent bc1a7dd commit a5e0eaf

4 files changed

Lines changed: 18 additions & 3 deletions

File tree

Doc/library/wsgiref.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,11 @@ input, output, and error streams.
609609
as :class:`BaseCGIHandler` and :class:`CGIHandler`) that are not HTTP origin
610610
servers.
611611

612+
.. versionchanged:: 3.3
613+
614+
The term "Python" is replaced with implementation specific term like
615+
"CPython", "Jython" etc.
616+
612617

613618
.. method:: BaseHandler.get_scheme()
614619

Lib/test/test_wsgiref.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from wsgiref.simple_server import make_server
1010
from io import StringIO, BytesIO, BufferedReader
1111
from socketserver import BaseServer
12+
from platform import python_implementation
13+
1214
import os
1315
import re
1416
import sys
@@ -129,9 +131,11 @@ def compare_generic_iter(make_it,match):
129131
class IntegrationTests(TestCase):
130132

131133
def check_hello(self, out, has_length=True):
134+
pyver = (python_implementation() + "/" +
135+
sys.version.split()[0])
132136
self.assertEqual(out,
133137
("HTTP/1.0 200 OK\r\n"
134-
"Server: WSGIServer/0.2 Python/"+sys.version.split()[0]+"\r\n"
138+
"Server: WSGIServer/0.2 " + pyver +"\r\n"
135139
"Content-Type: text/plain\r\n"
136140
"Date: Mon, 05 Jun 2006 18:49:54 GMT\r\n" +
137141
(has_length and "Content-Length: 13\r\n" or "") +
@@ -185,9 +189,11 @@ def app(e, s):
185189
out, err = run_amock(validator(app))
186190
self.assertTrue(err.endswith('"GET / HTTP/1.0" 200 4\n'))
187191
ver = sys.version.split()[0].encode('ascii')
192+
py = python_implementation().encode('ascii')
193+
pyver = py + b"/" + ver
188194
self.assertEqual(
189195
b"HTTP/1.0 200 OK\r\n"
190-
b"Server: WSGIServer/0.2 Python/" + ver + b"\r\n"
196+
b"Server: WSGIServer/0.2 "+ pyver + b"\r\n"
191197
b"Content-Type: text/plain; charset=utf-8\r\n"
192198
b"Date: Wed, 24 Dec 2008 13:29:32 GMT\r\n"
193199
b"\r\n"

Lib/wsgiref/simple_server.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,14 @@
1414
import sys
1515
import urllib.parse
1616
from wsgiref.handlers import SimpleHandler
17+
from platform import python_implementation
1718

1819
__version__ = "0.2"
1920
__all__ = ['WSGIServer', 'WSGIRequestHandler', 'demo_app', 'make_server']
2021

2122

2223
server_version = "WSGIServer/" + __version__
23-
sys_version = "Python/" + sys.version.split()[0]
24+
sys_version = python_implementation() + "/" + sys.version.split()[0]
2425
software_version = server_version + ' ' + sys_version
2526

2627

Misc/NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ Core and Builtins
2323
Library
2424
-------
2525

26+
- Issue #5931: wsgiref environ variable SERVER_SOFTWARE will specify an
27+
implementation specific term like Cpython, Jython instead of generic "Python"
28+
2629
- Issue #13248: Remove obsolete argument "max_buffer_size" of BufferedWriter
2730
and BufferedRWPair, from the io module.
2831

0 commit comments

Comments
 (0)