Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Ian Kelly :

> On Thu, Jul 6, 2017 at 9:41 AM, Marko Rauhamaa  wrote:
>> As a good example of the style I'm looking for, take a look at:
>>
>>https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html>
>
> Java reference types have basically the same concept of identity as
> Python objects, so I dug around to find what definition Java uses.

Good for you!

> [...]
> If that language were used for Python, would it suffice for you?

Unfortunately, the Java definition, which does a good job elsewhere,
fails here. Maybe its suggestive of the difficulty of the topic.

Notice that Scheme refers directory to conventional RAM:

   Variables and objects such as pairs, vectors, and strings implicitly
   denote locations or sequences of locations. A string, for example,
   denotes as many locations as there are characters in the string.
   (These locations need not correspond to a full machine word.) [...]

   http://www.schemers.org/Documents/Standards/R5RS/HTML/r
   5rs-Z-H-6.html#%_sec_3.4>


   The eqv? procedure returns #t if:
   [...]

   * obj1 and obj2 are pairs, vectors, or strings that denote the same
 locations in the store (section 3.4).

   http://www.schemers.org/Documents/Standards/R5RS/HTML/r
   5rs-Z-H-9.html#%_sec_6.1>


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

> ./Include/pyatomic.h:37:5: error: 'atomic_int' does not name a type

I don't understand how you got this error. The line 37 of pyatomic.h is only 
compiled when you build Python itself. At least, since Python 3.5.1 and Python 
3.6.0.

Did you try to build Python? Or did you try to build a C extension?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Privy: An easy, fast lib to password-protect your data

2017-07-06 Thread Rhodri James

On 06/07/17 17:53, ofekmeis...@gmail.com wrote:

Do you better understand what Privy is for now? If so, is there anything in 
particular you think could be made more clear in the docs?



I think the point is that you failed to include any context in your 
advert.  An unadorned link in a post will gather interest only from the 
sort of people who haven't yet collected enough viruses to learn not to 
click on untrusted links.  While these may be the people who need your 
product, they probably won't use it.  The rest of us remain ignorant but 
safe.


Then you went and bumped it, which is just plain rude.

--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Marko Rauhamaa :

> Notice that Scheme refers directory to conventional RAM:
s/directory/directly/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Fri, 7 Jul 2017 01:21 am, Marko Rauhamaa wrote:

> Steve D'Aprano :
> 
>> On Thu, 6 Jul 2017 07:24 pm, Marko Rauhamaa wrote:
>>
>>> While talking about addresses might or might not be constructive, let
>>> me just point out that there is no outwardly visible distinction
>>> between "address" or "identity".
>>
>> Er, yes there is. Address refers to a position in space. Identity
>> refers to the state or quality of being identical (i.e. the same). My
>> identity remains the same as I travel from one address to another.
> 
> That sounds metaphysical.

A concrete example of a person moving from one address to another is about as
far from metaphysical as it is possible to get.

You've done this repeatedly over the years, insisting that Python needs a formal
definition of identity and claiming that the definitions given are circular,
based on what seems to me to be metaphysical and vague criticisms.

In practice, none of your questions about identity seem to make the slightest
bit of difference to Python programming. The Python concept of identity, as
informal as it might be, works, and leads to a consistent and understandable
programming model.

I still don't understand what you get out of this. Will it make you a better
programmer? No. Will it help you understand Python code better? No. Will it
help you predict the result of calling the `is` operator? No, you seem to be
perfectly able to correctly predict the result when required.

So apart from the chance that you're just trolling us for fun, I don't
understand what possible motive you have or why you think this is an important
question.

But on the possibility that you are genuinely interested in the answers, I'll
try to answer your questions below.



> What I'm looking for is snippets of Python code that illustrate the
> difference.

The difference between *what*?

Your statement here is too vague for me to understand, but I'll take a guess:
you want some code demonstrating the difference between address and identity.

Well, for starters, that's a category error: address and identity are not the
same kind of thing, and so cannot be compared directly.

An address is a concrete location or place, in other words a physical position
in some space, while identity is the abstract state or quality of being
identical (sameness), in other words a state of being.

In full generality, I doubt that there is any definition of "identity" which can
be fully satisfactory, but in the context of Python we can be more specific:

Nominally two objects are identical (have the same identity) if they are one and
the same object, and are not identical if they are different objects.

Python doesn't provide any functions for getting the address of objects, in fact
the Python execution model doesn't have a concept of an object's physical
location. But we can model location by considering the index of an object in a
list or array as a kind of address:

a = [1, 2, None]
b = [1, 2, 3, 4, 5, 6, 7, 8, None]
# Address of None, within a
assert a.find(None) == 2
# Address of None, within b
assert b.find(None) == 8

# Are these two references to None references to the same object?
assert a[2] is b[8]


There is no function or operator or statement in Python that returns the
identity of an object. Such a thing cannot exist: identity refers to a state of
being, like "hot" or "cold" or "dead" or "alive", it is not in and of itself a
value that can be returned any more than I can hold "alive" in my hand. It is
an abstractum (an abstract thing):

https://en.wikipedia.org/wiki/Abstract_and_concrete

Treating identity as a thing itself is an example of the fallacy of reification:

https://en.wikipedia.org/wiki/Reification_%28fallacy%29

Hence:

Abstract: identity (of a certain thing, e.g. the identity of a person)

Concrete: a specific thing (e.g. a specific person)

And in the context of Python:

Abstract: object identity

Concrete: this particular object

What Python does provide is a function to compare (nominally) two values and
return True if they refer to the same object in the Python virtual machine,
otherwise return False. Namely the `is` operator.

Abstract: do the two operands have the same identity?

Concrete: are the two operands the same object?


(Note that the Python VM is an abstraction which is emulated by the interpreter.
The Python VM operates in terms of objects, but the interpreter may be written
in a language without objects. Fundamentally computers do nothing but flip
bits, so it is abstractions all the way down. And even flipping bits is an
abstraction.)

Python also provides a function "id()" which returns a ID number that uniquely
distinguishes the object from any other object, providing the two exist at the
same time. The ID number is not the same thing as the object itself, nor is it
the "identity" of the object. It's just a label for the object, one which can
cease to be valid once the object ceases to exist.

You are not your social 

Re: About the implementation of del in Python 3

2017-07-06 Thread Nathan Ernst
In Python, "==" is not a reference equality operator (and I hate Java for
their misuse of the operator), so I absolutely disagree with using the Java
description to describe Python's "==" operator, primarily because, well,
it's wrong. Simple example:

With Python 3.5.2 (should hold for any version 2.4 or greater):
>>> a = 1
>>> b = 1
>>> a == b
True
>>> a is b
True
>>> c = 1000
>>> d = 1000
>>> c == d
True
>>> c is d
False

The "==" operator is testing for equality or equivalence. The "is" operator
is testing for identity. Are these 2 things/names/references the same
*instance*.?  Python internalizes small integers (IIRC, the range [0, 100]
is internalized).  Although integers in Python are immutable, they're not
always the same *instance*.

Hence, identity and equality/equivalence are separate. Identity checking in
Python (or at least CPython) is faster than equivalence (can test the
pointer to the underlying CPython object), but may lead to unexpected
results. One of the reasons you really only see the "is" operator used in
production code is to test against None, because None is a read-only
singleton.

On Thu, Jul 6, 2017 at 11:28 AM, Ian Kelly  wrote:

> On Thu, Jul 6, 2017 at 9:41 AM, Marko Rauhamaa  wrote:
> > As a good example of the style I'm looking for, take a look at:
> >
> >https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html>
>
> Java reference types have basically the same concept of identity as
> Python objects, so I dug around to find what definition Java uses.
> This is what I came up with:
>
> """
> There may be many references to the same object. Most objects have
> state, stored in the fields of objects that are instances of classes
> or in the variables that are the components of an array object. If two
> variables contain references to the same object, the state of the
> object can be modified using one variable's reference to the object,
> and then the altered state can be observed through the reference in
> the other variable.
> """
>
> Also, under the reference equality operator:
>
> """
> At run time, the result of == is true if the operand values are both
> null or both refer to the same object or array; otherwise, the result
> is false.
> The result of != is false if the operand values are both null or both
> refer to the same object or array; otherwise, the result is true.
> """
>
> If that language were used for Python, would it suffice for you?
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30780] IDLE: configdialog - add tests for ConfigDialog GUI.

2017-07-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

PR to fix type in moduleTearDown.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30862] parent logger should also check the level

2017-07-06 Thread Vinay Sajip

Vinay Sajip added the comment:


New changeset 0653fba51c03d20fa4381ba0836acd17fd05b04b by Vinay Sajip in branch 
'master':
bpo-30862: Updated Logger.setLevel documentation. (GH-2604)
https://github.com/python/cpython/commit/0653fba51c03d20fa4381ba0836acd17fd05b04b


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30780] IDLE: configdialog - add tests for ConfigDialog GUI.

2017-07-06 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
pull_requests: +2673

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

See the following commit of bpo-25150:

commit 6df29ada02d22c43a8d439a70b820cb1ceacca42
Author: Victor Stinner 
Date:   Fri Sep 18 15:06:34 2015 +0200

Issue #25150: Hide the private _Py_atomic_xxx symbols from the public
Python.h header to fix a compilation error with OpenMP. PyThreadState_GET()
becomes an alias to PyThreadState_Get() to avoid ABI incompatibilies.

It is important that the _PyThreadState_Current variable is always accessed
with the same implementation of pyatomic.h. Use the PyThreadState_Get()
function so extension modules will all reuse the same implementation.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Chris Angelico :

> On Fri, Jul 7, 2017 at 1:21 AM, Marko Rauhamaa  wrote:
>> What I'm looking for is snippets of Python code that illustrate the
>> difference.
>>
>> That's how you can illustrate the difference between the "==" and "is"
>> operators:
>>
>> >>> ["a"] is ["a"]
>> False
>> >>> ["a"] == ["a"]
>> True
>
> When you have an address, you can use that to locate the thing.

