Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread INADA Naoki
When adding new key, dk_usable is decremented. When removing key, dk_usable is not decremented. So I think dk_usable & ma_used pair can be used to detect dict size modification. On Wed, Dec 14, 2016 at 8:02 AM, Serhiy Storchaka wrote: > On 13.12.16 11:51, Max Moroz wrote:

Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Serhiy Storchaka
On 13.12.16 11:51, Max Moroz wrote: Would it be worth ensuring that an exception is ALWAYS raised if a key is added to or deleted from a dictionary during iteration? Currently, dict.__iter__ only raises "RuntimeError" when "dictionary changed size during iteration". I managed to add 1 key and

Re: [Python-Dev] Implementation difference of audioop.lin2lin in Python2 and Python3

2016-12-13 Thread Martin Panter
On 13 December 2016 at 13:37, MRAB wrote: > On 2016-12-13 11:31, KH Luke Kim wrote: >> >> Hello, >> recently there had been some issues in audioread and librosa that 3-byte >> samples can be loaded in Python 3 but 2. >> >> The documentation says that the

Re: [Python-Dev] Removing memoryview object patch from Python 2.7

2016-12-13 Thread Robert Collins
On 14 December 2016 at 01:26, Sesha Narayanan Subbiah wrote: > Hello > > > I have some implementation that currently uses python 2.6.4, which I m > trying to upgrade to Python 2.7.6. After upgrade, I get the following error: > > > "expected string or Unicode object,

Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Chris Angelico
On Wed, Dec 14, 2016 at 5:13 AM, Joe Jevnik wrote: >> Is it possible to add a key, triggering a resize of the dict, then > remove one, and continue iterating through the old (deallocated) > memory? > > You can add and remove keys between calling next which would resize the

Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Eric V. Smith
> On Dec 13, 2016, at 12:48 PM, Guido van Rossum wrote: > >> On Tue, Dec 13, 2016 at 8:52 AM, Eric V. Smith wrote: >> >> > On Dec 13, 2016, at 11:42 AM, Raymond Hettinger >> > wrote: >> > >> >> On Dec 13, 2016, at 1:51 AM,

Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Chris Angelico
On Wed, Dec 14, 2016 at 4:48 AM, Guido van Rossum wrote: > IIUC the private version gets updated every time the dict gets modified -- > but what we need here should only trigger when a key is added or removed, > not when a value is updated. Is it possible to add a key,

Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Guido van Rossum
On Tue, Dec 13, 2016 at 8:52 AM, Eric V. Smith wrote: > > > On Dec 13, 2016, at 11:42 AM, Raymond Hettinger < > raymond.hettin...@gmail.com> wrote: > > > >> On Dec 13, 2016, at 1:51 AM, Max Moroz wrote: > >> > >> Would it be worth ensuring that an

Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Eric V. Smith
> On Dec 13, 2016, at 11:42 AM, Raymond Hettinger > wrote: > > >> On Dec 13, 2016, at 1:51 AM, Max Moroz wrote: >> >> Would it be worth ensuring that an exception is ALWAYS raised if a key >> is added to or deleted from a dictionary during

Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Raymond Hettinger
> On Dec 13, 2016, at 8:42 AM, Raymond Hettinger > wrote: > >> On Dec 13, 2016, at 1:51 AM, Max Moroz wrote: >> >> Would it be worth ensuring that an exception is ALWAYS raised if a key >> is added to or deleted from a dictionary during

Re: [Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Raymond Hettinger
> On Dec 13, 2016, at 1:51 AM, Max Moroz wrote: > > Would it be worth ensuring that an exception is ALWAYS raised if a key > is added to or deleted from a dictionary during iteration? > > I suspect the cost of a more comprehensive error reporting is not > worth the benefit,

Re: [Python-Dev] Implementation difference of audioop.lin2lin in Python2 and Python3

2016-12-13 Thread MRAB
On 2016-12-13 11:31, KH Luke Kim wrote: Hello, recently there had been some issues in audioread and librosa that 3-byte samples can be loaded in Python 3 but 2. The documentation says that the audioop.lin2lin function in Python 3 support 1-, 2-, 3-, 4-byte samples but only 1-, 2-, 4-byte

[Python-Dev] Implementation difference of audioop.lin2lin in Python2 and Python3

2016-12-13 Thread KH Luke Kim
Hello, recently there had been some issues in audioread and librosa that 3-byte samples can be loaded in Python 3 but 2. The documentation says that the audioop.lin2lin function in Python 3 support 1-, 2-, 3-, 4-byte samples but only 1-, 2-, 4-byte samples in Python 2. I wonder why 3-byte

[Python-Dev] Removing memoryview object patch from Python 2.7

2016-12-13 Thread Sesha Narayanan Subbiah
Hello I have some implementation that currently uses python 2.6.4, which I m trying to upgrade to Python 2.7.6. After upgrade, I get the following error: "expected string or Unicode object, memoryview found" On checking further, I could find that memory view object has been back ported to

[Python-Dev] Removing memoryview object patch from Python 2.7

2016-12-13 Thread Sesha Narayanan Subbiah
Hello I have some implementation that currently uses python 2.6.4, which I m trying to upgrade to Python 2.7.6. After upgrade, I get the following error: "expected string or Unicode object, memoryview found" On checking further, I could find that memory view object has been back ported to

Re: [Python-Dev] Someons's put a "Python 2.8" on GitHub

2016-12-13 Thread Stephen J. Turnbull
Wes Turner writes: > [Continuing to play devil's advocate for the sake of clarification] I will answer briefly here, but for further discussion, I will go to personal mail. (I don't recommend that, I'm really at the limit of things I ever knew well. ;-) > On Mon, Dec 12, 2016 at 2:40 AM,

[Python-Dev] Making sure dictionary adds/deletes during iteration always raise exception

2016-12-13 Thread Max Moroz
Would it be worth ensuring that an exception is ALWAYS raised if a key is added to or deleted from a dictionary during iteration? Currently, dict.__iter__ only raises "RuntimeError" when "dictionary changed size during iteration". I managed to add 1 key and delete 1 key from the dictionary in the

[Python-Dev] Fwd: Removing memoryview object patch from Python 2.7

2016-12-13 Thread Sesha Narayanan Subbiah
-- Forwarded message -- From: Sesha Narayanan Subbiah Date: Tue, Dec 13, 2016 at 1:41 PM Subject: Removing memoryview object patch from Python 2.7 To: python-dev@python.org Hello I have some implementation that currently uses python 2.6.4, which I m

[Python-Dev] Removing memoryview object patch from Python 2.7

2016-12-13 Thread Sesha Narayanan Subbiah
Hello I have some implementation that currently uses python 2.6.4, which I m trying to upgrade to Python 2.7.6. After upgrade, I get the following error: "expected string or Unicode object, memoryview found" On checking further, I could find that memory view object has been back ported to