[issue28480] Compile error on Modules/socketmodule.c

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9316b4ebf3fa by Martin Panter in branch '3.6':
Issue #28480: Avoid label at end of compound statement --without-threads
https://hg.python.org/cpython/rev/9316b4ebf3fa

New changeset 7cb86d404866 by Martin Panter in branch '3.6':
Issue #28480: Adjust or skip tests if multithreading is disabled
https://hg.python.org/cpython/rev/7cb86d404866

New changeset 948cf38793ce by Martin Panter in branch 'default':
Issue #28480: Merge multithreading fixes from 3.6
https://hg.python.org/cpython/rev/948cf38793ce

--

___
Python tracker 

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



Re: function call questions

2016-10-19 Thread Frank Millman
wrote in message 
news:5506e4d8-bd1d-4e56-8d1b-f71fa8293...@googlegroups.com...


在 2016年10月19日星期三 UTC+8下午3:17:18,Peter Otten写道:

chenyong20...@gmail.com wrote:

> 在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道:
>> On 2016-10-19 03:15, chenyong20...@gmail.com wrote:
>> > Thanks Peter and Anssi for your kind help. Now I'm ok with the first
>> > question. But the second question still confused me. Why "it seems 
>> > that

>> > after root = root.setdefault(ch,{}) tree['a'] and root are the same
>> > object" and follows tree['a']['b']? Thanks.
>> >



please forgive my stupid. I still can't follow this.


Let's see if I can explain. I am using 't' and 'r' instead of 'tree' and 
'root', but otherwise it is the same as your original example.



t = {}
r = t
id(t)

2542235910088

id(r)

2542235910088

At this point, t and r are both references to the same empty dictionary.


r = r.setdefault('a', {})


This has done two things.

It has inserted the key 'a' into the dictionary, and set its value to {}.


t

{'a': {}}

id(t)

2542235910088

It has also rebound 'r' so that it now references the new empty dictionary 
that has been inserted.



r

{}

id(r)

2542234429896

t['a']

{}

id(t['a'])

2542234429896

Now continue this process with r = r.setdefault('b', {}), and watch what 
happens.


Hopefully this will help you to understand. Feel free to ask further if not 
sure.


Frank Millman


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


[issue28481] Weird string comparison bug

2016-10-19 Thread Eryk Sun

Eryk Sun added the comment:

Interning of strings is an implementation detail for the efficient storage of 
variable and attribute names. A string with ':' in it cannot be a variable or 
attribute name and thus is not interned. But you don't need to know which 
strings are interned or why they're interned because correct Python code should 
never compare strings by identity. Use an equality comparison, e.g. (var2 == 
':bb'). Generally identity comparisons are of limited use in Python, such as 
checking for a singleton object such as None.

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

___
Python tracker 

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



[issue28482] test_typing fails if asyncio unavailable

2016-10-19 Thread Martin Panter

New submission from Martin Panter:

If you compile with “configure --without-threads”, various tests are already 
skipped because they rely on multithreading. However test_typing does not seem 
to handle this. It tries to import “asyncio”, which seems to depend on 
multithreading. I presume it is expected that asyncio requires multithreading, 
so perhaps the affected tests should be skipped in test_typing. Here is my 
attempt to skip them; please review.

--
components: Tests
files: st-typing.patch
keywords: patch
messages: 279013
nosy: gvanrossum, martin.panter
priority: normal
severity: normal
stage: patch review
status: open
title: test_typing fails if asyncio unavailable
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45147/st-typing.patch

___
Python tracker 

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



[issue28447] socket.getpeername() failure on broken TCP/IP connection

2016-10-19 Thread Georgey

Georgey added the comment:

The socket close accident is not caused by queue or calling handle_sock_error 
at all, it happened right after select error

After changing the Exception handling of main Thread:

except Exception as err:
print("error:"+str(err))
print(sock.getpeername())
mailbox.put( (("sock_err",sock), 'Server') )
continue
 
server_sock.close()


I also get the same type of error:


Traceback (most recent call last):
  File "C:\Users\user\Desktop\SelectWinServer.py", line 112, in 
data = sock.recv(BUFSIZ)
ConnectionResetError: [WinError 10054] connection forcibly close

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\user\Desktop\SelectWinServer.py", line 123, in 
print(sock.getpeername())
OSError: [WinError 10038] not a socket


--

___
Python tracker 

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



[issue28481] Weird string comparison bug

2016-10-19 Thread MinJae Kwon

New submission from MinJae Kwon:

I found bug i think about string comparison

> var1 = 'aa'
> var1 is 'aa' # This is True

But if the string literal has special chacter (e.g., colon), the comparison 
results in False

> var2 = ':bb'
> var2 is ':bb' # This is False

Check it please.

--
components: Unicode
messages: 279011
nosy: MinJae Kwon, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Weird string comparison bug
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue28480] Compile error on Modules/socketmodule.c

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 17629dee23ca by Martin Panter in branch '2.7':
Issue #28480: Avoid label at end of compound statement --without-threads
https://hg.python.org/cpython/rev/17629dee23ca

--
nosy: +python-dev

___
Python tracker 

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



[issue28474] WinError(): Python int too large to convert to C long

2016-10-19 Thread Kelvin You

Kelvin You added the comment:

Here is the full list of windows error code:
https://msdn.microsoft.com/en-us/library/cc231196.aspx
You can see a lot of error codes is above 0x8000.

--

___
Python tracker 

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



[issue26240] Docstring of the subprocess module should be cleaned up

2016-10-19 Thread Martin Panter

Martin Panter added the comment:

.
I left some comments on the code review.

Also, I’m not sure about the links to the online documentation. We don’t do 
this for other modules as far as I know. The pydoc module and help() commands 
already add their own links, which can be configured via PYTHONDOCS.

--

___
Python tracker 

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



[issue28474] WinError(): Python int too large to convert to C long

2016-10-19 Thread Kelvin You

Kelvin You added the comment:

I report this issue because the function 
WlanScan(https://msdn.microsoft.com/zh-cn/library/windows/desktop/ms706783(v=vs.85).aspx)
 returns a error code 0x80342002 when the WLAN is disabled on Windows 10.  
ctypes.WinError() raise an exception of 'Python int too large to convert to C 
long' when handle this error code.

--

___
Python tracker 

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



Re: function call questions

2016-10-19 Thread chenyong20000
在 2016年10月19日星期三 UTC+8下午3:17:18,Peter Otten写道:
> chenyong20...@gmail.com wrote:
> 
> > 在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道:
> >> On 2016-10-19 03:15, chenyong20...@gmail.com wrote:
> >> > Thanks Peter and Anssi for your kind help. Now I'm ok with the first
> >> > question. But the second question still confused me. Why "it seems that
> >> > after root = root.setdefault(ch,{}) tree['a'] and root are the same
> >> > object" and follows tree['a']['b']? Thanks.
> >> >
> >> You call the .setdefault method with a key and a default value.
> >> 
> >> The .setdefault method does this: if the key is in the dict, it returns
> >> the associated value, else it puts the key and the default into the dict
> >> and then returns the default.
> > 
> > thanks for the reply. I understand this. I'm now confused on why tree got
> > its magic result.
> 
> Perhaps it is easier to understand if you rewrite the function without 
> setdefault()?
> 
> def add_to_tree(root, value_string):
> print "root is %s, value_string is %s" % (root, value_string)
> for ch in value_string:
> print "ch is %s" % ch
> if ch not in root: # always true if the root arg is an empty dict
> root[ch] = {}
> root = root[ch] # inside the function the inner dict becomes the new
> # root
> print "root is", root
> print "tree is", tree

please forgive my stupid. I still can't follow this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [FAQ] "Best" GUI toolkit for python

2016-10-19 Thread Demosthenes Koptsis


I have the book already.

Thank you Michael


Regards,

Dim


On 10/20/2016 01:30 AM, Michael Torrie wrote:

On 10/19/2016 01:13 PM, Demosthenes Koptsis wrote:

Did you suggest PySide than PyQt...?

Only that I'm using it right now, but I'm making sure my code will run
with PyQt.  I don't see a huge benefit of PySide except for the source
code license (LGPL so you can use it without fee in a proprietary project).

My opinion is that if you're fine with the GPL license of PyQt for open
source projects, it's the way to go.

If not, then with a little bit more effort PySide works pretty well.
They are close enough to each other to be more or less compatible.


I want to start with a Python Qt Framework.

I'd say start with PyQt then.  Most examples on the net assume PyQt
anyway.  That book you mentioned is pretty good.  For a while a couple
of universities were offering it for download as a pdf to support their
classes.  Might be possible to find it in a search.


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


Re: Converting the keys of a dictionary from numeric to string

2016-10-19 Thread Paul Rubin
pozz  writes:
> I have a dictionary where the keys are numbers: ...

Python 2.7.5:

>>> mydict = { 1: 1000, 2: 1500, 3: 100 }
>>> keydict = { 1: "apples", 2: "nuts", 3: "tables" }
>>> newdict = dict((keydict[k],v) for k,v in mydict.items())
>>> print newdict
{'tables': 100, 'nuts': 1500, 'apples': 1000}
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28474] WinError(): Python int too large to convert to C long

