[issue25601] test_cpickle failure on the ware-gentoo-x86 builbot

2015-11-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Tests
type:  -> behavior
versions: +Python 2.7

___
Python tracker 

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



[issue25601] test_cpickle failure on the ware-gentoo-x86 builbot

2015-11-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +alexandre.vassalotti, pitrou

___
Python tracker 

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



Re: Question about math.pi is mutable

2015-11-11 Thread Marko Rauhamaa
Steven D'Aprano :

> Since compile, eval and exec are Python built-ins, if it doesn't
> include a byte-code compiler, it isn't Python. It's just a subset of
> Python.

compile() can be implemented trivially, or in any other manner. It
simply needs to return a "code object." I suspect even a string might
work as a code object.


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


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Alexander Mohr

Alexander Mohr added the comment:

Sorry for being obscure before, it was hard to pinpoint.  I think I just 
figured it out!  I had code like this in a subprocess:

def worker():
while True:
obj = self.queue.get()
# do work with obj using asyncio http module

def producer():
nonlocal self
obj2 = self.queue.get()
return obj2


workers = []
for i in range(FILE_OP_WORKERS):
t = asyncio.ensure_future(worker())
t.add_done_callback(op_finished)
workers.append(t)

while True:
f = loop.run_in_executor(None, producer)
obj = loop.run_until_complete(f)

t = async_queue.put(obj)
loop.run_until_complete(t)

loop.run_until_complete(asyncio.wait(workers))

where self.queue is a multiprocessing.Queue, and async_queue is an asyncio 
queue.  The idea is that I have a process populating a multiprocessing queue, 
and I want to transfer it to an syncio queue while letting the workers do their 
thing.

Without knowing the underlying behavior, my theory is that when python blocks 
on the multiprocessing queue lock, it releases socket events to the async http 
module's selectors, and then when the async loop gets to the selectors they're 
released again.

If I switch the producer to instead use a queue.get_nowait and busy wait with 
asyncio.sleep I don't get the error...however this is not ideal is we're busy 
waiting.

Thanks!

--

___
Python tracker 

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



Re: Using subprocess to capture a progress line

2015-11-11 Thread Chris Warrick
On 10 November 2015 at 23:47, Tim Johnson  wrote:
> Using python 2.7.6 on ubuntu 14.04
> The application in question is run with bash and gnome-terminal :
>
> I've written a command-line "wrapper" for youtube-dl, executing
> youtube-dl as a subprocess.
>
> --
> youtube-dl reports download progress on one line. I.E. the line is
> overwritten numerous times with no carriage return until the
> downloading is finished.
> --
>
> The following code runs the youtube-dl command and reports each line
> as output by youtube-dl
> ###
> p = subprocess.Popen(list(args), stderr=subprocess.STDOUT,
>  stdout=subprocess.PIPE)
> while True:
> line = p.stdout.readline()
> if not line:
> break
> tmp = line.strip()
> print tmp
> ###
>
> However this method not does show the download progress _until_ the
> download is complete.

There is no \n character at the end — which means that
p.stdout.readline() cannot return. In fact, if you printed repr() of
the line you read, you would get this:

b'\r[download]  54.9% of 2.73MiB at 26.73KiB/s ETA 00:47\r[download]
55.0% of 2.73MiB at 79.33KiB/s ETA 00:15\r…snip…\r[download] 100% of
2.73MiB in 00:01\n'

The download line is implemented using \r, which is the carriage
return character (return to the first character), and then by
overwriting characters that were already printed.

The solution? There are numerous. I’ll help you by obscuring the worst one.

(1) [recommended] figure out how to make youtube_dl work as a library,
read its main file to figure out the problem. Don’t mess with
subprocess.
(2) [don’t do it] do you need to intercept the lines? If you don’t set
stderr= and stdout=, things will print just fine.
(3) [DON’T DO IT] .ernq() punenpgre ol punenpgre naq znxr n zrff.

PS. Thank you for setting a sensible Reply-To header on your messages.
Which is something the list should be doing.

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25598] Fix memory_hex (#9951) for non-contiguous buffers

2015-11-11 Thread Stefan Krah

Changes by Stefan Krah :


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



[issue7759] mhlib fails on Btrfs filesystem (test_mhlib failure)

2015-11-11 Thread R. David Murray

R. David Murray added the comment:

Sure, why not.  Having buildbots be green is good, and I doubt anyone is using 
mhlib any more even in python2.  And if they are the chances this will break 
something seems extremely small.

--
nosy: +r.david.murray

___
Python tracker 

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



Re: Using subprocess to capture a progress line

2015-11-11 Thread Chris Warrick
On 11 November 2015 at 17:16, Tim Johnson  wrote:
>> (2) [don’t do it] do you need to intercept the lines? If you don’t set
>> stderr= and stdout=, things will print just fine.
>   Got to try that before using the module, just for edification.

At which point your initial code sample will become:
###
p = subprocess.Popen(list(args))
###

(is list(args) really necessary? Wouldn’t plain Popen(args) just work?)

-- 
Chris Warrick 
PGP: 5EAAEA16
-- 
https://mail.python.org/mailman/listinfo/python-list


new to python, help please !!

2015-11-11 Thread Anas Belemlih
i am  a beginning programmer,  i am trying to write a simple code to compare 
two character sets in 2 seperate files. ( 2 hash value files basically)
idea is:
 open both files, measure the length of the  loop on.

if the length doesn't match, ==  files do not  match

if length matchs, loop  while comparing each character from each file if they 
match. 
 please tell me what i am doing wrong ?  i am using python 2.7

**
hash1= open ("file1.md5", "r")
line1 =hash1.read()
hash2 = open("file2.md5","r")
line2= hash2.read()

number1 = len(line1)
number2 = len(line2)

#**
i=0
s1=line1[i]
s2=line2[i]
count = 0

if number1 != number2:
print " hash table not the same size"
else:
while count < number1:
if s1 == s2:
print " character", line1[i]," matchs"
i=i+1
count=count+1
else
print "Hash values corrupt"
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Marko Rauhamaa
Ulli Horlacher :

> What is the best practise for a cross platform timeout handler?

Here's the simplest answer:

   https://docs.python.org/3/library/threading.html#threading.Timer

(Also available in Python 2.)


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


[issue25601] test_cpickle failure on the ware-gentoo-x86 buildbot

2015-11-11 Thread Zachary Ware

Zachary Ware added the comment:

This also happened on my Windows buildbot: 
http://buildbot.python.org/all/builders/AMD64%20Windows8.1%20Non-Debug%202.7/builds/195

That build is running again as build 196.

--

___
Python tracker 

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



[issue7759] mhlib fails on Btrfs filesystem (test_mhlib failure)

2015-11-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The test now is passed.

--
resolution: wont fix -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



Re: new to python, help please !!

2015-11-11 Thread Tim Chase
On 2015-11-11 08:34, Anas Belemlih wrote:
> i am  a beginning programmer,  i am trying to write a simple code
> to compare two character sets in 2 seperate files. ( 2 hash value
> files basically) idea is: open both files, measure the length of
> the  loop on.
> 
> if the length doesn't match, ==  files do not  match
> 
> if length matchs, loop  while comparing each character from each
> file if they match. please tell me what i am doing wrong ?  i am
> using python 2.7
> 
> **
> hash1= open ("file1.md5", "r")
> line1 =hash1.read()
> hash2 = open("file2.md5","r")
> line2= hash2.read()
> 
> number1 = len(line1)
> number2 = len(line2)
> 
> #**
> i=0
> s1=line1[i]
> s2=line2[i]
> count = 0
> 
> if number1 != number2:
>   print " hash table not the same size"
> else:
> while count < number1:
>   if s1 == s2:
>   print " character", line1[i]," matchs"
>   i=i+1
>   count=count+1
>   else
>   print "Hash values corrupt"

Well, the immediate answer is that you don't update s1 or s2 inside
your loop.  Also, the indent on "count=count+1" is wrong.  Finally,
if the hashes don't match, you don't break out of your while loop.
That said, the pythonesque way of writing this would likely look
something much more like

  with open("file1.md5") as a, open("file2.md5") as b:
for s1, s2 in zip(a, b):
  if s1 != s2:
print("Files differ")

You can compare the strings to get the actual offset if you want, or
check the lengths if you really want a more verbatim translation of
your code:

  with open("file1.md5") as a, open("file2.md5") as b:
for s1, s2 in zip(a, b):
  if len(s1) != len(s2):
print("not the same size")
  else:
for i, (c1, c2) in enumerate(zip(s1, s2)):
  if c1 == c2:
print(" character %s matches" %  c1)
  else:
print(" %r and %r differ at position %i" % (s1, s2, i))

-tkc



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


[issue25599] asyncio.iscoroutinefunction returns unexpected results when presented with unittest.mock.Mock

2015-11-11 Thread Theron Luhn

Theron Luhn added the comment:

For me, the context is a test I was writing that went something like this:

>>> import asyncio
>>> from unittest.mock import Mock
>>> loop = asyncio.get_event_loop()
>>> blocking_func = Mock()
>>> loop.run_in_executor(None, blocking_func)
Traceback (most recent call last):
  File "", line 1, in 
  File 
"/usr/local/Cellar/python3/3.5.0/Frameworks/Python.framework/Versions/3.5/lib/python3.5/asyncio/base_events.py",
 line 497, in run_in_executor
raise TypeError("coroutines cannot be used with run_in_executor()")
TypeError: coroutines cannot be used with run_in_executor()

I understand that the nature of Mock makes its behaviors ambiguous.  However, 
there are a few reasons I think asyncio.iscoroutinefunction(Mock()) should be 
false:

1) inspect.iscoroutinefunction reports false.  asyncio.iscoroutinefunction 
should be consistent with this.
2) A coroutine function should return a coroutine object.  Mock's default 
behavior won't return a coroutine object, so it shouldn't be identified as a 
coroutine function by default.
3) It's tidier to make a non-coroutine function Mock into a coroutine function 
(asyncio.coroutine(Mock())) than it is to make a coroutine function Mock into a 
non-coroutine function Mock (mock._is_coroutine is implementation-specific 
hack).

