[issue26338] remove duplicate bind addresses in create_server

2016-03-02 Thread Yury Selivanov

Yury Selivanov added the comment:

Committed. Thanks, Sebastien!

--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
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



Re: urlopen, six, and py2

2016-03-02 Thread Chris Angelico
On Thu, Mar 3, 2016 at 2:36 AM, Fabien  wrote:
> On 03/02/2016 03:35 PM, Matt Wheeler wrote:
>>
>> I agree that six should probably handle this,
>
>
> Thank you Matt and Chris for your answers. Do you think I should open an
> issue on six? It sounds unlikely that I am the first one having this
> problem...
>
> (until this difference with urlopen I have found six to be extremely good at
> helping not caring about python versions at all)

What happens if you use 'requests' rather than urlopen? My guess is
that requests will already have dealt with this.

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


[issue26347] BoundArguments.apply_defaults doesn't handle empty arguments

2016-03-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 94879997ea5f by Yury Selivanov in branch '3.5':
inspect: Fix BoundArguments.apply_defaults to handle empty arguments
https://hg.python.org/cpython/rev/94879997ea5f

New changeset 779a0d51f7e2 by Yury Selivanov in branch 'default':
Merge 3.5 (issue #26347)
https://hg.python.org/cpython/rev/779a0d51f7e2

--
nosy: +python-dev

___
Python tracker 

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



[issue25647] Return of asyncio.coroutine from asyncio.coroutine doesn't work with enabled asyncio debug

2016-03-02 Thread Yury Selivanov

Yury Selivanov added the comment:

Vladimir, thanks for the patch!

--
resolution:  -> fixed
stage:  -> 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



[issue25647] Return of asyncio.coroutine from asyncio.coroutine doesn't work with enabled asyncio debug

2016-03-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fd21f162e377 by Yury Selivanov in branch '3.5':
asyncio: Fix @coroutine to recognize CoroWrapper (issue #25647)
https://hg.python.org/cpython/rev/fd21f162e377

New changeset e3aee2f16937 by Yury Selivanov in branch 'default':
Merge 3.5 (issue #25647)
https://hg.python.org/cpython/rev/e3aee2f16937

--
nosy: +python-dev

___
Python tracker 

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



Re: urlopen, six, and py2

2016-03-02 Thread Fabien

On 03/02/2016 03:35 PM, Matt Wheeler wrote:

I agree that six should probably handle this,


Thank you Matt and Chris for your answers. Do you think I should open an 
issue on six? It sounds unlikely that I am the first one having this 
problem...


(until this difference with urlopen I have found six to be extremely 
good at helping not caring about python versions at all)

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


Re: Explaining names vs variables in Python

2016-03-02 Thread Jussi Piitulainen
Ian Kelly writes:

> On Wed, Mar 2, 2016 at 2:35 AM, Jussi Piitulainen wrote:
>> The following are too delicate for me. I suppose the answers could have
>> been different, but I can't guess what mechanism actually leads to these
>> results. Just idle curiosity on my part.
>>
> 890 is 890
>> True
> id(890) == id(890)
>> True
>
> This has to do with the way code blocks are compiled. In the
> interactive interpreter, a single line like '890 is 890' is compiled
> to a single code object. The constant 890 appears twice in the same
> code block, so the optimizer uses the same constant for both. Note in
> the following that the same index appears for both, so they're
> actually the same object reference.

No wonder my guesses failed. This is different.

 import dis
 dis.dis('890 is 890')
>   1   0 LOAD_CONST   0 (890)
>   3 LOAD_CONST   0 (890)
>   6 COMPARE_OP   8 (is)
>   9 RETURN_VALUE
 compile('890 is 890', '', 'exec').co_consts
> (890, None)
>
>
> As for the earlier example of:
>
> 1 + 1 is 2
>> True
> 800 + 90 + 0 is 890
>> False
>
> This one actually surprises me a little, because the optimizer is also
> smart enough to evaluate '800 + 90 + 0' and just store a constant of
> 890:
>
 dis.dis('800 + 90 + 0 is 890')
>   1   0 LOAD_CONST   5 (890)
>   3 LOAD_CONST   3 (890)
>   6 COMPARE_OP   8 (is)
>   9 RETURN_VALUE
 compile('800 + 90 + 0 is 890', '', 'exec').co_consts
> (800, 90, 0, 890, None, 890, 890)
>
> Not smart enough to reuse the existing reference in this case
> apparently, or even to prune out the original constants that are no
> longer used in the code.

So it has access to three 890-objects and compares two of them :)

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


Re: Correct IDLE usage (was Reason for not allowing import twice but allowing reload())

2016-03-02 Thread Rustom Mody
On Tuesday, March 1, 2016 at 12:23:02 PM UTC+5:30, Terry Reedy wrote:
> On 2/29/2016 7:42 AM, Rustom Mody wrote:
> 
> > Is import needed at all when trying out in Idle?
> ...
> > So it does appear that
> > 1. import not necessary with(in) idle
> > 2. However import and f5 (ie is run as main) are different
> >
> > May some idle experts elaborate on this? Whats the idle idiom of import-ing?
> 
> Rustom, since I know that you are not a rank beginner, I have trouble 
> understanding what you are asking.  

Heh!
I know some things; dont know many things

> F5 when editing foo.py is equivalent 
> to running "python -i foo.py" on a command line while 'in' the directory 
> containing foo.py.  In both cases, foo.py is run as a main module, with 
> __name__ == '__main__'.  The difference is that F5 runs foo.py under 
> IDLE supervision, with results going into and interactive inputs coming 
> from IDLE shell instead of the console interpreter.
> 
> Imports are used in a module to access objects within the imported module.

Let me try to explain again

There is import and import.
There is the formal meaning of the import keyword in python -- call it import-f
There is the informal expectation and need of programmers to 'pull something 
into python' -- call it import-i

That there is some cognitive dissonance between import-f and import-i is seen
in the OP's question itself; also Chris' "I dont believe the language should be
changed" 

So the question is around:
What is the best practice for doing import-i in python?
As the OP finds import-f works once and fails thereafter

In idle one can get the desired result of import-i with F5
Is that right?

Also in general is there good usecases for import-f at that interpreter prompt
in idle?
I think not but not sure of it
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reason for not allowing import twice but allowing reload()

2016-03-02 Thread Grant Edwards
On 2016-03-02, Ian Kelly  wrote:

> Software updates? The nice thing about *nix systems is that *most*
> updates don't require a reboot. I'm still going to reboot any time
> there's a kernel update though, and those are fairly frequent. I could
> read the patch notes to determine whether this new kernel version is
> actually important, but it takes less of my time just to go ahead and
> reboot.

I try to remember to reboot every couple weeks or so even without a
kernel update.  There sometimes updates to things like the "rc" stuff
or udev or whatnot which occasionally cause boot-time problems.  If
you let too much time go by between reboots, and something that
happend several months ago is going to cause a problem at boot time,
that reboot is guaranteed to happen when it's the most inconvenient.
And it's a lot easier to figure out the problem when it's due to a
recent update.

> With my company-owned Macbook Air, the security policy will
> eventually schedule a *forced* reboot when there are "critical"
> updates to be installed. Thankfully the scheduler is pretty good
> about making sure it's not catching the user at an inopportune
> moment.


-- 
Grant Edwards   grant.b.edwardsYow! Let's all show human
  at   CONCERN for REVERAND MOON's
  gmail.comlegal difficulties!!
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explaining names vs variables in Python

2016-03-02 Thread Ian Kelly
On Wed, Mar 2, 2016 at 2:35 AM, Jussi Piitulainen
 wrote:
> The following are too delicate for me. I suppose the answers could have
> been different, but I can't guess what mechanism actually leads to these
> results. Just idle curiosity on my part.
>
 890 is 890
> True
 id(890) == id(890)
> True

This has to do with the way code blocks are compiled. In the
interactive interpreter, a single line like '890 is 890' is compiled
to a single code object. The constant 890 appears twice in the same
code block, so the optimizer uses the same constant for both. Note in
the following that the same index appears for both, so they're
actually the same object reference.

>>> import dis
>>> dis.dis('890 is 890')
  1   0 LOAD_CONST   0 (890)
  3 LOAD_CONST   0 (890)
  6 COMPARE_OP   8 (is)
  9 RETURN_VALUE
>>> compile('890 is 890', '', 'exec').co_consts
(890, None)


As for the earlier example of:

 1 + 1 is 2
> True
 800 + 90 + 0 is 890
> False

This one actually surprises me a little, because the optimizer is also
smart enough to evaluate '800 + 90 + 0' and just store a constant of
890:

>>> dis.dis('800 + 90 + 0 is 890')
  1   0 LOAD_CONST   5 (890)
  3 LOAD_CONST   3 (890)
  6 COMPARE_OP   8 (is)
  9 RETURN_VALUE
>>> compile('800 + 90 + 0 is 890', '', 'exec').co_consts
(800, 90, 0, 890, None, 890, 890)

Not smart enough to reuse the existing reference in this case
apparently, or even to prune out the original constants that are no
longer used in the code.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explaining names vs variables in Python

2016-03-02 Thread Rustom Mody
On Wednesday, March 2, 2016 at 7:42:09 PM UTC+5:30, Marko Rauhamaa wrote:
> Chris Angelico :
> 
> > On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa  wrote:
> >> Chris Angelico :
> >>
> >>> Python defines that every object has an identity, which can be
> >>> represented as an integer. Since this is an intrinsic part of the
> >>> object, no two distinct objects can truly have identical
> >>> characteristics. Python's objects are like rifles - there are many
> >>> like it, but this one is mine.
> >>
> >> How can you be sure Python isn't returning the same id value for two
> >> distinct objects?
> >
> > The same way I can be sure about anything else in Python. It's a
> > language guarantee.
> 
> Actually, my question is (intentionally) nonsensical.
> 
> The sameness or distinctness of two objects is not directly defined in
> Python. The definition is simply:
> 
>Two objects X and Y are called identical if
> 
>X is Y
> 
>evaluates to a true value.
> 
> Additionally, we have:
> 
>If objects X and Y are identical, it is guaranteed that
> 
>   id(X) == id(Y)
> 
>evaluates to a true value.
> 
> Even more strongly, we have:
> 
>For any objects X and Y,
> 
>   id(X) == id(Y) if X is Y else id(X) != id(Y)
> 
>evaluates to a true value.
> 
> What is missing is the rules that are obeyed by the "is" operator.

is is not is
is is was
[fermionic or bosonic?]
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: urlopen, six, and py2

2016-03-02 Thread Chris Angelico
On Thu, Mar 3, 2016 at 1:35 AM, Matt Wheeler  wrote:
>> from six.moves.urllib.request import urlopen
>>
>> try:
>> with urlopen('http://www.google.com') as resp:
>> _ = resp.read()
>> except AttributeError:
>> # python 2
>> resp = urlopen('http://www.google.com')
>> _ = resp.read()
>
> This is poor practise as you aren't closing "resp".
> This leaves state lying around that you don't need anymore, which is
> the whole purpose of the context manager that 3 provides.
> It will *usually* be cleaned up when leaving the current scope, but
> won't if there is an exception thrown. Using the context manager
> ensures resp is *always* cleaned up properly even if an exception is
> thrown.

Not sure why you say it won't if there's an exception thrown. This
code will do the same thing on both versions:

def get_data():
resp = urlopen('http://www.google.com')
return resp.read()

Absent the context manager, this depends on object disposal for its
cleanup. But whether this function returns normally or raises an
exception, the response object goes out of scope at the same time.
There's no guarantee that it'll be cleaned up immediately when the
function exits, but it's the same for the exceptional and
non-exceptional cases.

Agreed that try/finally is the best way to do cross-platform code here:

def get_data():
resp = urlopen('http://www.google.com')
try:
return resp.read()
finally:
resp.close()

It's reasonably compact, and fairly clear. And it has the exact
guarantee that the context manager has (before the function exits, the
'finally' block will be performed, and resources will be properly
released).

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


Re: urlopen, six, and py2

2016-03-02 Thread Matt Wheeler
On 2 March 2016 at 14:05, Fabien  wrote:
> [snip]
> My question is: why does the python3 version need a "with" block while the
> python2 version doesn't? Can I skip the "with" entirely, or should I rather
> do the following:

It's not a case of "need", using the "with" construction is an added
feature, not a burden!

> from six.moves.urllib.request import urlopen
>
> try:
> with urlopen('http://www.google.com') as resp:
> _ = resp.read()
> except AttributeError:
> # python 2
> resp = urlopen('http://www.google.com')
> _ = resp.read()

This is poor practise as you aren't closing "resp".
This leaves state lying around that you don't need anymore, which is
the whole purpose of the context manager that 3 provides.
It will *usually* be cleaned up when leaving the current scope, but
won't if there is an exception thrown. Using the context manager
ensures resp is *always* cleaned up properly even if an exception is
thrown.

I agree that six should probably handle this, but in the meantime you
could use contextlib.closing ([1]) rather than rolling your own. It
even uses urlopen as an example.

If you absolutely want to roll your own then don't bother with the
context manager provided by 3 at all, just use:

resp = urlopen('http://www.google.com')
try:
_ = resp.read()
finally:
resp.close()

But as this is wordier and more fragile than using a context manager
to clean up for you, I expect you won't bother :).


[1] https://docs.python.org/2/library/contextlib.html#contextlib.closing

-- 
Matt Wheeler
http://funkyh.at
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-03-02 Thread Zachary Ware

Changes by Zachary Ware :


--
nosy: +zach.ware

___
Python tracker 

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



Re: Explaining names vs variables in Python

2016-03-02 Thread Marko Rauhamaa
Chris Angelico :

> On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa  wrote:
>> Chris Angelico :
>>
>>> Python defines that every object has an identity, which can be
>>> represented as an integer. Since this is an intrinsic part of the
>>> object, no two distinct objects can truly have identical
>>> characteristics. Python's objects are like rifles - there are many
>>> like it, but this one is mine.
>>
>> How can you be sure Python isn't returning the same id value for two
>> distinct objects?
>
> The same way I can be sure about anything else in Python. It's a
> language guarantee.

Actually, my question is (intentionally) nonsensical.

The sameness or distinctness of two objects is not directly defined in
Python. The definition is simply:

   Two objects X and Y are called identical if

   X is Y

   evaluates to a true value.

Additionally, we have:

   If objects X and Y are identical, it is guaranteed that

  id(X) == id(Y)

   evaluates to a true value.

Even more strongly, we have:

   For any objects X and Y,

  id(X) == id(Y) if X is Y else id(X) != id(Y)

   evaluates to a true value.

What is missing is the rules that are obeyed by the "is" operator.


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


urlopen, six, and py2

2016-03-02 Thread Fabien

Hi,

it seems that urlopen had no context manager for versions < 3. The 
following code therefore will crash on py2 but not on py3.


from six.moves.urllib.request import urlopen
with urlopen('http://www.google.com') as resp:
_ = resp.read()

Error:
AttributeError: addinfourl instance has no attribute '__exit__'

I actually wonder if this is not something that the six library should 
take care of upstream, but in the meantime I could simply do what is 
suggested on this stackoverflow post:


http://stackoverflow.com/questions/30627937/tracebaclk-attributeerroraddinfourl-instance-has-no-attribute-exit

My question is: why does the python3 version need a "with" block while 
the python2 version doesn't? Can I skip the "with" entirely, or should I 
rather do the following:


from six.moves.urllib.request import urlopen

try:
with urlopen('http://www.google.com') as resp:
_ = resp.read()
except AttributeError:
# python 2
resp = urlopen('http://www.google.com')
_ = resp.read()

(which is quite ugly).

Thanks!

Fabien



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


Re: Explaining names vs variables in Python

2016-03-02 Thread Chris Angelico
On Thu, Mar 3, 2016 at 12:39 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>
>> Python defines that every object has an identity, which can be
>> represented as an integer. Since this is an intrinsic part of the
>> object, no two distinct objects can truly have identical
>> characteristics. Python's objects are like rifles - there are many
>> like it, but this one is mine.
>
> How can you be sure Python isn't returning the same id value for two
> distinct objects?

The same way I can be sure about anything else in Python. It's a
language guarantee. If you're bothered by that, you should also be
concerned that str(x) might not actually call x.__str__(), or that
a+b*c might evaluate the addition before the multiplication.

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


Re: Explaining names vs variables in Python

2016-03-02 Thread Marko Rauhamaa
Chris Angelico :

> Python defines that every object has an identity, which can be
> represented as an integer. Since this is an intrinsic part of the
> object, no two distinct objects can truly have identical
> characteristics. Python's objects are like rifles - there are many
> like it, but this one is mine.

How can you be sure Python isn't returning the same id value for two
distinct objects?


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


[issue26472] Infinite loop

2016-03-02 Thread Christian Heimes

Christian Heimes added the comment:

In open(False) Fale is interpreted as int 0. The function call opens file 
descriptor 0 (stdin) and waits for incoming data.

Try this code, enter some text and press enter to see what is going on:

with open(False) as f:
for line in f:
print('stdin: ', line)

--
nosy: +christian.heimes
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



[issue26472] Infinite loop

2016-03-02 Thread Tibichte

New submission from Tibichte:

The code below runs indefinitely:

with open(False) as f:
for line in f:
print(line)

--
components: IO
messages: 261113
nosy: DarkMagus
priority: normal
severity: normal
status: open
title: Infinite loop
type: behavior
versions: Python 3.5

___
Python tracker 

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



Re: Explaining names vs variables in Python

2016-03-02 Thread Jussi Piitulainen
Chris Angelico  writes:

> Python defines that every object has an identity, which can be
> represented as an integer. Since this is an intrinsic part of the
> object, no two distinct objects can truly have identical
> characteristics. Python's objects are like rifles - there are many
> like it, but this one is mine.

Rifles are not mines. A rifle hurts you from a distance. A mine hurts
you when you step on it.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26448] dis.findlabels ignores EXTENDED_ARG

2016-03-02 Thread Barun Parruck

Barun Parruck added the comment:

So...firstly hi, and sorry for disappearing like that!

You want tests for the dis.findlabels library? What sort of tests are you 
looking for? Similiarly sized bytecode streams like the ones we worked with, or 
did you have something else in mind?

B

--

___
Python tracker 

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



Re: Explaining names vs variables in Python

2016-03-02 Thread Chris Angelico
On Wed, Mar 2, 2016 at 11:34 PM, Marko Rauhamaa  wrote:
> The ontological question is, can two *distinct* objects with *identical*
> characteristics exist?
>
> The fermionic answer is, no.
>
> The bosonic answer is, sure.
>
> Set theory has fermionic ontology (it's called extensionality).
>
> Python sits on the fence on that one, allowing either ontology.

Python defines that every object has an identity, which can be
represented as an integer. Since this is an intrinsic part of the
object, no two distinct objects can truly have identical
characteristics. Python's objects are like rifles - there are many
like it, but this one is mine.

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


Re: Explaining names vs variables in Python

2016-03-02 Thread Marko Rauhamaa
Steven D'Aprano :

> On Wed, 2 Mar 2016 08:03 pm, Jesper K Brogaard wrote:
>
>> As I understand it, when you use 'is', you are comparing addresses to
>> objects, not the values contained in the objects. Use '==' instead.
>
> You should not think about addresses, because the location of objects
> is not part of the language. It is implementation-dependent.

The ontological question is, can two *distinct* objects with *identical*
characteristics exist?

The fermionic answer is, no.

The bosonic answer is, sure.

Set theory has fermionic ontology (it's called extensionality).

Python sits on the fence on that one, allowing either ontology.

> This is why the id() function is NOT documented as returning the
> address of an object, but of returning an ID number. Let's look at IDs
> in IronPython:
>
 a, b, c = [], 1, "Hello world!"
 print id(a), id(b), id(c), id(None)
> 43 44 45 0
>
>
> And in Jython:
>
 a, b, c = [], 1, "Hello world!"
 print id(a), id(b), id(c), id(None)
> 1 2 3 4

Python doesn't define or use the concept of an "address."


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


[issue26465] Upgrade OpenSSL shipped with python installers

2016-03-02 Thread Christian Heimes

Christian Heimes added the comment:

New security releases of Python are scheduled for the near future, most likelye 
mid to end of March.

--

___
Python tracker 

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



[issue26468] shutil.copy2 raises OSError if filesystem doesn't support chmod

2016-03-02 Thread Vojtěch Pachol

Vojtěch Pachol added the comment:

Actually it is a remote fs mounted via samba. OS is Linux.

Tracebacks with Python versions I have:

$ python2.7
Python 2.7.11 (default, Jan 11 2016, 21:04:40) 
[GCC 5.3.1 20160101] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copy2("src", "dst")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
  File "/usr/lib/python2.7/shutil.py", line 100, in copystat
os.chmod(dst, mode)
OSError: [Errno 95] Operation not supported: 'dst'
>>> 
$ python3.4
Python 3.4.4 (default, Jan  5 2016, 15:35:18) 
[GCC 5.3.1 20160101] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copy2("src", "dst")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.4/shutil.py", line 246, in copy2
copystat(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.4/shutil.py", line 191, in copystat
lookup("chmod")(dst, mode, follow_symlinks=follow)
OSError: [Errno 95] Operation not supported: 'dst'
>>> 
$ python3.5
Python 3.5.1+ (default, Jan 13 2016, 15:09:18) 
[GCC 5.3.1 20160101] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shutil
>>> shutil.copy2("src", "dst")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/shutil.py", line 252, in copy2
copystat(src, dst, follow_symlinks=follow_symlinks)
  File "/usr/lib/python3.5/shutil.py", line 197, in copystat
lookup("chmod")(dst, mode, follow_symlinks=follow)
OSError: [Errno 95] Operation not supported: 'dst'
>>>

--

___
Python tracker 

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



[issue26471] load_verify_locations(cadata) should load AUX ASN.1 to supported trusted certs

2016-03-02 Thread Christian Heimes

New submission from Christian Heimes:

https://docs.python.org/2/library/ssl.html#ssl.SSLContext.load_verify_locations 
can load certs from a file, a directory or from memory. OpenSSL's loaders for 
cafile and capath load auxiliary data of trusted certs. The custom loader for 
cadata ignores AUX data because it uses PEM_read_bio_X509() instead of 
PEM_read_bio_X509_AUX().

With the recent fix of OpenSSL 1.0.2 
https://github.com/openssl/openssl/commit/a3baa171053547488475709c7197592c66e427cf
 trusted certificates now work again. I propose to change cadata to load trust 
settings, too.

--
assignee: christian.heimes
components: Extension Modules
messages: 261109
nosy: alex, christian.heimes, dstufft, giampaolo.rodola, janssen, pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: load_verify_locations(cadata) should load AUX ASN.1 to supported trusted 
certs
type: security
versions: Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

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



[issue26465] Upgrade OpenSSL shipped with python installers

2016-03-02 Thread Alex Gaynor

Changes by Alex Gaynor :


--
nosy: +christian.heimes, dstufft, giampaolo.rodola, janssen, pitrou

___
Python tracker 

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



[issue26470] Make OpenSSL module compatible with OpenSSL 1.1.0

2016-03-02 Thread Christian Heimes

New submission from Christian Heimes:

OpenSSL 1.1.0 is changing a lot of internals. Most structs are opaque, RC4 and 
SSLv2 are gone. I've a rough patch in my private repos. I'll submit the patch 
as soon as the code is compatible with OpenSSL 1.0.2, too.

https://github.com/python/cpython/compare/master...tiran:feature/openssl110

--
assignee: christian.heimes
messages: 261108
nosy: alex, christian.heimes, dstufft, giampaolo.rodola, janssen, pitrou
priority: normal
severity: normal
stage: needs patch
status: open
title: Make OpenSSL module compatible with OpenSSL 1.1.0
type: security
versions: Python 2.7, Python 3.5

___
Python tracker 

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



Re: Everything good about Python except GUI IDE?

2016-03-02 Thread Marko Rauhamaa
Gordon Levi :

> I find it difficult to believe that you _love_ updating your contacts
> using Emacs even if it gives you an excuse to get some therapy from
> Eliza. It seems equally unlikely that you can do without phone numbers
> and addresses for your contacts.

WP8 doesn't allow me to modify the contacts using emacs. And to my
knowledge, emacs still doesn't have a phone-call-mode.

I *love* using emacs for everything I can because the whole gamut of
emacs' typing machinery is at my disposal.

I readily admit that reading Wikipedia articles still works better with
Firefox than emacs.


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


[issue21042] ctypes.util.find_library() should return full pathname instead of filename in linux

2016-03-02 Thread Tamás Bence Gedai

Tamás Bence Gedai added the comment:

Is there anything else that I can do for this issue?

--

___
Python tracker 

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



Re: How to know if an object is still be referenced?

2016-03-02 Thread jfong
Terry Reedy at 2016/3/2  UTC+8 3:04:10PM wrote:
> On 3/1/2016 9:35 PM, jf...@ms4.hinet.net wrote:
> > Recently I was puzzled by a tkinter problem. The codes below (from a book) 
> > can display the picture correctly.
> >
> >  gifdir = "../gifs/"
> >  from tkinter import *
> >  win = Tk()
> >  photo = PhotoImage(file=gifdir + "ora-pp.gif")
> >  Button(win, image=photo).pack()
> >  win.mainloop()
> 
> Since photo is a global name, the binding remain until you explicitly 
> delete it or exit the app.
> 
> > And the codes below (from another book) will also work.
> >
> >  class DrumMachine:
> >  
> >  
> >  def create_play_bar(self):
> >  
> >  
> >  photo = PhotoImage(file='images/signature.gif')
> >  label = Label(playbar_frame, image=photo)
> >  label.image = photo
> >  label.grid(row=start_row, column=50, padx=1, sticky='w')
> >  
> >  
> 
> Here photo is a local name and the binding disappears when the function 
> exits.  I would rewrite it to follow pattern 1.
> 
>   self.photo = PhotoImage(file='images/signature.gif')
>   label = Label(playbar_frame, image=self.photo)
> 
> To me, saving an attribute reference is not worth the extra line.
> 
> > In the second example, I noticed that the "photo" was referenced two times
> > and I think it might be a redundancy so I remove the line "label.image = 
> > photo". But it fails then.
> 
> On another question, I made the same suggestion.  Oops.
> 
> -- 
> Terry Jan Reedy

Thanks, Terry. After reading your reply I noticed that I had make a mistake. 
The "image" is not an attribute of the Button. It's an option. The 
"label.image=photo" does a different thing. But it didn't help on solving my 
puzzle.

If the problem was caused by the "photo" is a local, then binding the "photo" 
to an local attribute ("label" is a local too) seems no meaning at all. But it 
did make difference! No idea how the underneath mechanism works.

I run this example under the pdb and it can display the picture correctly even 
without the "label.image=photo" statement. Why it fails on running at real 
time? tk event scheduling? I don't know.

--Jach

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


[issue26468] shutil.copy2 raises OSError if filesystem doesn't support chmod

2016-03-02 Thread Eric V. Smith

Eric V. Smith added the comment:

I agree that copy2 should not fail because chmod fails. Could you please 
provide the entire traceback message when it fails (on both 2.7 and 3.4 or 
3.5)? And what OS are you running on, and what filesystem?

It looks like the error happens because errno=95 (EOPNOTSUPP, probably) isn't 
in the list of errors that _copyxattr catches, while (ENOTSUP=134 on Linux) is.

I think the documentation is also incorrect. Of course copy2 can fail: what 
about out of disk space? I think the documentation is trying to say that copy2 
never fails because it can't preserve metadata. And the wording in the docs 
"copy2() never returns failure" is also odd, it should say "copy2() never 
raises an exception because it cannot preserve file metadata".

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python, eric.smith

___
Python tracker 

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



Re: What arguments are passed to the __new__ method ?

2016-03-02 Thread Steven D'Aprano
On Wed, 2 Mar 2016 08:23 pm, ast wrote:


> An other question:
> 
> What is the very first method launched when an instantiation is done ?
> e.g  obj = MyClass(0, 5, 'xyz')
> 
> is it __call__ (from object or MyClass if overriden) ?

No, not object or MyClass. The *metaclass* __call__ is called.

For most objects, the metaclass is `type`.

The metaclass is the type of the class: classes are objects too, which means
that like all objects, they have a class. That is the metaclass.


*** WARNING ***

Metaclasses are a very advanced technique. You are not expected to
understand this.



> then _call__ launches __new__ and then __init__
> This would be coherent with the language
> 
> or is it __new__ then __init__ as said on courses I read ?

Let us create a metaclass that inherits from `type`:



class Meta(type):
def __new__(meta, name, bases, namespace):
print "**Creating new Meta instance"
print "Metaclass:", meta
print "New class name:", name
print "Base classes used:", bases
print "Namespace used as class dict:", namespace
return type.__new__(meta, name, bases, namespace)
def __init__(cls, *args):
print "**Initialising Meta instance %s" % cls
def __call__(cls):
print "**Calling Meta instance %s" % cls
return super(Meta, cls).__call__()



Now let me use that metaclass to create a new class:

class MyClass(object):
__metaclass__ = Meta
def __new__(cls):
print "^^Creating new instance of %s" % cls
return super(MyClass, cls).__new__(cls)
def __init__(self):
print "^^Initialising MyClass instance %s" % self
def __call__(self):
print "^^Calling MyClass instance %s" % self
return "Hello World!"



which prints:

**Creating new Meta instance
Metaclass: 
New class name: MyClass
Base classes used: (,)
Namespace used as class dict: {'__call__': , '__module__': '__main__', '__metaclass__':
, '__new__': , '__init__': }
**Initialising Meta instance 


Now let me create a new MyClass instance:

instance = MyClass()


which prints:

**Calling Meta instance 
^^Creating new instance of 
^^Initialising MyClass instance <__main__.MyClass object at 0xb7cf2bec>


Finally, let me call the instance:

print instance()



which prints:


^^Calling MyClass instance <__main__.MyClass object at 0xb7cf2bec>
Hello World!



-- 
Steven

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


Re: Explaining names vs variables in Python

2016-03-02 Thread Salvatore DI DIO
Thank you very much ast and all of you. 

I better understant now

Regards

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


[issue17873] _ctypes/libffi missing bits for aarch64 support

2016-03-02 Thread Berker Peksag

Berker Peksag added the comment:

This has been fixed as part of updating libffi in issue 22176: 
https://github.com/python/cpython/blob/master/Modules/_ctypes/libffi/fficonfig.py.in#L20

Thanks for the report and for the patch, Andreas!

--
nosy: +berker.peksag
resolution:  -> out of date
stage: patch review -> 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



Re: Explaining names vs variables in Python

2016-03-02 Thread ast


"Salvatore DI DIO"  a écrit dans le message de 
news:a894d5ed-d906-4ff7-a537-32bf0187e...@googlegroups.com...



It is a little difficult to explain this behavior to a newcommer in Python
Can someone give me the right argument to expose ?



It is explained with many details here:
http://blog.lerner.co.il/why-you-should-almost-never-use-is-in-python/ 


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


Explaining names vs variables in Python (follow)

2016-03-02 Thread Salvatore DI DIO
Thank you very much all of you.
I better understand now

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


[issue26466] cannot build python 2.7.11 on AIX

2016-03-02 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

Does Python 2.7.10 build fine ? If so, then perhaps xlc doesn't
like the computed gotos in ceval.c.

You could try compiling with:

./configure ... --without-computed-gotos ...

to check.

--
nosy: +lemburg

___
Python tracker 

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



[issue13492] ./configure --with-system-ffi=LIBFFI-PATH

2016-03-02 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution:  -> out of date
stage: needs patch -> 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



Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Wed, 2 Mar 2016 08:03 pm, Jesper K Brogaard wrote:

> As I understand it, when you use 'is', you are comparing addresses to
> objects, not the values contained in the objects. Use '==' instead.

You should not think about addresses, because the location of objects is not
part of the language. It is implementation-dependent.

In CPython, objects are fixed to a single location in the heap, and will
never move. But in Jython and IronPython, objects in the python layer are
based on JVM (Java Virtual Machine) and CLR (Common Language Runtime)
objects, which can move around in memory. Both the JVM and the CLR can move
objects, so the location is not constant. Likewise for PyPy, which can
delete and re-create objects behind the scenes, possibly in different
memory locations.

This is why the id() function is NOT documented as returning the address of
an object, but of returning an ID number. Let's look at IDs in IronPython:

>>> a, b, c = [], 1, "Hello world!"
>>> print id(a), id(b), id(c), id(None)
43 44 45 0


And in Jython:

>>> a, b, c = [], 1, "Hello world!"
>>> print id(a), id(b), id(c), id(None)
1 2 3 4




-- 
Steven

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


[issue25660] tabs don't work correctly in python repl

2016-03-02 Thread Berker Peksag

Changes by Berker Peksag :


--
status: open -> closed

___
Python tracker 

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



[issue22176] update internal libffi copy to 3.1, introducing AArch64 and POWER ELF ABIv2

2016-03-02 Thread Berker Peksag

Changes by Berker Peksag :


--
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



Re: Reason for not allowing import twice but allowing reload()

2016-03-02 Thread Rustom Mody
On Wednesday, March 2, 2016 at 3:45:28 PM UTC+5:30, Rustom Mody wrote:
> On Wednesday, March 2, 2016 at 7:53:10 AM UTC+5:30, Ian wrote:
> > On Tue, Mar 1, 2016 at 6:19 PM, Steven D'Aprano wrote:
> > > On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote:
> > >
> > >> There's a big difference between
> > >> that and clocking a year of uptime just because you can, though.
> > >
> > > What other reason is there for having a year of uptime?
> > >
> > > It's not like it is difficult. My laptop doesn't actually go anywhere: for
> > > historical reasons, it's a laptop but it is (mostly) used as a desktop. It
> > > sits on my desk. If there's a power outage, the handy built-in UPS
> > > (battery) keeps it alive for an hour or two. I come in, I nudge the mouse
> > > to wake xscreensaver and authenticate; I do my work; then I run
> > > xscreensaver to lock the screen and leave.
> > >
> > > If I need access to something from home, I can SSH into the office 
> > > network,
> > > and from there into the laptop.
> > >
> > > The OS is as stable as the surface of the moon, and simply doesn't crash 
> > > or
> > > go down ever. (If only Firefox was as good, alas, but when it does crash 
> > > it
> > > is nearly always because I've allowed Javascript to run on some popular,
> > > multimedia-rich, information-free website.) I don't reboot because I don't
> > > need to reboot. Why would you reboot just for the sake of rebooting?
> > 
> > Software updates? The nice thing about *nix systems is that *most*
> > updates don't require a reboot. I'm still going to reboot any time
> > there's a kernel update though, and those are fairly frequent. I could
> > read the patch notes to determine whether this new kernel version is
> > actually important, but it takes less of my time just to go ahead and
> > reboot.
> 
> Dunno what systems you folks use...
> My ubuntu(s) 15.10 seem to (my estimates not hard data)
> - update every couple of days
> - kernel/security updates every 2-3 weeks
> 
> "Stable as the surface of the moon"??
> Well thats strong
> The other day I 
> - aptitude purge-d the kernel I was running on
>   [I was trying to show off to someone that ubuntu would not allow that!]
> - machine kept running merrily but thereafter aptitude crashed
> - Until I rebooted an older kernel; installed the one I had removed and 
> rebooted to that

Right now as I write this a libssl security update.
No suggested reboot
But I should be rebooting if I were paranoid about security
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Explaining names vs variables in Python

2016-03-02 Thread Steven D'Aprano
On Wed, 2 Mar 2016 07:32 pm, Salvatore DI DIO wrote:

> Hello,
> 
> I know Python does not have variables, but names.
> Multiple names cant then be bound to the same objects.

Multiple names CAN be bound to the same object:

py> x = y = []
py> x is y
True
py> z = x
py> y.append("Hello world!")
py> z
['Hello world!']


So that is *three* names bound to the same list object.


> So this behavior
> 
 b = 234
 v = 234
 b is v
> True
> 
> according to the above that is ok

When I try that in different versions of Python, I get different results:

# Python 2.4
py> b = 234
py> v = 234
py> b is v
False

What you are seeing is a version-dependent optimization. Not all versions of
Python will behave the same way. The reason you can do that is that
integers are immutable objects and cannot be modified. So the Python
interpreter will cache some integers, and avoid creating new objects. So:

py> a, b = 50, 
py> c, d = 50, 
py> a is c  # the same object is reused for 50 each time
True
py> c is d  # new int objects are created for  each time
False


In Python 2.7, I think that the interpreter caches small ints from -1 to
255. But do not rely on this, because it is just an optimization and can
and will change from version to version.

You should never use `is` to test for equality. Use == to test for equality.
Use `is` *only* to test for object identity ("the same object").



-- 
Steven

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


Re: Reason for not allowing import twice but allowing reload()

2016-03-02 Thread Rustom Mody
On Wednesday, March 2, 2016 at 7:53:10 AM UTC+5:30, Ian wrote:
> On Tue, Mar 1, 2016 at 6:19 PM, Steven D'Aprano wrote:
> > On Wed, 2 Mar 2016 09:29 am, Ian Kelly wrote:
> >
> >> There's a big difference between
> >> that and clocking a year of uptime just because you can, though.
> >
> > What other reason is there for having a year of uptime?
> >
> > It's not like it is difficult. My laptop doesn't actually go anywhere: for
> > historical reasons, it's a laptop but it is (mostly) used as a desktop. It
> > sits on my desk. If there's a power outage, the handy built-in UPS
> > (battery) keeps it alive for an hour or two. I come in, I nudge the mouse
> > to wake xscreensaver and authenticate; I do my work; then I run
> > xscreensaver to lock the screen and leave.
> >
> > If I need access to something from home, I can SSH into the office network,
> > and from there into the laptop.
> >
> > The OS is as stable as the surface of the moon, and simply doesn't crash or
> > go down ever. (If only Firefox was as good, alas, but when it does crash it
> > is nearly always because I've allowed Javascript to run on some popular,
> > multimedia-rich, information-free website.) I don't reboot because I don't
> > need to reboot. Why would you reboot just for the sake of rebooting?
> 
> Software updates? The nice thing about *nix systems is that *most*
> updates don't require a reboot. I'm still going to reboot any time
> there's a kernel update though, and those are fairly frequent. I could
> read the patch notes to determine whether this new kernel version is
> actually important, but it takes less of my time just to go ahead and
> reboot.

Dunno what systems you folks use...
My ubuntu(s) 15.10 seem to (my estimates not hard data)
- update every couple of days
- kernel/security updates every 2-3 weeks

"Stable as the surface of the moon"??
Well thats strong
The other day I 
- aptitude purge-d the kernel I was running on
  [I was trying to show off to someone that ubuntu would not allow that!]
- machine kept running merrily but thereafter aptitude crashed
- Until I rebooted an older kernel; installed the one I had removed and 
rebooted to that
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26466] cannot build python 2.7.11 on AIX

2016-03-02 Thread Michael Felt

Michael Felt added the comment:

Patched to fp22: vacpp.11.1.0.22.aix53TL7-71.sept2015.ptf.tar.Z

after reinstalling system! to be sure no garbage left around.

Only updates are openSSL/SSH packages; no RPM's installed.

Same error message(s).

Tried compiling ceval.o with -O0 (capt. O, zero) - same messages

Tried linking with .o files only (no archive) - effectively, same message.
root@x064:[/data/prj/aixtools/python-2.7.11]xlc  -o python  Modules/python.o 
Python/*.o
ld: 0711-596 SEVERE ERROR: Object Python/ceval.o
An RLD for section 2 (.data) refers to symbol 0,
but the storage class of the symbol is not C_EXT or C_HIDEXT.
ld: 0711-596 SEVERE ERROR: Object Python/ceval.o
An RLD for section 2 (.data) refers to symbol 0,
but the storage class of the symbol is not C_EXT or C_HIDEXT.

Maybe xlc does not know how to code the differences

snip:
diff -u ./python-2.7.10/Python/ceval.c ./python-2.7.11/Python/ceval.c | head -50
michael@x071:[/data/prj/aixtools/src]ython-2.7.11/Python/ceval.c | head -50<
--- ./python-2.7.10/Python/ceval.c  2015-05-23 16:09:24 +
+++ ./python-2.7.11/Python/ceval.c  2015-12-05 19:47:19 +
@@ -615,7 +615,7 @@
to guarantee that _Py_CheckRecursiveCall() is regularly called.
Without USE_STACKCHECK, there is no need for this. */
 int
-_Py_CheckRecursiveCall(char *where)
+_Py_CheckRecursiveCall(const char *where)
 {
 PyThreadState *tstate = PyThreadState_GET();
 
@@ -688,6 +688,100 @@
 PyObject *
 PyEval_EvalFrameEx(PyFrameObject *f, int throwflag)
 {
+#ifdef DYNAMIC_EXECUTION_PROFILE
+  #undef USE_COMPUTED_GOTOS
+#endif
+#ifdef HAVE_COMPUTED_GOTOS
+#ifndef USE_COMPUTED_GOTOS
+#define USE_COMPUTED_GOTOS 1
+#endif
+#else
+#if defined(USE_COMPUTED_GOTOS) && USE_COMPUTED_GOTOS
+#error "Computed gotos are not supported on this compiler."
+#endif
+#undef USE_COMPUTED_GOTOS
+#define USE_COMPUTED_GOTOS 0
+#endif
+#if USE_COMPUTED_GOTOS
+/* Import the static jump table */
+#include "opcode_targets.h"
+
+  /* This macro is used when several opcodes defer to the same implementation
+   (e.g. SETUP_LOOP, SETUP_FINALLY) */
+#define TARGET_WITH_IMPL(op, impl) \
+TARGET_##op: \
+opcode = op; \
+oparg = NEXTARG(); \
+case op: \
+goto impl; \
+
+#define TARGET_WITH_IMPL_NOARG(op, impl) \
+TARGET_##op: \
+opcode = op; \
+case op: \
+goto impl; \
+
+#define TARGET_NOARG(op) \
+TARGET_##op: \

In "character" a big change from 2.7.8 to 2.7.10
michael@x071:[/data/prj/aixtools/python]diff -u ./old/Python-2.7.8/Python/ceval>
--- ./old/Python-2.7.8/Python/ceval.c   2014-06-30 02:05:46 +
+++ ./old/Python-2.7.10/Python/ceval.c  2015-05-23 16:09:24 +
@@ -66,9 +66,11 @@
even in 64-bit mode, we need to use "a" and "d" for the lower and upper
32-bit pieces of the result. */
 
-#define READ_TIMESTAMP(val) \
-__asm__ __volatile__("rdtsc" : \
- "=a" (((int*)&(val))[0]), "=d" (((int*)&(val))[1]));
+#define READ_TIMESTAMP(val) do {\
+unsigned int h, l;  \
+__asm__ __volatile__("rdtsc" : "=a" (l), "=d" (h)); \
+(val) = ((uint64)l) | (((uint64)h) << 32);  \
+} while(0)
 
 
 #else
@@ -355,12 +357,6 @@
 if (interpreter_lock) {
 int err = errno;
 PyThread_acquire_lock(interpreter_lock, 1);
-/* _Py_Finalizing is protected by the GIL */
-if (_Py_Finalizing && tstate != _Py_Finalizing) {
-PyThread_release_lock(interpreter_lock);
-PyThread_exit_thread();
-assert(0);  /* unreachable */
-}
 errno = err;
 }
 #endif
@@ -1025,12 +1021,6 @@
 
 PyThread_acquire_lock(interpreter_lock, 1);
 
-/* Check if we should make a quick exit. */
-if (_Py_Finalizing && _Py_Finalizing != tstate) {
-PyThread_release_lock(interpreter_lock);
-PyThread_exit_thread();
-}
-
 if (PyThreadState_Swap(tstate) != NULL)
 Py_FatalError("ceval: orphan tstate");
 
@@ -1957,9 +1947,13 @@
 if (err == 0) continue;
 break;
 }
+t = PyObject_Repr(w);
+if (t == NULL)
+break;
 PyErr_Format(PyExc_SystemError,
  "no locals found when storing %s",
- PyObject_REPR(w));
+ PyString_AS_STRING(t));
+Py_DECREF(t);
 break;
 
 case DELETE_NAME:
@@ -1971,9 +1965,13 @@
  w);
 break;
 }
