IndexError: list index out of range

2016-12-12 Thread Elnaz
hi
i am begginer in python. I have written a code and given this error:
IndexError: list index out of range

In my program, I have h=32 bits input. i divide this 32 bits to 4*8 block and 
every 8-block is n. so n=0:7;(h=int(n/4))
I want to rotate 0 to 7 bits for 2 bits: 0,1,2,3,4,5,6,7--->2,3,4,5,6,7
Iwrite this code:
def rottwo(self, X, n, r):
assert r >= 1
temp = [None]*n
for i in range(n-r) :
temp[i] = X[i+r]
for i in range(n-r,n) :
temp[i] = X[i-n+r]
return temp
this function work correctly. but I also want to rotate 24 to 31 bits for 5 
bits: 24,25,26,27,28,29,30,31-->29,30,31,24,25,26,27,28

when I write this code:
def rotfive(self, X, n, r):
   assert r >= 1
   temp = [None]*n
   for i in range(n-r) :
temp[i+24] = X[i+3*n+r]
   for i in range(n-r,n) :
temp[i+24] = X[i+2*n+r]
   return temp 
beacase temp is of size n I cannot access index 3*n+i. index on the list temp 
should be less than equal to n-1 . 
I son't know how I must correct this
Is there any one to help me?
thanks in advanse.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28512] PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject() always set the offset attribute to None

2016-12-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ah, it was a remnants of backporting to 3.5. Commented-out lines are used in 
3.6. The line above these lines was used in 3.5. Test is passed with both 
variants. I commented out the 3.6 variant, but forgot to remove it (or remove 
old 3.5 variant and keep 3.6 variant). Do you think I should remove commented 
out lines, or left the code as is?

--

___
Python tracker 

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



Nested functions, how do they work (stack related)

2016-12-12 Thread Veek M
I was reading the wiki on 'Call stack' because I wanted to understand 
what a traceback object was. My C/C++ isn't good enough to deal with raw 
python source since I have no background in CS. Also, you just can't 
dive into the python src - it takes a good deal of reading and 
background.. (the types will be confusing for a start)

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

'Programming languages that support nested subroutines also have a field 
in the call frame that points to the stack frame of the latest 
activation of the procedure that most closely encapsulates the callee, 
i.e. the immediate scope of the callee. This is called an access link or 
static link (as it keeps track of static nesting during dynamic and 
recursive calls) and provides the routine (as well as any other routines 
it may invoke) access to the local data of its encapsulating routines at 
every nesting level. 

Some architectures, compilers, or optimization cases store one link for 
each enclosing level (not just the immediately enclosing), so that 
deeply nested routines that access shallow data do not have to traverse 
several links; this strategy is often called a "display".'

1. What is the difference between a 'call frame' and a 'stack frame' in 
the above context? I know that a stack frame is all the data related to 
one - CALL foo; 

2. He's saying that within the 'call frame' (whatever that is) there's 
an address to one of the previous stack frames of the wrapper function ? 
What does all that mean in terms of nested functions? Access link? How 
are nested function stacks setup..

3. What exactly is a traceback object - we know that an instance object 
is a dictionary and some glue logic that allows you to pretend that 
methods are stored within the instance and call using x.sin(self) etc.
But I was reading: pydoc traceback AND:
http://effbot.org/librarybook/traceback.htm

'Extract the raw traceback from the current stack frame'
A stack frame contains (from wiki) the parameters, local variables, next 
instruction address so.. what's a raw traceback - does the default 
exception handler realize 'okay error' and then walk the stack and 
extract data and prettify it for display and build a magical traceback 
object? Is this documented for dummies what exactly it does?
(i know that's what it's doing but I HAVE NO CLUE so.. are there books 
on this)

How exactly does an exception fit in with tracebacks? How does all this 
fit in with nested functions? 

4. When you call a nested function (decorator), it generally returns a 
wrapper function but I thought he was just returning a reference to a 
function object but obviously since it can see it's environment, how is 
the stack being setup?


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


[issue28948] Facing issue while running Python 3.6.0rc1 windows x86-64 web based installer

2016-12-12 Thread arpit arora

arpit arora added the comment:

Hi Steve,

I only installed the mentioned version and if there is any update for the same 
then i may not be aware of that.

Thanks & Regards
Arpit Arora

--

___
Python tracker 

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



[issue28958] Python should return comperhansive error when SSLContext cannot be created

2016-12-12 Thread Ilya Kulakov

New submission from Ilya Kulakov:

When SSLContext cannot be created, python raises an SSLError exception with 
"failed to allocate SSL context".

https://hg.python.org/cpython/file/4def2a2901a5/Modules/_ssl.c#l2260

This is completely useless to debug the error. In fact many errors raised from 
_ssl.c are non-helpful.

Python's SSLError should be extended to include comprehensive information about 
OpenSSL's error stack which can be extracted with `ERR_get_error_line`.

--
assignee: christian.heimes
components: SSL
messages: 283078
nosy: Ilya.Kulakov, christian.heimes
priority: normal
severity: normal
status: open
title: Python should return comperhansive error when SSLContext cannot be 
created
type: enhancement
versions: 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



[issue26110] Speedup method calls 1.2x

2016-12-12 Thread INADA Naoki

INADA Naoki added the comment:

> Technically the patch LGTM. But we should find the cause of the regression in 
> some benchmarks.

The benchmark is on Sandy Bridge (Core i5 2400) and I didn't use PGO build.
perf_event reported branch-miss rate increase at cpickle's save function.

I'll rerun benchmark with PGO build. I hope PGO is friendly with CPU branch
prediction, like L1/L2 cache.

Anyway, recent amd64 CPUs have more large branch history.

> And would be nice to extend the optimization to C functions.
> In any case this optimization is worth mentioning in What's New.

I'll do them.

--

___
Python tracker 

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



Re: Method to know if object support being weakreferenced ?

2016-12-12 Thread Gregory Ewing

Matthias Bussonnier wrote:

I search for a method
capable of telling me whether an object can be weakreferenced.


Objects that can be weakly referenced have a __weakref__ attribute.
So you could use hasattr(obj, '__weakref__').

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


[issue28933] AC: Accept None as a Py_ssize_t default value

2016-12-12 Thread Julien Palard

Julien Palard added the comment:

Hi Larry,

Do you mean a new converter in clinic.py like Nullable_Py_ssizze_t, or a 
converter that I copy/paste every time I need it like 
http://bugs.python.org/review/28754/patch/19417/76440 ?

--

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Gregory Ewing

Ned Batchelder wrote:

if a C++ constructor raises an exception, will the corresponding destructor
be run, or not? (No, because it never finished making an object of type T.)


So it just leaks any memory that's been allocated by
the partially-run constructor?

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


[issue26110] Speedup method calls 1.2x

2016-12-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Technically the patch LGTM. But we should find the cause of the regression in 
some benchmarks.

And would be nice to extend the optimization to C functions.

In any case this optimization is worth mentioning in What's New.

--

___
Python tracker 

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



[issue28957] undefined symbol: PyUnicodeUCS2_FromUnicode when executing any command with pip2.7

2016-12-12 Thread Ramakrishna Kommineni

New submission from Ramakrishna Kommineni:

Hi,

I have installed python from source in the directory 
/home/rkommine/software/python2.7.
During installation there are no errors seen.
I have added the below environment variables to my bashrc

export 
PATH=/home/rkommine/software/python2.7.12/bin:/home/rkommine/software/tcltk8.6.6/bin:$PATH
export 
LD_LIBBRARY_PATH=/home/rkommine/software/python2.7.12/lib:$LD_LIBBRARY_PATH

rkommine@rubuntu:~/Downloads$ which python2.7
/home/rkommine/software/python2.7.12/bin/python2.7
rkommine@rubuntu:~/Downloads$ python2.7 --version
Python 2.7.12
rkommine@rubuntu:~/Downloads$ which pip2.7
/home/rkommine/software/python2.7.12/bin/pip2.7

But when I execute any command with pip2.7 I am getting the below errors

rkommine@rubuntu:~/Downloads$ pip2.7 --version
Traceback (most recent call last):
  File "/home/rkommine/software/python2.7.12/bin/pip2.7", line 7, in 
from pip import main
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/__init__.py",
 line 16, in 
from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/vcs/subversion.py",
 line 9, in 
from pip.index import Link
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/index.py",
 line 30, in 
from pip.wheel import Wheel, wheel_ext
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/wheel.py",
 line 32, in 
from pip import pep425tags
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/pep425tags.py",
 line 9, in 
import ctypes
  File "/home/rkommine/software/python2.7.12/lib/python2.7/ctypes/__init__.py", 
line 7, in 
from _ctypes import Union, Structure, Array
ImportError: 
/home/rkommine/software/python2.7.12/lib/python2.7/lib-dynload/_ctypes.so: 
undefined symbol: PyUnicodeUCS2_FromUnicode
rkommine@rubuntu:~/Downloads$ pip2.7 install robotframework
Traceback (most recent call last):
  File "/home/rkommine/software/python2.7.12/bin/pip2.7", line 7, in 
from pip import main
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/__init__.py",
 line 16, in 
from pip.vcs import git, mercurial, subversion, bazaar  # noqa
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/vcs/subversion.py",
 line 9, in 
from pip.index import Link
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/index.py",
 line 30, in 
from pip.wheel import Wheel, wheel_ext
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/wheel.py",
 line 32, in 
from pip import pep425tags
  File 