--

___
Python tracker 

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



Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
Marko Rauhamaa  wrote:
> Ulli Horlacher :
> 
> > What is the best practise for a cross platform timeout handler?
> 
> Here's the simplest answer:
> 
>https://docs.python.org/3/library/threading.html#threading.Timer
> 
> (Also available in Python 2.)

Hmmm... not so simple for me. My test code:

from time import *
import threading
import sys

def hello(): 
raise ValueError("hello!!!")

t = threading.Timer(3.0,hello)
t.start()
try:
  print "start"
  sleep(5)
  print "end"
except ValueError as e:
  print e.args[0]
  sys.exit(1)


gives:


start
Exception in thread Thread-1:
Traceback (most recent call last):
  File "/usr/lib/python2.7/threading.py", line 551, in __bootstrap_inner
self.run()
  File "/usr/lib/python2.7/threading.py", line 759, in run
self.function(*self.args, **self.kwargs)
  File "x.py", line 7, in hello
def hello(): raise ValueError("hello!!!")
ValueError: hello!!!

end



-- 
Ullrich Horlacher  Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de
Universitaet Stuttgart Tel:++49-711-68565868
Allmandring 30aFax:++49-711-682357
70550 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new to python, help please !!

2015-11-11 Thread Ben Finney
Anas Belemlih  writes:

> i am  a beginning programmer,  i am trying to write a simple code to
> compare two character sets in 2 seperate files. ( 2 hash value files
> basically)

Welcome, and congratulations on arriving at Python for your programming!

As a beginning programmer, you will benefit from joining the ‘tutor’
forum , which is
much better suited to collaborative teaching of newcomers.