+t = PyObject_Repr(w);
+if (t == NULL)
+break;
 PyErr_Format(PyExc_SystemError,
  "no locals when deleting %s",
- 

[issue26469] Bug in ConfigParser when setting new values in extended interpolation

2016-03-02 Thread Michael Jacob

Michael Jacob added the comment:

My bad.

ConfigParser expects an interpolation object, not a class.

Instead of c=ConfigParser(interpolation=ExtendedInterpolation)

you need to create it with:

c=ConfigParser(interpolation=ExtendedInterpolation())

Sorry about that.

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

___
Python tracker 

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



Re: Everything good about Python except GUI IDE?

2016-03-02 Thread Gordon Levi
Marko Rauhamaa  wrote:

>Gordon Levi :
>
>> Nobody likes filling in forms but how do you suggest converting a form
>> based app into something loveable.
>
>Straight HTML does forms just fine without CSS or JavaScript, yet few
>can resist.
>
>> What interface would make you love adding a new contact to your
>> address book?
>
>In my case, the address book is a ~/.mailrc file, which I edit using
>emacs.

I find it difficult to believe that you _love_ updating your contacts
using Emacs even if it gives you an excuse to get some therapy from
Eliza. It seems equally unlikely that you can do without phone numbers
and addresses for your contacts.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26469] Bug in ConfigParser when setting new values in extended interpolation

