Skip to content

Commit 57dddfb

Browse files
committed
Merged revisions 59642-59665 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r59653 | martin.v.loewis | 2008-01-01 22:05:17 +0100 (Tue, 01 Jan 2008) | 3 lines Return results from Python callbacks to Tcl as Tcl objects. Fixes Tk issue #1851526 ........ r59654 | martin.v.loewis | 2008-01-01 22:08:18 +0100 (Tue, 01 Jan 2008) | 4 lines Always convert Text.index result to string. This improves compatibility with Tcl 8.5, which would otherwise return textindex objects. ........ r59655 | martin.v.loewis | 2008-01-01 22:09:07 +0100 (Tue, 01 Jan 2008) | 2 lines News item for r59653. ........ r59656 | martin.v.loewis | 2008-01-02 00:00:00 +0100 (Wed, 02 Jan 2008) | 1 line Don't link with Tix; Tix is loaded dynamically by Tcl. ........ r59657 | martin.v.loewis | 2008-01-02 00:00:48 +0100 (Wed, 02 Jan 2008) | 1 line Use Visual Studio 2009 on the build slaves. ........ r59658 | martin.v.loewis | 2008-01-02 00:36:24 +0100 (Wed, 02 Jan 2008) | 1 line Test in PCbuild directory. ........ r59661 | kurt.kaiser | 2008-01-02 05:11:28 +0100 (Wed, 02 Jan 2008) | 6 lines Issue1177 r58207 and r58247 patch logic is reversed. I noticed this when I tried to use urllib to retrieve a file which required auth. Fix that and add a test for 401 error to verify. ........ r59662 | kurt.kaiser | 2008-01-02 06:23:38 +0100 (Wed, 02 Jan 2008) | 2 lines Change docstrings to comments so test output will display normally. ........ r59665 | christian.heimes | 2008-01-02 18:43:40 +0100 (Wed, 02 Jan 2008) | 5 lines Removed PCbuild8/ directory and added a new build directory for VS 2005 based on the VS 2008 build directory to PC/VS8.0. The script PCbuild/vs8to9.py was added to sync changes from PCbuild to PC/VS8.0. Kristjan, the initial creator of the PCbuild8 directory is fine with the replacement. I've moved the new version of the VS 2005 build directory next to the other legacy build directories. The new sync script is based on the work of wreck and syncs changes in the project, property and solution files. ........
1 parent ba3febc commit 57dddfb

72 files changed

Lines changed: 5463 additions & 6414 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Lib/lib-tk/Tkinter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2977,7 +2977,7 @@ def image_names(self):
29772977
return self.tk.call(self._w, "image", "names")
29782978
def index(self, index):
29792979
"""Return the index in the form line.char for INDEX."""
2980-
return self.tk.call(self._w, 'index', index)
2980+
return str(self.tk.call(self._w, 'index', index))
29812981
def insert(self, index, chars, *args):
29822982
"""Insert CHARS before the characters at INDEX. An additional
29832983
tag can be given in ARGS. Additional CHARS and tags can follow in ARGS."""

Lib/test/test_urllib.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,23 @@ def test_read(self):
126126
finally:
127127
self.unfakehttp()
128128

129+
def test_read_bogus(self):
130+
# urlopen() should raise IOError for many error codes.
131+
self.fakehttp(b'''HTTP/1.1 401 Authentication Required
132+
Date: Wed, 02 Jan 2008 03:03:54 GMT
133+
Server: Apache/1.3.33 (Debian GNU/Linux) mod_ssl/2.8.22 OpenSSL/0.9.7e
134+
Connection: close
135+
Content-Type: text/html; charset=iso-8859-1
136+
''')
137+
try:
138+
self.assertRaises(IOError, urllib.urlopen, "http://python.org/")
139+
finally:
140+
self.unfakehttp()
141+
129142
def test_empty_socket(self):
130143
# urlopen() raises IOError if the underlying socket does not send any
131144
# data. (#1680230)
132-
self.fakehttp(b"")
145+
self.fakehttp(b'')
133146
try:
134147
self.assertRaises(IOError, urllib.urlopen, "http://something")
135148
finally:

Lib/urllib.py

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def _open_generic_http(self, connection_factory, url, data):
359359