-- 
 \ “As scarce as truth is, the supply has always been in excess of |
  `\   the demand.” —Josh Billings |
_o__)  |
Ben Finney

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


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Alexander Mohr

Alexander Mohr added the comment:

clarification, adding the fut.done() check, or monkey patching:
orig_sock_connect_cb = 
asyncio.selector_events.BaseSelectorEventLoop._sock_connect_cb
def _sock_connect_cb(self, fut, sock, address):
if fut.done(): return
return orig_sock_connect_cb(self, fut, sock, address)

--

___
Python tracker 

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



[issue25601] test_cpickle failure on the ware-gentoo-x86 buildbot

2015-11-11 Thread Zachary Ware

Zachary Ware added the comment:

I also have no idea how that happened, but seems to have been a fluke. Build 
101 is fine, and nothing has changed on that box.

--

___
Python tracker 

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



[issue25601] test_cpickle failure on the ware-gentoo-x86 buildbot

2015-11-11 Thread Zachary Ware

Zachary Ware added the comment:

Build 196 on the Windows bot is fine.  Could be a bizarre test ordering issue?  
Nothing else should have changed between builds 195 and 196 on the Windows bot.

--

___
Python tracker 

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Alexander Mohr

Alexander Mohr added the comment:

Actually, I just realized I had fixed it locally by changing the callback to 
the following:
429 def _sock_connect_cb(self, fut, sock, address):
430 if fut.cancelled() or fut.done():
431 return
 
so a fix is still needed, and I also verified this happens with python3.4 as 
well.

--
status: closed -> open
versions: +Python 3.4

___
Python tracker 

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



Re: Python.exe is not a valid Win32 application error message

2015-11-11 Thread Michael Torrie
On 11/11/2015 10:21 AM, Quivis wrote:
> On Tue, 10 Nov 2015 00:34:23 +, M. Kamisato wrote:
> 
>> I am running python on Windows XP SP3 and download version 3.5xx.  I got
>> the above error message and could not run the program.
>> I have downloaded Python version 2.7xx and it runs fine.
>> Is there any way I can get version 3.5xx to run on my computer?
>> Mel KamisatoBuena Park, CA
> 
> 
> Did you DL the 64-bit version...?

In this case, it would not matter; Windows XP is simply too old to run
Python 3.5, but the web page neglects to mention that, and the installer
does not yet warn the user, though it will in the next minor version
release.

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


Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Marko Rauhamaa
Ulli Horlacher :

> Hmmm... not so simple for me. My test code:
>
> from time import *
> import threading
> import sys
>
> def hello(): 
> raise ValueError("hello!!!")
>
> t = threading.Timer(3.0,hello)
> t.start()
> try:
>   print "start"
>   sleep(5)
>   print "end"
> except ValueError as e:
>   print e.args[0]
>   sys.exit(1)

Correct. The timer callback function (hello) would be called in a
separate thread. An exception raised in one thread cannot be caught in
the main thread. In general, there is no way for a thread to interrupt a
sibling thread that is in a blocking function call.


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


Re: new to python, help please !!

2015-11-11 Thread John Gordon
In <93aef8e5-3d6f-41f4-a625-cd3c20076...@googlegroups.com> Anas Belemlih 
 writes:

> i=0
> s1=line1[i]
> s2=line2[i]
> count = 0

> if number1 != number2:
>   print " hash table not the same size"
> else:
> while count < number1:
>   if s1 == s2:
>   print " character", line1[i]," matchs"
>   i=i+1
>   count=count+1
>   else
>   print "Hash values corrupt"

It looks like you're expecting s1 and s2 to automatically update their
values when i gets incremented, but it doesn't work like that.  When you
increment i, you also have to reassign s1 and s2.

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


[issue7759] mhlib fails on Btrfs filesystem (test_mhlib failure)

2015-11-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 37431d9abbcd by Serhiy Storchaka in branch '2.7':
Issue #7759: Fixed the mhlib module on filesystems that doesn't support
https://hg.python.org/cpython/rev/37431d9abbcd

--
nosy: +python-dev

___
Python tracker 

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



cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
I am rewriting a Perl program into Python (2.7).
It must run on Linux and Windows.
With Linux I have no problems, but Windows... :-(

The current show stopper is signal.SIGALRM which is not available on
Windows:

  File "fexit.py", line 674, in formdata_post
signal.signal(signal.SIGALRM,timeout_handler)
  AttributeError: 'module' object has no attribute 'SIGALRM'


  https://docs.python.org/2/library/signal.html

  signal.alarm(time) (...) Availability: Unix.

Perl for Windows has had SIGALRM support (or some kind of emulation).

Ok, I have to redesign this part of my code:

  def timeout_handler(sig,frame): 
raise ValueError("timeout!")

  signal.signal(signal.SIGALRM,timeout_handler)

  while True:
chunk = fileo.read(bs)
sock.sendall(chunk)
(...)


What is the best practise for a cross platform timeout handler?




-- 
Ullrich Horlacher  Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de
Universitaet Stuttgart Tel:++49-711-68565868
Allmandring 30aFax:++49-711-682357
70550 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
-- 
https://mail.python.org/mailman/listinfo/python-list


Python.exe is not a valid Win32 application error message

2015-11-11 Thread M. Kamisato via Python-list
I am running python on Windows XP SP3 and download version 3.5xx.  I got the 
above error message and could not run the program.
I have downloaded Python version 2.7xx and it runs fine.
Is there any way I can get version 3.5xx to run on my computer?
Mel KamisatoBuena Park, CA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python.exe is not a valid Win32 application error message

2015-11-11 Thread Michael Torrie
On 11/11/2015 06:13 AM, Chris Angelico wrote:
> On Tue, Nov 10, 2015 at 11:34 AM, M. Kamisato via Python-list
>  wrote:
>> I am running python on Windows XP SP3 and download version 3.5xx.  I got the 
>> above error message and could not run the program.
>> I have downloaded Python version 2.7xx and it runs fine.
>> Is there any way I can get version 3.5xx to run on my computer?
>> Mel KamisatoBuena Park, CA
> 
> You can't get 3.5 to run on XP, no; your options are:
> 
> 1) Install Python 3.4, which does support XP
> 2) Upgrade to a newer version of Windows (anything from Vista onward
> will run 3.5; to save having to do this in future, jump straight to 7
> or 10)
> 3) Make the jump to Linux or FreeBSD or some other OS.
> 
> When 3.5.1 is released (currently scheduled for early December),
> you'll get a clear and simple error when you try to install, rather
> than strange issues about it not being a valid program. That won't
> change the platform support, but at least it won't be as confusing.

The Python website is looking very professional and polished these days.
 But we still don't have a simple message on the download page telling
people Windows XP is no longer supported.  Given the number of people
posting lately (several each week), I would think even with the limited
time and resources of the python.org webmaster a little warning message
would be in order.  Even when the installer is fixed, it would still be
nice to have basic OS requirements listed before the download is ever
clicked.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Alexander Mohr

Alexander Mohr added the comment:

I'm going to close this as I've found a work-around, if I find a better 
test-case I'll open a new bug.

--
resolution:  -> later
status: open -> closed

___
Python tracker 

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



[issue25601] test_cpickle failure on the ware-gentoo-x86 buildbot

2015-11-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
title: test_cpickle failure on the ware-gentoo-x86 builbot -> test_cpickle 
failure on the ware-gentoo-x86 buildbot

___
Python tracker 

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



Re: Using subprocess to capture a progress line

2015-11-11 Thread Tim Johnson
* Chris Warrick  [15 00:55]:
> On 10 November 2015 at 23:47, Tim Johnson  wrote:
> > Using python 2.7.6 on ubuntu 14.04
<..> 
> There is no \n character at the end — which means that
> p.stdout.readline() cannot return. In fact, if you printed repr() of
> the line you read, you would get this:
> 
> b'\r[download]  54.9% of 2.73MiB at 26.73KiB/s ETA 00:47\r[download]
> 55.0% of 2.73MiB at 79.33KiB/s ETA 00:15\r…snip…\r[download] 100% of
> 2.73MiB in 00:01\n'
> 
> The download line is implemented using \r, which is the carriage
> return character (return to the first character), and then by
> overwriting characters that were already printed.
> 
> The solution? There are numerous. I’ll help you by obscuring the worst one.
> 
> (1) [recommended] figure out how to make youtube_dl work as a library,
> read its main file to figure out the problem. Don’t mess with
> subprocess.
  Was my first goal, had some problems, but I have solved them in
  part by finding the good documentation of the developers.

  I.E., the subprocess method _is_ going away and I will be using
  the youtube_dl module.

> (2) [don’t do it] do you need to intercept the lines? If you don’t set
> stderr= and stdout=, things will print just fine.
  Got to try that before using the module, just for edification.

> (3) [DON’T DO IT] .ernq() punenpgre ol punenpgre naq znxr n zrff.
> 
> PS. Thank you for setting a sensible Reply-To header on your messages.
> Which is something the list should be doing.
  LOL! Glad to help :)
  Thanks for the reply and the further education. 
  Cheers
-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25601] test_cpickle failure on the ware-gentoo-x86 builbot

2015-11-11 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

http://buildbot.python.org/all/builders/x86%20Gentoo%20Non-Debug%20with%20X%202.7/builds/100/steps/test/logs/stdio

There are a lot of failures, all look as:
==
ERROR: test_simple_newobj (test.test_cpickle.FileIOCPicklerFastTests)
--
Traceback (most recent call last):
  File 
"/buildbot/buildarea/2.7.ware-gentoo-x86/build/Lib/test/pickletester.py", line 
1145, in test_simple_newobj
s = self.dumps(x, proto)
  File 
"/buildbot/buildarea/2.7.ware-gentoo-x86/build/Lib/test/test_cpickle.py", line 
141, in dumps
p.dump(arg)
AttributeError: 'module' object has no attribute '_reduce_ex'

--

It looks as the _reduce_ex() function is missed in the copy_reg module. Have no 
ideas how it is possible.

--
messages: 254483
nosy: serhiy.storchaka, zach.ware
priority: normal
severity: normal
status: open
title: test_cpickle failure on the ware-gentoo-x86 builbot

___
Python tracker 

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



Re: Question about math.pi is mutable

2015-11-11 Thread Steven D'Aprano
On Wed, 11 Nov 2015 07:30 pm, Marko Rauhamaa wrote:

> Steven D'Aprano :
> 
>> Since compile, eval and exec are Python built-ins, if it doesn't
>> include a byte-code compiler, it isn't Python. It's just a subset of
>> Python.
> 
> compile() can be implemented trivially, or in any other manner. It
> simply needs to return a "code object." I suspect even a string might
> work as a code object.

Sure. That's just quality of implementation. In principle, a Python
interpreter might even operate without any byte-code at all, parsing each
line of code before executing it.

Nevertheless, whatever quality of implementation compile/eval/exec offer,
they *must* be available at runtime, otherwise the language is just a
subset of Python.



-- 
Steven

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


xlwings v0.5.0 ads support for Matplotlib in Excel

2015-11-11 Thread Felix Zumstein
I am pleased to announce the release of xlwings v0.5.0: 

Amongst other new features and bug fixes, this release allow to use Matplotlib 
in Excel in just 2 lines of code. Watch: 
https://twitter.com/ZoomerAnalytics/status/664159348822835200

Check the Release Notes for full details: 
http://docs.xlwings.org/whatsnew.html 

About xlwings: 
xlwings is a BSD-licensed python library that makes it easy to call python from 
Excel and vice versa: 

Interact with Excel from python using a syntax that is close to VBA yet 
pythonic. 
Replace your VBA macros with python code and still pass around your workbooks 
as easily as before. 
xlwings fully supports NumPy arrays and Pandas DataFrames. 

It works with Microsoft Excel on Windows and Mac. 

http://xlwings.org 
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Guide in Deskop Application Development in Python for newbies

2015-11-11 Thread Leonard Andrew Mesiera
Thank you sir @Chris Warrick for your great suggestion, even though I
really got overwhelmed by the things that I need to study to get this
project done. I'm really new to programming  so I havent heard or even
tried DJANGO, but on your suggestion, if thats what I need to get my
project done, that would I do. It would really take alot of time for me to
finish this project, but thank you man, I really appreciate your help

On Sun, Nov 8, 2015 at 5:22 PM, Chris Warrick  wrote:

> On 7 November 2015 at 15:44,   wrote:
> > How do you start building a desktop application in python? I mean where
> do I start? Besides installing python on your windows what else do I need,
> and any suggestion on how do I accomplish this project.
> >
> > Right now I really want to finish this beauty pageant judging system
> which requires to have a client and a server, client would be for the
> judges and a server that computes the scores from all the categories, (i do
> hope you get I want mean by that project). I just finished reading
> Headfirst Python and I really loving this language, so any help from all
> the great programmers here would be so great.
> > --
> > https://mail.python.org/mailman/listinfo/python-list
>
> This project requires two very different components, or one monolithic
> server.
>
> The first one is the server. It basically needs to talk to clients
> (via HTTP) and to a database. This is a trivial app to write in your
> favorite web framework, eg. Django [0]. Come up with a good database
> structure (read the excellent tutorial and documentation, should get
> you there), write some models. But you can’t write your views just
> yet. Because the views you write depend strictly on the client.
>
> For the client, you basically have two choices:
> (a) write a web application in Django;
> (b) use a GUI framework and make a standalone desktop application.
>
> If you choose option (a), you need to learn HTML/CSS and write the
> views for your Django application (or use a ready-made front-end
> framework, eg. Bootstrap [1]). This is the simplest choice, and it
> takes a lot of work away from you. Your users will use their favorite
> web browser to access the voting system, log in, and make their votes,
> and there is no special setup for them (apart from giving them
> credentials to access your app). Your Django views will use the
> built-in Django templating, forms, and is relatively simple to do
> (might even be doable in a weekend).
>
> Route (b) is much more complicated. To follow this route, you need to
> pick a GUI framework. There are also multiple options, I personally
> recommend PySide, but you could also try wxWidgets, pygobject or kivy.
> The web app side of things will require serializing data to JSON and
> writing a RESTful API, but there are ready-made solutions for many web
> frameworks [2].
> But most of those come with a catch: they usually make you produce
> ugly code, because they are wrappers around ugly C++ APIs. And then
> you need to write code to talk to your HTTP server. You can’t use the
> beautiful requests library, because it will block — so there’s more
> work ahead, unless you want your app to be unresponsive every time you
> talk to the server. For example, in Qt, you would need to use Qt
> networking capabilities (which work asynchronously within the event
> loop), or some other implementation that you can use asynchronously
> (eg. Twisted, but then you lock yourself to Python 2, which is bad, or
> threading, which has its limitations…)
> And then you need to distribute your app to your users. Which is
> already hard, because you need to coordinate Python, your GUI
> framework, and your app. Are your users on Windows, Linux, or OS X? If
> you have at least one person on a platform, you will need some sort of
> testing environment…
>
> And no matter which route you choose, you can’t do much without a
> Linux server, so there’s more learning to do.
>
> Sadly, developing big things is hard and requires a lot of knowledge —
> especially if you’re a one-man-band.
> Here’s a short list of skills you need, with a subjectively suggested
> implementation and ease of implementation:
>
> * understanding of the HTTP protocol (*)
> * web application development (Django *)
> * database schema writing (planning out the structure + Django ORM **)
> * app server setup (uWSGI + nginx + Linux ***)
> * database setup (PostgreSQL *** or something simpler[3])
> * Route A:
>   * HTML/CSS skills; a front-end framework (Bootstrap **)
> * Route B:
>   * RESTful APIs (Django REST Framework ***/* if you use OAuth)
>   * GUI framework (PyQt )
>   * talking to your server from within the framework (/*)
>
> [0]: https://www.djangoproject.com/
> [1]: http://getbootstrap.com/
> [2]: http://www.django-rest-framework.org/
> [3]: If this is going to be VERY small, you could go with a sqlite
> database, which requires zero setup, but which is not suited for

Re: Python.exe is not a valid Win32 application error message

2015-11-11 Thread Chris Angelico
On Tue, Nov 10, 2015 at 11:34 AM, M. Kamisato via Python-list
 wrote:
> I am running python on Windows XP SP3 and download version 3.5xx.  I got the 
> above error message and could not run the program.
> I have downloaded Python version 2.7xx and it runs fine.
> Is there any way I can get version 3.5xx to run on my computer?
> Mel KamisatoBuena Park, CA

You can't get 3.5 to run on XP, no; your options are:

1) Install Python 3.4, which does support XP
2) Upgrade to a newer version of Windows (anything from Vista onward
will run 3.5; to save having to do this in future, jump straight to 7
or 10)
3) Make the jump to Linux or FreeBSD or some other OS.

When 3.5.1 is released (currently scheduled for early December),
you'll get a clear and simple error when you try to install, rather
than strange issues about it not being a valid program. That won't
change the platform support, but at least it won't be as confusing.

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


[issue25600] argparse, argument_default=argparse.SUPPRESS seems to have no effect

2015-11-11 Thread R. David Murray

R. David Murray added the comment:

If you specify a default for an argument, that overrides the global default.

--
nosy: +r.david.murray
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



[issue25602] Add support for EVFILT_USER kqueue filter

2015-11-11 Thread Jakub Klama

New submission from Jakub Klama:

It's useful for doing signaling between threads (especially I/O-bound threads).

Related github pull request: https://github.com/python/cpython/pull/23

--
components: Library (Lib)
files: 0001-Add-support-for-EVFILT_USER-kqueue-filter.patch
keywords: patch
messages: 254485
nosy: jceel
priority: normal
severity: normal
status: open
title: Add support for EVFILT_USER kqueue filter
type: enhancement
versions: Python 3.6
Added file: 
http://bugs.python.org/file41014/0001-Add-support-for-EVFILT_USER-kqueue-filter.patch

___
Python tracker 

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



Re: Guide in Deskop Application Development in Python for newbies

2015-11-11 Thread Leonard Andrew Mesiera
Thank you sir @Chris Warrick for your great suggestion, even though I
really got overwhelmed by the things that I need to study to get this
project done. I'm really new to programming  so I havent heard or even
tried DJANGO, but on your suggestion, if thats what I need to get my
project done, that would I do. It would really take alot of time for me to
finish this project, but thank you man, I really appreciate your help

On Wed, Nov 11, 2015 at 8:38 PM, Leonard Andrew Mesiera <
leonardmesi...@gmail.com> wrote:

> Thank you sir @Chris Warrick for your great suggestion, even though I
> really got overwhelmed by the things that I need to study to get this
> project done. I'm really new to programming  so I havent heard or even
> tried DJANGO, but on your suggestion, if thats what I need to get my
> project done, that would I do. It would really take alot of time for me to
> finish this project, but thank you man, I really appreciate your help
>
>
> On Sun, Nov 8, 2015 at 5:22 PM, Chris Warrick  wrote:
>
>> On 7 November 2015 at 15:44,   wrote:
>> > How do you start building a desktop application in python? I mean where
>> do I start? Besides installing python on your windows what else do I need,
>> and any suggestion on how do I accomplish this project.
>> >
>> > Right now I really want to finish this beauty pageant judging system
>> which requires to have a client and a server, client would be for the
>> judges and a server that computes the scores from all the categories, (i do
>> hope you get I want mean by that project). I just finished reading
>> Headfirst Python and I really loving this language, so any help from all
>> the great programmers here would be so great.
>> > --
>> > https://mail.python.org/mailman/listinfo/python-list
>>
>> This project requires two very different components, or one monolithic
>> server.
>>
>> The first one is the server. It basically needs to talk to clients
>> (via HTTP) and to a database. This is a trivial app to write in your
>> favorite web framework, eg. Django [0]. Come up with a good database
>> structure (read the excellent tutorial and documentation, should get
>> you there), write some models. But you can’t write your views just
>> yet. Because the views you write depend strictly on the client.
>>
>> For the client, you basically have two choices:
>> (a) write a web application in Django;
>> (b) use a GUI framework and make a standalone desktop application.
>>
>> If you choose option (a), you need to learn HTML/CSS and write the
>> views for your Django application (or use a ready-made front-end
>> framework, eg. Bootstrap [1]). This is the simplest choice, and it
>> takes a lot of work away from you. Your users will use their favorite
>> web browser to access the voting system, log in, and make their votes,
>> and there is no special setup for them (apart from giving them
>> credentials to access your app). Your Django views will use the
>> built-in Django templating, forms, and is relatively simple to do
>> (might even be doable in a weekend).
>>
>> Route (b) is much more complicated. To follow this route, you need to
>> pick a GUI framework. There are also multiple options, I personally
>> recommend PySide, but you could also try wxWidgets, pygobject or kivy.
>> The web app side of things will require serializing data to JSON and
>> writing a RESTful API, but there are ready-made solutions for many web
>> frameworks [2].
>> But most of those come with a catch: they usually make you produce
>> ugly code, because they are wrappers around ugly C++ APIs. And then
>> you need to write code to talk to your HTTP server. You can’t use the
>> beautiful requests library, because it will block — so there’s more
>> work ahead, unless you want your app to be unresponsive every time you
>> talk to the server. For example, in Qt, you would need to use Qt
>> networking capabilities (which work asynchronously within the event
>> loop), or some other implementation that you can use asynchronously
>> (eg. Twisted, but then you lock yourself to Python 2, which is bad, or
>> threading, which has its limitations…)
>> And then you need to distribute your app to your users. Which is
>> already hard, because you need to coordinate Python, your GUI
>> framework, and your app. Are your users on Windows, Linux, or OS X? If
>> you have at least one person on a platform, you will need some sort of
>> testing environment…
>>
>> And no matter which route you choose, you can’t do much without a
>> Linux server, so there’s more learning to do.
>>
>> Sadly, developing big things is hard and requires a lot of knowledge —
>> especially if you’re a one-man-band.
>> Here’s a short list of skills you need, with a subjectively suggested
>> implementation and ease of implementation:
>>
>> * understanding of the HTTP protocol (*)
>> * web application development (Django *)
>> * database schema writing (planning out the structure + Django ORM **)
>> * app 

pytest-benchmark v3.0 released!

2015-11-11 Thread Ionel Cristian Mărieș
Hello,

I've just released a new version of the pytest plugin for benchmarks. It
integrates very well into your pytest suite and has loads of features and
options. It works very well on all sorts of scenarios - check it out!

Docs: http://pytest-benchmark.readthedocs.org/en/stable/

Repository and issues: https://github.com/ionelmc/pytest-benchmark


Thanks,
-- Ionel Cristian Mărieș, http://blog.ionelmc.ro
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

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


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Guido van Rossum

Guido van Rossum added the comment:

I'm not an expert on this terminology but don't you have that backwards?
Assume we're using select() for a second. If you ask select() "is this FD
ready" several times in a row without doing something to the FD it will
answer yes every time once the FD is ready. IIUC that's what
level-triggered means, and that's what causes the bug.

--

___
Python tracker 

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



[issue23883] __all__ lists are incomplete

2015-11-11 Thread Berker Peksag

Berker Peksag added the comment:

I like Martin's support.expected_module_api() suggestion in msg247167. I still 
find passing self to a function just to use assertCountEqual a bit weird, but I 
can live with that.

--

___
Python tracker 

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



Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Terry Reedy

On 11/11/2015 11:16 AM, Ulli Horlacher wrote:

I am rewriting a Perl program into Python (2.7).


I recommend using 3.4+ if you possibly can.


It must run on Linux and Windows.
With Linux I have no problems, but Windows... :-(

The current show stopper is signal.SIGALRM which is not available on
Windows:



Perl for Windows has had SIGALRM support (or some kind of emulation).

Ok, I have to redesign this part of my code:

   def timeout_handler(sig,frame):
 raise ValueError("timeout!")

   signal.signal(signal.SIGALRM,timeout_handler)

   while True:
 chunk = fileo.read(bs)
 sock.sendall(chunk)
 (...)

What is the best practise for a cross platform timeout handler?


The cross-platform 3.4 asyncio module has some functions with timeouts.
(3.5 has new 'async' syntac which supposedly makes it easier to use.  I 
have not looked at this yet.)


For instance: coroutine asyncio.wait(futures, *, loop=None, 
timeout=None, return_when=ALL_COMPLETED)
Wait for the Futures and coroutine objects given by the sequence 
futures to complete. Coroutines will be wrapped in Tasks. Returns two 
sets of Future: (done, pending).

...
Usage:
  done, pending = yield from asyncio.wait(fs)

I believe the backport on pypi.python.org, called tulip, works on 2.7.

In the example above, the read/send would be a task.  Wait on the task, 
and when it returns, cancel the task if in pending.



--
Terry Jan Reedy

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


Re: More tkinter Madness

2015-11-11 Thread Paul Rubin
Tim Daneliuk  writes:
> Some months ago, I put it on a couple of VPS servers (FreeBSD
> and Linux) and BOOM, it doesn't run.  I asked around here and got some
> suggestions and then did some homework.

I'd expect a VPS server to have no display--is it an X client forward to
your workstation?  Are all the proper X libraries installed?  Note that
X port forwarding over the internet is generally unusable even if your
internet connection is pretty fast.  It's kind of ok over a LAN.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25603] spelling mistake - 26.1 typing

2015-11-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 81cc0cea2323 by Zachary Ware in branch '3.5':
Issue #25603: Add missing parenthesis.
https://hg.python.org/cpython/rev/81cc0cea2323

New changeset 1af59662f6d5 by Zachary Ware in branch 'default':
Closes #25603: Merge with 3.5
https://hg.python.org/cpython/rev/1af59662f6d5

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

I don't believe this is a case of nonidempotent callbacks, unless you are 
referring to Future.set_result(), which by design can't be called twice.  The 
callbacks are given an inconsistent opportunity to modify the poll set because 
of indeterminacy in the ioloop.  That being said I understand your reluctance 
given the amount of turmoil this has but would argue that consistency with 
tornado is a powerful ally and that a model where any callback using call_soon 
will be guaranteed the opportunity to modify the poll set is a good thing.

--

___
Python tracker 

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

Guido,

Shouldn't this not be the case for level triggered polling?  From looking at 
selectors it looks like these are always level triggered which means they 
should only event once.

--

___
Python tracker 

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



Re: How to get 'od' run?

2015-11-11 Thread Michael Torrie
On 11/11/2015 08:21 PM, Michael Torrie wrote:
> On 11/11/2015 08:04 PM, fl wrote:
>> Hi,
>>
>> I am learning python. I see a previous post has such code:
>>
>>
>>
>>
>>
>>>>> data = '"binääridataa"\n'.encode('utf-8') 
>>>>> f = open('roska.txt', 'wb') 
>>>>> f.write(data) 
>>17 
>>>>> f.close() 
>>
>> The .encode methods produced a bytestring, which Python likes to display 
>> as ASCII characters where it can and in hexadecimal where it cannot: 
>>
>>>>> data 
>>b'"bin\xc3\xa4\xc3\xa4ridataa"\n' 
>>
>> An "octal dump" in characters (where ASCII, otherwise apparently octal) 
>> and the corresponding hexadecimal shows that it is, indeed, these bytes 
>> that ended up in the file: 
>>
>> $ od -t cx1 roska.txt 
>  ^^^
> This is most likely a bash prompt. Therefore "od" is a program on your
> computer.  Nothing to do with Python at all.
> 
> To get Python to display \x## hex codes for non-ascii characters in a
> byte stream, you can print out the repr() of the byte string.  For example:
> 
> print (repr(my_unicode_string.encode('utf-8')))

Also there are numerous recipes for doing standard hex dumps out there.
 For example,

http://code.activestate.com/recipes/142812-hex-dumper/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Guido van Rossum

Guido van Rossum added the comment:

Thanks, but I don't like the idea of that patch. It feels like a hack that 
makes it less likely that the issue occurs, but I don't feel we should rely on 
the callbacks being called before checking the selector again. There may be 
other reasons (perhaps a future modification to the code) why we might 
occasionally check the selector redundantly. IOW I think we should really 
ensure that all I/O callbacks are properly idempotent.

--

___
Python tracker 

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

Attached server side of repro.

--
Added file: http://bugs.python.org/file41017/Issue25593_repro_server.py

___
Python tracker 

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

Just reproduced on Linux, Fedora Core 23.

--

___
Python tracker 

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Alexander Mohr

Alexander Mohr added the comment:

attaching my simplified testcase and logged an aiohttp bug: 
https://github.com/KeepSafe/aiohttp/issues/633

--
Added file: http://bugs.python.org/file41018/test_app.py

___
Python tracker 

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



Re: More tkinter Madness

2015-11-11 Thread Chris Angelico
On Thu, Nov 12, 2015 at 12:52 PM, Tim Daneliuk
 wrote:
> I am the author of twander (https://www.tundraware.com/Software/twander).
> This code has run flawlessly for years on FreeBSD, Linux, MacOS and
> Windows.  Some months ago, I put it on a couple of VPS servers (FreeBSD
> and Linux) and BOOM, it doesn't run.  I asked around here and got some
> suggestions and then did some homework.
>
> Traceback (most recent call last):
>   File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main

It's running here under Python 2.6. Sorry if this is a question you've
already been asked, but were you successfully running under 2.6
elsewhere? Might be a versioning issue.

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


[issue24421] Race condition compiling Modules/_math.c

2015-11-11 Thread Mike Gilbert

Changes by Mike Gilbert :


--
nosy: +floppymaster

___
Python tracker 

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



Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Marko Rauhamaa
Terry Reedy :

> The cross-platform 3.4 asyncio module has some functions with
> timeouts.

Even that doesn't forcefully interrupt an obnoxious blocking function
call like

   time.sleep(1)

The original question claimed signal.alarm() would do the trick in
Linux. However, even that cannot be relied on as "man alarm" states:

   sleep(3) may be implemented using SIGALRM; mixing calls to alarm()
   and sleep(3) is a bad idea.

I'm thinking the only portable way is to run a watchdog process with
subprocess or multiprocessing.


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


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

Attaching simplified test setup.   It does take some doing to repro so the 
local async server is required to make it happen (for me).  When I tried just 
pointing to python.org it would not repro in 100 iterations, but using a local 
dummy server repros 100% for me.

--
Added file: http://bugs.python.org/file41016/Issue25593_repro_client.py

___
Python tracker 

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



Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Cameron Simpson

On 11Nov2015 16:16, Ulli Horlacher  wrote:

I am rewriting a Perl program into Python (2.7).
It must run on Linux and Windows.
With Linux I have no problems, but Windows... :-(

The current show stopper is signal.SIGALRM which is not available on
Windows:

 File "fexit.py", line 674, in formdata_post
   signal.signal(signal.SIGALRM,timeout_handler)
 AttributeError: 'module' object has no attribute 'SIGALRM'

 https://docs.python.org/2/library/signal.html

 signal.alarm(time) (...) Availability: Unix.

Perl for Windows has had SIGALRM support (or some kind of emulation).

Ok, I have to redesign this part of my code:

 def timeout_handler(sig,frame):
   raise ValueError("timeout!")

 signal.signal(signal.SIGALRM,timeout_handler)

 while True:
   chunk = fileo.read(bs)
   sock.sendall(chunk)
   (...)

What is the best practise for a cross platform timeout handler?


I suggest you look at the socket.settimeout function. Avoid SIGALRM altogether.  
Then (untested):


 import socket
 ...
 socket.settimeout(timeout_in_seconds)
 ...
 while True:
   ...
   chunk = fileo.read(bs)
   try:
 sock.sendall(chunk)
   except socket.timeout as e:
 ... complain about timeout, reciting "e" in the message ...

Cheers,
Cameron Simpson 

I think you're confusing "recognizing" and "understanding" with "caring".
The net is cruel, sometimes, but always fair.
   - Rick Gordon 
--
https://mail.python.org/mailman/listinfo/python-list


[issue25603] spelling mistake - 26.1 typing

2015-11-11 Thread Matthias welp

New submission from Matthias welp:

Almost at the end of the page, under Usage of Typing.NamedTuple(...), this code 
snippet occurs: `Employee = typing.NamedTuple('Employee', [('name', str), 'id', 
int)])`. Unfortunately, this has an error in its parenthesis. 

This can easily be fixed by adding an opening bracket before the `'id'`-part, 
as seen here: `Employee = typing.NamedTuple('Employee', [('name', str), ('id', 
int)])`.

--
assignee: docs@python
components: Documentation
messages: 254511
nosy: Matthias welp, docs@python
priority: normal
severity: normal
status: open
title: spelling mistake - 26.1 typing
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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

Nevermind, in the case of writeablity it won't matter either way.

--

So in looking at tornado's ioloop they run the ready callbacks before calling 
poll().  So the callbacks can modify the poll set.

--

___
Python tracker 

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



Re: Python.exe is not a valid Win32 application error message

2015-11-11 Thread Steve Hayes
On Wed, 11 Nov 2015 08:39:21 -0500, Dennis Lee Bieber
 wrote:

>On Tue, 10 Nov 2015 00:34:23 + (UTC), "M. Kamisato via Python-list"
> declaimed the following:
>
>>I am running python on Windows XP SP3 and download version 3.5xx.  I got the 
>>above error message and could not run the program.
>>I have downloaded Python version 2.7xx and it runs fine.
>>Is there any way I can get version 3.5xx to run on my computer?
>>Mel KamisatoBuena Park, CA
>
>   Install Windows Vista, 7, 8.1, or 10.
>
>   Windows XP is not a supported OS for Python 3.5+

Or revert to an earlier version of Python that does work. 


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25569] Memory leak in SSLSocket.getpeercert()

2015-11-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 10c3646b2d59 by Benjamin Peterson in branch '2.7':
fix memory leak in _get_crl_dp (closes #25569)
https://hg.python.org/cpython/rev/10c3646b2d59

New changeset aabe273b20ab by Benjamin Peterson in branch '3.4':
fix memory leak in _get_crl_dp (closes #25569)
https://hg.python.org/cpython/rev/aabe273b20ab

New changeset 07a298572d93 by Benjamin Peterson in branch '3.5':
merge 3.5 (#25569)
https://hg.python.org/cpython/rev/07a298572d93

New changeset fb55b1ab43fc by Benjamin Peterson in branch 'default':
merge 3.5 (#25569)
https://hg.python.org/cpython/rev/fb55b1ab43fc

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



More tkinter Madness

2015-11-11 Thread Tim Daneliuk
I am the author of twander (https://www.tundraware.com/Software/twander).
This code has run flawlessly for years on FreeBSD, Linux, MacOS and
Windows.  Some months ago, I put it on a couple of VPS servers (FreeBSD
and Linux) and BOOM, it doesn't run.  I asked around here and got some
suggestions and then did some homework.

I see the error being thrown by using the trace module, but it's not 
terribly meaningful to me.  Any ideas of what this means - again,
I emphasize this is only happening on VPS hosts:

 --- modulename: Tkinter, funcname: _cnfmerge
Tkinter.py(76): if type(cnfs) is DictionaryType:
Tkinter.py(77): return cnfs
Tkinter.py(1046): res = ()
Tkinter.py(1047): for k, v in cnf.items():
Tkinter.py(1048): if v is not None:
Tkinter.py(1049): if k[-1] == '_': k = k[:-1]
Tkinter.py(1050): if callable(v):
Tkinter.py(1052): elif isinstance(v, (tuple, list)):
Tkinter.py(1064): res = res + ('-'+k, v)
Tkinter.py(1047): for k, v in cnf.items():
Tkinter.py(1048): if v is not None:
Tkinter.py(1049): if k[-1] == '_': k = k[:-1]
Tkinter.py(1050): if callable(v):
Tkinter.py(1052): elif isinstance(v, (tuple, list)):
Tkinter.py(1064): res = res + ('-'+k, v)
Tkinter.py(1047): for k, v in cnf.items():
Tkinter.py(1048): if v is not None:
Tkinter.py(1049): if k[-1] == '_': k = k[:-1]
Tkinter.py(1050): if callable(v):
Tkinter.py(1052): elif isinstance(v, (tuple, list)):
Tkinter.py(1064): res = res + ('-'+k, v)
Tkinter.py(1047): for k, v in cnf.items():
Tkinter.py(1065): return res
Traceback (most recent call last):
  File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main
"__main__", fname, loader, pkg_name)
  File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code
exec code in run_globals
  File "/usr/lib64/python2.6/trace.py", line 823, in 
main()
  File "/usr/lib64/python2.6/trace.py", line 811, in main
t.runctx(code, globs, globs)
  File "/usr/lib64/python2.6/trace.py", line 512, in runctx
exec cmd in globals, locals
  File "/local/TundraWare/bin/twander.py", line 5464, in 
UI = twanderUI(UIroot)
  File "/local/TundraWare/bin/twander.py", line 2152, in __init__
self.CmdBtn = Menubutton(self.mBar, text=COMMANDMENU, underline=0, 
state=DISABLED)
  File "/usr/lib64/python2.6/lib-tk/Tkinter.py", line 2710, in __init__
Widget.__init__(self, master, 'menubutton', cnf, kw)
  File "/usr/lib64/python2.6/lib-tk/Tkinter.py", line 1932, in __init__
(widgetName, self._w) + extra + self._options(cnf))
_tkinter.TclError
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new to python, help please !!

2015-11-11 Thread Steven D'Aprano
On Thursday 12 November 2015 04:48, Quivis wrote:

> On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote:
> 
>> md5
> 
> If those are md5 values stored inside files, wouldn't it be easier to
> just hash them?
> 
> import hashlib
> 
> m1 = hashlib.sha224(open('f1').read()).hexdigest()
> m2 = hashlib.sha224(open('f2').read()).hexdigest()

I presume that the purpose of the exercise is to learn basic Python skills 
like looping.

Also, using sha224 when all you want is a simple "different"/"equal" is 
horribly inefficient. Sha224 needs to read the entire file, every single 
byte, *and* perform a bunch of expensive cryptographic operations. Consider 
reading two five GB files, the first starting with byte \x30 and the second 
starting with byte \x60. The two bytes are different, so we know the files 
differ, but sha224 still needs to do a massive amount of work.



-- 
Steve

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


[issue25603] spelling mistake - 26.1 typing

2015-11-11 Thread Zachary Ware

Zachary Ware added the comment:

Thanks for the report!

--
nosy: +zach.ware
versions: +Python 3.6

___
Python tracker 

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



Re: How to get 'od' run?

2015-11-11 Thread Michael Torrie
On 11/11/2015 08:04 PM, fl wrote:
> Hi,
> 
> I am learning python. I see a previous post has such code:
> 
> 
> 
> 
> 
>>>> data = '"binääridataa"\n'.encode('utf-8') 
>>>> f = open('roska.txt', 'wb') 
>>>> f.write(data) 
>17 
>>>> f.close() 
> 
> The .encode methods produced a bytestring, which Python likes to display 
> as ASCII characters where it can and in hexadecimal where it cannot: 
> 
>>>> data 
>b'"bin\xc3\xa4\xc3\xa4ridataa"\n' 
> 
> An "octal dump" in characters (where ASCII, otherwise apparently octal) 
> and the corresponding hexadecimal shows that it is, indeed, these bytes 
> that ended up in the file: 
> 
> $ od -t cx1 roska.txt 
 ^^^
This is most likely a bash prompt. Therefore "od" is a program on your
computer.  Nothing to do with Python at all.

To get Python to display \x## hex codes for non-ascii characters in a
byte stream, you can print out the repr() of the byte string.  For example:

print (repr(my_unicode_string.encode('utf-8')))


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


Re: Python.exe is not a valid Win32 application error message

2015-11-11 Thread Steve Hayes
On Thu, 12 Nov 2015 00:13:29 +1100, Chris Angelico 
wrote:

>On Tue, Nov 10, 2015 at 11:34 AM, M. Kamisato via Python-list
> wrote:
>> I am running python on Windows XP SP3 and download version 3.5xx.  I got the 
>> above error message and could not run the program.
>> I have downloaded Python version 2.7xx and it runs fine.
>> Is there any way I can get version 3.5xx to run on my computer?
>> Mel KamisatoBuena Park, CA
>
>You can't get 3.5 to run on XP, no; your options are:
>
>1) Install Python 3.4, which does support XP
>2) Upgrade to a newer version of Windows (anything from Vista onward
>will run 3.5; to save having to do this in future, jump straight to 7
>or 10)
>3) Make the jump to Linux or FreeBSD or some other OS.

That is useful to know. 

I get messages (from Glary Utilities) that some of my programs
(including Python) need to be updated, but when I've downloaded and
updated them, the update hasn't worked. 


-- 
Steve Hayes from Tshwane, South Africa
Web:  http://www.khanya.org.za/stevesig.htm
Blog: http://khanya.wordpress.com
E-mail - see web page, or parse: shayes at dunelm full stop org full stop uk
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: new to python, help please !!

2015-11-11 Thread Marko Rauhamaa
Steven D'Aprano :

> On Thursday 12 November 2015 04:48, Quivis wrote:
>
>> On Wed, 11 Nov 2015 08:34:30 -0800, Anas Belemlih wrote:
>> 
>>> md5
>> 
>> If those are md5 values stored inside files, wouldn't it be easier to
>> just hash them?
>> 
>> import hashlib
>> 
>> m1 = hashlib.sha224(open('f1').read()).hexdigest()
>> m2 = hashlib.sha224(open('f2').read()).hexdigest()
>
> I presume that the purpose of the exercise is to learn basic Python
> skills like looping.

And if you really wanted to compare two files that are known to contain
MD5 checksums, the simplest way is:

   with open('f1.md5') as f1, open('f2.md5') as f2:
   if f1.read() == f2.read():
   ...
   else:
   ...


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


Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
Marko Rauhamaa  wrote:

> I'm thinking the only portable way is to run a watchdog process with
> subprocess or multiprocessing.

How can a subprocess interrupt a function in another process?

For example: waiting for user input with a timeout.

raw_input("Hit ENTER to continue or wait 10 s")



-- 
Ullrich Horlacher  Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de
Universitaet Stuttgart Tel:++49-711-68565868
Allmandring 30aFax:++49-711-682357
70550 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Chris Angelico
On Thu, Nov 12, 2015 at 5:43 PM, Christian Gollwitzer  wrote:
> My understanding of async is that it creates an event loop. In which case
> the loop has no chance to run within a block of code that computes anything,
> is that correct?

This is correct. At its simplest, asynchronous code is an abstraction
over the select() call, which basically says "Hey system, tell me when
(a) I can read from here, (b) I can write to here, or (c) I've been
waiting this long". The most common use is sockets; a web server has
its main listening socket (it becomes readable when someone connects),
any clients that haven't finished sending their requests yet (they
become readable when more data arrives), any clients that you're still
sending to (they become writeable when there's room in their output
buffers), and maybe some sort of periodic checks ("every hour, do
maintenance"). Whenever you finish a bit of processing (reading from a
client, sending to a client, whatever), you return to the "event
loop", which in this case would be select().

An async library makes all this look a lot cleaner in your code, but
ultimately, it's not preemptive. You still have to make sure the
processing doesn't take too long.

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


Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Christian Gollwitzer

Am 12.11.15 um 07:14 schrieb Marko Rauhamaa:

Terry Reedy :


The cross-platform 3.4 asyncio module has some functions with
timeouts.


Even that doesn't forcefully interrupt an obnoxious blocking function
call like

time.sleep(1)


A blocking call - granted. But what happens in a blocking loop, i.e.

for i in range(10):
pass

?

My understanding of async is that it creates an event loop. In which 
case the loop has no chance to run within a block of code that computes 
anything, is that correct? Or does it hook into the interpreter and is 
able to interrupt the program between bytecodes?



I'm thinking the only portable way is to run a watchdog process with
subprocess or multiprocessing.


What about a thread which calls exit() after the timeout? Does that 
forcefully kill the whole process?


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


Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
Terry Reedy  wrote:
> On 11/11/2015 11:16 AM, Ulli Horlacher wrote:
> > I am rewriting a Perl program into Python (2.7).
> 
> I recommend using 3.4+ if you possibly can.

It is not possible.
The main target platform offers only python 2.7

-- 
Ullrich Horlacher  Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de
Universitaet Stuttgart Tel:++49-711-68565868
Allmandring 30aFax:++49-711-682357
70550 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25530] ssl: OP_NO_SSLv3 should always be set unless a user specifically asks for it

2015-11-11 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d80954d941c7 by Benjamin Peterson in branch '2.7':
always set OP_NO_SSLv3 by default (closes #25530)
https://hg.python.org/cpython/rev/d80954d941c7

New changeset 56f64ec9259f by Benjamin Peterson in branch '3.4':
always set OP_NO_SSLv3 by default (closes #25530)
https://hg.python.org/cpython/rev/56f64ec9259f

New changeset d1737db0f1b2 by Benjamin Peterson in branch '3.5':
merge 3.4 (#25530)
https://hg.python.org/cpython/rev/d1737db0f1b2

New changeset 2899acbd2b46 by Benjamin Peterson in branch 'default':
merge 3.5 (#25530)
https://hg.python.org/cpython/rev/2899acbd2b46

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Guido van Rossum

Guido van Rossum added the comment:

I wonder if the bug is in aiohttp? The code you show is still too complex
to debug for me.

--

___
Python tracker 

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



[issue21748] glob.glob does not sort its results

2015-11-11 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

This code repros without aiohttp when pitted against the previously attached 
web server (again on OSX 10.11, mid-2012 MBPr).

Admittedly this may seem very arbitrary but I have better reasons in my 
production code for stopping an IOLoop and starting it again (which seems to be 
important to the reproduction steps).


import asyncio

loop = asyncio.get_event_loop()

def batch_open():
for i in range(100):
c = asyncio.ensure_future(asyncio.open_connection('127.0.0.1', 8080))
c.add_done_callback(on_resp)

def on_resp(task):
task.result()
loop.stop()

loop.call_soon(batch_open)
while True:
loop.run_forever()

--

___
Python tracker 

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Guido van Rossum

Guido van Rossum added the comment:

Justin's repro provides a clue: when the event loop is stopped before all
callbacks have been processed, when the loop is restarted the I/O selector
is asked again to do its work, and it will report all the same sockets as
ready. So then the callback will be put into the ready queue again (even
though it's already there). Then the second call will find the future
already done.

I'm not sure how this explains Alexander's issue but it's probably
something similar. We should carefully review the other I/O callbacks too
-- most of them look like they don't mind being called spuriously, but
there are a few others (_sock_recv, _sock_sendall, _sock_accept) that look
like they check for fut.cancelled() and might be susceptible to the same
bug.

--

___
Python tracker 

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



How to get 'od' run?

2015-11-11 Thread fl
Hi,

I am learning python. I see a previous post has such code:





   >>> data = '"binääridataa"\n'.encode('utf-8') 
   >>> f = open('roska.txt', 'wb') 
   >>> f.write(data) 
   17 
   >>> f.close() 

The .encode methods produced a bytestring, which Python likes to display 
as ASCII characters where it can and in hexadecimal where it cannot: 

   >>> data 
   b'"bin\xc3\xa4\xc3\xa4ridataa"\n' 

An "octal dump" in characters (where ASCII, otherwise apparently octal) 
and the corresponding hexadecimal shows that it is, indeed, these bytes 
that ended up in the file: 

$ od -t cx1 roska.txt 


When I run the above line with python 2.7, it does not recognize 'od'.

Is it from a package? Or some internal function?

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


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

I'm attaching a patch that runs `_ready` callbacks at the start of `_run_once`. 
 The style and implications are ranging so I leave it to you at this point.

--
keywords: +patch
Added file: 
http://bugs.python.org/file41019/run_once_testfix_for_Issue25593.patch

___
Python tracker 

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Guido van Rossum

Guido van Rossum added the comment:

Sorry, the code you posted is still incomprehensible. E.g. I suppose your
worker doesn't really have
```
obj = self.queue.get()
```
but rather something like
```
obj = yield from async_queue.get()
```
But in the end, even with that hypothesis, I can't explain what you're
seeing, and I believe there is a bug related to bad mixing multiprocessing
and asyncio in some code you're not showing, and your "fix" just masks the
problem. Note that the code you posted doesn't touch sockets in any way,
while the issue you're seeing is related to sockets. So there *must* be
more to it.

--

___
Python tracker 

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



Re: Using subprocess to capture a progress line

2015-11-11 Thread Tim Johnson
* Chris Warrick  [15 07:54]:
> On 11 November 2015 at 17:16, Tim Johnson  wrote:
> >> (2) [don’t do it] do you need to intercept the lines? If you don’t set
> >> stderr= and stdout=, things will print just fine.
> >   Got to try that before using the module, just for edification.
> 
> At which point your initial code sample will become:
> ###
> p = subprocess.Popen(list(args))
> ###
> 
  Yeah, 'list is redundant.
  Progress is now showing, but I forgot to say that I've lost the
  original intent, and that was to examine each line so that I could
  pull out the title.

  No matter. I'm on the way to make the youtube_dl module working.
  cheers

-- 
Tim 
http://www.akwebsoft.com, http://www.tj49.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Alexander Mohr

Alexander Mohr added the comment:

self.queue is not an async queue, as I stated above its a multiprocessing 
queue.  This code is to multiplex a multiprocessing queue to a async queue.

--

___
Python tracker 

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



Re: using binary in python

2015-11-11 Thread Christian Gollwitzer

Am 10.11.15 um 22:29 schrieb kent nyberg:

On Mon, Nov 09, 2015 at 10:20:25PM -0800, Larry Hudson via Python-list wrote:

Your questions are somewhat difficult to answer because you misunderstand
binary.  The key is that EVERYTHING in a computer is binary.  There are NO
EXCEPTIONS, it's all binary ALL the time.  The difference comes about in how
this binary data is displayed and manipulated.  I want to emphasize, ALL the
DATA is binary.



Thanks alot for taking the time.
I get it now. I sort of, but not fully, misunderstood the conecpt of binary 
files.
The thing I was after; and the thing Im playing with now after a more 
succesfull time with google,
is writing more specific things to a file than just strings.
English is not my native language so please forgive me, but
I wanted to write specifc 16bit codes, and read them. And later play with 
bitwise operations on them. Sort of.
It might not make sense at all, but hey..  it doesnt have to


I think I understand what you want. Look at the struct module:

https://docs.python.org/2/library/struct.html

You can write/read binary data from files with standard means. Using 
struct, you can interpret or format integer values into a specific 
binary format. That would allow to create a reader or writer for a given 
binary format in Python.


Christian


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


[issue18689] add argument for formatter to logging.Handler and subclasses in logging module

2015-11-11 Thread Derek Wilson

Derek Wilson added the comment:

> It's not an ideal world. Sorry, but I think this change is too invasive to 
> consider.

Obviously its not ideal, which is why my suggestion doesn't require intelligent 
3rd party libraries and is explicitly not invasive. As I said in my previous 
comment, using a keyword only argument means: "If [3rd party libraries] haven't 
[properly handled **kwargs] then nothing changes for them and they just support 
exactly the same features they supported previously."

The upshot is it is not invasive and no one needs to care unless they want to 
use the new functionality.

As far as this change being needed or not, nothing "needs" to be made easier to 
use if it is possible to use it. But that isn't really a good reason not to 
improve things.

I honestly think that part of the reason this hasn't come up is because the 
advanced features of logging are so difficult to use that people just don't use 
it to its fullest extent. On top of that, when learning python, logging is way 
harder to grok than it should be for someone new to python.

Logging and unittest are two of the most important libraries for new 
pythonistas to learn, but they are also some of the most nebulous, stateful, 
magical, java-like, complicated, verbose, and difficult to master packages in 
python.

They've been around for a while for sure - but doesn't that rather mean that 
they could use an update?

I'm willing to submit a patch if it has the smallest chance of being considered?

--
versions: +Python 3.6 -Python 3.4

___
Python tracker 

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



Re: cross platform alternative for signal.SIGALRM?

2015-11-11 Thread Ulli Horlacher
Marko Rauhamaa  wrote:

> Correct. The timer callback function (hello) would be called in a
> separate thread. An exception raised in one thread cannot be caught in
> the main thread. In general, there is no way for a thread to interrupt a
> sibling thread that is in a blocking function call.

Then threading.Timer is not a solution for my problem.

-- 
Ullrich Horlacher  Server und Virtualisierung
Rechenzentrum IZUS/TIK E-Mail: horlac...@tik.uni-stuttgart.de
Universitaet Stuttgart Tel:++49-711-68565868
Allmandring 30aFax:++49-711-682357
70550 Stuttgart (Germany)  WWW:http://www.tik.uni-stuttgart.de/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Justin Mayfield

Justin Mayfield added the comment:

I believe I'm seeing this bug in a non-threaded and non-forked env.  

System:
 OSX 10.11.1 (15B42)
 Python 3.5.0 (from brew install)

I'm using aiohttp to create several dozens of HTTP connections to the same 
server (an async tornado web server).  Nothing special is being done around the 
event loop creation (standard get_event_loop()).  However in my system the 
event loop is frequently stopped, via ioloop.stop(), and restarted via 
ioloop.run_forever().  I'm not sure this is related to the issue yet, but it's 
worth mentioning.

I can't provide simplified test code just yet, but I can reproduce in my env 
with nearly 100% odds when doing a full system test.  Attached is a sample 
backtrace.

--
nosy: +Justin Mayfield
Added file: http://bugs.python.org/file41015/asyncio_invalid_state_bt.txt

___
Python tracker 

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



[issue25593] _sock_connect_cb can be called twice resulting in InvalidStateError

2015-11-11 Thread Alexander Mohr

Alexander Mohr added the comment:

Perhaps I'm doing something really stupid, but I was able to reproduce the two 
issues I'm having with the following sample script. If you leave the monkey 
patch disabled, you get the InvalidStateError, if you enable it, you get the 
ServerDisconnect errors that I'm currently seeing which I work-around with 
retries.  Ideas?

import asyncio
import aiohttp
import multiprocessing
import aiohttp.server
import logging
import traceback

# Monkey patching
import asyncio.selector_events

# http://bugs.python.org/issue25593
if False:
orig_sock_connect_cb = 
asyncio.selector_events.BaseSelectorEventLoop._sock_connect_cb
def _sock_connect_cb(self, fut, sock, address):
if fut.done(): return
return orig_sock_connect_cb(self, fut, sock, address)
asyncio.selector_events.BaseSelectorEventLoop._sock_connect_cb = 
_sock_connect_cb


class HttpRequestHandler(aiohttp.server.ServerHttpProtocol):
@asyncio.coroutine
def handle_request(self, message, payload):
response = aiohttp.Response(self.writer, 200, 
http_version=message.version)
response.add_header('Content-Type', 'text/html')
response.add_header('Content-Length', '18')
response.send_headers()
yield from asyncio.sleep(0.5)
response.write(b'It Works!')
yield from response.write_eof()


def process_worker(q):
loop = asyncio.get_event_loop()
#loop.set_debug(True)
connector = aiohttp.TCPConnector(force_close=False, keepalive_timeout=8, 
use_dns_cache=True)
session = aiohttp.ClientSession(connector=connector)
async_queue = asyncio.Queue(100)

@asyncio.coroutine
def async_worker(session, async_queue):
while True:
try:
print("blocking on asyncio queue get")
url = yield from async_queue.get()
print("unblocking on asyncio queue get")
print("get aqueue size:", async_queue.qsize())
response = yield from session.request('GET', url)
try:
data = yield from response.read()
print(data)
finally:
yield from response.wait_for_close()
except:
traceback.print_exc()

def producer(q):
print("blocking on multiprocessing queue get")
obj2 = q.get()
print("unblocking on multiprocessing queue get")
print("get qempty:", q.empty())
return obj2

def worker_done(f):
try:
f.result()
print("worker exited")
except:
traceback.print_exc()

workers = []
for i in range(100):
t = asyncio.ensure_future(async_worker(session, async_queue))
t.add_done_callback(worker_done)
workers.append(t)

@asyncio.coroutine
def doit():
print("start producer")
obj = yield from loop.run_in_executor(None, producer, q)
print("finish producer")

print("blocking on asyncio queue put")
yield from async_queue.put(obj)
print("unblocking on asyncio queue put")
print("put aqueue size:", async_queue.qsize())

while True:
loop.run_until_complete(doit())


def server():
loop = asyncio.get_event_loop()
#loop.set_debug(True)

f = loop.create_server(lambda: HttpRequestHandler(debug=True, 
keep_alive=75), '0.0.0.0', '8080')

srv = loop.run_until_complete(f)
loop.run_forever()


if __name__ == '__main__':
q = multiprocessing.Queue(100)

log_proc = multiprocessing.log_to_stderr()
log_proc.setLevel(logging.DEBUG)

p = multiprocessing.Process(target=process_worker, args=(q,))
p.start()

p2 = multiprocessing.Process(target=server)
p2.start()

while True:
print("blocking on multiprocessing queue put")
q.put("http://0.0.0.0:8080;)
print("unblocking on multiprocessing queue put")

print("put qempty:", q.empty())

--

___
Python tracker 

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



[issue7759] mhlib fails on Btrfs filesystem (test_mhlib failure)

2015-11-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is even simpler and more reliable patch. It works even if the subfolder is 
a symlink to the directory on the filesystem that doesn't support links 
counting for directories.

--
Added file: http://bugs.python.org/file41011/mhlib_nlinks_3.patch

___
Python tracker 

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



[issue25263] test_tkinter fails randomly on the buildbots "AMD64 Windows10" (3.4, 3.5, 3.x)

2015-11-11 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Tests are fixed.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 2.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




[issue23883] __all__ lists are incomplete

2015-11-11 Thread Jacek Kołodziej

Changes by Jacek Kołodziej :


Added file: http://bugs.python.org/file41012/Issue23883_all.v6.patch

___
Python tracker 

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



[issue23883] __all__ lists are incomplete

2015-11-11 Thread Jacek Kołodziej

Jacek Kołodziej added the comment:

Serhiy, thank you for the review. I've made proposed changes (along with 
rebasing Issue23883_all patch; Issue23883_test_gettext.v3.patch still applies 
cleanly).

--
Added file: 
http://bugs.python.org/file41013/Issue23883_support_check__all__.v6.patch

___
Python tracker 

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