2016-03-02 Thread Michael Jacob

New submission from Michael Jacob:

There seems to be a bug in configparser when setting new values in extended 
interpolation:

python --version
Python 3.5.1

from configparser import ConfigParser, ExtendedInterpolation
c=ConfigParser(interpolation=ExtendedInterpolation)
c.add_section('test')
c.set('test', 'key', 'value')
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python3.5/configparser.py", line 1190, in set
super().set(section, option, value)
  File "/usr/lib/python3.5/configparser.py", line 891, in set
value)
TypeError: before_set() missing 1 required positional argument: 'value'

It works ithout extended interpolation, though.

--
components: Library (Lib)
messages: 261101
nosy: Michael Jacob
priority: normal
severity: normal
status: open
title: Bug in ConfigParser when setting new values in extended interpolation
type: crash
versions: Python 3.5

___
Python tracker 

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



Re: Explaining names vs variables in Python

2016-03-02 Thread Jussi Piitulainen
Salvatore DI DIO writes:

[- -]

> But where is the consistency ? if I try :
>
 v = 890
 w = 890
 v is w
> False

I think it goes as follows.

Python keeps a cached pool of some numbers that may occur relatively
often. When a numerical expression evaluates to a cached value, it
returns the cached object instead.

>>> 1 + 1 is 2
True
>>> 800 + 90 + 0 is 890
False