2016-10-19 Thread Josh Rosenberg

Josh Rosenberg added the comment:

You can't use I as a format code safely; it silently ignores/wraps overflow on 
the conversion, where i raises on overflow. The unsigned converters are 
basically useless for resilient code in 99% of cases.

I *think* I remember some private utility functions for doing this using O& 
though, not sure if they're available in callproc.c...

--
nosy: +josh.r

___
Python tracker 

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



[issue28447] socket.getpeername() failure on broken TCP/IP connection

2016-10-19 Thread Georgey

Georgey added the comment:

I have changed the code to report any error that occurs in receiving message,

and it reports: [WinError10054] An existing connection was forcibly closed by 
the remote host

Well, this error is the one we need to handle, right? A server need to deal 
with abrupt offlines of clients. Yes the romote host has dropped and connection 
has been broken, but that does not mean we cannot recall its address. 

If this is not a bug, I don't know what is a bug in socket module.

--
import socket
import select, time
import queue, threading

ISOTIMEFORMAT = '%Y-%m-%d %X'
BUFSIZ = 2048
TIMEOUT = 10
ADDR = ('', 15625)

SEG = "◎◎"
SEG_ = SEG.encode()

active_socks = []
socks2addr = {}


server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 
server_sock.bind(ADDR)
server_sock.listen(10)
active_socks.append(server_sock)

mailbox = queue.Queue()

#

def send(mail):   
mail_ = SEG_+ mail.encode()
##The SEG_ at the beginning can seperate messeges for recepient when 
internet busy

for sock in active_socks[1:]:
try:
sock.send(mail_)
except:
handle_sock_err(sock)

def handle_sock_err(sock): 
try:
addr_del = sock.getpeername() 
except:
addr_del = socks2addr[sock]


active_socks.remove(sock) 
socks2addr.pop(sock) 
sock.close()

send("OFFLIN"+str(addr_del) )

#
class Sender(threading.Thread):
#process 'mails' - save and send
def __init__(self, mailbox):
super().__init__()
self.queue = mailbox

def analyze(self, mail, fromwhere):
send( ' : '.join((fromwhere, mail)) )

def run(self):

while True:
msg, addr = mailbox.get()  ###
  
if msg[0] =="sock_err":
print("sock_err @ ", msg[1]) 
#alternative> print("sock_err @ " + repr( msg[1] ) )
#the alternaive command greatly reduces socket closing

handle_sock_err(msg[1])
continue 

self.analyze(msg, addr)

sender = Sender(mailbox)
sender.daemon = True
sender.start()

#
while True:
onlines = list(socks2addr.values()) 
print( '\n'+time.strftime(ISOTIMEFORMAT, time.localtime(time.time())) )
print( 'online: '+str(onlines))

read_sockets, write_sockets, error_sockets = 
select.select(active_socks,[],[],TIMEOUT)

for sock in read_sockets:
#New connection
if sock ==server_sock:
# New Client coming in
clisock, addr = server_sock.accept() 
ip = addr[0]

active_socks.append(clisock)
socks2addr[clisock] = addr
 
#Some incoming message from a client
else:
# Data recieved from client, process it
try:
data = sock.recv(BUFSIZ)
if data:
fromwhere = sock.getpeername()
mail_s = data.split(SEG_)   ##seperate messages
del mail_s[0]
for mail_ in mail_s:
mail = mail_.decode()
print("recv>"+ mail)
   
except Exception as err:
print( "SOCKET ERROR: "+str(err) )
mailbox.put( (("sock_err",sock), 'Server') )
continue
 
server_sock.close()
  

==

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

___
Python tracker 

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



Converting the keys of a dictionary from numeric to string

2016-10-19 Thread pozz

I have a dictionary where the keys are numbers:

mydict = { 1: 1000, 2: 1500, 3: 100 }

I would like to convert keys from number to string representation:

mydict = { "apples": 1000, "nuts": 1500, "tables": 100 }

Of course, somewhere I have the association between key-numbers and 
key-strings, maybe in another dictionary:


keydict = { 1: "apples", 2: "nuts", 3; "tables" }

How could I make the conversion? My solution:

keydict = { 1: "Joseph", 2: "Michael", 3: "John" }
mydict = { 1: 1000, 2: 2000, 3: 3000 }
newdict = {}
for k in mydict.keys():
newdict.update({keydict[k]: mydict[k]})
print(newdict)

I tried changing just mydict (without creating newdict), without success.
--
https://mail.python.org/mailman/listinfo/python-list


[issue28480] Compile error on Modules/socketmodule.c

2016-10-19 Thread Masayuki Yamamoto

Masayuki Yamamoto added the comment:

Oh, that's enough to work, Martin.
I confirmed too.

--

___
Python tracker 

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



[issue28480] Compile error on Modules/socketmodule.c

2016-10-19 Thread Martin Panter

Martin Panter added the comment:

Thanks for the report and patch. I think an empty statement might be better 
than the dummy assignment. Let me know if the following would work and I will 
commit it:

   done:
+;  /* necessary for --without-threads flag */
 Py_END_ALLOW_THREADS

--
nosy: +martin.panter
stage:  -> patch review

___
Python tracker 

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



[issue28447] socket.getpeername() failure on broken TCP/IP connection

2016-10-19 Thread Martin Panter

Martin Panter added the comment:

When I run your program on Linux (natively, and I also tried Wine), the worst 
behaviour I get is a busy loop as soon as a client shuts down the connection 
and recv() returns an empty string. I would have to force an exception in the 
top level code to trigger the rest of the code.

Anyway, my theory is your socket is closed in a previous handle_sock_err() 
call. Your KeyError from socks2addr is further evidence of this. I suggest to 
look at why handle_sock_err() is being called, what exceptions are being 
handled, where they were raised, what the contents and size of “mailbox” is, 
etc.

I suggest you go elsewhere for general help with Python programming (e.g. the 
python-list mailing list), unless it actually looks like a bug in Python.

--
resolution: remind -> not a bug
status: open -> closed
type: crash -> behavior

___
Python tracker 

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



[issue28480] Compile error on Modules/socketmodule.c

2016-10-19 Thread Masayuki Yamamoto

New submission from Masayuki Yamamoto:

_socket module has failed to compile with --without-threads flag since 
554fb699af8c, because Py_END_ALLOW_THREADS macro exists behind the done label ( 
Modules/socketmodule.c:666 ).

If --without-threads flag goes on, Py_END_ALLOW_THREADS macro replaces to just 
right curly bracket. Therefore, between label and end of block have no 
statements. There needs meaningless statement (e.g. result = result;) to avoid 
compile error.
I wrote a one line patch as a test.

--
components: Build, Extension Modules
files: socketmodule-behind-label.patch
keywords: patch
messages: 279000
nosy: masamoto
priority: normal
severity: normal
status: open
title: Compile error on Modules/socketmodule.c
type: compile error
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45146/socketmodule-behind-label.patch

___
Python tracker 

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



[issue28444] Missing extensions modules when cross compiling python 3.5.2 for arm on Linux

2016-10-19 Thread Martin Panter

Martin Panter added the comment:

Your second patch looks better, given my limited understanding of the scripts 
involved. :) I left one more suggestion though.

--

___
Python tracker 

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



[issue28479] Missing indentation in using/windows.rst

2016-10-19 Thread STINNER Victor

STINNER Victor added the comment:

Thanks for your contribution Julien.

--
nosy: +haypo

___
Python tracker 

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



[issue28479] Missing indentation in using/windows.rst

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 39ac5093bdbb by Victor Stinner in branch '3.6':
Close #28479: Fix reST syntax in windows.rst
https://hg.python.org/cpython/rev/39ac5093bdbb

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue28479] Missing indentation in using/windows.rst

2016-10-19 Thread Julien

New submission from Julien:

Hi,

In https://docs.python.org/3.7/using/windows.html, right before 
https://docs.python.org/3.7/using/windows.html#additional-modules, the "Changed 
in version 3.6:" content lacks an indentation.

It look like it's nothing, but it breaks the PDF generation, by generating 
invalid latex.

I attached the simple patch to fix this, and tested it, it's now rendered with 
the correct indentation and the PDF builds successfully.

A grep -A10 -r 'versionchanged::$' show no other problems of indentation on 
those blocks (and shows this is the right way to fix it).

--
assignee: docs@python
components: Documentation
files: using_windows_versionchanged.patch
keywords: patch
messages: 278996
nosy: docs@python, sizeof
priority: normal
severity: normal
status: open
title: Missing indentation in using/windows.rst
type: enhancement
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45145/using_windows_versionchanged.patch

___
Python tracker 

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



Re: [FAQ] "Best" GUI toolkit for python

2016-10-19 Thread Michael Torrie
On 10/19/2016 01:13 PM, Demosthenes Koptsis wrote:
> Did you suggest PySide than PyQt...?

Only that I'm using it right now, but I'm making sure my code will run
with PyQt.  I don't see a huge benefit of PySide except for the source
code license (LGPL so you can use it without fee in a proprietary project).