You are pulling that out of your hat (or a dictionary). Python doesn't
define the concept at all (yet it manages to locate every useful thing
there is).

> In C, that's pointer dereferencing. If I give you the id of a Python
> object, can you locate that object and find out something about it? If
> you can't, it's not an address.
>
> And you have to make this work in Python (the language), not just
> CPython (the interpreter). I'll consider an answer satisfactory if it
> runs on the Big Four - CPython, Jython, IronPython, and PyPy - and
> mainly, you need to show that it works in Jython, because that's the
> most different.

I don't follow you. A code example, please.

>> Unfortunately, when I try it, I get:
>>
>> >>> a is a
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> NameError: name 'a' is not defined
>
> And oh how terrible, Python doesn't define any other operators on
> unassigned names either. The 'is' operator is looking at OBJECT
> identity, so you need to have an OBJECT. If you don't understand that
> part of Python's object model, I recommend learning from Ned
> Batchelder:

It's enough to point to the Language Reference if you have a link.

>>> First part is implied by Python's execution model,
>>
>> [Citation needed]
>
> https://docs.python.org/3/reference/executionmodel.html

Sorry, which sentence?

>>> and the second by the definition of the `is` operator.
>>
>> [Citation needed]
>
> https://docs.python.org/3/reference/expressions.html#is-not

That one in its entirety:

   The operators "is" and "is not" test for object identity: x is y is
   true if and only if x and y are the same object. Object identity is
   determined using the id() function. x is not y yields the inverse
   truth value.

That simply defines the identity with whatever is returned by the id()
function. The id() function, in turn, is defined to be:

   Return the “identity” of an object. This is an integer which is
   guaranteed to be unique and constant for this object during its
   lifetime. Two objects with non-overlapping lifetimes may have the
   same id() value.

which doesn't clarify anything.

> Just don't try explaining to a novice programmer that way. It's a
> waste of everyone's time.

I believe the concept of an object is among the more difficult things
for novice programmers to get.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 3:05 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>
>> On Fri, Jul 7, 2017 at 1:21 AM, Marko Rauhamaa  wrote:
>>> What I'm looking for is snippets of Python code that illustrate the
>>> difference.
>>>
>>> That's how you can illustrate the difference between the "==" and "is"
>>> operators:
>>>
>>> >>> ["a"] is ["a"]
>>> False
>>> >>> ["a"] == ["a"]
>>> True
>>
>> When you have an address, you can use that to locate the thing.
>
> You are pulling that out of your hat (or a dictionary). Python doesn't
> define the concept at all (yet it manages to locate every useful thing
> there is).

That's right. Python does not use the term "address" as part of its
object model. So when you ask me to define it, all I can do is look
outside of Python.

There might be a reason for this. Like, maybe, that Python doesn't use
addresses in its object model.

>> In C, that's pointer dereferencing. If I give you the id of a Python
>> object, can you locate that object and find out something about it? If
>> you can't, it's not an address.
>>
>> And you have to make this work in Python (the language), not just
>> CPython (the interpreter). I'll consider an answer satisfactory if it
>> runs on the Big Four - CPython, Jython, IronPython, and PyPy - and
>> mainly, you need to show that it works in Jython, because that's the
>> most different.
>
> I don't follow you. A code example, please.

If I have the address of something in C, I can dereference that and
get at the data therein. Can you do that in Python? If you want to
claim that object identity is a form of address, you should be able to
show that it can be used as one.

 First part is implied by Python's execution model,
>>>
>>> [Citation needed]
>>
>> https://docs.python.org/3/reference/executionmodel.html
>
> Sorry, which sentence?

I think you're probably missing some fundamentals of how Python works,
so have a read of the whole page.

>> https://docs.python.org/3/reference/expressions.html#is-not
>
> That one in its entirety:
>
>The operators "is" and "is not" test for object identity: x is y is
>true if and only if x and y are the same object. Object identity is
>determined using the id() function. x is not y yields the inverse
>truth value.
>
> That simply defines the identity with whatever is returned by the id()
> function.

No; it defines object identity as "are the same object", relying on
our external comprehension of identity. It then says that you can
coalesce the identity to an integer using the id() function.

> The id() function, in turn, is defined to be:
>
>Return the “identity” of an object. This is an integer which is
>guaranteed to be unique and constant for this object during its
>lifetime. Two objects with non-overlapping lifetimes may have the
>same id() value.
>
> which doesn't clarify anything.

If you start with object identity, the id() function makes sense given
the above definition. You cannot, however, use the id() function to
define object identity, since id values can be reused.

>> Just don't try explaining to a novice programmer that way. It's a
>> waste of everyone's time.
>
> I believe the concept of an object is among the more difficult things
> for novice programmers to get.

Maybe, for certain technical definitions of "object" (eg in Python,
everything is an object, but in JavaScript, an object is a mapping
type, as distinct from an array, except that an array is an object
too, and... yeah); but the concept of a "thing" is fairly well
understood. I have explained Python's object model to people using
physical things on my desk, and never had anyone go "but what's the
address of that thing". People grok Python's objects just fine when
you relate them to real-world objects. I can explain merge sort using
a deck of cards and my desk, I can explain the stack using the same
tools, and I can even explain stuff using vanilla-flavoured sugar -
because Python parallels our world beautifully.

(So do many other languages. I've explained JS to people the same way.
And I've never explained JS by starting with C.)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27584] New addition of vSockets to the python socket module

2017-07-06 Thread Cathy Avery

Cathy Avery added the comment:

So I revised my code based on the reviews and I passed all the checks ... now 
what?

Thanks,

Cathy

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26506] [EASY] hex() documentation: mention "%x" % int

2017-07-06 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:


New changeset 67ba4fa467825d6a0c0a21cc54ff1df2ed1b by Mariatta (Manvisha 
Kodali) in branch 'master':
bpo-26506: hex() documentation: mention %x % int (GH-2525)
https://github.com/python/cpython/commit/67ba4fa467825d6a0c0a21cc54ff1df2ed1b


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30779] IDLE: configdialog -- factor out Changes class

2017-07-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I am working on this now.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

Oh, wait, I read your message backward. You said that the fix doesn't work?

Hum, how can I reproduce the issue? What is your use case?

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30862] parent logger should also check the level

2017-07-06 Thread Vinay Sajip

Changes by Vinay Sajip :


--
pull_requests: +2672

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Terry Reedy

On 7/6/2017 11:41 AM, Marko Rauhamaa wrote:

Chris Angelico :


The formal definition is that objects have identities, and that
assignment (including function parameters and return values) gives you
a reference to the same object.


My example didn't contain a single assignment, but a variation of your
statement would make a good part in a definition of identity.


"A person just walked into the revolving door and came back out
again." "Is it the same person?" "I don't know. What's the definition
of identity?"

Of course it's the same person. You don't need to identify that person
by a social security number in order to say "the SAME PERSON came back
out". You identify him/her by... identity.


Here's how identity is dealt with in First-Order Logic:

https://en.wikipedia.org/wiki/First-order_logic#Semantics>

In other words, identity is mapped to the "sameness" in a domain of
discourse.

In Second-Order Logic, you can define identity directly:

 ∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y))


Programming languages are different beasts, of course, but "objects" and
"identity" are such important foundational topics that you'd expect a
bit more than hand-waving when defining the data model.

As a good example of the style I'm looking for, take a look at:

https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html>


Marko




--
Terry Jan Reedy


--
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Terry Reedy
Sorry, finger twitch.  Wish there were a minute grace period to recall 
such mistakes.


On 7/6/2017 2:16 PM, Terry Reedy wrote:


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


[issue30532] email.policy.SMTP.fold() mangles long headers

2017-07-06 Thread R. David Murray

R. David Murray added the comment:

Thanks, Joel!

--
resolution:  -> fixed
stage: backport needed -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30532] email.policy.SMTP.fold() mangles long headers

2017-07-06 Thread R. David Murray

R. David Murray added the comment:


New changeset 3bbdf990a2c1b0b303b950058e3177a1bd5f697a by R. David Murray (Joel 
Hillacre) in branch '3.5':
bpo-30532: Fix whitespace folding in certain cases (#2592)
https://github.com/python/cpython/commit/3bbdf990a2c1b0b303b950058e3177a1bd5f697a


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread Melroy van den Berg

Melroy van den Berg added the comment:

Yea I'm building Python 3.6.1 from source, using gcc and 
--with-cxx-main=correct/location/to/g++ flag. So the warning message appears 
during ./configure about that it can't find g++.

I didn't try to patch it using the attachments of this issue. Since I was 
hoping it's fixed in the release itself. I was using gcc/g++ version 4.9.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30819] Linking with 'ld -b' fails with 64-bit using Itanium HP compiler

2017-07-06 Thread Robert Boehne

Changes by Robert Boehne :


--
nosy: +haypo

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30861] StreamReader does not return reamaing and ready data buffer before raise the Exeption

2017-07-06 Thread pfreixes

pfreixes added the comment:

As was said, the assumption here is the data that came to the buffer must be 
available.

For example, the next snippet shows a Redis client that expects the data 
message plus the RST packet, where the redis-server was configured to accept 
max N connections, the connection used by this snippet was the N+1

import socket
import time

s = socket.socket(
socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost", 6379))

# give enought time to get the
# data plus the RST Package
time.sleep(1)

# read the data
print(s.recv(100))

It works like a charm.

IMHO this is not a matter of RST vs close graceful, its a matter of giving 
always the chance to the developer to read the data that is still remaining and 
ready into the buffer.

The current implementation is in somehow not predictable. Different network 
latencies with the same scenario can produce different outputs and the same 
with how the read of the Streamer is handled by the developer.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30532] email.policy.SMTP.fold() mangles long headers

2017-07-06 Thread R. David Murray

R. David Murray added the comment:


New changeset c60d2f5e8609b040ab58c498fde23928fe9dbef5 by R. David Murray (Joel 
Hillacre) in branch '3.6':
bpo-30532: Fix whitespace folding in certain cases (#2591)
https://github.com/python/cpython/commit/c60d2f5e8609b040ab58c498fde23928fe9dbef5


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 7:10 AM, Marko Rauhamaa  wrote:
> Steve D'Aprano :
>
>> An address is a concrete location or place, in other words a physical
>> position in some space, while identity is the abstract state or
>> quality of being identical (sameness), in other words a state of
>> being.
>
> Whether id() returns one such thing or not can't be discerned by a
> Python program. What's more, for any compliant implementation of id(),
> you can interpret the returned number as an address in some address
> space (whether it's useful or not to interpret it that way).

And I can interpret "Marko Rauhamaa" as a MIME-encoded IPv6 address.
Does that mean it is one?

31:aae4::45ab:a16a:669a

This is clearly your identity, and your address.

>> In full generality, I doubt that there is any definition of "identity"
>> which can be fully satisfactory, but in the context of Python we can
>> be more specific:
>>
>> Nominally two objects are identical (have the same identity) if they
>> are one and the same object, and are not identical if they are
>> different objects.
>
> I believe identity can be defined much better, in numerous isomorphic
> ways in fact.
>
> For example, we could equate each object with a sequence number
> (unrelated with its id()). You can define that the "None" object is in
> fact the natural number 0. The "False" object is in fact the natural
> number 1 etc for all the primordial objects. During the execution of the
> program, new objects are created, which simply associates
> characteristics to ever higher natural numbers.

That's pretty much how Jython assigns IDs. However, it does not assign
them when objects are created, but when they're first passed to id().

>>> lists = [[], [], [], [], []]
>>> lists[0] is lists[1]
False
>>> id(lists[0])
2
>>> id(lists[4])
3
>>> id(lists[2])
4
>>> id(lists[0])
2
>>> id(lists[1])
5

In the Jython world, the ID of an object is an attribute of it.
Objects can have identity (and be tested for identity with 'is')
without having IDs. So identity is not defined in terms of ID, but ID
in terms of identity.

>> Why do you have to generalise it? The name "a" here stands in for any
>> reference to any object.
>
> "Any reference to any object" is difficult to define syntactically as
> the reference itself might perform some dunder magic.

A simple name lookup cannot, I believe, be messed with. Nor can a literal.

> For example, you can't say that necessarily
>
>x.y is x.y

No, that's right, any more than you would expect

[] is []

to be true. These are expressions that (can potentially) construct new
objects. But if you can show me a situation in which "a is a" is
False, I would be very surprised.

> No, just trying to emphasize the difference between syntax and semantics.
>
>"a is a"
>
> is a specific, legal statement in Python.

And it means "the object bound to the name 'a' is the same as the
object bound to the name 'a'". If there's no such object, it's not the
same as itself, in the same way that float("nan") is not equal to
itself - in each case, there is no "itself" (with floats, that's a
matter of value, rather than identity, but the same concept applies).

> We could generalize and say (wrongly) that
>
>"X is X"
>
> where X stands for any legal Python expression, is always true. However,
> X might be undefined or produce side effects.

You can always overgeneralize. So? I could generalize and say that "a
is a" is a specific, legal statement in APL, since it's valid and
meaningful in Python. Doesn't really mean much.

>> "x is y is true if and only if x and y are the same object."
>
> I suppose what is meant is the above:
>
>∀X ∈ Σ ∀Y ∈ Σ Φ(concat(X, "is", Y)) = 1 ↔ Φ(X) ≡ Φ(Y)

 yeah I think I prefer the version in the docs. It's pretty clear
what it means. I've no idea what you're saying here with all that
concatenation and stuff, but the truth is way simpler. If the two
sides are the same object, 'is' returns true. Seriously, what's not
clear?

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30860] Consolidate stateful C globals under a single struct.

2017-07-06 Thread Antoine Pitrou

Antoine Pitrou added the comment:

After looking at the PR, I'm a bit skeptical about this.  Suddenly a lot of 
things which are implementation details get moved to the public include files, 
which makes things more confusing from my POV.  I also don't know why all 
globals should be consolidated in a single place (it is not a widespread policy 
in other projects AFAIK, but I may be mistaken).

Perhaps it would be more reasonable to consolidate the globals in each .c file 
independently, without trying to join all of them together in one place nor 
expose them in the public include files.

--
nosy: +pitrou

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Steve D'Aprano :

> An address is a concrete location or place, in other words a physical
> position in some space, while identity is the abstract state or
> quality of being identical (sameness), in other words a state of
> being.

Whether id() returns one such thing or not can't be discerned by a
Python program. What's more, for any compliant implementation of id(),
you can interpret the returned number as an address in some address
space (whether it's useful or not to interpret it that way).

> In full generality, I doubt that there is any definition of "identity"
> which can be fully satisfactory, but in the context of Python we can
> be more specific:
>
> Nominally two objects are identical (have the same identity) if they
> are one and the same object, and are not identical if they are
> different objects.

I believe identity can be defined much better, in numerous isomorphic
ways in fact.

For example, we could equate each object with a sequence number
(unrelated with its id()). You can define that the "None" object is in
fact the natural number 0. The "False" object is in fact the natural
number 1 etc for all the primordial objects. During the execution of the
program, new objects are created, which simply associates
characteristics to ever higher natural numbers.

That kind of mathematical treatment would be precise, but alas, hardly
very helpful for beginning programmers.

That's why I proposed the Puppy Data Model for Python months back. It
involved puppies, leashes and pegs.

>> In fact,
>> 
>> a is a
>> 
>> would be a *great* start for a formal definition/requirement of the "is"
>> operator, although you'd have to generalize it to
>> 
>> b is b
>> c is c
>> 
>> etc as well.
>
> Why do you have to generalise it? The name "a" here stands in for any
> reference to any object.

"Any reference to any object" is difficult to define syntactically as
the reference itself might perform some dunder magic.

For example, you can't say that necessarily

   x.y is x.y

>> Unfortunately, when I try it, I get: 
>> 
>> >>> a is a
>> Traceback (most recent call last):
>>   File "", line 1, in 
>> NameError: name 'a' is not defined
>
> Now you're just trolling.

No, just trying to emphasize the difference between syntax and semantics.

   "a is a"

is a specific, legal statement in Python.

We could generalize and say (wrongly) that

   "X is X"

where X stands for any legal Python expression, is always true. However,
X might be undefined or produce side effects.

Or maybe you want to say:

   ∀X ∈ Σ ∀Y ∈ Σ Φ(concat(X, "is", Y)) = 1 ↔ Φ(X) ≡ Φ(Y)

where Σ is the set of legal Python expressions. That would reduce the
problem to defining the interpretation function Φ. That's probably
necessary anyway.

>>> and the second by the definition of the `is` operator.
>> 
>> [Citation needed]
>
> Now you're taking the piss. Do I have to look everything up for you?
>
> https://docs.python.org/3/reference/expressions.html#is
>
> "x is y is true if and only if x and y are the same object."

I suppose what is meant is the above:

   ∀X ∈ Σ ∀Y ∈ Σ Φ(concat(X, "is", Y)) = 1 ↔ Φ(X) ≡ Φ(Y)


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30183] [HPUX] compilation error in pytime.c with cc compiler

2017-07-06 Thread Robert Boehne

Changes by Robert Boehne :


--
pull_requests: +2674

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30861] StreamReader does not return reamaing and ready data buffer before raise the Exeption

2017-07-06 Thread Guido van Rossum

Guido van Rossum added the comment:

We seem to have a failure to communicate. I'm sure your example code "works", 
but you're not showing what's in the data it receives that is important for the 
app to read (your example just prints it).

And surely your app should be robust even if the connection is closed *without* 
ever receiving that data (since it may be lost in transit).

If you need an application-level error your design should include it in the 
protocol, not use the connection closing.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

I don't think that CPython can be built by g++. If you consider that it
should, please open a new issue since it's a different use case.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27268] Incorrect error message on float('')

2017-07-06 Thread Wolfgang Maier

Wolfgang Maier added the comment:

Could somebody turn this into a PR to move things forward?

I guess Nofar mistakenly set resolution to "works for me", but meant "patch 
works for me"?

--
nosy: +wolma

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



About the implementation of del in Python 3

2017-07-06 Thread Dan Wissme
I thought that del L[i] would slide L[i+1:] one place to the left, 
filling the hole, but :


>>> L
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
>>> id(L)
4321967496
>>> id(L[5])# address of 50 ?
4297625504
>>> del L[2]
>>> id(L[4]) # new address of 50 ?
4297625504
>>> id(L)
4321967496

So the element 50 is still at the same memory location.
What del L[i] do exactly, and what is its complexity ? O(1) or O(n) ?
Thanks,

   dan
--
https://mail.python.org/mailman/listinfo/python-list


[issue30863] Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString()

2017-07-06 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Since Python 3.3 PyUnicode_AsUnicodeAndSize() is deprecated in favour of 
PyUnicode_AsWideChar() and PyUnicode_AsWideCharString(). But the latter two are 
implemented using PyUnicode_AsUnicodeAndSize(). This prevents adding the 
deprecation compiler warning for PyUnicode_AsUnicodeAndSize(). Other side 
effect -- PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() cache the 
wchar_t* representation of the PyUnicode object increasing its memory 
consumption.

Proposed patch reimplements PyUnicode_AsWideChar(), 
PyUnicode_AsWideCharString() and PyUnicode_AsUnicodeAndSize() using two common 
helper functions. PyUnicode_AsWideChar() and PyUnicode_AsWideCharString() no 
longer cache the wchar_t* representation.

--
components: Interpreter Core, Unicode
messages: 297813
nosy: ezio.melotti, haypo, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString()
type: resource usage
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Thu, Jul 6, 2017 at 5:35 PM, Jussi Piitulainen
 wrote:
> Incidentally, let no one point out that ids are not memory addresses.
> It says in the interactive help that they are (Python 3.4.0):
>
> Help on built-in function id in module builtins:
>
> id(...)
> id(object) -> integer
>
> Return the identity of an object. This is guaranteed to be unique
> among simultaneously existing objects. (Hint: it's the object's
> memory address.)