This way programs don't fill the memory with a large number of copies of
frequently occurring numbers like 2, and also don't keep rare numbers
like 890 around in the cache unnecessarily.

Python doesn't keep track of how often numbers actually occur. I think
it considers 0, 1, 2, ..., n, up to some rather small n, heuristically
frequent, and that's it. Also, this is an implementation detail.

Hm, -5, -4, -3, -2, -1 also seem cached when I try them, but -6 not.

The following are too delicate for me. I suppose the answers could have
been different, but I can't guess what mechanism actually leads to these
results. Just idle curiosity on my part.

>>> 890 is 890
True
>>> id(890) == id(890)
True

>>> 890 is 891
False
>>> id(890) == id(891)
False

Python 3.4.3 (default, Oct 14 2015, 20:33:09) 
[GCC 4.8.4] on linux
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: What arguments are passed to the __new__ method ?

2016-03-02 Thread ast


"ast"  a écrit dans le message de 
news:56d5d043$0$632$426a7...@news.free.fr...

ty  for the détailed explanations.


An other question:

What is the very first method launched when an instantiation is done ?
e.g  obj = MyClass(0, 5, 'xyz')

is it __call__ (from object or MyClass if overriden) ?
then _call__ launches __new__ and then __init__
This would be coherent with the language

or is it __new__ then __init__ as said on courses I read ?




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