My opinion is that if you're fine with the GPL license of PyQt for open
source projects, it's the way to go.

If not, then with a little bit more effort PySide works pretty well.
They are close enough to each other to be more or less compatible.

> I want to start with a Python Qt Framework.

I'd say start with PyQt then.  Most examples on the net assume PyQt
anyway.  That book you mentioned is pretty good.  For a while a couple
of universities were offering it for download as a pdf to support their
classes.  Might be possible to find it in a search.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue22431] Change format of test runner output

2016-10-19 Thread Jon Dufresne

Changes by Jon Dufresne :


--
nosy: +jdufresne

___
Python tracker 

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



[issue20361] -W command line options and PYTHONWARNINGS environmental variable should not override -b / -bb command line options

2016-10-19 Thread Jon Dufresne

Changes by Jon Dufresne :


--
nosy: +jdufresne

___
Python tracker 

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



[issue1520879] make install change: Allow $DESTDIR to be relative

2016-10-19 Thread Douglas Greiman

Douglas Greiman added the comment:

Duplicate of http://bugs.python.org/issue11411

--

___
Python tracker 

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



[issue1520879] make install change: Allow $DESTDIR to be relative

2016-10-19 Thread Douglas Greiman

Changes by Douglas Greiman :


--
status: open -> closed

___
Python tracker 

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



[issue28478] Built-in module 'Time' does not enable functions if -Wno-error specified in the build environment

2016-10-19 Thread toast12

toast12 added the comment:

Excuse my typo. I meant -Werror and not -Wno-error

--

___
Python tracker 

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



[issue28478] Built-in module 'Time' does not enable functions if -Wno-error specified in the build environment

2016-10-19 Thread toast12

New submission from toast12:

Our build environment uses -Wno-error. However, this causes problems enabling 
all the functions in built-in module 'time':

configure:11130: checking for strftime
-
-
cc1: warnings being treated as errors
conftest.c:236: error: conflicting types for built-in function 'strftime'

Because strftime was not enabled, we had problems running xmlrpc.client:

>>> from xmlrpc import client 
Traceback (most recent call last):   File "", line 1, inFile 
"XXX/lib64/python3.5/xmlrpc/client.py", line 267, in  if 
_day0.strftime('%Y') == '0001':  # Mac OS X AttributeError: module 'time' 
has no attribute 'strftime' >>>

As a workaround, I am passing -fno-builtin now. But I believe this should be 
handled on the python end

--
components: Extension Modules
messages: 278993
nosy: toast12
priority: normal
severity: normal
status: open
title: Built-in module 'Time' does not enable functions if -Wno-error specified 
in the build environment
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



[issue28475] Misleading error on random.sample when k < 0

2016-10-19 Thread Francisco Couzo

Changes by Francisco Couzo :


Added file: http://bugs.python.org/file45144/random_sample2.patch

___
Python tracker 

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



[issue28475] Misleading error on random.sample when k < 0

2016-10-19 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I would rather revise the existing message to say that it cannot be negative or 
larger that population.

--

___
Python tracker 

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



Pyro4 now with remote iterators

2016-10-19 Thread Irmen de Jong
Hi,

I have just released Pyro4 version 4.49; https://pypi.python.org/pypi/Pyro4

(super short description: it is a library that allows you to transparently call 
methods
on objects that are running on other machines, as if they were local)

Pyro now also supports remote iterators. This means you can loop over a remote 
iterator
(or generator) that is running on another machine, and get the items on demand 
as they
are consumed by your client code.

Server:

class RemoteObject:
@Pyro4.expose
def numbers(self):
i = 0
while i<10:
yield i
i += 1

Client:

r = Pyro4.Proxy(".")
for number in r.numbers():
print(number)


When used correctly this feature can avoid having to build large data 
structures and
returning those all at once from a remote call. Instead, you now can return them
piecemeal and only that which is actually used by the client.

The feature is also supported by the Pyrolite client library for Java and 
.NET/C#.
I think it is pretty nifty and interesting enough to post about it here :)


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


[issue26685] Raise errors from socket.close()

2016-10-19 Thread Yury Selivanov

Yury Selivanov added the comment:

>> Would you mind to open an issue specific for asyncio?

> I'll open an issue on GH today to discuss with you/Guido/asyncio devs.

Guido, Victor, please take a look: https://github.com/python/asyncio/pull/449

--

___
Python tracker 

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



Re: Inplace shuffle function returns none

2016-10-19 Thread Sayth Renshaw
Hi Chris

I read this last night and thought i may have woken with a frightfully witty 
response.

I didnt however.

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


Re: [FAQ] "Best" GUI toolkit for python

2016-10-19 Thread Demosthenes Koptsis

Thanks Michael,

now i have a clear look about Py GUIs.

Did you suggest PySide than PyQt...?

I want to start with a Python Qt Framework.


On 10/19/2016 09:43 PM, Michael Torrie wrote:

On 10/19/2016 12:18 PM, Demosthenes Koptsis wrote:

I thought PyQt was supported by Qt company...

I don't think so.  PyQt is a commercial product of Riverbank Computing.
It's dual-licensed under the GPL and a proprietary license you can buy.
Riverbank may have had a relationship with Trolltech back in the day,
but I'm not aware of any current business relationship between Riverbank
and the Qt project or the Qt company.  Riverbank is obviously happy to
be a part of the Qt open source community.

PySide was created by Nokia when they owned Qt. Basically they wanted a
python toolkit that they could use without being beholden to Riverbank.
It's clear that Nokia never wanted to monetize Qt like TrollTech did,
but rather use it to develop their own phone operating system.  That
didn't pan out and Nokia spun off Qt to it's own organization/company,
and PySide is part of that Qt Project.

PySide development is ongoing but the pace is not as rapid as PyQt.
Riverbank still develops and sells PyQt and support to companies and has
stable Qt5 support now.  I wondered if PySide would ultimately kill off
PyQt, but so far that has not been the case.


There is also an official book by Prentice Hall:

Rapid GUI Programming with Python and Qt (Prentice Hall Open Source
Software Development)

https://www.amazon.com/Programming-Python-Prentice-Software-Development/dp/0132354187/ref=sr_1_1?ie=UTF8=1476901015=8-1=rapid+qt+python

Inside the book the apps are been developed in PyQt

Not sure what makes this an "official book." It has nothing to do with
the Qt Project or the Qt Company.



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


[issue28444] Missing extensions modules when cross compiling python 3.5.2 for arm on Linux

2016-10-19 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Thanks for reviewing the patch Martin.

> Why do you remove the code that loops over Modules/Setup? Maybe is it 
> redundant with the other code for removing the already-built-in modules?

Yes because this is redundant, maybe not the case when this was written 15 
years ago.


> The logic matching MODOBJS doesn’t look super robust.

Agreed on both points.


> if you added Modules/Setup.config to the list of Setup files to process, 
> would that eliminate the need to look at both MODOBJS and 
> sys.builtin_module_names?

The processing of the Setup files done by setup.py is not robust either. It 
does not handle the lines of the form ' = '. The syntax described 
in Setup.dist allows for:
mod_form1 mod_form2 _mod_source.c
where both the 'mod_form1' and 'mod_form2' modules depend on the same source 
file and one would like to build them statically. makesetup handles that case 
while setup.py does not.
There is no guarantee that a change in the makesetup machinery would be 
systematically reflected in a change to setup.py. And indeed this is the case 
now - as you point it out - setup.py is currently missing the parsing of 
Setup.config.

Here is a new patch that uses the result of the parsing done by makesetup in 
setup.py.

--
Added file: http://bugs.python.org/file45143/removed_modules_2.patch

___
Python tracker 

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



Re: [FAQ] "Best" GUI toolkit for python

2016-10-19 Thread Michael Torrie
On 10/19/2016 12:18 PM, Demosthenes Koptsis wrote:
> I thought PyQt was supported by Qt company...

I don't think so.  PyQt is a commercial product of Riverbank Computing.
It's dual-licensed under the GPL and a proprietary license you can buy.
Riverbank may have had a relationship with Trolltech back in the day,
but I'm not aware of any current business relationship between Riverbank
and the Qt project or the Qt company.  Riverbank is obviously happy to
be a part of the Qt open source community.

PySide was created by Nokia when they owned Qt. Basically they wanted a
python toolkit that they could use without being beholden to Riverbank.
It's clear that Nokia never wanted to monetize Qt like TrollTech did,
but rather use it to develop their own phone operating system.  That
didn't pan out and Nokia spun off Qt to it's own organization/company,
and PySide is part of that Qt Project.

PySide development is ongoing but the pace is not as rapid as PyQt.
Riverbank still develops and sells PyQt and support to companies and has
stable Qt5 support now.  I wondered if PySide would ultimately kill off
PyQt, but so far that has not been the case.

> There is also an official book by Prentice Hall:
> 
> Rapid GUI Programming with Python and Qt (Prentice Hall Open Source 
> Software Development)
> 
> https://www.amazon.com/Programming-Python-Prentice-Software-Development/dp/0132354187/ref=sr_1_1?ie=UTF8=1476901015=8-1=rapid+qt+python
> 
> Inside the book the apps are been developed in PyQt