"/home/rkommine/software/python2.7.12/lib/python2.7/site-packages/pip/pep425tags.py",
 line 9, in 
import ctypes
  File "/home/rkommine/software/python2.7.12/lib/python2.7/ctypes/__init__.py", 
line 7, in 
from _ctypes import Union, Structure, Array
ImportError: 
/home/rkommine/software/python2.7.12/lib/python2.7/lib-dynload/_ctypes.so: 
undefined symbol: PyUnicodeUCS2_FromUnicode
rkommine@rubuntu:~/Downloads$ 

Could you please help to fix this error?
Thanks in advance.

--
components: ctypes
files: Installation.Log.txt
messages: 283074
nosy: Ramakrishna Kommineni
priority: normal
severity: normal
status: open
title: undefined symbol: PyUnicodeUCS2_FromUnicode when executing any command 
with pip2.7
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file45869/Installation.Log.txt

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Chris Angelico
On Tue, Dec 13, 2016 at 4:45 PM, Steven D'Aprano
 wrote:
> I don't understand the point of bringing up Javascript. Ben has already said
> that we shouldn't feel the need to mindlessly copy C++ terminology. Is it your
> position that we *should* copy Javascript terminology? Why Javascript and not
> C++ or ObjectiveC? Even when it goes against the obvious English mnemonic?

I'm saying that ALL these terminology debates are needlessly pedantic.
Whatever word you use, you're going to have to explain the Python
semantics as distinct from everyone else's, so don't sweat it. Whether
we call __init__ the constructor or initializer, there is going to be
someone out there who misinterprets it. Go with whatever, pick the
easiest to explain (which is probably "__new__ is allocator, __init__
is initializer"), and don't try to burden the terms alone with the job
of explaining Python's semantics.

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


Re: Method to know if object support being weakreferenced ?

2016-12-12 Thread Steven D'Aprano
On Tuesday 13 December 2016 15:57, Matthias Bussonnier wrote:

[...]
> I could of course write a function that try/except and return False/True
> depending on the result, but that seem suboptimal as how can I know that the
> TypeError does come from not being able to take a weak reference ? And not
> from something else ?

Do you mean something like this?

try:
proxy = weakref.proxy(obj)
except TypeError:
proxy = None


Where else could it come from?

> The common Idiom in CPython, at the C layer seem to be
> PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob)). So I can (and did) write a C-extension
> that expose such a function, but it does seem silly that no one else did that
> before me, and that no one seemed to have encountered the problem before.
> 
> So am I missing something ? Is such a function not useful ?  Is there any
> reason not to have it in the stdlib ?

You could try raising a feature request on the bug tracker.



-- 
Steven
"Ever since I learned about confirmation bias, I've been seeing 
it everywhere." - Jon Ronson

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


Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Steven D'Aprano
On Tuesday 13 December 2016 10:23, Chris Angelico wrote:

> On Tue, Dec 13, 2016 at 10:17 AM, Ben Finney 
> wrote:
>> If the differences didn't matter I would agree that “overly pedantic” is
>> fair. But those differences trip up newcomers. Thinking of
>> ‘Foo.__init__’ leads people to wonder where the ‘self’ attribute came
>> from – am I not meant to be constructing it? — and to attempt to return
>> that instance. And when the time comes to lean about ‘__new__’ the
>> confusion continues, because the newcomer has been told that something
>> *else* is the constructor, so what's this?
> 
> In JavaScript, it's normal to talk about "calling a function as a
> constructor". When you do, there is a 'this' object before you start.
> Should we tell the JavaScript folks to be more pedantic, because
> 'this' should end up existing? 

You've ignored Ben's critical point that if we call __init__ the "constructor", 
what do we call __new__? (Perhaps we should call __new__ the "initialiser" for 
maximum confusion.)

I don't understand the point of bringing up Javascript. Ben has already said 
that we shouldn't feel the need to mindlessly copy C++ terminology. Is it your 
position that we *should* copy Javascript terminology? Why Javascript and not 
C++ or ObjectiveC? Even when it goes against the obvious English mnemonic?

__init__ is the INITialiser (it initialises an existing instance);

__new__ creates/constructs a NEW instance


> Does it really even matter when memory
> gets allocated and the object's identity assigned? 

Actually, yes it does. Try constructing an immutable object like a subclass of 
float, str or int from the __init__ method. Attaching attributes to the 
instance doesn't count.


class PositiveInt(int):
def __init__(self, arg):
arg = abs(arg)
return super().__init__(self, arg)


So much fail...



> Before __init__
> gets called, the object isn't "truly there" - its fundamental
> invariants may not yet have been established, and key attributes might
> not have been set up.

"Fundamental invariants" is tricky though -- are they *truly* fundamental? This 
is Python -- I can easily make a Python-based class that lacks the attributes 
that its methods assume will be there, or delete them after creation.

But there is one thing which truly is fundamental: the instance creation, the 
moment that object.__new__ returns a new instance. Before calling that, the 
instance genuinely doesn't exist; after object.__new__ returns, it genuinely 
does. (Even if it isn't fully initialised.)

Unlike __init__, object.__new__ is atomic: it either succeeds, or it doesn't. 
So object.__new__ really is the constructor of instances, and so following 
standard practice, MyClass.__new__ which inherits from object ought to be 
called the same thing. (Even if it is no longer atomic, due to being written in 
Python.)


> Once __init__ finishes, there is an expectation
> that attributes and invariants are sorted out.
> 
> This is like the old "Python doesn't have variables" thing.
> Ultimately, every language has slightly different semantics (otherwise
> they'd be trivial transformations, like Ook and Brainf*), so you have
> to learn that the "constructor" might have slightly different
> semantics. Accept it - embrace it. Learn it.

We're not debating what other languages should call __new__ and __init__ or 
whatever their equivalents are. We're debating what Python should call them.

For some prior art, consider ObjectiveC. To create a new instance of a class, 
you call:

[[MyClass alloc] init]

where alloc is the "allocator" (it basically just allocates memory, and very 
little else) and init is the "initialiser" (because it initialises the newly 
created instance.

In more modern versions of ObjectiveC, there's a short-cut:

[MyClass new]

where new calls alloc then init for you.

In Ruby, people think of two distinct things as the "constructor", depending on 
what you are doing. [Source: my resident Ruby expert at work.] If you are 
talking about *writing* a class, the constructor is the initialize method:

class MyClass
def initialize
...
end
end

But if you are talking about *creating an instance* it is the new method:

MyClass.new

which itself automatically calls initialize behind the scenes. (I'm told that 
it is possible to override new, but nobody does it.)


It seems to me that both of these are quite similar to Python's model.



-- 
Steven
"Ever since I learned about confirmation bias, I've been seeing 
it everywhere." - Jon Ronson

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


Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Steven D'Aprano
On Tuesday 13 December 2016 12:12, Ned Batchelder wrote:

> On Monday, December 12, 2016 at 6:17:43 PM UTC-5, Ben Finney wrote:
>> Ned Batchelder  writes:
>> 
>> > Claiming that __init__ isn't a constructor seems overly pedantic to
>> > me.
>> 
>> Whereas to me, claiming that ‘Foo.__init__’ is a constructor seems
>> needlessly confusing.
>> 
> ...
>> * A constructor should return the instance. ‘Foo.__init__’ does not do
>>   that; ‘Foo.__new__’ does.
> 
> This seems like an odd thing to insist on. C++ and Java constructors
> don't return the instance.

I'm not sure what you mean by that. I think they do, at least in C++.

Normally in C++ you would create an instance like this:

MyClass obj(arg);


In Python terms, that would be written as: `obj = MyClass(arg)`.


But one can also create "anonymous objects" which aren't assigned to a named 
variable:

something.method( MyClass(args) );


Doesn't that count as "returning an instance"?


> C++ allocators return the instance.

As I understand it, C++ allocators are specialist methods used in the standard 
library for container classes which allocate storage, i.e. the equivalent of 
Python lists and dicts.

http://en.cppreference.com/w/cpp/concept/Allocator

As far as I can tell, they aren't relevant to "simple" record- or struct-like 
objects.


> I'm happy to call __new__ an allocator. It serves exactly the same
> role in Python as allocators do in C++: its job is to create the raw
> material for the object, and they very rarely need to be written.

I think that last part is wrong in Python. Any time you are creating an 
immutable class -- and some of us do that a lot -- you generally need to write 
__new__. That makes __new__ very different from C++ allocators, and more like 
C++ constructors.

On the other hand, __new__ seems to be quite similar to ObjectiveC's `alloc`, 
which is called the allocator, and __init__ similar to ObjectiveC's init, which 
is the initialiser!

ObjectiveC also has a new method, which just calls alloc then init.


>> If the differences didn't matter I would agree that “overly pedantic” is
>> fair. But those differences trip up newcomers. Thinking of
>> ‘Foo.__init__’ leads people to wonder where the ‘self’ attribute came
>> from – am I not meant to be constructing it? — and to attempt to return
>> that instance.
> 
> Creating objects is confusing, but beginners don't come to Python
> with an expectation of what a "constructor" is.  Filling in the
> attributes of an object is just as clearly a kind of construction
> as allocating memory.


Remember that in Python __new__ can do a lot more than just allocate memory.

It just seems really weird to describe __init__ as a constructor when it 
initialises an existing instance: "initialiser" just seems to be the obvious 
term for it. (Do I really need to spell it out? __INIT__/INITialiser.)

Python's object creation model seems to be a lot closer to that of ObjectiveC 
or C++ than Javascript, so copying Javascript's terminology seems risky to me.



-- 
Steven
"Ever since I learned about confirmation bias, I've been seeing 
it everywhere." - Jon Ronson

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


Method to know if object support being weakreferenced ?

2016-12-12 Thread Matthias Bussonnier
Hi all, 

I was recently had to use weakreferences, using the weakref module, and came 
across the fact that some object cannot be weakreferenced. If you try to do so 
you get greated by a TypeError, which is a totally expected and documented 
behavior. 

As I tend to prefer the "Look before you leap" approach I search for a method 
capable of telling me whether an object can be weakreferenced. Which I failed 
to found. 

I could of course write a function that try/except and return False/True 
depending on the result, but that seem suboptimal as how can I know that the 
TypeError does come from not being able to take a weak reference ? And not from 
something else ?

The common Idiom in CPython, at the C layer seem to be 
PyType_SUPPORTS_WEAKREFS(Py_TYPE(ob)). So I can (and did) write a C-extension 
that expose such a function, but it does seem silly that no one else did that 
before me, and that no one seemed to have encountered the problem before. 

So am I missing something ? Is such a function not useful ?  Is there any 
reason not to have it in the stdlib ?

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


[issue25458] ftplib: command response shift - mismatch

2016-12-12 Thread Ivan Pozdeev

Ivan Pozdeev added the comment:

I tried to fix `urllib' and ultimately failed. In a nutshell, handling of the 
aftermath of an `ntransfercmd' is broken.

Since `ntransfercmd'/`transfercmd' returns a socket, handling of an 
end-of-transmission response is done in independently invoked code - upon the 
socket's close. So, if any other operation on the command connection is 
attempted before that, `ftplib's handling of the session breaks.

The plan to fix follows, but first, some background:

According to 
http://stackoverflow.com/questions/2549829/using-ftplib-for-multithread-uploads 
, FTP actually doesn't, and is not designed to, handle transfers in 
"background". In that you surely can send a further command on the socket, but 
the server won't actually read it until it's done with the transfer.

According to 
http://stackoverflow.com/questions/31560701/ftp-data-connections-reuse , data 
connections cannot be reused.

(RFC959 is vague on both points)

Now, the proposed fix design:

* upon starting a transfer, an FTP object sets a flag, `transfer_in_progress'.
* any public subroutine that would send a further command checks the flag. 
Then, there are a few options:
a) refuse any further commands outright until the user explicitly closes 
the socket (whose close handler would also handle the end-of-transfer response)
b) check the wire for an end-of-transfer response and if it's there, handle 
it and allow the command. Closing the socket may or may not handle the response 
in its own right.
c) allow the command even if there's no end-of-transfer response. Then 
handling of the transfer response is done with the function parsing the 
response for the new command - which will hang until the transfer is complete.
* the code handling the end-of-transfer response clears the flag.