[issue26468] shutil.copy2 raises OSError if filesystem doesn't support chmod

2016-03-02 Thread Vojtěch Pachol

New submission from Vojtěch Pachol:

`copy2` checks if `os` nodule has `chmod` and then it uses it without thinking. 

On filesystems that doesn't support `chmod` it ends with

OSError: [Errno 95] Operation not supported: 

which is not acceptable since documentation says "copy2() never returns 
failure".

--
components: Library (Lib)
messages: 261100
nosy: Vojtěch Pachol
priority: normal
severity: normal
status: open
title: shutil.copy2 raises OSError if filesystem doesn't support chmod
versions: Python 2.7, Python 3.4, Python 3.5

___
Python tracker 

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



Effects of caching frequently used objects, was Re: Explaining names vs variables in Python

2016-03-02 Thread Peter Otten
Salvatore DI DIO wrote:

> Hello,
> 
> I know Python does not have variables, but names.
> Multiple names cant then be bound to the same objects.
> 
> So this behavior
> 
 b = 234
 v = 234
 b is v
> True
> 
> according to the above that is ok
> 
> 
> 
> But where is the consistency ? if I try :
> 
 v = 890
 w = 890
 v is w
> False
> 
> It is a little difficult to explain this behavior to a newcommer in Python
> 
> Can someone give me the right argument to expose ?