Sorry, not the case.


Help on built-in function id in module builtins:

>>> help(id)
id(obj, /)
Return the identity of an object.

This is guaranteed to be unique among simultaneously existing objects.
(CPython uses the object's memory address.)

>>> help(id)
Help on built-in function id in module __builtin__:

id(...)

 help(id)
Help on built-in function id in module __builtin__:

id(...)
Return the identity of an object: id(x) == id(y) if and only if x is y.


The interactive help does not say that in any version newer than the
3.4 that you tested. The function does not return an address, it
returns an identity.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Terry Reedy

On 7/6/2017 3:08 AM, Dan Wissme wrote:
I thought that del L[i] would slide L[i+1:] one place to the left, 
filling the hole, but :


 >>> L
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
 >>> id(L)
4321967496
 >>> id(L[5])# address of 50 ?
4297625504
 >>> del L[2]
 >>> id(L[4]) # new address of 50 ?
4297625504
 >>> id(L)
4321967496



So the element 50 is still at the same memory location.
What del L[i] do exactly, and what is its complexity ? O(1) or O(n) ?


A list is an array of references to objects that exist outside of the 
list.  Del deleted a reference, not any of the objects.


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
Dan Wissme writes:

> I thought that del L[i] would slide L[i+1:] one place to the left,
> filling the hole, but :
>
 L
> [0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
 id(L)
> 4321967496
 id(L[5])# address of 50 ?
> 4297625504
 del L[2]
 id(L[4]) # new address of 50 ?
> 4297625504
 id(L)
> 4321967496
>
> So the element 50 is still at the same memory location.
> What del L[i] do exactly, and what is its complexity ? O(1) or O(n) ?

id identifies the object that is stored at that index, not the location.
Locations are not objects.

Consider [L[5], L[5]] where the same object is stored in two different
places. In the implementation level there is some kind of reference in
the internal representation of the list to the representation of the
object somewhere else in memory. In the language level, the object
simply is stored in two places, and that's nothing unusual. Storing or
fetching or passing or returning objects around does not make copies.

Incidentally, let no one point out that ids are not memory addresses.
It says in the interactive help that they are (Python 3.4.0):

Help on built-in function id in module builtins:

id(...)
id(object) -> integer

Return the identity of an object. This is guaranteed to be unique
among simultaneously existing objects. (Hint: it's the object's
memory address.)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30863] Rewrite PyUnicode_AsWideChar() and PyUnicode_AsWideCharString()

2017-07-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +2667

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30861] StreamReader does not return reamaing and ready data buffer before raise the Exeption

2017-07-06 Thread Dima Tisnek

Dima Tisnek added the comment:

My 2c:

Pau's concern seems valid, in a sense that stream should work like TCP.
That's what most users would assume -- read out data until the end, only then 
you can see what the actual error was (socket closed, or timeout or hard error)

However, I suspect the devil may be in details -- the patch appears to assume 
that exception is only set by the underlying source of data (in which case user 
wants to read out everything up to the exception).

I can imagine a couple of use-case where an exception is set "out of band":
* to terminate bad reader (e.g. against Slowris attack)
* there's a matching StreamWriter (e.g. shared socket)

P.S.
If I'm wrong here, then bug report and patch must be clearer :)

--
nosy: +Dima.Tisnek

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Privy: An easy, fast lib to password-protect your data

2017-07-06 Thread ofekmeister
> The person spamming right now would be you. You just posted a link,
> without any explanations, any marketing blurbs, nothing.

I've explained everything as succinctly as I can in the readme. Pasting bits of 
it here would not benefit anyone.

> Why would I use your tool instead of something established, that has
> been properly audited — say, PGP for example?

Did you read the page? PGP and Privy are used for different things. A key 
manager could, though, use Privy to store private keys.

> How do I know your one-man project has no security holes, backdoors,
> or other vulnerabilities? How do I know that the encryption method
> chosen by you is sound? If there is no leaked data?

Privy is a thin wrapper around Cryptography's (OpenSSL) Fernet interface 
https://github.com/pyca/cryptography/blob/master/src/cryptography/fernet.py and 
https://github.com/hynek/argon2_cffi which is simply a binding to 
https://github.com/p-h-c/phc-winner-argon2

Privy itself is really just 40 SLOC 
https://github.com/ofek/privy/blob/a3d4bdb24464ad85606c1ab5e78c58ae489b0569/privy/core.py#L42-L82

> And I really dislike the description of your project ...
> What does “password-protecting” mean? Why is this not “encrypting”?

This is encryption, but specifically by means of a password. This paradigm is 
often tricky to get correct. 
https://security.stackexchange.com/questions/88984/encrypting-with-passwords-encryption-of-key-vs-data

> How do you expect this to work with API keys?

Encrypted keys would likely be stored in a DB somehow. Check out 
https://github.com/fugue/credstash
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30862] parent logger should also check the level

2017-07-06 Thread Vinay Sajip

Vinay Sajip added the comment:

As RDM says, this behaviour is as designed. The logger's setLevel documentation 
says:

"Sets the threshold for this logger to lvl. Logging messages which are less 
severe than lvl will be ignored. When a logger is created, the level is set to 
NOTSET (which causes all messages to be processed when the logger is the root 
logger, or delegation to the parent when the logger is a non-root logger). Note 
that the root logger is created with level WARNING.

The term ‘delegation to the parent’ means that if a logger has a level of 
NOTSET, its chain of ancestor loggers is traversed until either an ancestor 
with a level other than NOTSET is found, or the root is reached.

If an ancestor is found with a level other than NOTSET, then that ancestor’s 
level is treated as the effective level of the logger where the ancestor search 
began, and is used to determine how a logging event is handled.

If the root is reached, and it has a level of NOTSET, then all messages will be 
processed. Otherwise, the root’s level will be used as the effective level."

Not sure how I can improve upon that, as it seems clear enough, but any 
suggestions are welcome.

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30855] [3.5] test_tk: test_use() of test_tkinter.test_widgets randomly fails with "integer value too large to represent" on with AMD64 Windows8 3.5

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:


New changeset f6d6480b93eca6f353784579108957108750c004 by Victor Stinner in 
branch '2.7':
[2.7] bpo-30855: Trying to fix test_use on Windows. (#2586)
https://github.com/python/cpython/commit/f6d6480b93eca6f353784579108957108750c004


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30847] asyncio: selector_events: add_urgent() for urgent data to read, 3rd argument of select.select()

2017-07-06 Thread Pim Klanke

Pim Klanke added the comment:

This is in fact the third catagory of select(), "exceptional conditions", but 
because some find the term "exceptional" confusing when used in a Python 
module, we decided to use the term "urgent data", borrowed from the poll(2) man 
page. (see bpo-30844)

An example of an exceptional conditions event is "out of band", another one is 
edge detection from GPIO Sysfs Interface.

The patch for fulfilling this issue can and will be supplied if and when 
bpo-30844 is merged. 30844 originally also contained the patch to asyncio, but 
I was asked to split it into two separate patches.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30799] Improved test coverage Lib/_osx_support.py 99%

2017-07-06 Thread chexex

New submission from chexex:

I will appreciate any feedback.

--
nosy: +ned.deily, ronaldoussoren

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30862] parent logger should also check the level

2017-07-06 Thread TaoQingyun

TaoQingyun added the comment:

yes, I understand the effective level. my question is that before call 
ancestor's handler, should also check `c.isEnabledFor(record.levelno)`

```
def callHandlers(self, record):
"""
Pass a record to all relevant handlers.

Loop through all handlers for this logger and its parents in the
logger hierarchy. If no handler was found, output a one-off error
message to sys.stderr. Stop searching up the hierarchy whenever a
logger with the "propagate" attribute set to zero is found - that
will be the last logger whose handlers are called.
"""
c = self 
found = 0
while c:
for hdlr in c.handlers:
found = found + 1
if record.levelno >= hdlr.level:
hdlr.handle(record)
if not c.propagate:
c = None#break out
else:
c = c.parent
...
```

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30865] python cannot import module located on a "VOLUME" directory

2017-07-06 Thread Adrien Pré

New submission from Adrien Pré:

This issue created on python-docker project 
https://github.com/docker-library/python/issues/210 indicates that python 
cannot import a module if it is located on a docker-volume.