Not sure what makes this an "official book." It has nothing to do with
the Qt Project or the Qt Company.

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


Re: Python-based monads essay part 2

2016-10-19 Thread Marko Rauhamaa
Chris Angelico :

> On Thu, Oct 20, 2016 at 3:51 AM, Marko Rauhamaa  wrote:
>>
>> def print(world, text, cont):
>> return cont(World(past=world, offset=text))
>>
>> def print_x_then_y(world, x, y, cont):
>> return print(world, x, lambda world2: print(world2, y, cont))
>>
> [...]
>>
>> The end result is an ordered sequence of events. The topological order
>> is a causal order (you need the past world to construct the future
>> world), and causal order generates a temporal order.
>
> Yeah, nice. You just made a mutable object with significant order of
> evaluation and then added enough external information to it that you
> can pretend it's immutable and can be evaluated in any order.

Please point out what is mutable in my code above. It doesn't have a
single mutable object. The world is recreated with each interaction.

(Parenthetically, that's how quantum mechanics explains life, universe
and everything. Nothing ever changes. Immutable particles/systems simply
get destroyed and created with every interaction. In fact, particles can
be abstracted out as figments of imagination -- the existence is a
network of interactions.)

> I could make that same transformation with literally any function,
> simply by taking "the world" as an input and an output. It makes the
> entire concept utterly meaningless.

Whether this mental gymnastics is useful, everybody can form their own
opinion.

A funny, semirelated anecdote about Scheme. Scheme does not have a
try/finally construct. It can't -- Scheme is too powerful. That's
because in Scheme, nothing is [guaranteed to be] final. After you leave
an execution context, a continuation may leak out that enables a
system-wide jump in the middle of the context.

Python could have similar continuations if it added a "resume" keyword:

def work(f):
...
message_from_grave = raise ValueError()
if message_from_grave == "CarryOn!":
...

def guard_it():
f = open(...)
try:
work(f)
finally:
f.close()

def main():
try:
guard_it()
except ValueError:
# I'm having none of it!
resume "CarryOn!"

The problem is, how can the file f unclose itself when work resumes?
Well, maybe we'd need another keyword:

def guard_it():
f = open(...)
try:
work(f)
finally:
f.close()
nevermind:
f.reopen()


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


Re: [FAQ] "Best" GUI toolkit for python

2016-10-19 Thread Demosthenes Koptsis

I thought PyQt was supported by Qt company...

There is also an official book by Prentice Hall:

Rapid GUI Programming with Python and Qt (Prentice Hall Open Source 
Software Development)


https://www.amazon.com/Programming-Python-Prentice-Software-Development/dp/0132354187/ref=sr_1_1?ie=UTF8=1476901015=8-1=rapid+qt+python

Inside the book the apps are been developed in PyQt

Regards,
Dim

On 10/19/2016 03:49 PM, Mark Summerfield wrote:

On Tuesday, October 18, 2016 at 9:09:46 PM UTC+1, Demosthenes Koptsis wrote:

My favorite GUIs are PyQt and wxPython.

I prefer PyQt than PySide because PySide seem to me like an abandoned
project.

[snip]

It does seem that PySide 1 isn't making any visible progress.

However, PySide 2 for Qt 5 is indeed progressing, and is being funded by The Qt 
Company: https://wiki.qt.io/PySide2


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


[issue28477] Add optional user argument to pathlib.Path.home()

2016-10-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

pathlib.Path.home() don't support the user argument for reasons.

The main problem is that os.path.expanduser() for other users is faked on 
Windows. It uses guessing, and perhaps it returns correct result in most cases. 
But in non-standard situations, if current user or other users have non-default 
home directory, it returns wrong result. I don't know wherever it works for 
users with non-ascii names or names containing special characters.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



Re: Python-based monads essay part 2

2016-10-19 Thread Chris Angelico
On Thu, Oct 20, 2016 at 3:51 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>> Okay. Now let's suppose that, instead of "73" in the first step, you
>> have "ask the user for an integer". Are you allowed to eliminate this
>> prompt, since the result of it cannot possibly affect anything? And if
>> not, why not?
>
> I would guess yes; that's how Python works as well:
>
> >>> 7 or input()
> 7
>

That's not quite the same. That's equivalent to:

if 7:
7
else:
input()

Short-circuiting depends only on what's known *prior* to that
evaluation. Dead code elimination removes the notion of time:

int(input("Enter something:")) * 0 + 5

This can simply return 5, because (barring an exception being thrown)
the value entered cannot affect the result. Python does not do this.
And any system that has optimization flags (PostgreSQL, Pike, etc),
this would be marked "has side effects", and therefore is not
considered dead code. But if you (maybe mistakenly) mark input() as a
pure function, then yes, this could indeed be optimized out.

> However, if we think of the I/O interaction (aka *the process*) to be
> the return value of a function, every bead in the I/O chain counts.

And that's what I mean about making function purity meaningless. Here,
look - this is a pure function!

magic_numbers = [1, 2, 4, 8]
def do_magic(x):
magic_numbers[x % 4] += x / 4
return magic_numbers[(x + 1) % 4]

Since the previous state of magic_numbers can be considered an input,
and the new state can be considered an output, this is a pure
function! Right?

>> If you consider that the world changes state as a result of asking the
>> user for input, then you've just eliminated all notion of functional
>> purity.
>
> Not necessarily. Nothing changes the world. Rather you have different
> worlds: the world of the past and the world of the future. The world of
> the past is in the past of the world of the future:
>
> def print(world, text, cont):
> return cont(World(past=world, offset=text))
>
> def print_x_then_y(world, x, y, cont):
> return print(world, x, lambda world2: print(world2, y, cont))
>
>> You have side effects, plain and simple, and you're using imperative
>> code.
>
> Technically, no. Thought-model-wise, yes.

Technical means nothing if you're destroying the meaning of functional
purity in order to squeeze I/O into it.

> My example above is purely functional as:
>
>  * Every object is immutable.
>
>  * The order of evaluation does not change the end result.
>
> The end result is an ordered sequence of events. The topological order
> is a causal order (you need the past world to construct the future
> world), and causal order generates a temporal order.

Yeah, nice. You just made a mutable object with significant order of
evaluation and then added enough external information to it that you
can pretend it's immutable and can be evaluated in any order. I could
make that same transformation with literally any function, simply by
taking "the world" as an input and an output. It makes the entire
concept utterly meaningless.

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


Re: Button Widget and Key Binding Problem

2016-10-19 Thread Wildman via Python-list
On Wed, 19 Oct 2016 04:39:03 +0100, MRAB wrote:

> The 'bind' method passes an 'event' object when it calls; the 'command' 
> callback doesn't.
> 
> You don't care about the 'event' object anyway, so you can just define a 
> single method with a default argument that you ignore:
> 
>  def load_image(self, event=None):
>  # code to load an image

That works perfectly.  Thank you.

-- 
 GNU/Linux user #557453
The cow died so I don't need your bull!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28477] Add optional user argument to pathlib.Path.home()

2016-10-19 Thread Josh Rosenberg

New submission from Josh Rosenberg:

os.path.expanduser supports both '~' and '~username` constructs to get home 
directories. It seems reasonable for pathlib.Path.home to default to getting 
the current user's home directory, but support passing an argument to get the 
home directory for another user. It means no need to use os.path.expanduser for 
the purpose (which always strikes me as a little "ugly" for portable code; the 
~ works, but it's using UNIX syntax in a way that makes it feel non-portable), 
making pathlib a more complete replacement.

--
components: Library (Lib)
messages: 278988
nosy: josh.r
priority: normal
severity: normal
status: open
title: Add optional user argument to pathlib.Path.home()
versions: Python 3.7

___
Python tracker 

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



Re: Python-based monads essay part 2

2016-10-19 Thread Marko Rauhamaa
Chris Angelico :
> Okay. Now let's suppose that, instead of "73" in the first step, you
> have "ask the user for an integer". Are you allowed to eliminate this
> prompt, since the result of it cannot possibly affect anything? And if
> not, why not?

I would guess yes; that's how Python works as well:

>>> 7 or input()
7


However, if we think of the I/O interaction (aka *the process*) to be
the return value of a function, every bead in the I/O chain counts.

> After all, eliminating terms that have been multiplied by zero is one
> form of algebra.

I wonder if the word "algebra" brings anything to this discussion. It
doesn't make Haskell any more or less functional.

> If you consider that the world changes state as a result of asking the
> user for input, then you've just eliminated all notion of functional
> purity.

Not necessarily. Nothing changes the world. Rather you have different
worlds: the world of the past and the world of the future. The world of
the past is in the past of the world of the future:

def print(world, text, cont):
return cont(World(past=world, offset=text))

def print_x_then_y(world, x, y, cont):
return print(world, x, lambda world2: print(world2, y, cont))

> You have side effects, plain and simple, and you're using imperative
> code.

Technically, no. Thought-model-wise, yes.

Of course, recursive functions can simulate Turing machines and vice
versa. You can write purely functional code in purely imperative style.

My example above is purely functional as:

 * Every object is immutable.

 * The order of evaluation does not change the end result.

The end result is an ordered sequence of events. The topological order
is a causal order (you need the past world to construct the future
world), and causal order generates a temporal order.

Now, *if* the Haskell VM chooses to *realize* I/O events *as soon as* it
becomes aware of them, you get traditional, imperative side effects.


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


[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thanks Zachary.

--

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c445746d0846 by Serhiy Storchaka in branch '3.5':
Issue #19795: Fixed formatting a table.
https://hg.python.org/cpython/rev/c445746d0846

New changeset 3b554c9ea1c4 by Serhiy Storchaka in branch '3.6':
Issue #19795: Fixed formatting a table.
https://hg.python.org/cpython/rev/3b554c9ea1c4

New changeset 884c9d9159dc by Serhiy Storchaka in branch 'default':
Issue #19795: Fixed formatting a table.
https://hg.python.org/cpython/rev/884c9d9159dc

New changeset ddf32a646457 by Serhiy Storchaka in branch '2.7':
Issue #19795: Fixed formatting a table.
https://hg.python.org/cpython/rev/ddf32a646457

--

___
Python tracker 

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



Re: how to evaluate a ast tree and change Add to Multiply ?

2016-10-19 Thread Jerry Hill
On Wed, Oct 12, 2016 at 5:55 AM, meInvent bbird  wrote:
> i just expect to
> rewrite + become multiply
> by edit the example in the link provided

This seems to work.  You need to define visit_BinOp instead of
visit_Num (since you want to mess with the binary operations, not the
numbers).  Then,in visit_BinOp, we just replace the ast.Add node with
an ast.Mult node.

import ast

class ChangeAddToMultiply(ast.NodeTransformer):
"""Wraps all integers in a call to Integer()"""
def visit_BinOp(self, node):
if isinstance(node.op, ast.Add):
node.op = ast.Mult()
return node

code = 'print(2+5)'
tree = ast.parse(code)
tree = ChangeAddToMultiply().visit(tree)
ast.fix_missing_locations(tree)
co = compile(tree, '', "exec")

exec(code)
exec(co)

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


[issue26685] Raise errors from socket.close()

2016-10-19 Thread Yury Selivanov

Yury Selivanov added the comment:

> Ah, you became reasonable :-D

Come on... :)

> Would you mind to open an issue specific for asyncio?

I'll open an issue on GH today to discuss with you/Guido/asyncio devs.

--

___
Python tracker 

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



Re: Python-based monads essay part 2

2016-10-19 Thread Chris Angelico
On Wed, Oct 19, 2016 at 9:26 AM, Gregory Ewing
 wrote:
> The things being reasoned about -- the actions -- are
> not themselves functions, but that doesn't mean there's
> any cheating going on. Would you say it was cheating
> to perform algebraic manipulations on an expression
> involving numbers or strings? Why should it be any
> different when the things being manipulated represent
> actions that affect the world?

Okay. Let me pick up two of functional programming's favourite idioms,
and you can help me understand how I/O monads fit into them.

1) Lazy evaluation. In an imperative language, you can't say "make me
a list of prime numbers, then take the 73rd element"; but functional
languages are perfectly happy to have an infinite-length as an object,
as long as you never actually ask for the last element or anything.

2) Related to the above: Dead code elimination. If the 73rd prime ends
up being multiplied by zero, Haskell is entirely justified in not
calculating it.

Okay. Now let's suppose that, instead of "73" in the first step, you
have "ask the user for an integer". Are you allowed to eliminate this
prompt, since the result of it cannot possibly affect anything? And if
not, why not? After all, eliminating terms that have been multiplied
by zero is one form of algebra. If numbers and strings and I/O monads
are all the same, there's no difference between "length of this
string" (an operation yielding an integer) and "ask the user for an
integer".

If you consider that the world changes state as a result of asking the
user for input, then you've just eliminated all notion of functional
purity. You have side effects, plain and simple, and you're using
imperative code. At what point can you deem that the algebra is safe?
At what boundary can any of your code manipulations still be done?

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


[issue26685] Raise errors from socket.close()

2016-10-19 Thread STINNER Victor

STINNER Victor added the comment:

"After thinking about this problem for a while, I arrived to the conclusion 
that we need to fix asyncio."

Ah, you became reasonable :-D

"Essentially, when a user passes a socket object to the event loop API like 
'create_server', they give up the control of the socket to the loop.  The loop 
should detach the socket object and have a full control over it."

I don't know how asyncio should be modified exactly, but I agree that someone 
should change in asyncio. The question is more about how to reduce headache 
because of the backward compatibility and don't kill performances.

Would you mind to open an issue specific for asyncio?

--

___
Python tracker 

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



[issue26685] Raise errors from socket.close()

2016-10-19 Thread Yury Selivanov

Yury Selivanov added the comment:

After thinking about this problem for a while, I arrived to the conclusion that 
we need to fix asyncio.  Essentially, when a user passes a socket object to the 
event loop API like 'create_server', they give up the control of the socket to 
the loop.  The loop should detach the socket object and have a full control 
over it.

--
status: open -> closed

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread Zachary Ware

Zachary Ware added the comment:

There's also an issue with a table in Doc/library/logging.rst, see 
http://buildbot.python.org/all/builders/Docs%203.x/builds/2675/steps/docbuild/logs/stdio

I'm not sure why that doesn't cause the build to fail, though, it's marked as 
an error.

--
nosy: +zach.ware

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for noticing this Victor.

--

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e4aa34a7ca53 by Serhiy Storchaka in branch '3.5':
Issue #19795: Improved more markups of True/False.
https://hg.python.org/cpython/rev/e4aa34a7ca53

New changeset dd7e48e3e5b0 by Serhiy Storchaka in branch '2.7':
Issue #19795: Improved more markups of True/False.
https://hg.python.org/cpython/rev/dd7e48e3e5b0

New changeset 7b143d6834cf by Serhiy Storchaka in branch '3.6':
Issue #19795: Improved more markups of True/False.
https://hg.python.org/cpython/rev/7b143d6834cf

New changeset 9fc0f20ea7de by Serhiy Storchaka in branch 'default':
Issue #19795: Improved more markups of True/False.
https://hg.python.org/cpython/rev/9fc0f20ea7de

--

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread STINNER Victor

STINNER Victor added the comment:

Thanks, "build #1563 of Docs 3.5 is complete: Success [build successful]": the 
bot is happy again ;-)

--

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread Fred L. Drake, Jr.

Fred L. Drake, Jr. added the comment:

Without the star would be right.  ReST does not support nested markup, and in 
this case, I don't think it would make sense anyway.

--
nosy: +fdrake

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 9ef78351d2e9 by Serhiy Storchaka in branch '3.5':
Issue #19795: Fixed markup errors.
https://hg.python.org/cpython/rev/9ef78351d2e9

New changeset 6c8a26e60728 by Serhiy Storchaka in branch '3.6':
Issue #19795: Fixed markup errors.
https://hg.python.org/cpython/rev/6c8a26e60728

New changeset 2127ef3b7660 by Serhiy Storchaka in branch 'default':
Issue #19795: Fixed markup errors.
https://hg.python.org/cpython/rev/2127ef3b7660

--

___
Python tracker 

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



[issue26568] Add a new warnings.showwarnmsg() function taking a warnings.WarningMessage object

2016-10-19 Thread Sebastian Berg

Sebastian Berg added the comment:

To make warning testing saner, in numpy we added basically my own version of 
catch_warnings on steroids, which needed/will need changing because of this.

Unless I missed it somewhere, this change should maybe put into the release 
notes to warn make it a bit easier to track down what is going on.

--
nosy: +seberg

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread STINNER Victor

STINNER Victor added the comment:

The "Docs" bot doesn't like your change:

http://buildbot.python.org/all/builders/Docs%203.x/builds/2673/steps/suspicious/logs/stdio


WARNING: [whatsnew/3.1:549] "`" found in "``False``"


WARNING: [whatsnew/3.4:163] "`" found in "to ``None`"
WARNING: [whatsnew/3.4:163] "`" found in " during finalization 
` ("
/buildbot/buildarea/3.x.ware-docs/build/Doc/whatsnew/3.4.rst:163: WARNING: 
undefined label: module globals are no longer set to ``none` (if the link has 
no caption the label must precede a section header)

Extract of the change:

-  protocol 3.  Another solution is to set the *fix_imports* option to 
**False**.
+  protocol 3.  Another solution is to set the *fix_imports* option to 
*``False``*.


I guess that it should ``False`` without star?

--
nosy: +haypo

___
Python tracker 

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



Re: Python GUI application embedding a web browser - Options?

2016-10-19 Thread Paul Moore
On Wednesday, 19 October 2016 13:54:09 UTC+1, Mark Summerfield  wrote:
>
> Since the application is a web app have you looked at:
> https://github.com/r0x0r/pywebview + https://github.com/dddomodossola/remi
> or at
> https://flexx.readthedocs.io/en/stable/
> These basically wrap the platform's web engine so you can write stand alone 
> desktop apps but coding in Python (which gets translated into HTML/JS).