You should not bother with object identity for objects other than None.
Some small integers are used a lot, e. g.

Python 3.4.3 (default, Oct 14 2015, 20:28:29) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.getrefcount(0)
606
>>> sys.getrefcount(1)
918
>>> sys.getrefcount(256)
31
>>> sys.getrefcount(-1)
51

therefore as an optimization the Python developers decided to put -5...256 
(actual range may vary across interpreter versions) into a cache and reuse 
them rather than build a new object for every instance. This may save both 
time and memory, but is otherwise irrelevant.

Something similar is done for strings:

>>> a = "hello"
>>> b = "hello"
>>> a is b
True
>>> a = "hello, world"
>>> b = "hello, world"
>>> a is b
False

But:

>>> a = "hello, world"; b = "hello, world"
>>> a is b
True

Again this is an optimization (mostly targeted at attribute names) which 
should not affect the behaviour of a properly written Python program.

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


Re: Explaining names vs variables in Python

2016-03-02 Thread Antoon Pardon
On 02/03/2016 09:32, Salvatore DI DIO wrote:
> Hello,
>
> I know Python does not have variables, but names.
> Multiple names cant then be bound to the same objects.
>
> So this behavior 

Python has variables. They are just not the kind of variables
you find in C and variations but more like variables in lisp,
scheme and smalltalk.
 

 b = 234
 v = 234
 b is v