yosifkit's comment suggest there is an issue in the UNC resolution with paths 
starting with `\\?\` 

Thesre is probably a fix to do in Lib\ntpath.py, however I am not sure how to 
fix that.

Steps to reproduce the issues are here: 
https://github.com/apre/windows-volume-issue

--
components: Library (Lib)
messages: 297820
nosy: Adrien Pré
priority: normal
severity: normal
status: open
title: python cannot import module located on a "VOLUME" directory
type: behavior
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30866] Add _testcapi.stack_pointer() to measure the C stack consumption

2017-07-06 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +2670

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30866] Add _testcapi.stack_pointer() to measure the C stack consumption

2017-07-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Usually we first merge a patch in master and after that cherry-pick it to other 
branches.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30867] Add necessary macro `HAVE_OPENSSL_VERIFY_PARAM` to avoid invalid declaration

2017-07-06 Thread signal1587

New submission from signal1587:

Compile Python (2.7.13) on platform which has OpenSSL (<0.9.8) will met error:

  /opt/Python-2.7.13/Modules/_ssl.c:177: error: syntax error before ‘*’ token

Since return type `X509_VERIFY_PARAM` got added to OpenSSL in version 0.9.8.

Surround the implementation of function `X509_STORE_get0_param` in (#ifdef 
HAVE_OPENSSL_VERIFY_PARAM ... #endif) guarantee to solve this problem.

--
assignee: christian.heimes
components: SSL
files: _ssl.patch
keywords: patch
messages: 297825
nosy: christian.heimes, signal1587
priority: normal
severity: normal
status: open
title: Add necessary macro `HAVE_OPENSSL_VERIFY_PARAM` to avoid invalid 
declaration
type: compile error
versions: Python 2.7
Added file: http://bugs.python.org/file46993/_ssl.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30319] Change socket.close() to ignore ECONNRESET

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

Thanks Martin for the long explanation. To simplify a lot, there is
and was never any warranty that a successful sock.send() call
delivered data to the peer. Each layer does its best, but the data can
be lost at any layer, and the peer is free to close the connection
*before* getting the data. Yeah, I agree that application level
signaling is required.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30855] [3.5] test_tk: test_use() of test_tkinter.test_widgets randomly fails with "integer value too large to represent" on with AMD64 Windows8 3.5

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

I backported fixes to 2.7 and 3.5 branches. The test fails randomly, so I close 
the issue and hope that it doesn't come back.

If it comes back on 3.5, we should now get the identifier which caused the 
failure. I will reopen the issue if the bug occurs again.

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30866] Add _testcapi.stack_pointer() to measure the C stack consumption

2017-07-06 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +2669

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Dan Wissme

Le 06/07/2017 à 09:29, Terry Reedy a écrit :

On 7/6/2017 3:08 AM, Dan Wissme wrote:

I thought that del L[i] would slide L[i+1:] one place to the left,
filling the hole, but :

 >>> L
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
 >>> id(L)
4321967496
 >>> id(L[5])# address of 50 ?
4297625504
 >>> del L[2]
 >>> id(L[4]) # new address of 50 ?
4297625504
 >>> id(L)
4321967496



So the element 50 is still at the same memory location.
What del L[i] do exactly, and what is its complexity ? O(1) or O(n) ?


A list is an array of references to objects that exist outside of the
list.  Del deleted a reference, not any of the objects.


So what 'del L[i]' do exactly in memory ? Same as L.pop(i) ? with 
complexity O(n-i) ?


 dan



--
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Chris Angelico :

> On Thu, Jul 6, 2017 at 5:35 PM, Jussi Piitulainen
>  wrote:
>> Incidentally, let no one point out that ids are not memory addresses.
>> It says in the interactive help that they are (Python 3.4.0):
>> [...]
>
> Sorry, not the case.
> [...]
>
> id(...)
> Return the identity of an object: id(x) == id(y) if and only if x is y.
>
>
> The interactive help does not say that in any version newer than the
> 3.4 that you tested. The function does not return an address, it
> returns an identity.

While talking about addresses might or might not be constructive, let me
just point out that there is no outwardly visible distinction between
"address" or "identity".

Equally well, we could replace those words with:

   serial number

   fixed asset tag

   social security number

   fermionic quantum state

   face

   fingerprint

   cryptographic hash


Ignoring the word that is used to talk about object identity, it would
be nice to have a precise formal definition for it. For example, I know
that any sound implementation of Python would guarantee:

>>> def f(a): return a
...
>>> a = object()
>>> a is f(a)
True

But how do I know it?


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30866] Add _testcapi.stack_pointer() to measure the C stack consumption

2017-07-06 Thread STINNER Victor

New submission from STINNER Victor:

In issues bpo-28870, bpo-29227, bpo-29233 and bpo-29234, I worked on reducing 
the C stack consumption. I now would to add the _testcapi.stack_pointer() that 
I used to be able to easily measure the stack consumption.

Try for example attached stack_overflow-3.py to measure the maximum number of C 
calls before a C stack overflow. The script also computes the average stack 
usage per C call for a specific kind of C call.

--
files: stack_overflow-3.py
messages: 297822
nosy: haypo, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Add _testcapi.stack_pointer() to measure the C stack consumption
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file46992/stack_overflow-3.py

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30866] Add _testcapi.stack_pointer() to measure the C stack consumption

2017-07-06 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +2668

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30865] python cannot import module located on a "VOLUME" directory

2017-07-06 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30864] Compile failure for linux socket CAN support

2017-07-06 Thread Riccardo Magliocchetti

New submission from Riccardo Magliocchetti:

I have an issue related to this while trying to compile statically Python 3.6.1 
(but latest master looks the same) against a static musl.

The problem is that i have AF_CAN defined because it's defined in 
linux/socket.h but by not having HAVE_LINUX_CAN_H defined in pyconfig.h the 
header which contains the definition of struct sockaddr_can is not included. I 
think (at least for linux) using AF_CAN for the conditionals is wrong and the 
HAVE_LINUX_CAN_H should be used instead.

I think the same applies for CAN_RAW and CAN_BCM because they are defined in 
the generic linux/can.h and not in a feature specific header.


Reference:
http://bugs.python.org/issue10141

--
components: IO
messages: 297816
nosy: Riccardo Magliocchetti
priority: normal
severity: normal
status: open
title: Compile failure for linux socket CAN support
versions: Python 3.6

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30847] asyncio: selector_events: add_urgent() for urgent data to read, 3rd argument of select.select()

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

Ok, it makes sense. Thanks :-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30847] asyncio: selector_events: add_urgent() for urgent data to read, 3rd argument of select.select()

2017-07-06 Thread Pim Klanke

Pim Klanke added the comment:

> "Let's say that we got read event on sockets A and B (in an ordered list from 
> selectors: A, then B), but B gets urgent data: should we handle B urgent data 
> before not-urgent A data?"

IMO No. The same strategy applies. urgent data events on B have priority over 
other events on B, but not necessarily over events on A. As long as the urgent 
data events for a certain file object are handled before other events for that 
file object, it should be fine.

> "Would it be possible to let the developer decide how to prioritize events?"
At this point asyncio has no support for prioritizing event handlers. If 
prioritizing should be necessary, it should IMO be implemented in a way that 
all event handlers can be prioritized and not just these events. I think we can 
agree that this falls outside the scope of this patch.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30866] Add _testcapi.stack_pointer() to measure the C stack consumption

2017-07-06 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +2671

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30339] test_multiprocessing_main_handling: "RuntimeError: Timed out waiting for results" on x86 Windows7 3.x

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

http://buildbot.python.org/all/builders/AMD64%20Windows7%20SP1%203.5/builds/229/steps/test/logs/stdio


==
FAIL: test_directory (test.test_multiprocessing_main_handling.SpawnCmdLineTest)
--
Traceback (most recent call last):
  File 
"C:\buildbot.python.org\3.5.kloth-win64\build\lib\test\test_multiprocessing_main_handling.py",
 line 197, in test_directory
self._check_script(script_dir)
  File 
"C:\buildbot.python.org\3.5.kloth-win64\build\lib\test\test_multiprocessing_main_handling.py",
 line 155, in _check_script
rc, out, err = assert_python_ok(*run_args, __isolated=False)
  File 
"C:\buildbot.python.org\3.5.kloth-win64\build\lib\test\support\script_helper.py",
 line 150, in assert_python_ok
return _assert_python(True, *args, **env_vars)
  File 
"C:\buildbot.python.org\3.5.kloth-win64\build\lib\test\support\script_helper.py",
 line 136, in _assert_python
err))
AssertionError: Process return code is 1
command line: 
['C:\\buildbot.python.org\\3.5.kloth-win64\\build\\PCbuild\\amd64\\python_d.exe',
 '-X', 'faulthandler', '-E', 
'C:\\Users\\Buildbot\\AppData\\Local\\Temp\\tmp7w5hs4kq', 'spawn']

stdout:
---

---

stderr:
---
Traceback (most recent call last):
  File "C:\buildbot.python.org\3.5.kloth-win64\build\lib\runpy.py", line 193, 
in _run_module_as_main
"__main__", mod_spec)
  File "C:\buildbot.python.org\3.5.kloth-win64\build\lib\runpy.py", line 85, in 
_run_code
exec(code, run_globals)
  File "C:\Users\Buildbot\AppData\Local\Temp\tmp7w5hs4kq\__main__.py", line 23, 
in 
raise RuntimeError("Timed out waiting for results")
RuntimeError: Timed out waiting for results
---

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Dan Wissme

Le 06/07/2017 à 09:29, Terry Reedy a écrit :

On 7/6/2017 3:08 AM, Dan Wissme wrote:

I thought that del L[i] would slide L[i+1:] one place to the left,
filling the hole, but :

 >>> L
[0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100]
 >>> id(L)
4321967496
 >>> id(L[5])# address of 50 ?
4297625504
 >>> del L[2]
 >>> id(L[4]) # new address of 50 ?
4297625504
 >>> id(L)
4321967496



So the element 50 is still at the same memory location.
What del L[i] do exactly, and what is its complexity ? O(1) or O(n) ?


A list is an array of references to objects that exist outside of the
list.  Del deleted a reference, not any of the objects.


So what 'del L[i]' do exactly in memory ? Same as L.pop(i) ? with 
complexity O(n-i) ?


 dan



--
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
Chris Angelico writes:

> On Thu, Jul 6, 2017 at 5:35 PM, Jussi Piitulainen
>  wrote:
>> Incidentally, let no one point out that ids are not memory addresses.
>> It says in the interactive help that they are (Python 3.4.0):
>>
>> Help on built-in function id in module builtins:
>>
>> id(...)
>> id(object) -> integer
>>
>> Return the identity of an object. This is guaranteed to be unique
>> among simultaneously existing objects. (Hint: it's the object's
>> memory address.)
>
> Sorry, not the case.
>
>
> Help on built-in function id in module builtins:
>
 help(id)
> id(obj, /)
> Return the identity of an object.
>
> This is guaranteed to be unique among simultaneously existing objects.
> (CPython uses the object's memory address.)
>
 help(id)
> Help on built-in function id in module __builtin__:
>
> id(...)
>
> help(id)
> Help on built-in function id in module __builtin__:
>
> id(...)
> Return the identity of an object: id(x) == id(y) if and only if x is y.
>
>
> The interactive help does not say that in any version newer than the
> 3.4 that you tested. The function does not return an address, it
> returns an identity.

Excellent. I'm happy to withdraw the prohibition.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30867] Add necessary macro that insure`HAVE_OPENSSL_VERIFY_PARAM` to avoid invalid function declaration

2017-07-06 Thread signal1587

Changes by signal1587 :


--
title: Add necessary macro `HAVE_OPENSSL_VERIFY_PARAM` to avoid invalid 
declaration -> Add necessary macro that insure`HAVE_OPENSSL_VERIFY_PARAM` to 
avoid invalid function declaration

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30867] Add necessary macro that insure `HAVE_OPENSSL_VERIFY_PARAM` to avoid invalid function declaration

2017-07-06 Thread signal1587

Changes by signal1587 :


--
title: Add necessary macro that insure`HAVE_OPENSSL_VERIFY_PARAM` to avoid 
invalid function declaration -> Add necessary macro that insure 
`HAVE_OPENSSL_VERIFY_PARAM` to avoid invalid function declaration

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Thu, 6 Jul 2017 06:51 pm, Dan Wissme wrote:

> So what 'del L[i]' do exactly in memory ? Same as L.pop(i) ? with
> complexity O(n-i) ?

It depends on what L is and what the value of i is. If L is a list, and i is the
last index of the list, then deleting it is quick. If i is 0, then Python has
to copy the entire list over by one slot, which will probably be O(n) slow.

If you care about the performance of this, then you probably shouldn't use a
list. Consider using collections.deque, which is optimized to be fast to insert
or delete items at both ends. (But it is slower to do so in the middle.)

By the way, the big O algorithmic complexity is not a language promise, so it is
possible that it could change in the future, or in some other implementation. I
think the only *guarantee* is that:

- appending to a list is amortised O(1);
- item retrieval from a list is O(1).

Anything else is implementation dependent and could (but probably won't) change.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread Melroy van den Berg

Melroy van den Berg added the comment:

I also got this problem with gcc/g++ version 4.9.3. 

./Include/pyatomic.h:37:5: error: 'atomic_int' does not name a type

I'm using Python 3.6.1. It's not fixed!

--
nosy: +Melroy van den Berg
versions: +Python 3.6 -Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30862] parent logger should also check the level

2017-07-06 Thread R. David Murray

R. David Murray added the comment:

@qingyunha: we are telling you that that would *introduce* a bug.  This is 
working the way it is supposed to.

Vinay, what if we rewrote the beginning of that paragraph like this:

Sets the threshold for this logger to lvl. Logging messages which are less 
severe than lvl will be ignored, logging messages which have severity lvl or 
higher will be emitted by whichever handler or handlers service this logger, 
unless the handler's level has been set to a higher severity level than lvl.

When a logger is created, the level is set to NOTSET

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30865] python cannot import module located on a "VOLUME" directory

2017-07-06 Thread R. David Murray

R. David Murray added the comment:

Reading through some of the linked material, it looks like the issue is with 
how UNC "symlinks" are resolved.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
Marko Rauhamaa writes:

> While talking about addresses might or might not be constructive, let
> me just point out that there is no outwardly visible distinction
> between "address" or "identity".

With a generational or otherwise compacting garbage collector there
would be. I believe that to be a valid implementation strategy.

Or you are using "address" in some abstract sense so that the "address"
does not change when the internal representation of the object is moved
to another location.

> Ignoring the word that is used to talk about object identity, it would
> be nice to have a precise formal definition for it. For example, I
> know that any sound implementation of Python would guarantee:
>
> >>> def f(a): return a
> ...
> >>> a = object()
> >>> a is f(a)
> True
>
> But how do I know it?

For me it's enough to know that it's the object itself that is passed
around as an argument, as a returned value, as a stored value, as a
value of a variable. This is the basic fact that lets me understand the
behaviour and performance of programs.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30858] Keyword can't be an expression?

2017-07-06 Thread R. David Murray

R. David Murray added the comment:

If I saw your message, I would think "what is a 'simple name'?".  There's no 
glossary entry for that, nor is it a concept used elsewhere in the 
documentation as far as I remember.  One could instead use "single identifier", 
 but the problem with both of those is that "end" *is* a simple name/single 
identifier.  The error isn't that an identifier was not used, the error is that 
an expression was used.  We unfortunately can't read the mind of the programmer 
to know that the *actual* error was using a '+' instead of a ','.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30866] Add _testcapi.stack_pointer() to measure the C stack consumption

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

> Usually we first merge a patch in master and after that cherry-pick it to 
> other branches.

Right. But in this case, I needed the patch for each branch, to run the test on 
all branches to write a blog post :-) Here are results (blog post spoiler!):

Table showing the C stack consumption in bytes, and the difference compared to
Python 3.5 (last release before I started working on FASTCALL):

    =    

Function  2.7 3.5  3.6   3.7
    =    

test_python_call  1,360 (**+352**)  1,008  1,120 (**+112**)960 (**-48**)
test_python_getitem   1,408 (**+288**)  1,120  1,168 (**+48**) 880 
(**-240**)
test_python_iterator  1,424 (**+192**)  1,232  1,200 (**-32**)   1,024 
(**-208**)
Total 4,192 (**+832**)  3,360  3,488 (**+128**)  2,864 
(**-496**)
    =    


Table showing the number of function calls before a stack overflow,
and the difference compared to Python 3.5:

  ===  ==  ===  
===
Function   2.73.5   3.6   3.7
  ===  ==  ===  
===
test_python_call   6,161 (**-2,153**)   8,314   7,482 (**-832**) 8,729 
(**+415**)
test_python_getitem5,951 (**-1,531**)   7,482   7,174 (**-308**) 9,522 
(**+2,040**)
test_python_iterator   5,885 (**-916**) 6,801   6,983 (**+182**) 8,184 
(**+1,383**)
Total  17,997 (**-4600**)  22,597  21,639 (**-958**)26,435 
(**+3,838**)
  ===  ==  ===  
===

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30866] Add _testcapi.stack_pointer() to measure the C stack consumption

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

I just published my blog post: "My contributions to CPython during 2017 Q1"
https://haypo.github.io/contrib-cpython-2017q1.html

See the "Stack consumption" section.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30860] Consolidate stateful C globals under a single struct.

2017-07-06 Thread Jeremy Kloth

Changes by Jeremy Kloth :


--
nosy: +jkloth

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Steve D'Aprano
On Thu, 6 Jul 2017 07:24 pm, Marko Rauhamaa wrote:

> While talking about addresses might or might not be constructive, let me
> just point out that there is no outwardly visible distinction between
> "address" or "identity".


Er, yes there is. Address refers to a position in space. Identity refers to the
state or quality of being identical (i.e. the same). My identity remains the
same as I travel from one address to another.


> Equally well, we could replace those words with:
> 
>serial number
> 
>fixed asset tag
> 
>social security number

Those are good ID numbers.

>fermionic quantum state

I don't think that is, since two electrons (fermions) in different atoms can be
in the same state.


>face

Identical twins would have something to say about that.


>fingerprint

In practice, the uniqueness of fingerprints is problematic, but I'll grant that
at least in principle they would make good IDs.


>cryptographic hash

By the pigeonhole principle, not actually unique. Only probably unique, provided
the number of objects given IDs is significantly smaller than the total number
of hashes. E.g. if you have 2**128+1 objects using a 128-bit hash, then there
must be two distinct objects with the same hash.


> Ignoring the word that is used to talk about object identity, it would
> be nice to have a precise formal definition for it. For example, I know
> that any sound implementation of Python would guarantee:
> 
> >>> def f(a): return a
> ...
> >>> a = object()
> >>> a is f(a)
> True
> 
> But how do I know it?

Which part is unclear? The fact that f(a) returns a, or the fact that `a is a`
is true?

First part is implied by Python's execution model, and the second by the
definition of the `is` operator.

I'm genuinely unsure what part of this you think needs a precise formal
definition.

(That's even putting aside that it may not be possible to give a precise formal
definition of "identity". See, for example, "The Axe of my Grandfather"
paradox.)




-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Thu, Jul 6, 2017 at 7:24 PM, Marko Rauhamaa  wrote:
> While talking about addresses might or might not be constructive, let me
> just point out that there is no outwardly visible distinction between
> "address" or "identity".
>
> Equally well, we could replace those words with:
>
>serial number
>
>fixed asset tag
>
>social security number
>
>fermionic quantum state
>
>face
>
>fingerprint
>
>cryptographic hash

Not so. An address is a place where you can look for something. If you
go to 51 Franklin Street, Boston, MA, USA, you should find the offices
of the Free Software Foundation. That wouldn't be the case if you go
to the FSF's serial number or fermionic quantum state. And a
cryptographic hash is a function of something's value, not its
identity; two identical strings have the same hash, even if they are
unique objects.

> Ignoring the word that is used to talk about object identity, it would
> be nice to have a precise formal definition for it. For example, I know
> that any sound implementation of Python would guarantee:
>
> >>> def f(a): return a
> ...
> >>> a = object()
> >>> a is f(a)
> True
>
> But how do I know it?

The formal definition is that objects have identities, and that
assignment (including function parameters and return values) gives you
a reference to the same object.

"A person just walked into the revolving door and came back out again."
"Is it the same person?"
"I don't know. What's the definition of identity?"

Of course it's the same person. You don't need to identify that person
by a social security number in order to say "the SAME PERSON came back
out". You identify him/her by... identity.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Steve D'Aprano :

> On Thu, 6 Jul 2017 07:24 pm, Marko Rauhamaa wrote:
>
>> While talking about addresses might or might not be constructive, let
>> me just point out that there is no outwardly visible distinction
>> between "address" or "identity".
>
> Er, yes there is. Address refers to a position in space. Identity
> refers to the state or quality of being identical (i.e. the same). My
> identity remains the same as I travel from one address to another.

That sounds metaphysical.

What I'm looking for is snippets of Python code that illustrate the
difference.

That's how you can illustrate the difference between the "==" and "is"
operators:

>>> ["a"] is ["a"]
False
>>> ["a"] == ["a"]
True

> Those are good ID numbers.
>
>>fermionic quantum state
>
> I don't think that is, since two electrons (fermions) in different
> atoms can be in the same state.

Beside the topic but (unlike the bosons) every fermion in the universe
differs in at least one parameter from all the rest. In your case, they
belong to different atoms.

>> Ignoring the word that is used to talk about object identity, it would
>> be nice to have a precise formal definition for it. For example, I know
>> that any sound implementation of Python would guarantee:
>> 
>> >>> def f(a): return a
>> ...
>> >>> a = object()
>> >>> a is f(a)
>> True
>> 
>> But how do I know it?
>
> Which part is unclear? The fact that f(a) returns a, or the fact that
> `a is a` is true?

In fact,

a is a

would be a *great* start for a formal definition/requirement of the "is"
operator, although you'd have to generalize it to

b is b
c is c

etc as well. Unfortunately, when I try it, I get:

>>> a is a
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'a' is not defined

Actually, getting the wording right in these kinds of definitions is
surprisingly tricky.

> First part is implied by Python's execution model,

[Citation needed]

> and the second by the definition of the `is` operator.

[Citation needed]

> I'm genuinely unsure what part of this you think needs a precise
> formal definition.
>
> (That's even putting aside that it may not be possible to give a
> precise formal definition of "identity". See, for example, "The Axe of
> my Grandfather" paradox.)

There are many ways to define identity:

 1. Map Python's data model to that of another programming language, for
example C. This technique is very common and useful. No wonder the
word "address" keeps popping up.

 2. List a number of formal requirements: any implementation that
complies with the requirements is a valid implementation of the
language.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread Melroy van den Berg

Melroy van den Berg added the comment:

Ow sorry, I though it was already fixed in the latest stable version of 3.x. 
Since is issue is from 2015.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
MRAB  writes:

> On 2017-07-06 15:29, Jussi Piitulainen wrote:
>> Marko Rauhamaa writes:
>>
>>> While talking about addresses might or might not be constructive,
>>> let me just point out that there is no outwardly visible distinction
>>> between "address" or "identity".
>>
>> With a generational or otherwise compacting garbage collector there
>> would be. I believe that to be a valid implementation strategy.
>>
>> Or you are using "address" in some abstract sense so that the
>> "address" does not change when the internal representation of the
>> object is moved to another location.
>>
>>> Ignoring the word that is used to talk about object identity, it
>>> would be nice to have a precise formal definition for it. For
>>> example, I know that any sound implementation of Python would
>>> guarantee:
>>>
>>> >>> def f(a): return a
>>> ...
>>> >>> a = object()
>>> >>> a is f(a)
>>> True
>>>
>>> But how do I know it?
>>
>> For me it's enough to know that it's the object itself that is passed
>> around as an argument, as a returned value, as a stored value, as a
>> value of a variable. This is the basic fact that lets me understand
>> the behaviour and performance of programs.
>>
> Perhaps you should be thinking of it as passing around the end of a
> piece of string, the other end being tied to the object itself. :-)

I don't find that helpful, and I don't find myself in need of such help.
Most of the time that piece of string is (those pieces of string are)
just a distraction to me. They get in the way. So I *don't*.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Chris Angelico :

> The formal definition is that objects have identities, and that
> assignment (including function parameters and return values) gives you
> a reference to the same object.

My example didn't contain a single assignment, but a variation of your
statement would make a good part in a definition of identity.

> "A person just walked into the revolving door and came back out
> again." "Is it the same person?" "I don't know. What's the definition
> of identity?"
>
> Of course it's the same person. You don't need to identify that person
> by a social security number in order to say "the SAME PERSON came back
> out". You identify him/her by... identity.

Here's how identity is dealt with in First-Order Logic:

   https://en.wikipedia.org/wiki/First-order_logic#Semantics>

In other words, identity is mapped to the "sameness" in a domain of
discourse.

In Second-Order Logic, you can define identity directly:

∀x ∀y x = y ↔ ∀P (P(x) ↔ P(y))


Programming languages are different beasts, of course, but "objects" and
"identity" are such important foundational topics that you'd expect a
bit more than hand-waving when defining the data model.

As a good example of the style I'm looking for, take a look at:

   https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html>


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 12:56 AM, MRAB  wrote:
> Perhaps you should be thinking of it as passing around the end of a piece of
> string, the other end being tied to the object itself. :-)

You mean like Elbonian currency?

http://dilbert.com/strip/2008-09-15

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Marko Rauhamaa
Jussi Piitulainen :

> Marko Rauhamaa writes:
>
>> While talking about addresses might or might not be constructive, let
>> me just point out that there is no outwardly visible distinction
>> between "address" or "identity".
>
> With a generational or otherwise compacting garbage collector there
> would be. I believe that to be a valid implementation strategy.
>
> Or you are using "address" in some abstract sense so that the "address"
> does not change when the internal representation of the object is moved
> to another location.

"Address" is just a word. In fact, I don't think there is any definition
in the Python data model that makes use of the term.

Personally, when talking about Python, I would regard "address" as an
endearing synonym for "identity".

>> Ignoring the word that is used to talk about object identity, it would
>> be nice to have a precise formal definition for it. For example, I
>> know that any sound implementation of Python would guarantee:
>>
>> >>> def f(a): return a
>> ...
>> >>> a = object()
>> >>> a is f(a)
>> True
>>
>> But how do I know it?
>
> For me it's enough to know that it's the object itself that is passed
> around as an argument, as a returned value, as a stored value, as a
> value of a variable. This is the basic fact that lets me understand
> the behaviour and performance of programs.

That "definition" is very circular. You haven't yet defined what is
"object itself". The word "self", in partucular, looks like yet another
synonym of "identity".

Anyway, it would be nice to have an explicit statement in the language
definition that says that passing an argument and returning a value
preserve the identity.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23644] g++ module compile fails with ‘_Atomic’ does not name a type

2017-07-06 Thread STINNER Victor

STINNER Victor added the comment:

> I'm using Python 3.6.1. It's not fixed!

Thanks for the confirmation of the fix ;-)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: About the implementation of del in Python 3

2017-07-06 Thread MRAB

On 2017-07-06 15:29, Jussi Piitulainen wrote:

Marko Rauhamaa writes:


While talking about addresses might or might not be constructive, let
me just point out that there is no outwardly visible distinction
between "address" or "identity".


With a generational or otherwise compacting garbage collector there
would be. I believe that to be a valid implementation strategy.

Or you are using "address" in some abstract sense so that the "address"
does not change when the internal representation of the object is moved
to another location.


Ignoring the word that is used to talk about object identity, it would
be nice to have a precise formal definition for it. For example, I
know that any sound implementation of Python would guarantee:

>>> def f(a): return a
...
>>> a = object()
>>> a is f(a)
True

But how do I know it?


For me it's enough to know that it's the object itself that is passed
around as an argument, as a returned value, as a stored value, as a
value of a variable. This is the basic fact that lets me understand the
behaviour and performance of programs.

Perhaps you should be thinking of it as passing around the end of a 
piece of string, the other end being tied to the object itself. :-)

--
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Jussi Piitulainen
Marko Rauhamaa writes:

> Jussi Piitulainen:
>
>> For me it's enough to know that it's the object itself that is passed
>> around as an argument, as a returned value, as a stored value, as a
>> value of a variable. This is the basic fact that lets me understand
>> the behaviour and performance of programs.
>
> That "definition" is very circular. You haven't yet defined what is
> "object itself". The word "self", in partucular, looks like yet
> another synonym of "identity".

Yes, I regard the identity of an object as the most *basic* thing.

> Anyway, it would be nice to have an explicit statement in the language
> definition that says that passing an argument and returning a value
> preserve the identity.

Isn't there? I think it's at least very strongly implied.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 12:59 AM, Marko Rauhamaa  wrote:
>> Or you are using "address" in some abstract sense so that the "address"
>> does not change when the internal representation of the object is moved
>> to another location.
>
> "Address" is just a word. In fact, I don't think there is any definition
> in the Python data model that makes use of the term.
>
> Personally, when talking about Python, I would regard "address" as an
> endearing synonym for "identity".

Why? The word has a perfectly good meaning, and it's based on
"addressability". That is, you can take the address and use it to
locate the thing in question. I have an email address; you can use
that email address to send information to me. When you do, you'll get
in touch with the mail server by sending packets to its IP address,
and the internet's routing rules will get them where they need to go.
If you want to ship me physical items, you'll need to know my street
address, which tells you where in Australia you can find my letter
box. None of this has anything to do with my identity; I've had a
number of addresses of each type, and if you use an outdated one, you
won't get to me.

Objects have identities in Python even if they haven't yet been
assigned ID numbers. It's hard to probe this (impossible in CPython),
but you can see the effects of it by messing around in Jython.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Chris Angelico
On Fri, Jul 7, 2017 at 1:21 AM, Marko Rauhamaa  wrote:
> Steve D'Aprano :
>
>> On Thu, 6 Jul 2017 07:24 pm, Marko Rauhamaa wrote:
>>
>>> While talking about addresses might or might not be constructive, let
>>> me just point out that there is no outwardly visible distinction
>>> between "address" or "identity".
>>
>> Er, yes there is. Address refers to a position in space. Identity
>> refers to the state or quality of being identical (i.e. the same). My
>> identity remains the same as I travel from one address to another.
>
> That sounds metaphysical.
>
> What I'm looking for is snippets of Python code that illustrate the
> difference.
>
> That's how you can illustrate the difference between the "==" and "is"
> operators:
>
> >>> ["a"] is ["a"]
> False
> >>> ["a"] == ["a"]
> True

When you have an address, you can use that to locate the thing. In C,
that's pointer dereferencing. If I give you the id of a Python object,
can you locate that object and find out something about it? If you
can't, it's not an address.

And you have to make this work in Python (the language), not just
CPython (the interpreter). I'll consider an answer satisfactory if it
runs on the Big Four - CPython, Jython, IronPython, and PyPy - and
mainly, you need to show that it works in Jython, because that's the
most different.

>> Which part is unclear? The fact that f(a) returns a, or the fact that
>> `a is a` is true?
>
> In fact,
>
> a is a
>
> would be a *great* start for a formal definition/requirement of the "is"
> operator, although you'd have to generalize it to
>
> b is b
> c is c
>
> etc as well. Unfortunately, when I try it, I get:
>
> >>> a is a
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'a' is not defined

And oh how terrible, Python doesn't define any other operators on
unassigned names either. The 'is' operator is looking at OBJECT
identity, so you need to have an OBJECT. If you don't understand that
part of Python's object model, I recommend learning from Ned
Batchelder:

https://nedbatchelder.com/text/names1.html

>> First part is implied by Python's execution model,
>
> [Citation needed]

https://docs.python.org/3/reference/executionmodel.html

>> and the second by the definition of the `is` operator.
>
> [Citation needed]

https://docs.python.org/3/reference/expressions.html#is-not

> There are many ways to define identity:
>
>  1. Map Python's data model to that of another programming language, for
> example C. This technique is very common and useful. No wonder the
> word "address" keeps popping up.

Very common, yes, but not so useful. Python's data model is not the
same as C's, and it's easier to explain without diving into the lower
level details.

Objects exist. You can ask a child about object identity and you'll
get sane responses.

* "If I put the ball behind my back, is it still a ball?"
* "If I put the ball inside this box, is it the same ball?"
* "I dip this ball in water; it is now wet. Is it still the same ball?"

No mention of pointers. No mention of C.

>  2. List a number of formal requirements: any implementation that
> complies with the requirements is a valid implementation of the
> language.

You want to go down that path? Okay. Start reading
https://docs.python.org/3/reference/ and let me know when you're done.
You may notice that it was easily able to supply the dolphins you
needed above.

Just don't try explaining to a novice programmer that way. It's a
waste of everyone's time.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: About the implementation of del in Python 3

2017-07-06 Thread Ian Kelly
On Thu, Jul 6, 2017 at 9:41 AM, Marko Rauhamaa  wrote:
> As a good example of the style I'm looking for, take a look at:
>
>https://docs.oracle.com/javase/specs/jls/se7/html/jls-17.html>

Java reference types have basically the same concept of identity as
Python objects, so I dug around to find what definition Java uses.
This is what I came up with:

"""
There may be many references to the same object. Most objects have
state, stored in the fields of objects that are instances of classes
or in the variables that are the components of an array object. If two
variables contain references to the same object, the state of the
object can be modified using one variable's reference to the object,
and then the altered state can be observed through the reference in
the other variable.
"""

Also, under the reference equality operator:

"""
At run time, the result of == is true if the operand values are both
null or both refer to the same object or array; otherwise, the result
is false.
The result of != is false if the operand values are both null or both
refer to the same object or array; otherwise, the result is true.
"""

If that language were used for Python, would it suffice for you?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30779] IDLE: configdialog -- factor out Changes class

2017-07-06 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
pull_requests: +2677

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Re: Test 0 and false since false is 0

2017-07-06 Thread Rick Johnson
On Thursday, July 6, 2017 at 9:29:29 PM UTC-5, Sayth Renshaw wrote:
> I was trying to solve a problem and cannot determine how to filter 0's but 
> not false.
> 
> Given a list like this
> ["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9]
> 
> I want to be able to return this list
> ["a","b",None,"c","d",1,False,1,3,[],1,9,{},9,0,0,0,0,0,0,0,0,0,0]
> 
> However if I filter like this 
> 
> def move_zeros(array):
> l1 = [v for v in array if v != 0]
> l2 = [v for v in array if v == 0]
> return l1 + l2
> 
> I get this 
> ['a', 'b', None, 'c', 'd', 1, 1, 3, [], 1, 9, {}, 9, 0, 0, 0, False, 0, 0, 0, 
> 0, 0, 0, 0] 
> 
> I have tried or conditions of v == False etc but then the 0's being false 
> also aren't moved. How can you check this at once?

Yep. This is a common pitfall for noobs, as no logic can
explain to them why integer 0 should bool False, and integer
1 should bool True. But what's really going to cook your
noodle is when you find out that any integer greater than 1
bools True. Go figure! They'll say it's for consistency
sake. But i say it's just a foolish consistency.

You need to learn the subtle difference between `==` and
`is`.

## PYTHON 2.x
>>> 1 == True
True
>>> 1 is True
False
>>> 0 == False
True
>>> 0 is False
False
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Test 0 and false since false is 0

2017-07-06 Thread Skip Montanaro
I was trying to solve a problem and cannot determine how to filter 0's but
not false.


I'm typing on my phone so can't paste a session, so I will attempt to apply
the Socratic method, and ask: Do you understand why your attempts have
failed so far? In what way are False and 0 the same? In what respects do
they differ? Hint: think class relationships.

Not trying to be difficult. Just thought I'd change things up a bit. If you
come away with a bit deeper appreciation of Python's type system, you'll be
a bit better off down the road.

Skip
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Test 0 and false since false is 0

2017-07-06 Thread Dan Sommers
On Fri, 07 Jul 2017 02:48:45 +, Stefan Ram wrote:

 def isfalse( x ):
> ...   return x == 0 and str( type( x )) == ""
> ...
> 

Don't depend on string representations of objects, unless you know what
you're doing.  Do this instead:

def isfalse(x):
return x == 0 and type(x) is bool

And why test against 0 in a function called isfalse?

def isfalse(x):
return x == False and type(x) is type(False)

Dan
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30869] regrtest: Add .idlerc to saved_test_environment

2017-07-06 Thread Louie Lu

Changes by Louie Lu :


--
pull_requests: +2679

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30869] regrtest: Add .idlerc to saved_test_environment

2017-07-06 Thread Louie Lu

New submission from Louie Lu:

In bpo #30780, there is a mistake of tearDownModule didn't restore the use rCfg.

To prevent future mistake, Adding .idlerc to regrtest saved_test_environment, 
so that `--fail-env-changed` option can detect .idlerc been changed in IDLE 
test.

--
components: Library (Lib)
messages: 297856
nosy: haypo, louielu, terry.reedy
priority: normal
severity: normal
status: open
title: regrtest: Add .idlerc to saved_test_environment
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30779] IDLE: configdialog -- factor out Changes class

2017-07-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Whoops, we seems to have partly overlapped (and made some of the same changes). 
 I plan to push my PR sometime tomorrow (it also changes configdialog and 
revised tests) after looking as yours.  Then move on to adding config tests, 
#30780.

The tests for config need the real config parsers, except for save.  But to 
fully test config, a mock save is needed.  I opened #30868 for this.

set_value (set_user_value) accesses neither configdialog nor changes.  So it is 
a function rather than a method, and I could have put it in config as such.  I 
added it as a staticmethod just above save_all instead because it is only used 
by save_all.

Any other of the now 74 methods of ConfigDialog that are not really methods 
thereof (don't use self) should also be removed and made module functions, in 
either module, or possibly changes methods.  I just want them tested first, if 
possible.

I *would* like to put all the extension changes in changes instead of some in a 
separate structure.  I believe the 'hard' part is that key changes have to be 
handled separately from the non-extension keys.  The code was contributed by 
someone else and once I determined that it worked by manual testing, I left it 
alone. Testing and moving and possibly rewriting the extension stuff would be a 
coherent issue and PR.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30780] IDLE: configdialog - add tests for ConfigDialog GUI.

2017-07-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:


New changeset 25a4206c243e3b1fa6f5b1c72a11b409b007694d by terryjreedy in branch 
'master':
bpo-30780: Fix error in idlelib.test_idle.test_configdialog (#2606)
https://github.com/python/cpython/commit/25a4206c243e3b1fa6f5b1c72a11b409b007694d


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



Test 0 and false since false is 0

2017-07-06 Thread Sayth Renshaw
I was trying to solve a problem and cannot determine how to filter 0's but not 
false.

Given a list like this
["a",0,0,"b",None,"c","d",0,1,False,0,1,0,3,[],0,1,9,0,0,{},0,0,9]

I want to be able to return this list
["a","b",None,"c","d",1,False,1,3,[],1,9,{},9,0,0,0,0,0,0,0,0,0,0]

However if I filter like this 

def move_zeros(array):
l1 = [v for v in array if v != 0]
l2 = [v for v in array if v == 0]
return l1 + l2

I get this 
['a', 'b', None, 'c', 'd', 1, 1, 3, [], 1, 9, {}, 9, 0, 0, 0, False, 0, 0, 0, 
0, 0, 0, 0] 

I have tried or conditions of v == False etc but then the 0's being false also 
aren't moved. How can you check this at once?


Cheers

Sayth
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: get value from list using widget

2017-07-06 Thread Rick Johnson
On Wednesday, July 5, 2017 at 4:15:34 PM UTC-5, Terry Reedy wrote:
> On 7/5/2017 12:34 PM, jorge.conr...@cptec.inpe.br wrote:
> 
> > I would like know dow can I select and get the value from
> > a list of values uisng widgets.
> 
> One way is to learn tkinter and then learn to use the
> Listbox widget. The doc references a couple of decent
> tutorial web sites. Stackoverflow has many good tkinter
> examples (in the answers, not the questions ;-).

Unfortunately for the occasional lurker of StackOverflow,
the "top voted" answer is not always the most informative,
and, in some rare cases, may even be outright bad advice. My
solution is to read the entire thread, and then, utilizing
my advanced analytical skills, decide which is the best.



-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30780] IDLE: configdialog - add tests for ConfigDialog GUI.

2017-07-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I posted PR 2612 for #30779 and expect to merge it tomorrow after sleep and 
final review.  It includes passing revisions of existing configdialog tests.  A 
PR dependent on 2612 could be posted before I do the merge.

Follow the model of using xyzpage names in asserts and tests would survive the 
refactoring of ConfigChanges discussed as a possibility on #30779.  I want to 
move forward on this, but not duplicate your work, so please post work done and 
immediate plans.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



  1   2   >