I think that's the opposite of what I want (which is a standalone desktop app 
coded in Python, than embeds an active webpage as a widget in the app). But 
I'll take a closer look - it may be that I'm not clear on what they are doing 
(pretty certain, I've barely any experience with what's available for Python 
outside of command line applications).

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


[issue28240] Enhance the timeit module: display average +- std dev instead of minimum

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4e4d4e9183f5 by Victor Stinner in branch 'default':
Issue #28240: Fix formatting of the warning.
https://hg.python.org/cpython/rev/4e4d4e9183f5

--

___
Python tracker 

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



[issue19795] Formatting of True/False/None in docs

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cef2373f31bb by Serhiy Storchaka in branch '2.7':
Issue #19795: Mark up None as literal text.
https://hg.python.org/cpython/rev/cef2373f31bb

New changeset a8d5b433bb36 by Serhiy Storchaka in branch '3.5':
Issue #19795: Mark up None as literal text.
https://hg.python.org/cpython/rev/a8d5b433bb36

New changeset 2e97ed8e7e3c by Serhiy Storchaka in branch '3.6':
Issue #19795: Mark up None as literal text.
https://hg.python.org/cpython/rev/2e97ed8e7e3c

New changeset 5f997b3cb59c by Serhiy Storchaka in branch 'default':
Issue #19795: Mark up None as literal text.
https://hg.python.org/cpython/rev/5f997b3cb59c

New changeset b7df6c09ddf9 by Serhiy Storchaka in branch '2.7':
Issue #19795: Mark up True and False as literal text instead of bold.
https://hg.python.org/cpython/rev/b7df6c09ddf9

New changeset 477a82ec81fc by Serhiy Storchaka in branch '3.5':
Issue #19795: Mark up True and False as literal text instead of bold.
https://hg.python.org/cpython/rev/477a82ec81fc

New changeset 91992ea3c6b1 by Serhiy Storchaka in branch '3.6':
Issue #19795: Mark up True and False as literal text instead of bold.
https://hg.python.org/cpython/rev/91992ea3c6b1

New changeset 8cc9ad294ea9 by Serhiy Storchaka in branch 'default':
Issue #19795: Mark up True and False as literal text instead of bold.
https://hg.python.org/cpython/rev/8cc9ad294ea9

--

___
Python tracker 

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



[issue28473] mailbox.MH crashes on certain Claws Mail .mh_sequences files

2016-10-19 Thread R. David Murray

R. David Murray added the comment:

I meant 'nmh'.  Also, if the problem is that mailbox blows up on an 
.mh_sequences file with bad records and doesn't provide any way to access the 
valid records (like nmh mostly manages to do), then that is something that 
could be fixed, and we can reopen the issue.

--
versions: +Python 3.6, Python 3.7 -Python 3.5

___
Python tracker 

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



Re: Python GUI application embedding a web browser - Options?

2016-10-19 Thread Mark Summerfield
On Wednesday, October 19, 2016 at 11:08:15 AM UTC+1, Paul  Moore wrote:
> I'm looking to write a GUI application in Python (to run on Windows, using 
> Python 3.5). The application is just a relatively thin wrapper around a 
> browser - it's presenting an existing web application, just in its own window 
> rather than in a standard browser window. I'm looking for advice on a good 
> GUI toolkit to use.
> 
> I've not done much GUI programming in Python, so I don't have a "preferred 
> toolkit" as such. A bit of Google searching found an embedded browser widget 
> in PyQt, but the examples I tried didn't work - it looks like the QWebView 
> class is deprecated and has been removed in the current version of PyQt. I 
> haven't really found any other examples (there's a "embedding a web page in 
> Tkinter" example I found, but it looks like it's just doing rendering, not 
> embedding a full browser - which I need as the site I want to access uses 
> CSS/JavaScript).
> 
> Is there any good option for this, or would I be better looking elsewhere for 
> a solution? I could probably work out how to knock something up using .NET, 
> or a HTA file, for example, I'm just more comfortable coding in Python.
> 
> Thanks,
> Paul

Since the application is a web app have you looked at:
https://github.com/r0x0r/pywebview + https://github.com/dddomodossola/remi
or at
https://flexx.readthedocs.io/en/stable/
These basically wrap the platform's web engine so you can write stand alone 
desktop apps but coding in Python (which gets translated into HTML/JS).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: [FAQ] "Best" GUI toolkit for python

2016-10-19 Thread Mark Summerfield
On Tuesday, October 18, 2016 at 9:09:46 PM UTC+1, Demosthenes Koptsis wrote:
> My favorite GUIs are PyQt and wxPython.
> 
> I prefer PyQt than PySide because PySide seem to me like an abandoned 
> project.
[snip]

It does seem that PySide 1 isn't making any visible progress.

However, PySide 2 for Qt 5 is indeed progressing, and is being funded by The Qt 
Company: https://wiki.qt.io/PySide2
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python GUI application embedding a web browser - Options?

2016-10-19 Thread Paul Moore
On 19 October 2016 at 12:10, Phil Thompson  wrote:
> The Chrome-based QWebEngineView (http://doc.qt.io/qt-5/qwebengineview.html) 
> is fully supported by PyQt.

Nice. Thanks for the pointer. Looks like the various bits of advice I
found on the web are a little out of date, is all.

Cheers,
Paul
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How can I copy one excel file data to another excel file by excluding hidden rows content using Python

2016-10-19 Thread Karim

On 19/10/2016 11:30, Kishore JK wrote:

I need to copy one excel file data into another excel file by excluding rows 
which were hidden in source excel file.

https://i.stack.imgur.com/NPUK6.png

As shown in the image, from the source excel file, I need to copy the data of 
row numbers 116,135 and 139 and exclude all the remaining rows which were 
hidden because of not matching the criteria.

I have tried below code, but this is copying entire data into new excel sheet.
wb = openpyxl.load_workbook('sourcefile.xlsx')
sheet = wb.active
sheet.title = 'Sheet1'
wb.save('destinationfile.xlsx')


Hello,

I use xlrd external module. This is only samples codes from one  of my 
class. You  can filter the row you want with an conditional statement.

You must have equivalent attribute in openpyxl module.

Import xlrd

Import csv

 self._book= xlrd.open_workbook(xlfilename)

 self._selected_sheets = [self._book.sheet_by_name(sheetname) for 
sheetname in sheets]


  writer = csv.writer(open(xlfilename, 'wb'), 
delimiter=self.file_format.delimiter)


  rows   = izip(*(sheet.col_values(col) for col in selected_columns))

  for row in rows:

   # NOTE!!!: could have UnicodeEncodeError exception raised here!

   try:

  writer.writerow(row)

   except UnicodeEncodeError, e:

   print("\nWarning: {0}. Row '{1}' will not be 
extracted!".format(e, row))



Regards

Karim


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


Re: Python GUI application embedding a web browser - Options?

2016-10-19 Thread Vincent Vande Vyvre

Le 19/10/2016 à 12:07, Paul Moore a écrit :

I'm looking to write a GUI application in Python (to run on Windows, using 
Python 3.5). The application is just a relatively thin wrapper around a browser 
- it's presenting an existing web application, just in its own window rather 
than in a standard browser window. I'm looking for advice on a good GUI toolkit 
to use.

I've not done much GUI programming in Python, so I don't have a "preferred toolkit" as 
such. A bit of Google searching found an embedded browser widget in PyQt, but the examples I tried 
didn't work - it looks like the QWebView class is deprecated and has been removed in the current 
version of PyQt. I haven't really found any other examples (there's a "embedding a web page in 
Tkinter" example I found, but it looks like it's just doing rendering, not embedding a full 
browser - which I need as the site I want to access uses CSS/JavaScript).

Is there any good option for this, or would I be better looking elsewhere for a 
solution? I could probably work out how to knock something up using .NET, or a 
HTA file, for example, I'm just more comfortable coding in Python.

Thanks,
Paul


Hi,

PyQt is a good choice to embed a web viewer in a GUI application.

There's no great differences between Qt4 and Qt5.

An example with PyQt4:
http://bazaar.launchpad.net/~vincent-vandevyvre/oqapy/2.0/files/head:/oqapy-2.0/g9n/

The same with PyQt5:
http://bazaar.launchpad.net/~vincent-vandevyvre/oqapy/3.0/files/head:/g9n/

--
Vincent V.V.
Oqapy  . python3-exiv2 
 . Qarte 
 . PaQager 

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


Re: Python GUI application embedding a web browser - Options?