> True
>
> according to the above that is ok

No that is just a coincidence. A consequent of the particular
implimentation, that has prepared a number of number objects
beforehand. There is no guarantee in the language that the
third statement above will produce True.

> But where is the consistency ? if I try :
>
 v = 890
 w = 890
 v is w
> False
>
> It is a little difficult to explain this behavior to a newcommer in Python.

This behaviour is undefined in the language. So there is nothing to explain
except that it depends on implementation details. Any program that depends
on two variable being the same or not the after similar code is wrong.

-- 
Antoon Pardon

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


Re: Explaining names vs variables in Python

2016-03-02 Thread Jesper K Brogaard

Den 02-03-2016 kl. 09:32 skrev Salvatore DI DIO:

Hello,

I know Python does not have variables, but names.
Multiple names cant then be bound to the same objects.

So this behavior


b = 234
v = 234
b is v

True

according to the above that is ok



But where is the consistency ? if I try :


v = 890
w = 890
v is w

False

It is a little difficult to explain this behavior to a newcommer in Python

Can someone give me the right argument to expose ?

Regards



You may get an answer to your question here: 
http://stackoverflow.com/questions/2419701/python-object-identity-question


As I understand it, when you use 'is', you are comparing addresses to 
objects, not the values contained in the objects. Use '==' instead.


Take a look here as well: 
https://docs.python.org/3.5/reference/datamodel.html


--
Venlig hilsen / Best regards
Jesper K. Brogaard

(remove upper case letters in my e-mail address)
--
https://mail.python.org/mailman/listinfo/python-list


Explaining names vs variables in Python

2016-03-02 Thread Salvatore DI DIO
Hello,

I know Python does not have variables, but names.
Multiple names cant then be bound to the same objects.

So this behavior 

>>> b = 234
>>> v = 234
>>> b is v
True

according to the above that is ok



But where is the consistency ? if I try :

>>> v = 890
>>> w = 890
>>> v is w
False

It is a little difficult to explain this behavior to a newcommer in Python

Can someone give me the right argument to expose ?

Regards

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


Re: Everything good about Python except GUI IDE?

2016-03-02 Thread Marko Rauhamaa
Chris Angelico :