360360
# According to RFC 2616, "2xx" code indicates that the client's
361361
# request was successfully received, understood, and accepted.
362-
if not (200 <= response.status < 300):
362+
if (200 <= response.status < 300):
363363
return addinfourl(response.fp, response.msg, "http:" + url)
364364
else:
365365
return self.http_error(
@@ -402,6 +402,77 @@ def open_https(self, url, data=None):
402402
"""Use HTTPS protocol."""
403403
return self._open_generic_http(self._https_connection, url, data)
404404

405+
import httplib
406+
user_passwd = None
407+
proxy_passwd = None
408+
if isinstance(url, str):
409+
host, selector = splithost(url)
410+
if host:
411+
user_passwd, host = splituser(host)
412+
host = unquote(host)
413+
realhost = host
414+
else:
415+
host, selector = url
416+
# here, we determine, whether the proxy contains authorization information
417+
proxy_passwd, host = splituser(host)
418+
urltype, rest = splittype(selector)
419+
url = rest
420+
user_passwd = None
421+
if urltype.lower() != 'https':
422+
realhost = None
423+
else:
424+
realhost, rest = splithost(rest)
425+
if realhost:
426+
user_passwd, realhost = splituser(realhost)
427+
if user_passwd:
428+
selector = "%s://%s%s" % (urltype, realhost, rest)
429+
#print "proxy via https:", host, selector
430+
if not host: raise IOError('https error', 'no host given')
431+
if proxy_passwd:
432+
import base64
433+
proxy_auth = base64.b64encode(proxy_passwd).strip()
434+
else:
435+
proxy_auth = None
436+
if user_passwd:
437+
import base64
438+
auth = base64.b64encode(user_passwd).strip()
439+
else:
440+
auth = None
441+
h = httplib.HTTPS(host, 0,
442+
key_file=self.key_file,
443+
cert_file=self.cert_file)
444+
if data is not None:
445+
h.putrequest('POST', selector)
446+
h.putheader('Content-Type',
447+
'application/x-www-form-urlencoded')
448+
h.putheader('Content-Length', '%d' % len(data))
449+
else:
450+
h.putrequest('GET', selector)
451+
if proxy_auth: h.putheader('Proxy-Authorization', 'Basic %s' % proxy_auth)
452+
if auth: h.putheader('Authorization', 'Basic %s' % auth)
453+
if realhost: h.putheader('Host', realhost)
454+
for args in self.addheaders: h.putheader(*args)
455+
h.endheaders()
456+
if data is not None:
457+
h.send(data)
458+
errcode, errmsg, headers = h.getreply()
459+
fp = h.getfile()
460+
if errcode == -1:
461+
if fp: fp.close()
462+
# something went wrong with the HTTP status line
463+
raise IOError('http protocol error', 0,
464+
'got a bad status line', None)
465+
# According to RFC 2616, "2xx" code indicates that the client's
466+
# request was successfully received, understood, and accepted.
467+
if (200 <= errcode < 300):
468+
return addinfourl(fp, headers, "https:" + url)
469+
else:
470+
if data is None:
471+
return self.http_error(url, fp, errcode, errmsg, headers)
472+
else:
473+
return self.http_error(url, fp, errcode, errmsg, headers,
474+
data)
475+
405476
def open_file(self, url):
406477
"""Use local file or FTP depending on form of URL."""
407478
if not isinstance(url, str):

Modules/_tkinter.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
19061906
PythonCmd_ClientData *data = (PythonCmd_ClientData *)clientData;
19071907
PyObject *self, *func, *arg, *res, *s;
19081908
int i, rv;
1909-
Tcl_Obj *tres;
1909+
Tcl_Obj *obj_res;
19101910

19111911
ENTER_PYTHON
19121912

@@ -1939,13 +1939,13 @@ PythonCmd(ClientData clientData, Tcl_Interp *interp, int argc, char *argv[])
19391939
if (res == NULL)
19401940
return PythonCmd_Error(interp);
19411941

1942-
tres = AsObj(res);
1943-
if (tres == NULL) {
1942+
obj_res = AsObj(res);
1943+
if (obj_res == NULL) {
19441944
Py_DECREF(res);
19451945
return PythonCmd_Error(interp);
19461946
}
19471947
else {
1948-
Tcl_SetObjResult(Tkapp_Interp(self), tres);
1948+
Tcl_SetObjResult(Tkapp_Interp(self), obj_res);
19491949
rv = TCL_OK;
19501950
}
19511951

0 commit comments

Comments
 (0)