Each option has drawbacks, so I'm not sure which one is the most pythonic.
I would go with b) because it would allow syntax like 
urllib.urlopen(<...>).read() which it does allow for HTTP.

--

___
Python tracker 

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



[issue28091] Document PEP 525

2016-12-12 Thread Eric Appelt

Eric Appelt added the comment:

I believe that I addressed all the comments in the previous review (although 
its always possible I missed something), and have a new patch with the 
improvements and fixes.

I also noticed that in asyncio, loop.shutdown_asyncgens() is a coroutinemethod 
and fixed the markup to reflect that as I previously labeled it a method. The 
example I added here is as suggested, but it differs from the example in PEP525 
in that shutdown_asyncgens() is run in a finally clause, which makes sense to 
me.

When applying the comments to sys.set_asyncgen_hooks() I verified that the 
keywords are optional but it is apparently not keyword only. I couldn't find 
many good examples of referencing source, so you may want to closely check how 
I linked to the shutdown_asyncgens() implementation.

--
Added file: http://bugs.python.org/file45868/pep525_pep530_docs_v1.patch

___
Python tracker 

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



[issue28956] return minimum of modes for a multimodal distribution instead of raising a StatisticsError

2016-12-12 Thread Srikanth Anantharam

New submission from Srikanth Anantharam:

return minimum of modes for a multimodal distribution

instead of raising a StatisticsError

--
components: Library (Lib)
messages: 283071
nosy: Srikanth Anantharam
priority: normal
pull_requests: 3
severity: normal
status: open
title: return minimum of modes for a multimodal distribution instead of raising 
a StatisticsError
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



[issue28955] Not matched behavior of numeric comparison with the documentation

2016-12-12 Thread woo yoo

woo yoo added the comment:

Maybe the description should be changed into "all order comparisons of 
not-a-number and any number will return False"

--

___
Python tracker 

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



[issue28955] Not matched behavior of numeric comparison with the documentation

2016-12-12 Thread woo yoo

New submission from woo yoo:

According to the documentation, which said "Additionally, comparing any number 
to a not-a-number value will return False. ",the comparison of `float('nan')!= 
1`should yield False, while the result is True.

Small errors like this in documentation should be corrected?

The related link 
https://docs.python.org/3/reference/expressions.html#value-comparisons

--
assignee: docs@python
components: Documentation
messages: 283069
nosy: docs@python, woo yoo
priority: normal
severity: normal
status: open
title: Not matched behavior of numeric comparison with the documentation
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



[issue20754] Distribution.parse_config_files uses interpolation since Python 3

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I forget if there was a reason for choosing RawConfigParser over ConfigParaer 
with interpolation=None. I'd like to know that before choosing the latter. I'd 
also like to see if appropriate the implementation patched in Setuptools, 
providing compatibility for older Pythons. 

Also, +1 for a test.

--

___
Python tracker 

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



[issue28950] regrtest: -j0 fails the check -j is not allowed together with -T/-l

2016-12-12 Thread Xiang Zhang

Changes by Xiang Zhang :


--
versions: +Python 2.7
Added file: 
http://bugs.python.org/file45867/test-command-line-j0-with-test.patch

___
Python tracker 

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



[issue26110] Speedup method calls 1.2x

2016-12-12 Thread INADA Naoki

Changes by INADA Naoki :


Added file: http://bugs.python.org/file45866/call_method_5.patch

___
Python tracker 

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



[issue28954] Incorrect EBNF rule of keywords_arguments

2016-12-12 Thread woo yoo

New submission from woo yoo:

This is the documented rule, which lacks a comma within the last line.
keywords_arguments   ::=  (keyword_item | "**" expression)
  ("," keyword_item | "**" expression)*
The correct form should be:
keywords_arguments   ::=  (keyword_item | "**" expression)
  ("," keyword_item |",""**" expression)*

The original documentation is 
https://docs.python.org/3/reference/expressions.html#calls

--
assignee: docs@python
components: Documentation
messages: 283067
nosy: docs@python, woo yoo
priority: normal
severity: normal
status: open
title: Incorrect EBNF rule of keywords_arguments
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: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Ned Batchelder
On Monday, December 12, 2016 at 6:17:43 PM UTC-5, Ben Finney wrote:
> Ned Batchelder  writes:
> 
> > Claiming that __init__ isn't a constructor seems overly pedantic to
> > me.
> 
> Whereas to me, claiming that ‘Foo.__init__’ is a constructor seems
> needlessly confusing.
> 
...
> * A constructor should return the instance. ‘Foo.__init__’ does not do
>   that; ‘Foo.__new__’ does.

This seems like an odd thing to insist on. C++ and Java constructors
don't return the instance.  C++ allocators return the instance. 
I'm happy to call __new__ an allocator. It serves exactly the same
role in Python as allocators do in C++: its job is to create the raw
material for the object, and they very rarely need to be written.

> 
> If the differences didn't matter I would agree that “overly pedantic” is
> fair. But those differences trip up newcomers. Thinking of
> ‘Foo.__init__’ leads people to wonder where the ‘self’ attribute came
> from – am I not meant to be constructing it? — and to attempt to return
> that instance.

Creating objects is confusing, but beginners don't come to Python
with an expectation of what a "constructor" is.  Filling in the 
attributes of an object is just as clearly a kind of construction
as allocating memory.

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


Re: Python constructors have particular semantics, and ‘Foo.__init__’ doesn't qualify (was: The right way to 'call' a class attribute inside the same class)

2016-12-12 Thread Juan C.
I agree with you, I'll post here the same thing I said in there for
another member:

On Mon, Dec 12, 2016 at 6:59 PM, Thomas 'PointedEars' Lahn
 wrote:
> 
>

Using the Python official doc link you provided, it clearly states
that `__new__` is the one called to "create a new instance of class
[...] The return value of __new__() should be the new object instance
(usually an instance of cls)."

On the other hand, `__init__` is "called after the instance has been
created (by __new__()), but before it is returned to the caller."

Here we have the same mindset regarding `__new__` vs `__init__`:

- http://python-textbok.readthedocs.io/en/1.0/Classes.html
"Note: __init__ is sometimes called the object’s constructor, because
it is used similarly to the way that constructors are used in other
languages, but that is not technically correct – it’s better to call
it the initialiser. There is a different method called __new__ which
is more analogous to a constructor, but it is hardly ever used."

- http://www.python-course.eu/python3_object_oriented_programming.php
"We want to define the attributes of an instance right after its
creation. __init__ is a method which is immediately and automatically
called after an instance has been created. [...] The __init__ method
is used to initialize an instance."

- https://en.wikipedia.org/wiki/Constructor_(object-oriented_programming)#Python
"In Python, constructors are defined by one or both of __new__ and
__init__ methods. A new instance is created by calling the class as if
it were a function, which calls the __new__ and __init__ methods. If a
constructor method is not defined in the class, the next one found in
the class's Method Resolution Order will be called."

- http://www.diveintopython3.net/iterators.html
"The __init__() method is called immediately after an instance of the
class is created. It would be tempting — but technically incorrect —
to call this the “constructor” of the class. It’s tempting, because it
looks like a C++ constructor (by convention, the __init__() method is
the first method defined for the class), acts like one (it’s the first
piece of code executed in a newly created instance of the class), and
even sounds like one. Incorrect, because the object has already been
constructed by the time the __init__() method is called, and you
already have a valid reference to the new instance of the class."

In general, the idea is simple, `__new__` constructs and `__init__`
initializes, this is what I believe in, after all the name `__init__`
already tell us that it's a *init* ialiser...

It doesn't matter if Java, C#, Javascript,  have
different approaches, I'm programming (or at least, trying to :p) in
Python, so I'll follow what the official doc and the vast majority of
books/courses/etc say.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28944] A lack of line 6

2016-12-12 Thread Josh Rosenberg

Josh Rosenberg added the comment:

You're reusing the same issue for completely different things. Make a separate 
issue for separate docs issues.

--
nosy: +josh.r

___
Python tracker 

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



[issue26876] Extend MSVCCompiler class to respect environment variables

2016-12-12 Thread Steve Dower

Steve Dower added the comment:

I'd rather only take the change to _msvccompiler and not the ones that are 
there for historical interest (a.k.a. backwards compatibility with people who 
never expect internal implementation details to change).

If any tools break because they're using the wrong compiler class, please file 
a bug against them.

I didn't check the 2.7 file, but the one for master is fine.

--

___
Python tracker 

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



Python constructors have particular semantics, and ‘Foo.__init__’ doesn't qualify (was: The right way to 'call' a class attribute inside the same class)

2016-12-12 Thread Ben Finney
Chris Angelico  writes:

> On Tue, Dec 13, 2016 at 10:17 AM, Ben Finney  
> wrote:
> > If the differences didn't matter I would agree that “overly
> > pedantic” is fair. But those differences trip up newcomers. Thinking
> > of ‘Foo.__init__’ leads people to wonder where the ‘self’ attribute
> > came from – am I not meant to be constructing it? — and to attempt
> > to return that instance. And when the time comes to lean about
> > ‘__new__’ the confusion continues, because the newcomer has been
> > told that something *else* is the constructor, so what's this?
>
> In JavaScript [different semantics apply].
>
> Ultimately, every language has slightly different semantics […], so
> you have to learn that the "constructor" might have slightly different
> semantics.

Please read again the message you extracted that quote from. I already
said I'm not claiming some other programming language's semantics should
dictate Python's.


What I'm saying is that in Python, there *already are* different
semantics for a constructor, and they don't match the semantics of
‘Foo.__init__’.

In Python, a constructor for a class is a class method. ‘Foo.__new__’ is
a constructor. ‘Foo.__init__’ is an instance method, so it's not a
constructor.

In Python, a constructor for a class makes the instance where it didn't
already exist. ‘Foo.__new__’ is a constructor. ‘Foo.__init__’ requires
the instance to already be constructed, so it's not a constructor.

In Python, a constructor for a class returns a new instance of that
class. ‘Foo.__new__’ is a constructor. ‘Foo.__init__’ must return None,
so it's not a constructor.

In Python, a custom constructor for a class follows the above
descriptions. ‘datetime.fromtimestamp’ is a constructor.
‘datetime.__init__’ is not.


None of this argues from the semantics of other programming languages,
so telling me other languages have different semantics is not a response
to this argument.

I'm showing that Python classes *already have* constructors, and
‘Foo.__init__’ doesn't qualify because it doesn't have the semantics of
Python constructors.

-- 
 \ “I've always wanted to be somebody, but I see now that I should |
  `\   have been more specific.” —Jane Wagner, via Lily Tomlin |