> On Wed, Mar 2, 2016 at 4:41 PM, Marko Rauhamaa  wrote:
>> I was talking about JSON for the standard I/O, not the command-line
>> arguments, as in:
>>
>>ps -ef | awk '/httpd/ { print $2 }'
>>
>> where "ps -ef" emits SPC-separated fields and LF-separated records, and
>> awk parses and processes them.
>
> If you want to change that, you have to change the entire ecosystem,
> not just the shell. You would have to teach every single program to
> use a different structure.

Correct. There could be translation utilities in the interim.

> A lot of programs already do support NUL-separation - usually with a
> -z parameter or something. But you won't be able to magically get them
> all to use JSON. And I doubt it would be advantageous anyway.

The advantages are obvious. Barely any programs do proper escaping, and
security problems abound.

Maybe a starting point would be a Python Toybox (https://en.wikipedia.org/wiki/Toybox>).

Ecosystem intertia aside, key to the success of such an endeavor would
be to find a Python equivalent for

   ps -ef | awk '/httpd/ { print $2 }'

that would be at least as convenient for the fingers and the eye.


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


[issue26466] cannot build python 2.7.11 on AIX

2016-03-02 Thread Michael Felt

Michael Felt added the comment:

At first I thought it might be a 0x0001 rather than 0x0003 (as I have no idea 
what the additional info is AND that the lines starting with [0] are the Symbol 
0 (zero) you indicate the message.

Also thought it might have been the double listing of some symbols where both 
the 'm' and the 'a4' lines start with 0x (but see those for other .o 
files as well)

And I verified that the .o file (outside the archive) also has '[705]' entries.

Need more guidance. I get neither heads nor tails...

So, dump -t libpython2.7.a snips:

libpython2.7.a[getbuildinfo.o]:

***Symbol Table Information***
[Index] mValue   Scn   Aux  SclassTypeName
[Index] a0Fname
[Index] a1  Tagndx  Lnno  Size  LnoptrEndndx
[Index] a2  TagndxFsiz  LnoptrEndndx
[Index] a3  Tagndx  Lnno  Size  Dimensions
[Index] a4   CSlen PARMhsh SNhash SMtype SMclass Stab SNstab
[Index] a5  SECTlen#RELent#LINnums

[0] m   0x-2 30x67 0x0003 .file
[1] a0
../src/python-2.7.11/Modules/getbuildinfo.c
[2] a0Tue Mar  1 
18:47:41 2016 
[3] a0IBM XL C for 
AIX, Version 11.1.0.20
[4] m   0x 1 10x03 0x .text
[5] a5  0x0180 0x000b 0x
[6] m   0x0180 2 10x03 0x .data
[7] a5  0x00c4 0x000e 0x
[8] m   0x0244 3 10x03 0x .bss
[9] a5  0x0034 0x 0x
[10]m   0x 1 10x6b 0x **No Symbol**
[11]a4  0x0180   00 57000
[12]m   0x 1 10x02 0x0020 ._Py_hgversion
[13]a4  0x000a   00  2000
[14]m   0x0020 1 10x02 0x0020 
._Py_hgidentifier
[15]a4  0x000a   00  2000
[16]m   0x0040 1 10x02 0x0020 
._Py_svnversion
[17]a4  0x000a   00  2000
[18]m   0x0060 1 10x02 0x0020 
.Py_GetBuildInfo
[19]a4  0x000a   00  2000
[20]m   0x0180 2 10x6b 0x TOC
[21]a4  0x   00 17   1500
[22]m   0x0184 2 10x6b 0x **No Symbol**
[23]a4  0x0004   00 17300
[24]m   0x01c8 2 10x6b 0x **No Symbol**
[25]a4  0x0079   00 33100
[26]m   0x0244 3 10x6b 0x _$STATIC_BSS
[27]a4  0x0034   00 35500
[28]m   0x0194 2 10x6b 0x _$STATIC_BSS
[29]a4  0x0004   00 17300
[30]m   0x0198 2 10x02 0x _Py_hgversion
[31]a4  0x000c   00 17   1000
[32]m   0x0180 2 10x6b 0x _Py_hgversion
[33]a4  0x0004   00 17300
[34]m   0x01a4 2 10x02 0x 
_Py_hgidentifier
[35]a4  0x000c   00 17   1000
[36]m   0x0188 2 10x6b 0x 
_Py_hgidentifier
[37]a4  0x0004   00 17300
[38]m   0x01b0 2 10x02 0x _Py_svnversion
[39]a4  0x000c   00 17   1000
[40]m   0x018c 2 10x6b 0x _Py_svnversion
[41]a4  0x0004   00 17300
[42]m   0x01bc 2 10x02 0x 
Py_GetBuildInfo
[43]a4  0x000c   00 17   1000
[44]m   0x0190 2 10x6b 0x 
Py_GetBuildInfo
[45]a4  0x0004   00 17300
[46]m   0x 0 10x02 0x .PyOS_snprintf
[47]a4  0x   00  0000

libpython2.7.a[acceler.o]:

***Symbol Table Information***
[Index] mValue   Scn   Aux  SclassTypeName
[Index] a0Fname
[Index] a1  Tagndx  Lnno  Size  LnoptrEndndx
[Index] a2  TagndxFsiz  LnoptrEndndx
[Index] a3  Tagndx  Lnno  Size  Dimensions
[Index] a4   CSlen PARMhsh SNhash SMtype SMclass Stab SNstab
[Index] a5 

Re: rdflib subclass problem

2016-03-02 Thread dieter
duncan smith  writes:

>   I'm just getting to grips with RDF and rdflib, and I've hit
> something I can't figure out.
>
> I have a graph with information on two people. (I haven't shown the
> imports below because they're scattered around my interactive session
> and I might reconstruct them incorrectly. Anyone familiar with rdflib
> will probably know what they are.)
>
>
 G = Graph()
 mark = BNode()
 nat = BNode()
 G.add((mark, RDF.type, FOAF.Person))
 G.add((mark, FOAF.firstName, Literal('mark')))
 G.add((nat, RDF.type, URIRef('Professor')))
 G.add((nat, FOAF.firstName, Literal('natalie')))
 G.add((URIRef('Professor'), RDFS.subClassOf, FOAF.Person))

>
>
> So I have specified that mark is a Person, natalie is a Professor, and
> that Professor is a subclass of Person. (I know that Professor is really
> a FOAF.title, but I'm just tinkering ATM.)
>
>
 qres = G.query(
> """SELECT DISTINCT ?aname
>WHERE {
>   ?a rdf:type foaf:Person .
>   ?a foaf:firstName ?aname .
>}""", initNs = {"rdf": RDF,"foaf": FOAF})
 for row in qres:
>   print "%s is a person" % row
>
>   
> mark is a person
 qres = G.query(
> """SELECT DISTINCT ?aname
>WHERE {
>   ?a rdf:type ?prof .
>   ?a foaf:firstName ?aname .
>}""", initNs = {"rdf": RDF,"foaf": FOAF, "prof":
> URIRef('Professor')})
 for row in qres:
>   print "%s is a Prof" % row
>
>   
> natalie is a Prof
> mark is a Prof

>
>
> But according to the above queries only mark is a Person, and each is a
> Professor. I would have thought that both would be Persons and only
> natalie would be a Professor. Can anyone spot where I'm going wrong
> here? Thanks.

What you observe would be consistent with "RDFS.subClassOf" working
in the other direction than the one you expect; i.e. that

   URIRef('Professor'), RDFS.subClassOf, FOAF.Person

means that "Person" is a subclass of "Professor" (not what
you expect, that "Professor" is a subclass of "Person").

Carefully check whether "A rel B" means that "B" is in relation "rel" to "A"
(I think that is the case) or that "A" is in relation "rel" to "B".

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


<    1   2