List of commits:
Subject Hash Author Date (UTC)
bpo-29816: Shift operation now has less opportunity to raise OverflowError. (#680) 918403cfc3304d27e80fb792357f40bb3ba69c4e Serhiy Storchaka 2017-03-30 06:47:07
bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716) 762bf40438a572a398e500c74e38f9894ea20a45 Serhiy Storchaka 2017-03-30 06:15:31
bpo-25996: Added support of file descriptors in os.scandir() on Unix. (#502) ea720fe7e99d68924deab38de955fe97f87e2b29 Serhiy Storchaka 2017-03-30 06:12:31
bpo-24821: Fixed the slowing down to 25 times in the searching of some (#505) 0a58f72762353768c7d26412e627ff196aac6c4e Serhiy Storchaka 2017-03-30 06:11:10
bpo-29878: Add global instances of int for 0 and 1. (#852) ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb Serhiy Storchaka 2017-03-30 06:09:41
Remove an unrequired TODO in test_urllib2. (#897) e6911a44f69c0d302db60f49952a9cf69da69a2b Senthil Kumaran 2017-03-30 06:02:29
bpo-29917: DOC: Remove link from PyMethodDef (#890) c3c7ef088583cc12bd218138036d1edb6de9c63f csabella 2017-03-30 00:27:50
bpo-29677: DOC: clarify documentation for `round` (GH-877) 85deefcf61d3cc192846f41a4ccc6df17da60c98 csabella 2017-03-29 21:14:06
bpo-29932: Fix small error message typos in arraymodule.c (GH-888) a90e64b78d74b80a7cbcca2237280c724b99431b Sylvain 2017-03-29 18:09:22
bpo-29927: Remove duplicate BufferError init and unnecessary semicolons (GH-866) c431854a0963d4ec2875efab2d2425a738895280 Louie Lu 2017-03-29 05:28:15
bpo-29936: fix typo __GNU*C*_MINOR__ (#878) 83371f4f7f70406ea5d08c5fa8dbdbbcc0355ee1 Niklas Fiekas 2017-03-29 04:58:01
bpo-28699: fix abnormal behaviour of pools in multiprocessing.pool (GH-693) 794623bdb232eafd8925f76470209afcdcbcdcd2 Xiang Zhang 2017-03-29 03:58:54
bpo-19791: Use functions from test support to check the symlink support. (GH-822) ec1f5df46ed37aa3e839d20298c4b361a9a74bc4 Vajrasky Kok 2017-03-28 19:32:35
bpo-10379: add 'monetary' to format_string, deprecate format 1cf93a76c2cf307f2e1e514a8944864f746337ea Garvit Khatri 2017-03-28 15:43:38
NEWS: remove duplicated "Build" section (GH-872) c8fa45bac2942accdb24dde318f87c9eb21dbfde INADA Naoki 2017-03-28 15:24:30
bpo-16011 clarify that 'in' always returns a boolean value 0ae7c8bd614d3aa1fcaf2d71a10ff1148c80d9b5 Amit Kumar 2017-03-28 14:13:01
Improve the documentation for template strings (#856) 9f74deba784fc8781d13ed564f69c02ed7c331bb Barry Warsaw 2017-03-28 14:02:07
bpo-29643: Fix check for --enable-optimizations (GH-129) 8cea5929f52801b0ce5928b46ef836e99a24321a Alex Wang 2017-03-28 12:50:51
Drop the standard gcc test build on Travis (GH-853) ad2f9e2c8a0b44b3e6aec9d28ba59e13239236f7 Brett Cannon 2017-03-27 23:39:54
Fix ref cycles in TestCase.assertRaises() (#193) bbd3cf8f1ef1e91a8d6dac6411e18b4b9084abf5 Victor Stinner 2017-03-27 22:56:28
Commit 918403cfc3304d27e80fb792357f40bb3ba69c4e - bpo-29816: Shift operation now has less opportunity to raise OverflowError. (#680)
ValueError always is raised rather than OverflowError for negative counts.
Shifting zero with non-negative count always returns zero.
Author: Serhiy Storchaka
Author date (UTC): 2017-03-30 06:47
Committer name: GitHub
Committer date (UTC): 2017-03-30 06:47
Parent(s): 762bf40438a572a398e500c74e38f9894ea20a45
Signer:
Signing key:
Signing status: N
Tree: 7c8a004d82a24b715b3c3b1f61a474d77c9ef0f7
File Lines added Lines deleted
Lib/test/test_long.py 30 2
Misc/NEWS 4 0
Objects/longobject.c 48 22
File Lib/test/test_long.py changed (mode: 100644) (index fd15f04ace..cc48259e35)
... ... class LongTest(unittest.TestCase):
906 906 self.check_truediv(-x, y) self.check_truediv(-x, y)
907 907 self.check_truediv(-x, -y) self.check_truediv(-x, -y)
908 908
909 def test_negative_shift_count(self):
910 with self.assertRaises(ValueError):
911 42 << -3
912 with self.assertRaises(ValueError):
913 42 << -(1 << 1000)
914 with self.assertRaises(ValueError):
915 42 >> -3
916 with self.assertRaises(ValueError):
917 42 >> -(1 << 1000)
918
909 919 def test_lshift_of_zero(self): def test_lshift_of_zero(self):
910 920 self.assertEqual(0 << 0, 0) self.assertEqual(0 << 0, 0)
911 921 self.assertEqual(0 << 10, 0) self.assertEqual(0 << 10, 0)
912 922 with self.assertRaises(ValueError): with self.assertRaises(ValueError):
913 923 0 << -1 0 << -1
924 self.assertEqual(0 << (1 << 1000), 0)
925 with self.assertRaises(ValueError):
926 0 << -(1 << 1000)
914 927
915 928 @support.cpython_only @support.cpython_only
916 929 def test_huge_lshift_of_zero(self): def test_huge_lshift_of_zero(self):
 
... ... class LongTest(unittest.TestCase):
918 931 # Other implementations may have a different boundary for overflow, # Other implementations may have a different boundary for overflow,
919 932 # or not raise at all. # or not raise at all.
920 933 self.assertEqual(0 << sys.maxsize, 0) self.assertEqual(0 << sys.maxsize, 0)
921 with self.assertRaises(OverflowError):
922 0 << (sys.maxsize + 1)
934 self.assertEqual(0 << (sys.maxsize + 1), 0)
935
936 @support.cpython_only
937 @support.bigmemtest(sys.maxsize + 1000, memuse=2/15 * 2, dry_run=False)
938 def test_huge_lshift(self, size):
939 self.assertEqual(1 << (sys.maxsize + 1000), 1 << 1000 << sys.maxsize)
940
941 def test_huge_rshift(self):
942 self.assertEqual(42 >> (1 << 1000), 0)
943 self.assertEqual((-42) >> (1 << 1000), -1)
944
945 @support.cpython_only
946 @support.bigmemtest(sys.maxsize + 500, memuse=2/15, dry_run=False)
947 def test_huge_rshift_of_huge(self, size):
948 huge = ((1 << 500) + 11) << sys.maxsize
949 self.assertEqual(huge >> (sys.maxsize + 1), (1 << 499) + 5)
950 self.assertEqual(huge >> (sys.maxsize + 1000), 0)
923 951
924 952 def test_small_ints(self): def test_small_ints(self):
925 953 for i in range(-5, 257): for i in range(-5, 257):
File Misc/NEWS changed (mode: 100644) (index b22322f96c..2bea5ec1e3)
... ... What's New in Python 3.7.0 alpha 1?
10 10 Core and Builtins Core and Builtins
11 11 ----------------- -----------------
12 12
13 - bpo-29816: Shift operation now has less opportunity to raise OverflowError.
14 ValueError always is raised rather than OverflowError for negative counts.
15 Shifting zero with non-negative count always returns zero.
16
13 17 - bpo-24821: Fixed the slowing down to 25 times in the searching of some - bpo-24821: Fixed the slowing down to 25 times in the searching of some
14 18 unlucky Unicode characters. unlucky Unicode characters.
15 19
File Objects/longobject.c changed (mode: 100644) (index 459eed9ab0..4862b76da6)
... ... long_bool(PyLongObject *v)
4277 4277 return Py_SIZE(v) != 0; return Py_SIZE(v) != 0;
4278 4278 } }
4279 4279
4280 /* wordshift, remshift = divmod(shiftby, PyLong_SHIFT) */
4281 static int
4282 divmod_shift(PyLongObject *shiftby, Py_ssize_t *wordshift, digit *remshift)
4283 {
4284 assert(PyLong_Check((PyObject *)shiftby));
4285 assert(Py_SIZE(shiftby) >= 0);
4286 Py_ssize_t lshiftby = PyLong_AsSsize_t((PyObject *)shiftby);
4287 if (lshiftby >= 0) {
4288 *wordshift = lshiftby / PyLong_SHIFT;
4289 *remshift = lshiftby % PyLong_SHIFT;
4290 return 0;
4291 }
4292 /* PyLong_Check(shiftby) is true and Py_SIZE(shiftby) >= 0, so it must
4293 be that PyLong_AsSsize_t raised an OverflowError. */
4294 assert(PyErr_ExceptionMatches(PyExc_OverflowError));
4295 PyErr_Clear();
4296 PyLongObject *wordshift_obj = divrem1(shiftby, PyLong_SHIFT, remshift);
4297 if (wordshift_obj == NULL) {
4298 return -1;
4299 }
4300 *wordshift = PyLong_AsSsize_t((PyObject *)wordshift_obj);
4301 Py_DECREF(wordshift_obj);
4302 if (*wordshift >= 0 && *wordshift < PY_SSIZE_T_MAX / (Py_ssize_t)sizeof(digit)) {
4303 return 0;
4304 }
4305 PyErr_Clear();
4306 /* Clip the value. With such large wordshift the right shift
4307 returns 0 and the left shift raises an error in _PyLong_New(). */
4308 *wordshift = PY_SSIZE_T_MAX / sizeof(digit);
4309 *remshift = 0;
4310 return 0;
4311 }
4312
4280 4313 static PyObject * static PyObject *
4281 4314 long_rshift(PyLongObject *a, PyLongObject *b) long_rshift(PyLongObject *a, PyLongObject *b)
4282 4315 { {
4283 4316 PyLongObject *z = NULL; PyLongObject *z = NULL;
4284 Py_ssize_t shiftby, newsize, wordshift, loshift, hishift, i, j;
4285 digit lomask, himask;
4317 Py_ssize_t newsize, wordshift, hishift, i, j;
4318 digit loshift, lomask, himask;
4286 4319
4287 4320 CHECK_BINOP(a, b); CHECK_BINOP(a, b);
4288 4321
4322 if (Py_SIZE(b) < 0) {
4323 PyErr_SetString(PyExc_ValueError,
4324 "negative shift count");
4325 return NULL;
4326 }
4327
4289 4328 if (Py_SIZE(a) < 0) { if (Py_SIZE(a) < 0) {
4290 4329 /* Right shifting negative numbers is harder */ /* Right shifting negative numbers is harder */
4291 4330 PyLongObject *a1, *a2; PyLongObject *a1, *a2;
 
... ... long_rshift(PyLongObject *a, PyLongObject *b)
4300 4339 Py_DECREF(a2); Py_DECREF(a2);
4301 4340 } }
4302 4341 else { else {
4303 shiftby = PyLong_AsSsize_t((PyObject *)b);
4304 if (shiftby == -1L && PyErr_Occurred())
4305 return NULL;
4306 if (shiftby < 0) {
4307 PyErr_SetString(PyExc_ValueError,
4308 "negative shift count");
4342 if (divmod_shift(b, &wordshift, &loshift) < 0)
4309 4343 return NULL; return NULL;
4310 }
4311 wordshift = shiftby / PyLong_SHIFT;
4312 newsize = Py_ABS(Py_SIZE(a)) - wordshift;
4344 newsize = Py_SIZE(a) - wordshift;
4313 4345 if (newsize <= 0) if (newsize <= 0)
4314 4346 return PyLong_FromLong(0); return PyLong_FromLong(0);
4315 loshift = shiftby % PyLong_SHIFT;
4316 4347 hishift = PyLong_SHIFT - loshift; hishift = PyLong_SHIFT - loshift;
4317 4348 lomask = ((digit)1 << hishift) - 1; lomask = ((digit)1 << hishift) - 1;
4318 4349 himask = PyLong_MASK ^ lomask; himask = PyLong_MASK ^ lomask;
 
... ... long_lshift(PyObject *v, PyObject *w)
4336 4367 PyLongObject *a = (PyLongObject*)v; PyLongObject *a = (PyLongObject*)v;
4337 4368 PyLongObject *b = (PyLongObject*)w; PyLongObject *b = (PyLongObject*)w;
4338 4369 PyLongObject *z = NULL; PyLongObject *z = NULL;
4339 Py_ssize_t shiftby, oldsize, newsize, wordshift, remshift, i, j;
4370 Py_ssize_t oldsize, newsize, wordshift, i, j;
4371 digit remshift;
4340 4372 twodigits accum; twodigits accum;
4341 4373
4342 4374 CHECK_BINOP(a, b); CHECK_BINOP(a, b);
4343 4375
4344 shiftby = PyLong_AsSsize_t((PyObject *)b);
4345 if (shiftby == -1L && PyErr_Occurred())
4346 return NULL;
4347 if (shiftby < 0) {
4376 if (Py_SIZE(b) < 0) {
4348 4377 PyErr_SetString(PyExc_ValueError, "negative shift count"); PyErr_SetString(PyExc_ValueError, "negative shift count");
4349 4378 return NULL; return NULL;
4350 4379 } }
4351
4352 4380 if (Py_SIZE(a) == 0) { if (Py_SIZE(a) == 0) {
4353 4381 return PyLong_FromLong(0); return PyLong_FromLong(0);
4354 4382 } }
4355 4383
4356 /* wordshift, remshift = divmod(shiftby, PyLong_SHIFT) */
4357 wordshift = shiftby / PyLong_SHIFT;
4358 remshift = shiftby - wordshift * PyLong_SHIFT;
4359
4384 if (divmod_shift(b, &wordshift, &remshift) < 0)
4385 return NULL;
4360 4386 oldsize = Py_ABS(Py_SIZE(a)); oldsize = Py_ABS(Py_SIZE(a));
4361 4387 newsize = oldsize + wordshift; newsize = oldsize + wordshift;
4362 4388 if (remshift) if (remshift)
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