List of commits:
Subject Hash Author Date (UTC)
bpo-30228: FileIO seek() and tell() set seekable (#1384) 999707373630ce090300c3c542066f493b12faa0 Victor Stinner 2017-05-02 13:10:39
bpo-30199: test_ssl closes all asyncore channels (#1381) 1dae7450c68bad498e57800387b24cb103c461fa Victor Stinner 2017-05-02 11:12:02
bpo-30132: distutils BuildExtTestCase use temp_cwd (#1380) 92fd6c9ef54a857815e3dca8ee74b2b4f5cdf154 Victor Stinner 2017-05-02 11:11:50
Clean up some confusing text left by PROTOCOL_SSLv23 -> PROTOCOL_TLS transition (#1355) d4069de5112f0408801ff2479476827bb3e0e8fc Nathaniel J. Smith 2017-05-02 05:43:31
bpo-30190: improved error msg for assertAlmostEqual(delta=...) (#1331) 5d7a8d0c13737fd531b722ad76c505ef47aac96a Giampaolo Rodola 2017-05-01 16:18:56
restore *data* parameter of binascii.b2a_base64 to positional-only (#1352) 1374dbb6940f29c49c2966551a06015857c942cc Xiang Zhang 2017-05-01 05:12:07
bpo-29679: Implement @contextlib.asynccontextmanager (#360) 2e624690bd74071358566300b7ef0bc45f444a30 Jelle Zijlstra 2017-05-01 01:25:58
bpo-30208: DOC: fix small typos in IDLE (#1354) 9dc2b3809f38be2e403ee264958106badfda142d csabella 2017-04-29 22:28:36
bpo-30158: Fix deprecation warnings in test_importlib introduced by bpo-29576. (#1285) 3cc8259b71ef784a9f7593f04da96043afe2228a Serhiy Storchaka 2017-04-29 04:06:49
Check that Python is 64-bit before enabling BLAKE2_USE_SSE. (#1332) 6c991bdee7ec4bedd8c1b8d3812dc884b654b57c Neil Schemenauer 2017-04-28 16:56:48
bpo-30197: Enhance functions swap_attr() and swap_item() in test.support. (#1341) d1a1def7bf221b04dcf3fc3a67aa19aa2f622f83 Serhiy Storchaka 2017-04-28 16:17:26
Improve the grammar in windows.rst (GH-1330) 80a3da4d4aad0b51893e1e2f696b6252eca80e07 Wieland Hoffmann 2017-04-28 16:12:57
bpo-30104: Only use -fno-strict-aliasing on dtoa.c (#1340) 826f83f1d562a7b878499bc3af2267cfdfe5f2f9 Victor Stinner 2017-04-28 13:07:10
bpo-30174: Remove duplicate definition from pickletools (#1301) 5a4e3d8f9c37e700402b23fafbfc413e5ca3113d Jelle Zijlstra 2017-04-27 16:05:26
bpo-30175: Skip client cert tests of test_imaplib (#1320) 5bccca58b9b2b3a925b16750bedbd907695ea8d7 Victor Stinner 2017-04-27 15:30:13
bpo-27200: Fix several doctests (GH-604) e65fcde85abf6617508f2d6b77020e24b8ca6f6b Marco Buttu 2017-04-27 12:23:34
Use the correct name for ISO in Unicode HOWTO. (#1312) 6fde770e4e940c19cd62de0b6aeb77840690843e Jesse Gonzalez 2017-04-27 05:12:17
bpo-28415: Note 0 conversion different between Python and C (#885) 88c38b32b761cb566759b8ad96704bff590a1de9 Louie Lu 2017-04-27 03:36:35
bpo-30142: Remove "callable" from the 2to3fixer documentation. (GH-1296) a90b990480f45b6a0ad02d43455cf8b620bac9c5 Dong-hee Na 2017-04-26 16:16:21
bpo-30101: Add support for curses.A_ITALIC. (#1015) ab7886b78574d9224b26dc3a5b08e5c105fbbf11 Eijebong 2017-04-26 15:17:12
Commit 999707373630ce090300c3c542066f493b12faa0 - bpo-30228: FileIO seek() and tell() set seekable (#1384)
FileIO.seek() and FileIO.tell() method now set the internal seekable
attribute to avoid one syscall on open() (in buffered or text mode).

The seekable property is now also more reliable since its value is
set correctly on memory allocation failure.
Author: Victor Stinner
Author date (UTC): 2017-05-02 13:10
Committer name: GitHub
Committer date (UTC): 2017-05-02 13:10
Parent(s): 1dae7450c68bad498e57800387b24cb103c461fa
Signer:
Signing key:
Signing status: N
Tree: 1085aacebf78a2a85280c6c9934ecfd315f13fcf
File Lines added Lines deleted
Misc/NEWS 3 0
Modules/_io/fileio.c 21 15
File Misc/NEWS changed (mode: 100644) (index 2a86c3419a..118483f943)
... ... Extension Modules
317 317 Library Library
318 318 ------- -------
319 319
320 - bpo-30228: The seek() and tell() methods of io.FileIO now set the internal
321 seekable attribute to avoid one syscall on open() (in buffered or text mode).
322
320 323 - bpo-30190: unittest's assertAlmostEqual and assertNotAlmostEqual provide a - bpo-30190: unittest's assertAlmostEqual and assertNotAlmostEqual provide a
321 324 better message in case of failure which includes the difference between better message in case of failure which includes the difference between
322 325 left and right arguments. (patch by Giampaolo Rodola') left and right arguments. (patch by Giampaolo Rodola')
File Modules/_io/fileio.c changed (mode: 100644) (index 922db3e470..a09c39f76a)
... ... _Py_IDENTIFIER(name);
73 73
74 74 #define PyFileIO_Check(op) (PyObject_TypeCheck((op), &PyFileIO_Type)) #define PyFileIO_Check(op) (PyObject_TypeCheck((op), &PyFileIO_Type))
75 75
76 /* Forward declarations */
77 static PyObject* portable_lseek(fileio *self, PyObject *posobj, int whence);
78
76 79 int int
77 80 _PyFileIO_closed(PyObject *self) _PyFileIO_closed(PyObject *self)
78 81 { {
 
... ... fileio_dealloc_warn(fileio *self, PyObject *source)
98 101 Py_RETURN_NONE; Py_RETURN_NONE;
99 102 } }
100 103
101 static PyObject *
102 portable_lseek(int fd, PyObject *posobj, int whence);
103
104 static PyObject *portable_lseek(int fd, PyObject *posobj, int whence);
105
106 104 /* Returns 0 on success, -1 with exception set on failure. */ /* Returns 0 on success, -1 with exception set on failure. */
107 105 static int static int
108 106 internal_close(fileio *self) internal_close(fileio *self)
 
... ... _io_FileIO___init___impl(fileio *self, PyObject *nameobj, const char *mode,
478 476 /* For consistent behaviour, we explicitly seek to the /* For consistent behaviour, we explicitly seek to the
479 477 end of file (otherwise, it might be done only on the end of file (otherwise, it might be done only on the
480 478 first write()). */ first write()). */
481 PyObject *pos = portable_lseek(self->fd, NULL, 2);
479 PyObject *pos = portable_lseek(self, NULL, 2);
482 480 if (pos == NULL) if (pos == NULL)
483 481 goto error; goto error;
484 482 Py_DECREF(pos); Py_DECREF(pos);
 
... ... _io_FileIO_seekable_impl(fileio *self)
600 598 if (self->fd < 0) if (self->fd < 0)
601 599 return err_closed(); return err_closed();
602 600 if (self->seekable < 0) { if (self->seekable < 0) {
603 PyObject *pos = portable_lseek(self->fd, NULL, SEEK_CUR);
601 /* portable_lseek() sets the seekable attribute */
602 PyObject *pos = portable_lseek(self, NULL, SEEK_CUR);
603 assert(self->seekable >= 0);
604 604 if (pos == NULL) { if (pos == NULL) {
605 605 PyErr_Clear(); PyErr_Clear();
606 self->seekable = 0;
607 } else {
606 }
607 else {
608 608 Py_DECREF(pos); Py_DECREF(pos);
609 self->seekable = 1;
610 609 } }
611 610 } }
612 611 return PyBool_FromLong((long) self->seekable); return PyBool_FromLong((long) self->seekable);
 
... ... _io_FileIO_write_impl(fileio *self, Py_buffer *b)
865 864
866 865 /* Cribbed from posix_lseek() */ /* Cribbed from posix_lseek() */
867 866 static PyObject * static PyObject *
868 portable_lseek(int fd, PyObject *posobj, int whence)
867 portable_lseek(fileio *self, PyObject *posobj, int whence)
869 868 { {
870 869 Py_off_t pos, res; Py_off_t pos, res;
870 int fd = self->fd;
871 871
872 872 #ifdef SEEK_SET #ifdef SEEK_SET
873 873 /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */ /* Turn 0, 1, 2 into SEEK_{SET,CUR,END} */
 
... ... portable_lseek(int fd, PyObject *posobj, int whence)
884 884 } }
885 885 #endif /* SEEK_SET */ #endif /* SEEK_SET */
886 886
887 if (posobj == NULL)
887 if (posobj == NULL) {
888 888 pos = 0; pos = 0;
889 }
889 890 else { else {
890 891 if(PyFloat_Check(posobj)) { if(PyFloat_Check(posobj)) {
891 892 PyErr_SetString(PyExc_TypeError, "an integer is required"); PyErr_SetString(PyExc_TypeError, "an integer is required");
 
... ... portable_lseek(int fd, PyObject *posobj, int whence)
909 910 #endif #endif
910 911 _Py_END_SUPPRESS_IPH _Py_END_SUPPRESS_IPH
911 912 Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
913
914 if (self->seekable < 0) {
915 self->seekable = (res >= 0);
916 }
917
912 918 if (res < 0) if (res < 0)
913 919 return PyErr_SetFromErrno(PyExc_OSError); return PyErr_SetFromErrno(PyExc_OSError);
914 920
 
... ... _io_FileIO_seek_impl(fileio *self, PyObject *pos, int whence)
943 949 if (self->fd < 0) if (self->fd < 0)
944 950 return err_closed(); return err_closed();
945 951
946 return portable_lseek(self->fd, pos, whence);
952 return portable_lseek(self, pos, whence);
947 953 } }
948 954
949 955 /*[clinic input] /*[clinic input]
 
... ... _io_FileIO_tell_impl(fileio *self)
961 967 if (self->fd < 0) if (self->fd < 0)
962 968 return err_closed(); return err_closed();
963 969
964 return portable_lseek(self->fd, NULL, 1);
970 return portable_lseek(self, NULL, 1);
965 971 } }
966 972
967 973 #ifdef HAVE_FTRUNCATE #ifdef HAVE_FTRUNCATE
 
... ... _io_FileIO_truncate_impl(fileio *self, PyObject *posobj)
992 998
993 999 if (posobj == Py_None || posobj == NULL) { if (posobj == Py_None || posobj == NULL) {
994 1000 /* Get the current position. */ /* Get the current position. */
995 posobj = portable_lseek(fd, NULL, 1);
1001 posobj = portable_lseek(self, NULL, 1);
996 1002 if (posobj == NULL) if (posobj == NULL)
997 1003 return NULL; return NULL;
998 1004 } }
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/benf_wspdigital/cpython

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/benf_wspdigital/cpython

Clone this repository using git:
git clone git://git.rocketgit.com/user/benf_wspdigital/cpython

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main