_o__)  |
Ben Finney

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


Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Chris Angelico
On Tue, Dec 13, 2016 at 10:17 AM, Ben Finney  wrote:
> If the differences didn't matter I would agree that “overly pedantic” is
> fair. But those differences trip up newcomers. Thinking of
> ‘Foo.__init__’ leads people to wonder where the ‘self’ attribute came
> from – am I not meant to be constructing it? — and to attempt to return
> that instance. And when the time comes to lean about ‘__new__’ the
> confusion continues, because the newcomer has been told that something
> *else* is the constructor, so what's this?

In JavaScript, it's normal to talk about "calling a function as a
constructor". When you do, there is a 'this' object before you start.
Should we tell the JavaScript folks to be more pedantic, because
'this' should end up existing? Does it really even matter when memory
gets allocated and the object's identity assigned? Before __init__
gets called, the object isn't "truly there" - its fundamental
invariants may not yet have been established, and key attributes might
not have been set up. Once __init__ finishes, there is an expectation
that attributes and invariants are sorted out.

This is like the old "Python doesn't have variables" thing.
Ultimately, every language has slightly different semantics (otherwise
they'd be trivial transformations, like Ook and Brainf*), so you have
to learn that the "constructor" might have slightly different
semantics. Accept it - embrace it. Learn it.

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


Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Ben Finney
Ned Batchelder  writes:

> Claiming that __init__ isn't a constructor seems overly pedantic to
> me.

Whereas to me, claiming that ‘Foo.__init__’ is a constructor seems
needlessly confusing.

* Classes already have a constructor, ‘Foo.__new__’. If we call
  something else the constructor, what do we call ‘__new__’? Are they
  both constructors?

* A constructor for Foo should start from “no instance” and result in
  “an instance of Foo”. ‘Foo.__init__’ does not do that; ‘Foo.__new__’
  does.

* A constructor should return the instance. ‘Foo.__init__’ does not do
  that; ‘Foo.__new__’ does.

If the differences didn't matter I would agree that “overly pedantic” is
fair. But those differences trip up newcomers. Thinking of
‘Foo.__init__’ leads people to wonder where the ‘self’ attribute came
from – am I not meant to be constructing it? — and to attempt to return
that instance. And when the time comes to lean about ‘__new__’ the
confusion continues, because the newcomer has been told that something
*else* is the constructor, so what's this?

> What's true is that Python's constructors (__init__) are different than
> C++ constructors.  In C++, you don't have an object of type T until the
> constructor has finished. In Python, you have an object of type T before
> __init__ has been entered.

I'm not going to argue that C++ should define terminology for other
languages. But “constructor” should have a close correlation with the
normal English-language meaning of the term.

That meaning matches ‘Foo.__new__’, which makes that method a
constructor. It does not match ‘Foo.__init__’, which makes that method
not a constructor.

> The reason to call __init__ a constructor is because of what is the
> same between C++ and Python: the constructor is where the author of
> the class can initialize instances of the class.

So you've just described what ‘Foo._init__’ does: it initialises the
existing instance. That's why it is better to call it the “initialiser”,
a term we already have and use correctly.

-- 
 \ “DRM doesn't inconvenience [lawbreakers] — indeed, over time it |
  `\ trains law-abiding users to become [lawbreakers] out of sheer |
_o__)frustration.” —Charles Stross, 2010-05-09 |
Ben Finney

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


[issue28923] Nonexisting encoding specified in Tix.py

2016-12-12 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I am a little puzzled as to how a file rename changed the content, but the 
annotation history seems to show that.  Anyway, ...

When I load the file in IDLE 2.7, I get a warning.  I am a bit surprised as 
this is not a proper encoding declaration.  IDLE's re must be a bit loose.

In 3.x, the file starts with

# -*-mode: python; fill-column: 75; tab-width: 8 -*-
#
# $Id$
#

This is all ancient, obsolete, junk specific to some editor.  (The file itself 
not used 4 space indents.) I think it should be removed from all current 
versions.  As near as I can tell, there are no non-ascii chars in the file.

--

___
Python tracker 

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



[issue28949] Stdlib modules disappear from file system

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I've reinstalled Dropbox, downgrading to 15.4.22. I'll see if that helps.

--

___
Python tracker 

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



[issue28949] Stdlib modules disappear from file system

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I don't think hard links are involved. I see symlinks in the .tox/python 
virutalenv, and virtualenv defaults to creating symlinks 
(https://github.com/pypa/virtualenv/blob/master/virtualenv.py#L565-L570) and 
falls back to copying files rather than hard linking.

--

___
Python tracker 

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



[issue28949] Stdlib modules disappear from file system

2016-12-12 Thread Ned Deily

Ned Deily added the comment:

That's sounding better, thanks.  Out of curiosity, are there hard links 
involved?

--

___
Python tracker 

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



[issue28933] AC: Accept None as a Py_ssize_t default value

2016-12-12 Thread Larry Hastings

Larry Hastings added the comment:

I don't want this change committed to CPython, you can do what you need with a 
converter so do that.

--

___
Python tracker 

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



[issue28091] Document PEP 525

2016-12-12 Thread Eric Appelt

Eric Appelt added the comment:

Yes - I'll work on the patch tonight.

--

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Steve D'Aprano
On Tue, 13 Dec 2016 07:15 am, Ned Batchelder wrote:

> Claiming that __init__ isn't a constructor seems overly pedantic to me.
> What's true is that Python's constructors (__init__) are different than
> C++ constructors.  In C++, you don't have an object of type T until the
> constructor has finished. In Python, you have an object of type T before
> __init__ has been entered.
> 
> The reason to call __init__ a constructor is because of what is the same
> between C++ and Python: the constructor is where the author of the class
> can initialize instances of the class.

That logic would have been more convincing back in the days of classic
classes in Python 1.5 or 2.0, less so after class/type unification where we
have an actual constructor __new__ that creates the instance.

The section of the docs that deal with object customization takes an
agnostic position, referring only to the "class constructor EXPRESSION"
(i.e. MyClass(spam, eggs) or equivalent):

https://docs.python.org/2/reference/datamodel.html#object.__init__

and similarly in __new__ (this time the v3 docs, just because):

https://docs.python.org/3/reference/datamodel.html#object.__new__


so if you want to be pedantic, one might argue that Python has a concept
of "object/class constructor expressions", MyClass(spam, eggs), but not of
constructor method(s). But that seems even stranger than insisting that:

- __new__ is the constructor method;
- __init__ is the initializer method.


Another way of naming things is to say that:

- __new__ is the allocator;
- __init__ is the initializer;
- the two together, __new__ + __init__, make up the constructor.

Not to be confused with the constructor expression, MyClass(spam, eggs), or
the alternative constructor, MyClass.make_instance(...).

Naming things is hard.



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


[issue28949] Stdlib modules disappear from file system

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I've just encountered what appears to be a different manifestation of the same 
issue. I unlinked the .tox directory and that rendered importlib broken.

$ pwd
/Users/jaraco/yg/queso
$ rm -R .tox
$ python
Python 3.6.0rc1 (v3.6.0rc1:29a273eee9a5, Dec  6 2016, 16:24:13) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> ^D
$ python -m tox
Could not import runpy module
Traceback (most recent call last):
  File 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/runpy.py", 
line 15, in 
import importlib.util
ModuleNotFoundError: No module named 'importlib.util'
$ ls /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib
__init__.py __pycache__ _bootstrap.py   
_bootstrap_external.py  abc.py  machinery.py

Although I'm not certain that another process wasn't involved, I'm confident 
that it was the removal of the .tox directory (and interaction with Dropbox) 
that caused the corruption.

--
title: Unable to launch Python interpreter -> Stdlib modules disappear from 
file system

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Juan C.
On Mon, Dec 12, 2016 at 6:59 PM, Thomas 'PointedEars' Lahn
 wrote:
> 

Using the Python official doc link you provided, it clearly states
that `__new__` is the one called to "create a new instance of class
[...] The return value of __new__() should be the new object instance
(usually an instance of cls)." On the other hand, `__init__` is
"called after the instance has been created (by __new__()), but before
it is returned to the caller."

Here we have the same mindset regarding `__new__` vs `__init__`:

- http://python-textbok.readthedocs.io/en/1.0/Classes.html
"Note: __init__ is sometimes called the object’s constructor, because
it is used similarly to the way that constructors are used in other
languages, but that is not technically correct – it’s better to call
it the initialiser. There is a different method called __new__ which
is more analogous to a constructor, but it is hardly ever used."

- http://www.python-course.eu/python3_object_oriented_programming.php
"We want to define the attributes of an instance right after its
creation. __init__ is a method which is immediately and automatically
called after an instance has been created. [...] The __init__ method
is used to initialize an instance."

- https://en.wikipedia.org/wiki/Constructor_(object-oriented_programming)#Python
"In Python, constructors are defined by one or both of __new__ and
__init__ methods. A new instance is created by calling the class as if
it were a function, which calls the __new__ and __init__ methods. If a
constructor method is not defined in the class, the next one found in
the class's Method Resolution Order will be called."

- http://www.diveintopython3.net/iterators.html
"The __init__() method is called immediately after an instance of the
class is created. It would be tempting — but technically incorrect —
to call this the “constructor” of the class. It’s tempting, because it
looks like a C++ constructor (by convention, the __init__() method is
the first method defined for the class), acts like one (it’s the first
piece of code executed in a newly created instance of the class), and
even sounds like one. Incorrect, because the object has already been
constructed by the time the __init__() method is called, and you
already have a valid reference to the new instance of the class."


In general, the idea is simple, `__new__` constructs and `__init__`
initializes, this is what I believe in, after all the name `__init__`
already tell us that it's a *init* ialiser...
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28949] Unable to launch Python interpreter

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

Before disabling SIP, I found I could use fs_usage to get some visibility into 
fs changes:

sudo fs_usage -w -f filesys | grep aliases.py

To test my understanding of fs_usage, I deleted aliases.py (also confirming 
that triggers the error). When I did so, I noticed something interesting - my 
Dropbox account detected deletion of 34 instances of a file called aliases.py. 
A quick search reveals that I have about 34 virtualenvs created by tox, each of 
which links .tox/python/lib/python3.6/encodings to 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings.

Now I'm suspecting that there's a race condition where Dropbox ends up deleting 
the system file. Either that, or there's a buggy piece of code somewhere that's 
deleting encodings/aliases.py (and possibly other files) in one of these 
virtualenvs, causing the file to be deleted in the system.

I'm using Dropbox v16.3.27 
(https://www.dropboxforum.com/t5/Desktop-client-builds/Beta-Build-16-3-27/td-p/197057).

I'll continue to investigate, but I'm becoming increasingly suspicious of this 
being an environmental problem.

--

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Ned Batchelder
On Monday, December 12, 2016 at 4:31:00 PM UTC-5, Gregory Ewing wrote:
> Ned Batchelder wrote:
> > In C++, you don't have an object of type T until the
> > constructor has finished. In Python, you have an object of type T before
> > __init__ has been entered.
> 
> That distinction seems a bit pedantic as well. Inside a C++
> constructor you have access to something having all the
> fields and methods of an object of type T, they just
> haven't been filled in yet.

I agree the distinction is pedantic. It does matter sometimes, such as:
if a C++ constructor raises an exception, will the corresponding destructor
be run, or not? (No, because it never finished making an object of type T.)

But in any case, all the more reason not to let C++ semantics govern
Python vocabulary.

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


[issue28933] AC: Accept None as a Py_ssize_t default value

2016-12-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

First, it looks weird if the default value affects accepted types. Second, how 
many use cases for your converter besides the bisect module?

--

___
Python tracker 

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



[issue28512] PyErr_SyntaxLocationEx() and PyErr_SyntaxLocationObject() always set the offset attribute to None

2016-12-12 Thread Berker Peksag

Berker Peksag added the comment:

Hi Serhiy, there are two commented-out lines in 
https://hg.python.org/cpython/rev/ea1c49ea8136#l3.10 (only in 3.5)


+#with self.assertRaises(AssertionError):
+#support.check_syntax_error(self, "x=1")

--
nosy: +berker.peksag

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Steve D'Aprano
On Tue, 13 Dec 2016 03:17 am, Chris Angelico wrote:

> You could check "foo" in self.__dict__, but I don't know of any
> real-world situations where you need to.

vars(self) is probably the better way to access self's namespace, rather
than directly self.__dict__. Unfortunately vars() doesn't understand
__slots__, which I think is an oversight.




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


[issue28089] asyncio: Document that TCP_NODELAY is now used by default

2016-12-12 Thread Yury Selivanov

Yury Selivanov added the comment:

> Yury, look good to you?

Yes; committed the patch with a small addition.  Thanks, Mariatta!

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



[issue28089] asyncio: Document that TCP_NODELAY is now used by default

2016-12-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 853e3f4d6cd9 by Yury Selivanov in branch '3.6':
Issue #28089: Document TCP_NODELAY in asyncio
https://hg.python.org/cpython/rev/853e3f4d6cd9

New changeset 0d209cc7ffdc by Yury Selivanov in branch 'default':
Merge 3.6 (issue #28089)
https://hg.python.org/cpython/rev/0d209cc7ffdc

--

___
Python tracker 

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



[issue28953] Use `raise from` when raising new IncompleteRead

2016-12-12 Thread Ram Rachum

Changes by Ram Rachum :


--
type:  -> behavior

___
Python tracker 

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



[issue28953] Use `raise from` when raising new IncompleteRead

2016-12-12 Thread Ram Rachum

New submission from Ram Rachum:

I had this error come up in my code, and because it doesn't use `raise ... 
from` I thought that the second error was unexpected, while in fact it wasn't. 
This patch should fix that.

--
components: Library (Lib)
files: 1.patch
keywords: patch
messages: 283052
nosy: cool-RR
priority: normal
severity: normal
status: open
title: Use `raise from` when raising new IncompleteRead
versions: Python 3.7
Added file: http://bugs.python.org/file45865/1.patch

___
Python tracker 

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



[issue28919] Simplify `_copy_func_details` in unittest.mock

2016-12-12 Thread Michael Foord

Michael Foord added the comment:

Yep, looks good to me to.

--

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Gregory Ewing

Ned Batchelder wrote:

In C++, you don't have an object of type T until the
constructor has finished. In Python, you have an object of type T before
__init__ has been entered.


That distinction seems a bit pedantic as well. Inside a C++
constructor you have access to something having all the
fields and methods of an object of type T, they just
haven't been filled in yet.

It's a bit like asking at what point between conception and
birth a baby starts to exist.

--
Greg

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


[issue28932] Fail compile Python 3.6.0rc1 on OpenBSD 6.0

2016-12-12 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +haypo
stage:  -> patch review
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



[issue28089] asyncio: Document that TCP_NODELAY is now used by default

2016-12-12 Thread Ned Deily

Ned Deily added the comment:

Yury, look good to you?

--
stage: patch review -> commit review
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



[issue28933] AC: Accept None as a Py_ssize_t default value

2016-12-12 Thread Julien Palard

Julien Palard added the comment:

> for just one use case

I don't think that using None in a default argument is "one use case", nor a 
"special case" it's more like a "widly used pattern" that I'd like to make 
simple to implement (also see http://bugs.python.org/issue28754#msg282891).

I'm not sure you're against my idea of accepting None like:

something: Py_ssize_t(c_default="-1") = None

Or you're against my implementation, which I can understand, I'm not a fan of 
modifying getargs.c for this, it may be doable by implementing a new converter 
in clinic.py like "Py_ssize_t_optional", and it may not require more work than 
modifying getargs.c.

But AC is already defining 4 different "default values", counting the "= value" 
from the AC DSL, I'm not sure that adding the "optional" string somewhere make 
any of this clearer, typically what about the semantic difference between:

something: Py_ssize_t_optional()

and

something: Py_ssize_t() = None

So my original idea was to accept "= None" indistinctly of the used type, I 
mean allowing:

something: Py_ssize_t(c_default=…) = None
something: float(c_default=…) = None
something: double(c_default=…) = None
…
…

Which is, I think, one of the clearest way to express "It's an optional 
parameter, on the Python side the default value is None, but c-side the default 
value is of the right type an is …".

In other words, I'm proposing to optionally extend the "c_default" usage from 
"not given" to "not given or given None".

I failed to implement if for any types, mainly because AC is delegating to 
getargs for Py_ssize_t, so I though starting with my specific need (Py_ssize_t 
for issue28754) was a good start and POC.

Another solution may be to change the Py_ssize_t_converter to drop the 
format_unit, allowing us to implement the converter in clinic instead of 
getargs.c. It's opening a long term door of completly dropping non-"O" format 
units. I mean, if we drop every non-"O" format units in clinic we'll be able to 
use a faster implementation of _PyArg_ParseStack, one not parsing a 
mini-arg-definition-language at runtime (the "OO|nO&:").

I'm willing to implement something clean for this but please be more precise in 
your feedback.

--

___
Python tracker 

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



[issue28923] Nonexisting encoding specified in Tix.py

2016-12-12 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +serhiy.storchaka, terry.reedy
stage:  -> patch review
type: compile error -> behavior

___
Python tracker 

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



[issue28949] Unable to launch Python interpreter

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

Looks like I can [disable 
SIP](http://internals.exposed/blog/dtrace-vs-sip.html) and dtrace will be 
viable.

--

___
Python tracker 

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



[issue28949] Unable to launch Python interpreter

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I thought I was on to something when I found this technique for using dtrace to 
detect a file deletion: 
https://blogs.oracle.com/zoneszone/entry/who_keeps_removing_that_file

However, I don't seem to have privilege to run it.

$ cat trap-aliases-delete 
#! /usr/sbin/dtrace -wqs

syscall::unlinkat:entry
/cleanpath(copyinstr(arg1)) == 
"/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/aliases.py"/
{
stop();
printf("%s[%d] caught removing aliases.py\n", execname, pid);
system("ptree %d; pstack %d; prun %d", pid, pid, pid);
}
$ sudo ./trap-aliases-delete
dtrace: system integrity protection is on, some features will not be available

dtrace: could not enable tracing: Permission denied

--

___
Python tracker 

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



[issue28919] Simplify `_copy_func_details` in unittest.mock

2016-12-12 Thread Berker Peksag

New submission from Berker Peksag:

Thanks for the patch. I only did a quick review, but it looks good to me.

--
nosy: +berker.peksag, michael.foord
stage:  -> patch review

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Thomas 'PointedEars' Lahn
Juan C. wrote:

> On Mon, Dec 12, 2016 at 12:34 PM, Thomas 'PointedEars' Lahn
>  wrote:
>> To call something means generally in programming, and in Python, to
>> execute it as a function instead: In the code above, the class object
>> referred to by “Box” is called twice in order to instantiate twice
>> (calling a class object in Python means to instantiate it, implicitly
>> calling its constructor method, “__init__”, if any), and the global
>> “print” function is called three times.
> 
> Since we are talking about Python terminology I believe that calling
> `__init__` a constructor is also wrong. I've already seem some
   ^
> discussions regarding it and the general consensus is that `__init__`
> shouldn't be called constructor as it isn't really a constructor (like
> Java/C# constructors). […]

IBTD:

,-
| 
| constructor
| 
| (programming)   1. In object-oriented languages, a function provided by a 
   
| class to initialise a newly created object. The constructor function 
  ^^
| typically has the same name as the class. It may take arguments, e.g. to 
| set various attributes of the object or it may just leave everything 
  
| undefined to be set elsewhere.
| 
| A class may also have a destructor function that is called when objects of 
| the class are destroyed.

Free On-line Dictionary of Computing, Last updated: 2014-10-04.

In Python, a class’s __init__() is called after its __new__() [1], and 
“typically” means “not always” (for another example, in clean PHP code the 
constructor’s name is “__construct”).



[In fact, there are constructors in object-oriented programming languages 
with prototype-based inheritance, like implementations of ECMAScript Ed. 1 
to 7 (except 4), too.]

-- 
PointedEars

Twitter: @PointedEars2
Please do not cc me. / Bitte keine Kopien per E-Mail.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28949] Unable to launch Python interpreter

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

I am using the python.org rc1 installer, confirmed to match the public md5 sum:

$ md5 ~/Downloads/python-3.6.0rc1-macosx10.6.pkg 
MD5 (/Users/jaraco/Downloads/python-3.6.0rc1-macosx10.6.pkg) = 
404c390ae27f067aaab34f168cf913eb

I downloaded ClamXav and had it scan my entire system. It found nothing of 
interest, only two Windows exploits, one in a driver from Asus and another in 
an attachment to an e-mail that was already filed as junk. It also found two 
"Eicar-Test-Signature" hits in old IRC logs.

So if my Mac has a virus, it's new enough that it's not being detected by 
ClamXav.

I'm going to continue to investigate and see if I can detect what event 
triggers the removal of that file.

--

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Ned Batchelder
On Monday, December 12, 2016 at 12:58:30 PM UTC-5, Juan C. wrote:
> Since we are talking about Python terminology I believe that calling
> `__init__` a constructor is also wrong. I've already seem some
> discussions regarding it and the general consensus is that `__init__`
> shouldn't be called constructor as it isn't really a constructor (like
> Java/C# constructors). Some source:
> 
> - 
> http://stackoverflow.com/questions/4859129/python-and-python-c-api-new-versus-init
> - http://stackoverflow.com/questions/674304/pythons-use-of-new-and-init

Claiming that __init__ isn't a constructor seems overly pedantic to me.
What's true is that Python's constructors (__init__) are different than
C++ constructors.  In C++, you don't have an object of type T until the
constructor has finished. In Python, you have an object of type T before
__init__ has been entered.

The reason to call __init__ a constructor is because of what is the same
between C++ and Python: the constructor is where the author of the class
can initialize instances of the class.

There are many programming languages, and they have similar overlapping
constructs, but there are differences among the constructs.  It's a
challenge to decide when those differences are great enough to use a
different name, and when those differences are slight enough to just note
them as a difference.

As an example, people are happy to use the word "function" for things in
Python, C, C++, Java, JavaScript, and Haskell, despite the huge differences
in how they behave.  The commonalities, especially in how these constructs
are used by developers to express themselves, are similar enough that
we call them all "functions."  It seems to me that we can do the same
for "constructor."

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


[issue28845] Clean up known issues for AIX

2016-12-12 Thread Julien Palard

Julien Palard added the comment:

LGTM but no AIX to test it.

--

___
Python tracker 

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



[issue28933] AC: Accept None as a Py_ssize_t default value

2016-12-12 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Agreed with Larry. "Special cases aren't special enough to break the rules." 
General converter shouldn't be changed for just one use case. Write your own 
special converter. Or just use the "O" converter and manually convert Python 
object to C value. That can be simpler and more readable.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue28933] AC: Accept None as a Py_ssize_t default value

2016-12-12 Thread Julien Palard

Julien Palard added the comment:

Hi Larry,

Did you take more time to review this patch and my last comments? I don't think 
it that awful as it does _not_ apply until explicitly asked for, but I'm open 
to discuss it.

--

___
Python tracker 

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



Re: SIP install error on windows

2016-12-12 Thread Phil Thompson
On 12 Dec 2016, at 7:29 pm, Xristos Xristoou  wrote:
> 
> 
> hello i want to install sip on windows bit using python 
> 32 bit.
> i download sip from this link https://www.riverbankcomputing.com
> i try to install from cmd line :
> 
> C:\WINDOWS\system32>cd C:\Users\username\Desktop\sip-4.17
> 
> C:\Users\username\Desktop\sip-4.17>python configure.py install
> and take that error any idea ?
> 
> This is SIP 4.17 for Python 2.7.11 on win32.
> Error: Unsupported macro name specified. Use the --show-build-macros flag to
> see a list of supported macros.

Try the documentation...

http://pyqt.sourceforge.net/Docs/sip4/installation.html

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


Re: SIP install error on windows

2016-12-12 Thread Xristos Xristoou
Τη Δευτέρα, 12 Δεκεμβρίου 2016 - 9:29:38 μ.μ. UTC+2, ο χρήστης Xristos Xristoou 
έγραψε:
> hello i want to install sip on windows bit using python 
>  32 bit.
> i download sip from this link https://www.riverbankcomputing.com
> i try to install from cmd line :
> 
> C:\WINDOWS\system32>cd C:\Users\username\Desktop\sip-4.17
> 
> C:\Users\username\Desktop\sip-4.17>python configure.py install
> and take that error any idea ?
> 
> This is SIP 4.17 for Python 2.7.11 on win32.
> Error: Unsupported macro name specified. Use the --show-build-macros flag to
> see a list of supported macros.

yes but i dont have python 3 i need use python 2.7
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: SIP install error on windows

2016-12-12 Thread Phil Thompson
On 12 Dec 2016, at 7:38 pm, Bob Gailer  wrote:
> 
> On Dec 12, 2016 2:30 PM, "Xristos Xristoou"  wrote:
>> 
>> 
>> hello i want to install sip on windows bit using python
>> 32 bit.
>> i download sip from this link https://www.riverbankcomputing.com
>> i try to install from cmd line :
>> 
>> C:\WINDOWS\system32>cd C:\Users\username\Desktop\sip-4.17
>> 
>> C:\Users\username\Desktop\sip-4.17>python configure.py install
>> and take that error any idea ?
> The instructions at Riverbank for installing sip tell me to use pip3
> install. I suggest you try that.

Not for Python v2.

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


[issue28952] csv.Sniffer().sniff(0 returns a value without the "strict" attribute

2016-12-12 Thread kevin

New submission from kevin:

In 
  
https://docs.python.org/3.5/library/csv.html#dialects-and-formatting-parameters 

the Dialect objects are described as supporting, among others, the 
Dialect.strict attribute, with a default value of False.  However, the
sniff() returns an object lacking this attribute entirely, not even with the 
value None.  At least on my inputs, which I'd include but they have personnel 
information.  I can redact it if required.

--
components: Library (Lib)
messages: 283041
nosy: 4Dummies
priority: normal
severity: normal
status: open
title: csv.Sniffer().sniff(0 returns a value without the "strict" attribute
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: SIP install error on windows

2016-12-12 Thread Bob Gailer
On Dec 12, 2016 2:30 PM, "Xristos Xristoou"  wrote:
>
>
> hello i want to install sip on windows bit using python
>  32 bit.
> i download sip from this link https://www.riverbankcomputing.com
> i try to install from cmd line :
>
> C:\WINDOWS\system32>cd C:\Users\username\Desktop\sip-4.17
>
> C:\Users\username\Desktop\sip-4.17>python configure.py install
> and take that error any idea ?
The instructions at Riverbank for installing sip tell me to use pip3
install. I suggest you try that.
>
> This is SIP 4.17 for Python 2.7.11 on win32.
> Error: Unsupported macro name specified. Use the --show-build-macros flag
to
> see a list of supported macros.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


SIP install error on windows

2016-12-12 Thread Xristos Xristoou

hello i want to install sip on windows bit using python 
 32 bit.
i download sip from this link https://www.riverbankcomputing.com
i try to install from cmd line :

C:\WINDOWS\system32>cd C:\Users\username\Desktop\sip-4.17

C:\Users\username\Desktop\sip-4.17>python configure.py install
and take that error any idea ?

This is SIP 4.17 for Python 2.7.11 on win32.
Error: Unsupported macro name specified. Use the --show-build-macros flag to
see a list of supported macros.

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


[issue28896] Embeddable zip allows Windows registry to override module location

2016-12-12 Thread Steve Dower

Steve Dower added the comment:

And that commit removes WindowsRegistryFinder from sys.meta_path on startup (as 
well as fixing regeneration of importlib when building on Windows).

It should *not* be cherry picked for 3.6.0.

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



[issue28896] Embeddable zip allows Windows registry to override module location

2016-12-12 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5bd248c2cc75 by Steve Dower in branch '3.6':
Issue #28896: Disable WindowsRegistryFinder by default.
https://hg.python.org/cpython/rev/5bd248c2cc75

New changeset 4bd131b028ce by Steve Dower in branch 'default':
Issue #28896: Disable WindowsRegistryFinder by default.
https://hg.python.org/cpython/rev/4bd131b028ce

--

___
Python tracker 

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



[issue11874] argparse assertion failure with brackets in metavars

2016-12-12 Thread paul j3

Changes by paul j3 :


--
priority: normal -> high

___
Python tracker 

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



[issue28941] Update the link to Source Code in Python Docs from hg to github

2016-12-12 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

There's source code of the documentation itself 
https://github.com/python/cpython/blob/master/Doc/library/abc.rst ) for 

and source code of abc.py 
https://github.com/python/cpython/blob/master/Lib/abc.py

Maybe I misunderstood, I figured issue #28929 is for fixing the docs url only.

--

___
Python tracker 

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



[issue28951] re.flags not documented in Module Contents as promised.

2016-12-12 Thread R. David Murray

R. David Murray added the comment:

When I follow the link to module contents, I find a list of the flags with 
their descriptions.  (re.A, re.I, etc, etc).  Perhaps you are confusing the 
letters used in the regular expression to represent the flags with the flags 
themselves?  I'm not sure how we could make that clearer.

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



[issue26876] Extend MSVCCompiler class to respect environment variables

2016-12-12 Thread Zachary Ware

Zachary Ware added the comment:

Steve, does the latest patch look good to you?

--

___
Python tracker 

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



[issue28941] Update the link to Source Code in Python Docs from hg to github

2016-12-12 Thread Brett Cannon

Brett Cannon added the comment:

How is this different from issue #28929?

--

___
Python tracker 

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



[issue28951] re.flags not documented in Module Contents as promised.

2016-12-12 Thread kevin

New submission from kevin:

In the online documentation of module re 
  (https://docs.python.org/3.5/library/re.html) 
under 
  6.2.1. Regular Expression Syntax
for item
  (?aiLmsux)
we are promised "The flags are described in Module Contents"
but no description is found there.  In fact a number of other references are 
found to flags, but no description of the individual flags.  AFAICT the closest 
thing to a description is found at the original reference -- at least it gives 
a code and name for each one.

--
assignee: docs@python
components: Documentation
messages: 283034
nosy: 4Dummies, docs@python
priority: normal
severity: normal
status: open
title: re.flags not documented in Module Contents as promised.
type: enhancement
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



PyCA/cryptography 1.7 released

2016-12-12 Thread Paul Kehrer
PyCA cryptography 1.7 has been released to PyPI. cryptography is a package
which provides cryptographic recipes and primitives to Python developers.
Our goal is for it to be your "cryptographic standard library". We support
Python 2.6-2.7, Python 3.3+, and PyPy.

Changelog (https://cryptography.io/en/latest/changelog/#id1):

* Support for OpenSSL 1.0.0 has been removed. Users on older version of
OpenSSL will need to upgrade.
* Added support for Diffie-Hellman key exchange using exchange()
* The OS random engine for OpenSSL has been rewritten to improve
compatibility with embedded Python and other edge cases. More information
about this change can be found in the pull request.

Thanks to everyone who helped with this release! The upcoming cryptography
1.8 will (among other features) switch our static wheels to link against
OpenSSL 1.1.0.

-Paul Kehrer (reaperhulk)
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread John Gordon
In  "Juan C." 
 writes:

> The instructor said that the right way to call a class attribute is to use
> 'Class.class_attr' notation, but on the web I found examples where people
> used 'self.class_attr' to call class attributes.

Class instances may override class attributes by creating local attributes
of the same name, in which case Class.class_attr and self.class_attr may
not be equal, so you'd have to use the correct one for your needs.

If you're sure that an instance does not override the class attribute,
then you can use whichever one you prefer.  self.class_attr may be more
convenient because you don't have to provide a specific class name.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"

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


[issue28950] regrtest: -j0 fails the check -j is not allowed together with -T/-l

2016-12-12 Thread Xiang Zhang

Changes by Xiang Zhang :


--
title: regrtest: -j0 fails the check -j are not allowed together with -T/-l -> 
regrtest: -j0 fails the check -j is not allowed together with -T/-l

___
Python tracker 

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



[issue28950] regrtest: -j0 fails the check -j are not allowed together with -T/-l

2016-12-12 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +haypo
title: -j0 fails the check -j are not allowed together with -T/-l -> regrtest: 
-j0 fails the check -j are not allowed together with -T/-l

___
Python tracker 

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



[issue28948] Facing issue while running Python 3.6.0rc1 windows x86-64 web based installer

2016-12-12 Thread Steve Dower

Steve Dower added the comment:

I don't support you have a file named "ucrtbase.dll" in your downloads 
directory? That would be a really simple explanation, and I'd know how to fix 
it.

If not, I don't have enough information from the logs to guess what the problem 
may be. For some reason, we thought you had already installed that update and 
so didn't try to install it again.

--

___
Python tracker 

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



[issue28950] -j0 fails the check -j are not allowed together with -T/-l

2016-12-12 Thread Xiang Zhang

New submission from Xiang Zhang:

For python test command line arguments, -j is not allowed together with -T/-l 
(don't know why):

[cpython]$ ./python -m test -j4 -T
usage: python -m test [options] [test_name1 [test_name2 ...]]
python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]]
regrtest.py: error: -T and -j don't go together!
Pass -h or --help for complete help.
[cpython]$ ./python -m test -j4 -l
usage: python -m test [options] [test_name1 [test_name2 ...]]
python path/to/Lib/test/regrtest.py [options] [test_name1 [test_name2 ...]]
regrtest.py: error: -l and -j don't go together!
Pass -h or --help for complete help.

But -j0 which also spawns multiple progresses fails the check.

--
components: Tests
files: test-command-line-j0.patch
keywords: patch
messages: 283032
nosy: xiang.zhang
priority: normal
severity: normal
stage: patch review
status: open
title: -j0 fails the check -j are not allowed together with -T/-l
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45864/test-command-line-j0.patch

___
Python tracker 

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



[issue28947] Facing issue while running Python 3.6.0rc1 windows x86-64 web based installer

2016-12-12 Thread Steve Dower

Changes by Steve Dower :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Facing issue while running Python 3.6.0rc1 windows x86-64 web 
based installer

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Juan C.
On Mon, Dec 12, 2016 at 12:34 PM, Thomas 'PointedEars' Lahn
 wrote:
> First of all, the proper term for what you are doing there is _not_ “call”;
> you are _accessing_ an attribute instead.

Indeed, `accessing` seems better. I was looking for a better word but
couldn't find at the moment.

> To call something means generally in programming, and in Python, to execute
> it as a function instead: In the code above, the class object referred to by
> “Box” is called twice in order to instantiate twice (calling a class object
> in Python means to instantiate it, implicitly calling its constructor
> method, “__init__”, if any), and the global “print” function is called three
> times.

Since we are talking about Python terminology I believe that calling
`__init__` a constructor is also wrong. I've already seem some
discussions regarding it and the general consensus is that `__init__`
shouldn't be called constructor as it isn't really a constructor (like
Java/C# constructors). Some source:

- 
http://stackoverflow.com/questions/4859129/python-and-python-c-api-new-versus-init
- http://stackoverflow.com/questions/674304/pythons-use-of-new-and-init
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Django broken pipe error

2016-12-12 Thread justin walters
On Mon, Dec 12, 2016 at 7:27 AM, roma  wrote:

> Thanks Justin,
>
> I believe, the whole database story has no influence on the broken pipe
> error. I've commented out the whole block and leave only return line:
> return HttpResponse(res, content_type="text/plain; charset=utf-8")
> The error is still present. And I have no influence on that.
>
> I call python from js client:
>
> var newTrendReport = new App.TrendReport();
> newTrendReport.set('search_phrase', search_phrase);
> newTrendReport.set('time_from', time_from);
> newTrendReport.set('time_to', time_to);
> newTrendReport.set('time_scale', time_scale);
> newTrendReport.set('category', category);
> newTrendReport.startExport(
>
> function(response){
> console.log("Successfully calculated trend report.");
> App.trendPage = new App.TrendPageView();
> App.trendPage.render(response);
> },
> );
>
> go throw:
>
> App.TrendReport = Backbone.Model.extend({
> urlRoot: "/api/trend_reports/",
> defaults: {
> search_phrase: "",
> time_from: "",
> time_to: "",
> time_scale: "",
> category: ""
> },
>
> startExportSuffix: "/export_report/",
>
> startExport: function( successCallback, errorCallback ) {
> console.log("start trend calculation");
> var that = this;
> var ajaxUrl = this.startExportSuffix;
> var options = {
> method: "POST",
> data: this.attributes,
> contentType: "application/json;charset=UTF-8",
> dataType: "json",
>
> error: errorCallback,
> success: successCallback
> };
> console.log("start trend export sync");
> App.ajax(ajaxUrl, options);
> }
>
> });
>
> and come in export_report method.
>
> My urls.py:
>
> url(r'^export_report', ensure_csrf_cookie(views.export_report),
> name="export_report"),
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I'm not super familiar with the way backbone does http requests, but
something seems off about the startExport function.
It seems to me that you are sending a post request to "/export_report/"
which is an endpoint that I'm guessing is nested
in an include from "/api/trend_reports/". However, it looks like the error
you're getting above says you aren't sending
the request to "https://root.com/api/trend_reports/export_report/;.
Instead, you are sending the request to "https://root.com/export_report/; .
Though, I'm also not sure that's the case because that would normally throw
a 404.

I also noticed that you set content type to 'application/json' in your js,
but the view function returns a 'text/plain' content type. Is
There a reason for this?

The data key in your js http function is set to the attributes variable
which, as far as I can tell, does not exist.

There's a lot going on here, but I think you can probably narrow it down to
something in your backbone code or the way
backbone handles http requests as the error you are getting is caused by
the client prematurely closing the socket.
It's possible backbone will stop reading the response since it isn't the
same content-type as the request.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28937] str.split(): remove empty strings when sep is not None

2016-12-12 Thread Vedran Čačić

Vedran Čačić added the comment:

I think Guido's mistake is relevant here. It tripped me too. Too much 
negatives, and "prune" is not really well-known verb. Besides, we already have 
str.splitlines' keepends, which works the opposite way.

--

___
Python tracker 

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



[issue28949] Unable to launch Python interpreter

2016-12-12 Thread Ned Deily

Ned Deily added the comment:

Jason, assuming you are using the python.org 3.6.0r1 installer, let us know 
what you find out!

--
nosy: +ned.deily

___
Python tracker 

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



[issue28937] str.split(): remove empty strings when sep is not None

2016-12-12 Thread Guido van Rossum

Guido van Rossum added the comment:

> except the other way around

Whoops. Indeed. So all's well here.

> x.split(tuple(string.whitespace))

Yes, that's what I was after. (But it can be a separate PR.)

--

___
Python tracker 

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



[issue28248] Upgrade installers to OpenSSL 1.0.2j

2016-12-12 Thread Ned Deily

Ned Deily added the comment:

@S Safihre. See the ReadMe included with the python.org 2.7.x installers.  (It 
is displayed at installation and a copy is installed to /Applications/Python 
2.7/ReadMe.rtf)  As explained there, for 2.7.13rc1 as in recent previous 2.7.x 
releases, only the 10.5+ installer variant is linked with the private copy of 
OpenSSL; the 10.6+ installer uses the Apple-supplied system version.

--

___
Python tracker 

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



[issue28921] Make str.count one character for latin1 string faster

2016-12-12 Thread Xiang Zhang

Xiang Zhang added the comment:

> The code looks too complex.

It is if looking at the patch alone. But the skill is used across stringlib and 
the only thing new is the bitwise operation.

str/bytes.count is not critical but not bad if it could be optimized and 
especially the effect is significant for long data.

I am not favour of rejecting it now but set priority to low.

--
priority: normal -> low

___
Python tracker 

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



[issue28949] Unable to launch Python interpreter

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

Hmm. Looks like I may [have a trojan](http://stackoverflow.com/a/4707258).

--

___
Python tracker 

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



[issue28937] str.split(): remove empty strings when sep is not None

2016-12-12 Thread Emanuel Barry

Emanuel Barry added the comment:

Barry: Sure, the docs example was just a quick write-up, you can word it 
however you want!

Guido: Pretty much, except the other way around (when prune is False, i.e. 
"don't remove empty strings").

The attached patch exposes the behaviour (it's identical to last night's, but 
I'm re-uploading it as an unrelated file went in), except that the `prune` 
argument isn't keyword-only (I didn't know how to do this, and didn't bother 
searching for just a proof-of-concept).

--
Added file: http://bugs.python.org/file45863/split_prune_1.patch

___
Python tracker 

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



Re: The right way to 'call' a class attribute inside the same class

2016-12-12 Thread Juan C.
On Sun, Dec 11, 2016 at 11:34 PM, Steve D'Aprano
 wrote:

> So... in summary:
>
>
> When *assigning* to an attribute:
>
> - use `self.attribute = ...` when you want an instance attribute;
>
> - use `Class.attribute = ...` when you want a class attribute in
>   the same class regardless of which subclass is being used;
>
> - use `type(self).attribute = ...` when you want a class attribute
>   in a subclass-friendly way.
>
>
> When *retrieving* an attribute:
>
> - use `self.attribute` when you want to use the normal inheritance
>   rules are get the instance attribute if it exists, otherwise a
>   class or superclass attribute;
>
> - use `type(self).attribute` when you want to skip the instance
>   and always return the class or superclass attribute.

Thanks, that seems simple enough.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28937] str.split(): remove empty strings when sep is not None

2016-12-12 Thread Emanuel Barry

Changes by Emanuel Barry :


Removed file: http://bugs.python.org/file45853/split_prune_1.patch

___
Python tracker 

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



[issue20754] Distribution.parse_config_files uses interpolation since Python 3

2016-12-12 Thread Berker Peksag

Berker Peksag added the comment:

Thanks! We also need a test case for the new behavior.

--
stage: resolved -> patch review

___
Python tracker 

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



[issue28949] Unable to launch Python interpreter

2016-12-12 Thread Jason R. Coombs

Jason R. Coombs added the comment:

Indeed it seems that aliases.py is missing.

$ ls 
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/a*
/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/encodings/ascii.py

--

___
Python tracker 

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



[issue28935] distutils use ConfigParser in Python 3.x and fails to parse setup.cfg with percent sign

2016-12-12 Thread Berker Peksag

Changes by Berker Peksag :


--
stage:  -> resolved
superseder:  -> Distribution.parse_config_files uses interpolation since Python 
3

___
Python tracker 

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



  1   2   >