2016-10-19 Thread Phil Thompson
On 19 Oct 2016, at 11:07 am, Paul Moore  wrote:
> 
> I'm looking to write a GUI application in Python (to run on Windows, using 
> Python 3.5). The application is just a relatively thin wrapper around a 
> browser - it's presenting an existing web application, just in its own window 
> rather than in a standard browser window. I'm looking for advice on a good 
> GUI toolkit to use.
> 
> I've not done much GUI programming in Python, so I don't have a "preferred 
> toolkit" as such. A bit of Google searching found an embedded browser widget 
> in PyQt, but the examples I tried didn't work - it looks like the QWebView 
> class is deprecated and has been removed in the current version of PyQt. I 
> haven't really found any other examples (there's a "embedding a web page in 
> Tkinter" example I found, but it looks like it's just doing rendering, not 
> embedding a full browser - which I need as the site I want to access uses 
> CSS/JavaScript).
> 
> Is there any good option for this, or would I be better looking elsewhere for 
> a solution? I could probably work out how to knock something up using .NET, 
> or a HTA file, for example, I'm just more comfortable coding in Python.

The Chrome-based QWebEngineView (http://doc.qt.io/qt-5/qwebengineview.html) is 
fully supported by PyQt.

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


[issue28447] socket.getpeername() failure on broken TCP/IP connection

2016-10-19 Thread Georgey

Georgey added the comment:

so when do you think the error socket closes?

--

___
Python tracker 

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



Python GUI application embedding a web browser - Options?

2016-10-19 Thread Paul Moore
I'm looking to write a GUI application in Python (to run on Windows, using 
Python 3.5). The application is just a relatively thin wrapper around a browser 
- it's presenting an existing web application, just in its own window rather 
than in a standard browser window. I'm looking for advice on a good GUI toolkit 
to use.

I've not done much GUI programming in Python, so I don't have a "preferred 
toolkit" as such. A bit of Google searching found an embedded browser widget in 
PyQt, but the examples I tried didn't work - it looks like the QWebView class 
is deprecated and has been removed in the current version of PyQt. I haven't 
really found any other examples (there's a "embedding a web page in Tkinter" 
example I found, but it looks like it's just doing rendering, not embedding a 
full browser - which I need as the site I want to access uses CSS/JavaScript).

Is there any good option for this, or would I be better looking elsewhere for a 
solution? I could probably work out how to knock something up using .NET, or a 
HTA file, for example, I'm just more comfortable coding in Python.

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


[issue28447] socket.getpeername() failure on broken TCP/IP connection

2016-10-19 Thread Martin Panter

Martin Panter added the comment:

I haven’t tried running your program, but I don’t see anything stopping 
multiple references to the same socket appearing in the “mailbox” queue. Once 
the first reference has been processed, the socket will be closed, so 
subsequent getpeername() calls will be invalid.

--

___
Python tracker 

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



How can I copy one excel file data to another excel file by excluding hidden rows content using Python

2016-10-19 Thread Kishore JK
I need to copy one excel file data into another excel file by excluding rows 
which were hidden in source excel file.

https://i.stack.imgur.com/NPUK6.png

As shown in the image, from the source excel file, I need to copy the data of 
row numbers 116,135 and 139 and exclude all the remaining rows which were 
hidden because of not matching the criteria.

I have tried below code, but this is copying entire data into new excel sheet.
wb = openpyxl.load_workbook('sourcefile.xlsx')
sheet = wb.active
sheet.title = 'Sheet1'
wb.save('destinationfile.xlsx')
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26944] test_posix: Android 'id -G' is entirely wrong or missing the effective gid

2016-10-19 Thread Xavier de Gaye

Changes by Xavier de Gaye :


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



[issue26944] test_posix: Android 'id -G' is entirely wrong or missing the effective gid

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset fb3e65aff225 by Xavier de Gaye in branch '3.6':
Issue #26944: Fix test_posix for Android where 'id -G' is entirely wrong
https://hg.python.org/cpython/rev/fb3e65aff225

New changeset 465c09937e85 by Xavier de Gaye in branch 'default':
Issue #26944: Merge with 3.6.
https://hg.python.org/cpython/rev/465c09937e85

--
nosy: +python-dev

___
Python tracker 

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



[issue28447] socket.getpeername() failure on broken TCP/IP connection

2016-10-19 Thread Georgey

Georgey added the comment:

As your request, I simplify the server here:
--
import socket
import select, time
import queue, threading

ISOTIMEFORMAT = '%Y-%m-%d %X'
BUFSIZ = 2048
TIMEOUT = 10
ADDR = ('', 15625)

SEG = "◎◎"
SEG_ = SEG.encode()

active_socks = []
socks2addr = {}


server_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
server_sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) 
server_sock.bind(ADDR)
server_sock.listen(10)
active_socks.append(server_sock)

mailbox = queue.Queue()

#

def send(mail):   
mail_ = SEG_+ mail.encode()
##The SEG_ at the beginning can seperate messeges for recepient when 
internet busy

for sock in active_socks[1:]:
try:
sock.send(mail_)
except:
handle_sock_err(sock)

def handle_sock_err(sock): 
try:
addr_del = sock.getpeername() 
except:
addr_del = socks2addr[sock]


active_socks.remove(sock) 
socks2addr.pop(sock) 
sock.close()

send("OFFLIN"+str(addr_del) )

#
class Sender(threading.Thread):
#process 'mails' - save and send
def __init__(self, mailbox):
super().__init__()
self.queue = mailbox

def analyze(self, mail, fromwhere):
send( ' : '.join((fromwhere, mail)) )

def run(self):

while True:
msg, addr = mailbox.get()  ###
  
if msg[0] =="sock_err":
print("sock_err @ ", msg[1]) 
#alternative> print("sock_err @ " + repr( msg[1] ) )
#the alternaive command greatly reduces socket closing

handle_sock_err(msg[1])
continue 

self.analyze(msg, addr)

sender = Sender(mailbox)
sender.daemon = True
sender.start()

#
while True:
onlines = list(socks2addr.values()) 
print( '\n'+time.strftime(ISOTIMEFORMAT, time.localtime(time.time())) )
print( 'online: '+str(onlines))

read_sockets, write_sockets, error_sockets = 
select.select(active_socks,[],[],TIMEOUT)

for sock in read_sockets:
#New connection
if sock ==server_sock:
# New Client coming in
clisock, addr = server_sock.accept() 
ip = addr[0]

active_socks.append(clisock)
socks2addr[clisock] = addr
 
#Some incoming message from a client
else:
# Data recieved from client, process it
try:
data = sock.recv(BUFSIZ)
if data:
fromwhere = sock.getpeername()
mail_s = data.split(SEG_)   ##seperate messages
del mail_s[0]
for mail_ in mail_s:
mail = mail_.decode()
print("recv>"+ mail)
   
except:
mailbox.put( (("sock_err",sock), 'Server') )
continue
 
server_sock.close()
  

==

The client side can be anything that tries to connect the server.
The original server has a bulletin function that basically echoes every message 
from any client to all clients. But you can ignore this function and limit the 
client from just connecting to this server and do nothing before close.

I find the error again:
--
sock_err @ 

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:/Users/user/Desktop/SelectWinServer.py", line 39, in handle_sock_err
addr_del = sock.getpeername()
OSError: [WinError 10038] 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Python34\lib\threading.py", line 911, in _bootstrap_inner
self.run()
  File "C:/Users/user/Desktop/SelectWinServer.py", line 67, in run
handle_sock_err(msg[1])
  File "C:/Users/user/Desktop/SelectWinServer.py", line 41, in handle_sock_err
addr_del = socks2addr[sock]
KeyError: 
=

It seems that "socks2addr" has little help when socket is closed and 
"getpeername()" fails - it will fail too.

However, I do find that altering

print("sock_err @ ", msg[1])
to
print("sock_err @ " + repr( msg[1] ) )

can reduce socket closing. Don't understand why and how important it is. 

BTW, on Windows 7 or Windows 10.

--

___
Python tracker 

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



Re: Inplace shuffle function returns none

2016-10-19 Thread Chris Angelico
On Wed, Oct 19, 2016 at 6:01 PM, Sayth Renshaw  wrote:
> Ok i think i do understand it. I searched the python document for in-place 
> functions but couldn't find a specific reference.
>
> Is there a particular part in docs or blog that covers it? Or is it 
> fundamental to all so not explicitly treated in one particular page?

It's not a rule, it's a design principle. So the best way to find out
about it is either to look at hundreds or thousands of Python standard
library functions and recognize a pattern... or ask on a mailing list
and be told :)

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


[issue23188] Provide a C helper function to chain raised (but not yet caught) exceptions

2016-10-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This helper is convenient in many cases, but it is very limited. It raises an 
exception with single string argument. It doesn't work in cases when the 
exception doesn't take arguments (PyErr_SetNone) or takes multiple or 
non-string arguments (PyErr_SetFromErrnoWithFilenameObject, 
PyErr_SetImportError). I think for public API we need more general solution. 
Something like this:

PyObject *cause = get_current_exception();
PyErr_SetImportError(msg, name, path);
set_cause_of_current_exception(cause);

--

___
Python tracker 

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



[issue28476] Remove redundant definition of factorial on test_random

2016-10-19 Thread STINNER Victor

STINNER Victor added the comment:

Thanks for your contribution Francisco.

test_random still pass. I pushed your safe and well contained patch. It don't 
see any good reason why test_random had its own pure (and slow) Python 
implementation of factorial(), it's probably because test_random.py was written 
before math.factorial() was added (Python 2.6).

--
nosy: +haypo

___
Python tracker 

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



[issue28476] Remove redundant definition of factorial on test_random

2016-10-19 Thread Roundup Robot

New submission from Roundup Robot:

New changeset c6588a7443a4 by Victor Stinner in branch 'default':
Close #28476: Reuse math.factorial() in test_random
https://hg.python.org/cpython/rev/c6588a7443a4

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue26944] test_posix: Android 'id -G' is entirely wrong or missing the effective gid

2016-10-19 Thread Xavier de Gaye

Changes by Xavier de Gaye :


--
title: android: test_posix fails -> test_posix: Android 'id -G' is entirely 
wrong or missing the effective gid

___
Python tracker 

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



[issue26944] android: test_posix fails

2016-10-19 Thread Xavier de Gaye

Changes by Xavier de Gaye :


--
dependencies:  -add the 'is_android' attribute to test.support

___
Python tracker 

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



[issue28476] Remove redundant definition of factorial on test_random

2016-10-19 Thread Francisco Couzo

Changes by Francisco Couzo :


--
components: Tests
files: test_random.patch
keywords: patch
nosy: franciscouzo
priority: normal
severity: normal
status: open
title: Remove redundant definition of factorial on test_random
Added file: http://bugs.python.org/file45142/test_random.patch

___
Python tracker 

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



Re: Inplace shuffle function returns none

2016-10-19 Thread Ben Finney
Sayth Renshaw  writes:

> Ok i think i do understand it. I searched the python document for
> in-place functions but couldn't find a specific reference. 

They aren't a separate kind of function.

A function can do anything Python code can do; indeed, most Python
programs do just about everything they do inside functions.

A function also, if it returns, returns a value. (Sometimes that is the
value ‘None’.)

There's no special distinction between functions that return ‘None’
versus those that don't. There's no special distinction between
functions that have other effects versus those that don't.

> Is there a particular part in docs or blog that covers it? Or is it
> fundamental to all so not explicitly treated in one particular page?

I don't really understand the question, but I hope that addresses it.

-- 
 \   “Prayer must never be answered: if it is, it ceases to be |
  `\   prayer and becomes correspondence.” —Oscar Wilde, _The Epigrams |
_o__)of Oscar Wilde_, 1952 |
Ben Finney

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


Re: Inplace shuffle function returns none

2016-10-19 Thread Peter Otten
Steve D'Aprano wrote:

> On Wed, 19 Oct 2016 07:25 am, Sayth Renshaw wrote:
> 
>> So why can't i assign the result slice to a variable b?
>> 
>> It just keeps getting none.
> 
> Of course you can assign the result slice to b. You just have to do it the
> right way.
> 
> You keep getting None because you do it the wrong way. Unfortunately you
> aren't showing us your code, so we have no idea what you are doing wrong.
> My guess is that you are doing something like this:
> 
> 
> a = [1, 2, 3, 4, 5, 6, 7, 8]
> b = random.shuffle(a)[0:3]
> 
> That's wrong -- shuffle() modifies the list you pass, and returns None.
> You cannot take a slice of None. Try this:
> 
> a = [1, 2, 3, 4, 5, 6, 7, 8]
> random.shuffle(a)
> b = a[0:3]
> print(b)

But once you understand how it works consider

>>> a = [1, 2, 3, 4, 5, 6, 7, 8]
>>> random.sample(a, 3)
[1, 5, 2]

instead. This should be more efficient for "small" samples and leaves `a` 
intact:

>>> a
[1, 2, 3, 4, 5, 6, 7, 8]


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


[issue25731] Assigning and deleting __new__ attr on the class does not allow to create instances of this class

2016-10-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution: fixed -> 
stage: resolved -> 
versions: +Python 3.7 -Python 3.4

___
Python tracker 

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



[issue28474] WinError(): Python int too large to convert to C long

2016-10-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Windows
nosy: +amaury.forgeotdarc, belopolsky, meador.inge, paul.moore, steve.dower, 
tim.golden, zach.ware
type: crash -> behavior
versions: +Python 3.7 -Python 3.3, Python 3.4

___
Python tracker 

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



[issue28475] Misleading error on random.sample when k < 0

2016-10-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee: docs@python -> rhettinger
components:  -Tests
nosy: +mark.dickinson, rhettinger
stage:  -> patch review
type:  -> behavior
versions: +Python 2.7, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue28475] Misleading error on random.sample when k < 0

2016-10-19 Thread Francisco Couzo

New submission from Francisco Couzo:

Improved a bit the error message when k < 0, and also added a comment about it 
on the documentation and an additional test case.

--
assignee: docs@python
components: Documentation, Library (Lib), Tests
files: random_sample.patch
keywords: patch
messages: 278964
nosy: docs@python, franciscouzo
priority: normal
severity: normal
status: open
title: Misleading error on random.sample when k < 0
Added file: http://bugs.python.org/file45141/random_sample.patch

___
Python tracker 

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



[issue28474] WinError(): Python int too large to convert to C long

2016-10-19 Thread Kelvin You

New submission from Kelvin You:

// callproc.c
static PyObject *format_error(PyObject *self, PyObject *args)
{
PyObject *result;
wchar_t *lpMsgBuf;
DWORD code = 0;
if (!PyArg_ParseTuple(args, "|i:FormatError", ))  
  ^ Here the format string should be 
"|I:FormatError"
return NULL;
if (code == 0)
code = GetLastError();
lpMsgBuf = FormatError(code);
if (lpMsgBuf) {
result = PyUnicode_FromWideChar(lpMsgBuf, wcslen(lpMsgBuf));
LocalFree(lpMsgBuf);
} else {
result = PyUnicode_FromString("");
}
return result;
}

--
components: ctypes
messages: 278963
nosy: Kelvin You
priority: normal
severity: normal
status: open
title: WinError(): Python int too large to convert to C long
type: crash
versions: Python 2.7, Python 3.3, Python 3.4, 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



Re: function call questions

2016-10-19 Thread Peter Otten
chenyong20...@gmail.com wrote:

> 在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道:
>> On 2016-10-19 03:15, chenyong20...@gmail.com wrote:
>> > Thanks Peter and Anssi for your kind help. Now I'm ok with the first
>> > question. But the second question still confused me. Why "it seems that
>> > after root = root.setdefault(ch,{}) tree['a'] and root are the same
>> > object" and follows tree['a']['b']? Thanks.
>> >
>> You call the .setdefault method with a key and a default value.
>> 
>> The .setdefault method does this: if the key is in the dict, it returns
>> the associated value, else it puts the key and the default into the dict
>> and then returns the default.
> 
> thanks for the reply. I understand this. I'm now confused on why tree got
> its magic result.

Perhaps it is easier to understand if you rewrite the function without 
setdefault()?

def add_to_tree(root, value_string):
print "root is %s, value_string is %s" % (root, value_string)
for ch in value_string:
print "ch is %s" % ch
if ch not in root: # always true if the root arg is an empty dict
root[ch] = {}
root = root[ch] # inside the function the inner dict becomes the new
# root
print "root is", root
print "tree is", tree


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


[issue25731] Assigning and deleting __new__ attr on the class does not allow to create instances of this class

2016-10-19 Thread Bohuslav "Slavek" Kabrda

Bohuslav "Slavek" Kabrda added the comment:

Hi all, it seems to me that this change has been reverted not only in 2.7, but 
also in 3.5 (changeset: 101549:c8df1877d1bc). Benjamin, was this intentional? 
If so, perhaps this issue should be reopened and not marked as resolved.

Thanks a lot!

--

___
Python tracker 

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



Re: Inplace shuffle function returns none

2016-10-19 Thread Sayth Renshaw
Ok i think i do understand it. I searched the python document for in-place 
functions but couldn't find a specific reference. 

Is there a particular part in docs or blog that covers it? Or is it fundamental 
to all so not explicitly treated in one particular page?

Thanks

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


Re: function call questions

2016-10-19 Thread chenyong20000
在 2016年10月19日星期三 UTC+8上午11:46:28,MRAB写道:
> On 2016-10-19 03:15, chenyong20...@gmail.com wrote:
> > Thanks Peter and Anssi for your kind help. Now I'm ok with the first 
> > question. But the second question still confused me. Why "it seems that
> > after root = root.setdefault(ch,{}) tree['a'] and root are the same
> > object" and follows tree['a']['b']? Thanks.
> >
> You call the .setdefault method with a key and a default value.
> 
> The .setdefault method does this: if the key is in the dict, it returns 
> the associated value, else it puts the key and the default into the dict 
> and then returns the default.

thanks for the reply. I understand this. I'm now confused on why tree got its 
magic result.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28472] SystemTap usage examples in docs are incorrect

2016-10-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 5c21df505684 by Benjamin Peterson in branch '3.6':
always use double quotes for SystemTap string literals (closes #28472)
https://hg.python.org/cpython/rev/5c21df505684

New changeset dc10bd89473b by Benjamin Peterson in branch 'default':
merge 3.6 (#28472)
https://hg.python.org/cpython/rev/dc10bd89473b

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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