[issue31724] test_xmlrpc_net should use something other than buildbot.python.org

2017-10-07 Thread Zachary Ware

Change by Zachary Ware :


--
stage: patch review -> needs patch

___
Python tracker 

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



[issue31724] test_xmlrpc_net should use something other than buildbot.python.org

2017-10-07 Thread Zachary Ware

Change by Zachary Ware :


--
keywords: +patch
pull_requests: +3894
stage: needs patch -> patch review

___
Python tracker 

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



[issue31724] test_xmlrpc_net should use something other than buildbot.python.org

2017-10-07 Thread Zachary Ware

Change by Zachary Ware :


--
title: test_xmlrpc should use something other than buildbot.python.org -> 
test_xmlrpc_net should use something other than buildbot.python.org

___
Python tracker 

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



[issue31724] test_xmlrpc should use something other than buildbot.python.org

2017-10-07 Thread Zachary Ware

New submission from Zachary Ware :

With the upgrade to buildbot 0.9, the xmlrpc interface to buildbot.python.org 
is removed, causing test_xmlrpc to fail.  The test should hit a different host, 
possibly on pythontest.net?

--
components: Tests
messages: 303894
nosy: loewis, zach.ware
priority: normal
severity: normal
stage: needs patch
status: open
title: test_xmlrpc should use something other than buildbot.python.org
versions: Python 2.7, 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



Re: "comprehend" into a single value

2017-10-07 Thread Andrew Z
and how about adding "IF" into the mix ?

as in :

a=0

dict= {10: ['a',1,'c'], 20: ['d',2,'f']}

for i in dict:

 p+= 10 if dict[i][1] in [1,2,3,4,5] else 0


can i "squish" "for" and "if" together ? or will it be too perl-ish ?





On Sun, Oct 8, 2017 at 12:37 AM, Andrew Z  wrote:

> Nathan, Bob - on the money. Thank you !
>
> On Sat, Oct 7, 2017 at 11:30 PM, bob gailer  wrote:
>
>> On 10/7/2017 11:17 PM, Nathan Hilterbrand wrote:
>>
>>> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
>>> p = sum([dict[i][1] for i in dict])
>>>
>>> Something like that?
>>>
>> Ah, but that's 2 lines.
>>
>> sum(val[1] for val in  {10: ['a',1,'c'], 20: ['d',2,'f']}.values())
>>
>> On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z  wrote:
>>>
>>> Hello,
   i wonder how  can i accomplish the following as a one liner:

 dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
 p = 0
 for i in dict:
  p += dict[i][1]


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


>> --
>> Image and video hosting by TinyPic
>>
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "comprehend" into a single value

2017-10-07 Thread Andrew Z
Nathan, Bob - on the money. Thank you !

On Sat, Oct 7, 2017 at 11:30 PM, bob gailer  wrote:

> On 10/7/2017 11:17 PM, Nathan Hilterbrand wrote:
>
>> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
>> p = sum([dict[i][1] for i in dict])
>>
>> Something like that?
>>
> Ah, but that's 2 lines.
>
> sum(val[1] for val in  {10: ['a',1,'c'], 20: ['d',2,'f']}.values())
>
> On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z  wrote:
>>
>> Hello,
>>>   i wonder how  can i accomplish the following as a one liner:
>>>
>>> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
>>> p = 0
>>> for i in dict:
>>>  p += dict[i][1]
>>>
>>>
>>> Thank you
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>>
> --
> Image and video hosting by TinyPic
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: "comprehend" into a single value

2017-10-07 Thread bob gailer

On 10/7/2017 11:17 PM, Nathan Hilterbrand wrote:

dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
p = sum([dict[i][1] for i in dict])

Something like that?

Ah, but that's 2 lines.

sum(val[1] for val in  {10: ['a',1,'c'], 20: ['d',2,'f']}.values())

On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z  wrote:


Hello,
  i wonder how  can i accomplish the following as a one liner:

dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
p = 0
for i in dict:
 p += dict[i][1]


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



--
Image and video hosting by TinyPic
--
https://mail.python.org/mailman/listinfo/python-list


Re: "comprehend" into a single value

2017-10-07 Thread Nathan Hilterbrand
dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
p = sum([dict[i][1] for i in dict])

Something like that?

On Sat, Oct 7, 2017 at 11:07 PM, Andrew Z  wrote:

> Hello,
>  i wonder how  can i accomplish the following as a one liner:
>
> dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
> p = 0
> for i in dict:
> p += dict[i][1]
>
>
> Thank you
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Introducing the "for" loop

2017-10-07 Thread Steve D'Aprano
On Sun, 8 Oct 2017 03:58 am, Terry Reedy wrote:


> No built-in function is an instance of FunctionType
>  >>> isinstance(compile, FunctionType)
> False

Ah yes, thanks Terry, I forgot that builtin functions have a distinct type.


[...]
> FunctionType == function defined by def statement or lambda expression.
> These are a subset of functions defined by Python code.

Indeed.


>> It is this last sense (an instance of FunctionType) which people are
>> thinking of when they state that range is not a function.
> 
> Unless one means 'function defined by def or class', excluding all
> functions defined in the interpreter implementation language, which can
> change as modules are recoded one way or the other, and some functions
> defined in Python, FunctionType is too narrow.

Yes, I forgot about the other ways functions can be created, such as partial
objects and builtins and callable instances. (C++ calls them functors.)

However, people often distinguish between functions and methods, since methods
carry their own implicit state ("self") and traditionally functions don't.
But of course the line between them is blurred:

- closures (a kind of function) do carry implicit state;

- static methods in Python (a kind of method) don't carry implicit state.


[...]
> I have the impression that classes being functions is somewhat peculiar
> to Python but I have not been exposed to enough OOP languages to know.

Many languages use function call syntax MyClass(args) (or something quite
close to function call syntax) for instantiating a class. In the sense that a
function is defined by the use of function call syntax, then classes are
functions.

But in the sense that in some languages functions are values but classes are
not (e.g. Java), then classes should be considered distinct from functions.

As always, it depends on what you mean by function.



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

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


"comprehend" into a single value

2017-10-07 Thread Andrew Z
Hello,
 i wonder how  can i accomplish the following as a one liner:

dict= {10: ['a',1,'c'], 20: ['d',2,'f']}
p = 0
for i in dict:
p += dict[i][1]


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


[issue31267] threading.Timer object is affected by changes to system time: Python locks should use a monotonic clock if available

2017-10-07 Thread Thomas Keppler

Thomas Keppler  added the comment:

Hello Victor,

thank you for your update on this issue.

By looking through the other bug reports you listed, it looks as if measures 
were implemented but never merged. Am I right with this observation? If so, 
will we ever see a switch over to monotonic time?

Thanks for the info :)

--
Best regards
Thomas

--

___
Python tracker 

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



Re: django project avoid reload page where work algorithm

2017-10-07 Thread MRAB

On 2017-10-08 01:40, Xristos Xristoou wrote:

I have a website where the user can be put three numbers on my html template 
and get some results from my personal mathematical algorithm. the result save 
at user personal table on my database and can see in specific tab in my website.
my problem is where the algorithm to calculate result maybe take time between 
5-10 minutes in this time the browser stay on reload. if user change tab or 
close browser or maybe have problem with internet connection then loose that 
request and need again to put the numbers and again wait for results.
I want after the user request from my form in html to keep this request and 
work my algorithm without reload the page and where the algorithm finish then 
to send the user some email or message or just need the user visit the tab of 
results to see new results.
that I want to avoid the problems where the algorithm is in running and user 
loose data or request or time.
is easy to do that using suproccess,celery or RabbitMQ ?
any idea ?

[snip]

You mentioned email, so why not just ask for an email address to which 
you will send the result?

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


django project avoid reload page where work algorithm

2017-10-07 Thread Xristos Xristoou
I have a website where the user can be put three numbers on my html template 
and get some results from my personal mathematical algorithm. the result save 
at user personal table on my database and can see in specific tab in my website.
my problem is where the algorithm to calculate result maybe take time between 
5-10 minutes in this time the browser stay on reload. if user change tab or 
close browser or maybe have problem with internet connection then loose that 
request and need again to put the numbers and again wait for results.
I want after the user request from my form in html to keep this request and 
work my algorithm without reload the page and where the algorithm finish then 
to send the user some email or message or just need the user visit the tab of 
results to see new results.
that I want to avoid the problems where the algorithm is in running and user 
loose data or request or time.
is easy to do that using suproccess,celery or RabbitMQ ?
any idea ?
here the code
views.py
def math_alg(request):
if request.method == "POST":
test = request.POST.get('no1')
test = request.POST.get('no3')
test = request.POST.get('no3')
#start algorith
calc_math(no1,no1,no3,result)
instance = rmodel.objects.create(user=request.user,rfield=result)
instance.save
return render(request, 'page.html', {'result': result})
html :
{% csrf_token %}
  op math calculate:
  
  
  

  
{{result }}

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


Re: Lies in education [was Re: The "loop and a half"]

2017-10-07 Thread Richard Damon

On 10/4/17 11:22 PM, Steve D'Aprano wrote:

The A and E in the word "are" are not vowels, since they are silent.


The A is clearly not silent, unless you have some strange pronunciation. 
The fact that are is pronounced just like the NAME of the letter R 
doesn't mean it is silent.


Compare the sound of the word are (which begins like the 'pirate' phrase 
arrgh) to me, to a word that begins with a letter R like rat or ring. 
There is a clear aspiration in the former that isn't in the latter.


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


Finding Old Posts on Python

2017-10-07 Thread Cai Gengyang
Hello,

Does anyone know of a way to find all my old posts about Python ? Thanks a lot!

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


Re: Lies in education [was Re: The "loop and a half"]

2017-10-07 Thread Pavol Lisy
On 10/5/17, Steve D'Aprano  wrote:

> The A and E in the word "are" are not vowels, since they are silent.

Interesting! :)

Is then R (half?) silent in word "Brazil"?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Creating a Dictionary

2017-10-07 Thread Pavol Lisy
On 10/5/17, Chris Angelico  wrote:
> On Thu, Oct 5, 2017 at 12:24 PM, Stefan Ram  wrote:
>>   One might wish to implement a small language with these commands:
>>
>> F - move forward
>> B - move backward
>> L - larger stepsize
>> S - smaller stepsize
>>
>>   . One could start with the following pseudocode for a dictionary:
>>
>> { 'F': lambda: myturtle.forward( s ),
>>   'B': lambda: myturtle.backward( s ),
>>   'L': lambda: global s; s *= 2,
>>   'S': lambda: global s; s /= 2 }
>>
>>   . But lambda-expressions cannot contain statements.
>>
>>   Any other suggestions?
>
> There are a few options here. One is to make use of a simple
> "collector decorator":
>
> commands = {}
> def cmd(f):
> commands[f.__name__.upper()] = f
> return f
>
> @cmd
> def f():
> myturtle.forward( s )
>
> @cmd
> def b():
> myturtle.backward( s )
>
> @cmd
> def l():
> global siz
> size *= 2
>
> @cmd
> def s():
> global siz
> size //= 2
>
> (Also untested, but the pattern is one I've used many times.)
>
> Another is to deploy the whole thing as a class, with no globals:
>
> class Turtle:
> def __init__(self):
> self.size = ...
> self.turtle = ...
> def cmd_F(self):
> self.turtle.forward(self.size)
> def cmd_B(self):
> self.turtle.backward(self.size)
> def cmd_L(self):
> self.size *= 2
> def cmd_S(self):
> self.size //= 2
>
> Note that I've added "cmd_" in front of the names, which means you can
> safely getattr(turtle, "cmd_" + letter) and be confident you won't
> accidentally grab something that isn't a command.
>
> (Note also that I used // for division. If your size is actually a
> float, then change those back to single slashes.)
>
> Either of these patterns would work fairly well. There are others,
> too, but I'd be inclined to use one of these.
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list

size = 2*size if size else 1
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue31655] SimpleNamespace accepts non-string keyword names

2017-10-07 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


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



[issue31655] SimpleNamespace accepts non-string keyword names

2017-10-07 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset cae6e4775b37c412609d3a0d303c0831ff0012ff by Serhiy Storchaka 
(Miss Islington (bot)) in branch '3.6':
[3.6] bpo-31655: Validate keyword names in SimpleNamespace constructor. 
(GH-3909) (#3920)
https://github.com/python/cpython/commit/cae6e4775b37c412609d3a0d303c0831ff0012ff


--

___
Python tracker 

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



[issue31655] SimpleNamespace accepts non-string keyword names

2017-10-07 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +3893

___
Python tracker 

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



[issue31655] SimpleNamespace accepts non-string keyword names

2017-10-07 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:


New changeset 79ba471488b936abda5ba5234b1ea90cbc94cae6 by Serhiy Storchaka in 
branch 'master':
bpo-31655: Validate keyword names in SimpleNamespace constructor. (#3909)
https://github.com/python/cpython/commit/79ba471488b936abda5ba5234b1ea90cbc94cae6


--

___
Python tracker 

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



Re: Introducing the "for" loop

2017-10-07 Thread Chris Angelico
On Sun, Oct 8, 2017 at 3:58 AM, Terry Reedy  wrote:
> No built-in function is an instance of FunctionType
 isinstance(compile, FunctionType)
> False
 isinstance(print, FunctionType)
> False
 type(compile)
> 
 type(int.bit_length)
> 
>
>
> FunctionType == function defined by def statement or lambda expression.
> These are a subset of functions defined by Python code.
>
> Unless one means 'function defined by def or class', excluding all functions
> defined in the interpreter implementation language, which can change as
> modules are recoded one way or the other, and some functions defined in
> Python, FunctionType is too narrow.  The predecate would have to be at least
>
> BuiltinFunction = type(compile)
> MethonDescriptor = type(int.bit_length)
> isinstance(x, (FunctionType, BuiltinFunction, MethodDescriptor))
>
> but that still excludes bound methods and partial functions.

The three types lack a concrete base class... but fortunately, they
have an abstract one.

>>> isinstance(print, collections.abc.Callable)
True
>>> isinstance(int.bit_length, collections.abc.Callable)
True
>>> isinstance(lambda: 1, collections.abc.Callable)
True
>>> isinstance(range, collections.abc.Callable)
True

Now I know my ABCs. :)

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


Re: exception should not stop program.

2017-10-07 Thread MRAB

On 2017-10-07 17:38, Prabu T.S. wrote:

I would like to continue to second function invocation 
"checkServiceStatus('AdobeARMservice')" even if the first
checkServiceStatus('Tomcat9')  has any exception.Please advice.Second 
function invocation not getting executed if any exception occurs in 
first.Please advice.


import psutil

def checkServiceStatus(server):
 status = None
 try:
 service = psutil.win_service_get(server)
 status = service.as_dict()
 print("%s (%s)" % (status['name'], status['display_name']))
 print("status: %s, start: %s, username: %s, pid: %s" % (
 status['status'], status['start_type'], status['username'], 
status['pid']))
 print("binpath: %s" % status['binpath'])
 print(" ")
 except Exception:
 pass
 return status

checkServiceStatus('Tomcat9')
checkServiceStatus('AdobeARMservice')

Catch the exception that's raised, like you're already doing in 
checkServiceStatus.

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


[issue31165] list_slice() does crash if the list is mutated indirectly by PyList_New()

2017-10-07 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

> What does "changing" mean exactly?

I'm not a GC expert. Maybe we should add a global flag that disable calling 
nontrivial destructors and set it in PyObject_GC_New(). The objects with 
nontrivial destructor should be added to the special queue and destroyed in 
"safe" place. There may be a problem with determining the "safe" place. I think 
that any Py_DECREF() is a "safe" place, and the eval loop is a "safe" place.

> What will be the effects on normal code?

I think this shouldn't affect Python code if perform deferred destroying in the 
eval loop. This can affect the execution of extensions if reference loops are 
created in C code. Some objects in loops can live longer that before.

> How do you know that it will not create new problems that didn't exist before?

I don't know. But we can try and see what is the result.

--

___
Python tracker 

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



Re: exception should not stop program.

2017-10-07 Thread Grant Edwards
On 2017-10-07, Jorge Gimeno  wrote:

> Catching all exceptions in a try-except block is almost always a bad
> idea.

Catching it and ignoring it as the OP was doing (or assuming it's some
particular exception) certainly is.

If you know (or suspect) that stderr isn't going anywhere that it will
be seen, then catching all exceptions at the top of your program and
logging them and exiting with an error status is a reasonable thing to
do.

#!/usr/bin/python

import sys,syslog,traceback

def main():
[...]

try:
main()
except:
syslog.syslog("%s: %s\n" % (sys.argv[0], traceback.format_exc()))
sys.exit(1)

If it's a GUI program, then popping up an error dialog instead of
sending it to syslog might make more sense -- if you can be reasonably
sure that the GUI framework is still operational.

-- 
Grant Edwards   grant.b.edwardsYow! Am I accompanied by a
  at   PARENT or GUARDIAN?
  gmail.com

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


Re: The "loop and a half"

2017-10-07 Thread Terry Reedy

On 10/7/2017 10:45 AM, Grant Edwards wrote:

On 2017-10-07, bartc  wrote:


Interactive Python requires quit() or exit(), complete with parentheses.


Nonsense.  On Unix you can just press ctrl-D (or whatever you have
configured as eof) at the command prompt. On windows, it's Ctrl-Z
.


IDLE's shell quits on ^D at a prompt on all systems.  (This became true 
before I worked on IDLE.)

Clicking the [X] button should close any window on all systems.

--
Terry Jan Reedy

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


Re: The "loop and a half"

2017-10-07 Thread bartc

On 07/10/2017 17:28, Steve D'Aprano wrote:

On Sun, 8 Oct 2017 01:15 am, bartc wrote:



You do remember this was about using programs /like/ sort as a model for
writing true interactive scrolling text apps?


I don't remember any such thing. I remember you *claiming* that, but if anyone
actually did make that claim, I haven't seen it.



bart:
> This doesn't make sense. For interactive use, you wouldn't bother
> testing for eof, as you'd be testing the eof status of the keyboard.
>

ChrisA:

> You mean the way heaps and heaps of Unix programs work, processing
> until EOF of stdin? Yeah, totally makes no sense, man, no sense at
> all.

bart:
> If you're referring to the ability to redirect stdin so that input can
> come from a file as well as from a live keyboard, then you're doing
> file handling; it's NOT interactive.

ChrisA:
> How would you write a sort program? How would you tell it that you're
> done entering data?

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


Re: Introducing the "for" loop

2017-10-07 Thread Terry Reedy

On 10/7/2017 5:09 AM, Steve D'Aprano wrote:

On Fri, 6 Oct 2017 11:44 pm, ROGER GRAYDON CHRISTMAN wrote:


Despite the documentation, I would still be tempted to say that range is a
function.
Taking duck-typing to the meta-level, every time I use range, I use its name
followed
by a pair of parentheses enclosing one to three parameters, and I get back
an
immutable sequence object.   It sure looks like a function to me.


I agree -- range() is a function in the (almost) mathematical sense, something
which takes arguments and returns a value. It's also a type (class), in the
OOP sense:


py> type(range)



The term "function" is ambiguous but normally clear from context. Often, the
differences make no difference, but when they are important, we can discuss
them:

- range is a callable (a callable object);

- it is also a type/class, and calling it returns an instance;

- it looks like, and behaves like, a function;

- and is, conceptually, a function;

- but it is *not* an instance of FunctionType:


py> from types import FunctionType
py> def function():
... pass
...
py> isinstance(function, FunctionType)
True
py> isinstance(range, FunctionType)
False


No built-in function is an instance of FunctionType
>>> isinstance(compile, FunctionType)
False
>>> isinstance(print, FunctionType)
False
>>> type(compile)

>>> type(int.bit_length)



FunctionType == function defined by def statement or lambda expression.
These are a subset of functions defined by Python code.


It is this last sense (an instance of FunctionType) which people are thinking
of when they state that range is not a function.


Unless one means 'function defined by def or class', excluding all 
functions defined in the interpreter implementation language, which can 
change as modules are recoded one way or the other, and some functions 
defined in Python, FunctionType is too narrow.  The predecate would have 
to be at least


BuiltinFunction = type(compile)
MethonDescriptor = type(int.bit_length)
isinstance(x, (FunctionType, BuiltinFunction, MethodDescriptor))

but that still excludes bound methods and partial functions.

I have the impression that classes being functions is somewhat peculiar 
to Python but I have not been exposed to enough OOP languages to know.


The other sense in which 'range is not a function' makes some sense is 
when it means 'range is not *just* a function'.  This is akin to when 
'people are not animals' means 'people are not (or should not be) *just* 
animals'.  Do people speaking other than English say subcategory Y of 
category X is special by saying 'Ys are not Xs'?


--
Terry Jan Reedy

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


Re: exception should not stop program.

2017-10-07 Thread Jorge Gimeno
Catching all exceptions in a try-except block is almost always a bad idea.
You can't tell the difference between an exception that you are looking to
handle and an exception that should cause your program to crash and burn
(because something is wrong). It's best to catch a specific exception.
What condition are you looking to handle here?

-Jorge

On Sat, Oct 7, 2017 at 9:38 AM, Prabu T.S.  wrote:

> I would like to continue to second function invocation
> "checkServiceStatus('AdobeARMservice')" even if the first
>checkServiceStatus('Tomcat9')  has any exception.Please advice.Second
> function invocation not getting executed if any exception occurs in
> first.Please advice.
>
>
> import psutil
>
> def checkServiceStatus(server):
> status = None
> try:
> service = psutil.win_service_get(server)
> status = service.as_dict()
> print("%s (%s)" % (status['name'], status['display_name']))
> print("status: %s, start: %s, username: %s, pid: %s" % (
> status['status'], status['start_type'], status['username'],
> status['pid']))
> print("binpath: %s" % status['binpath'])
> print(" ")
> except Exception:
> pass
> return status
>
> checkServiceStatus('Tomcat9')
> checkServiceStatus('AdobeARMservice')
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: The "loop and a half"

2017-10-07 Thread Grant Edwards
On 2017-10-07, Steve D'Aprano  wrote:

> sort *could* detect when it is reading from stdin interactively and give an
> introductory message.

There are some command-line utilities that try to do that: they modify
their behavior when they think that stdin or stdout is connected to a
"terminal" instead of a pipe.  Personally, I find that annoying and
inconvenient.  I hate it when I run a program, look at the output and
decide I want to do some processing on it, so I hit 'ctrl-P' and pipe
the output to sed, grep, awk, sort, whatever.

And it doesn't work.


After wasting _way_ too much time trying to figure out what I did
wrong in my sed/grep/awk/whatever command, I finally realize that the
@#$!% program changes its output format when stdout is a pipe, and the
rest of the pipeline was designed to process the stdout-is-a-terminal
output format.

And don't get me started on command-line utilities that use colored
output that's only usable if yor terminal is configured with a black
background. Hint to gentoo portage authors: yellow-on-white text is
_not_ readable.

-- 
Grant






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


Re: exception should not stop program.

2017-10-07 Thread Prabu T.S.
On Saturday, October 7, 2017 at 12:38:11 PM UTC-4, Prabu T.S. wrote:
> I would like to continue to second function invocation 
> "checkServiceStatus('AdobeARMservice')" even if the first 
>checkServiceStatus('Tomcat9')  has any exception.Please advice.Second 
> function invocation not getting executed if any exception occurs in 
> first.Please advice.
> 
> 
> import psutil
> 
> def checkServiceStatus(server):
> status = None
> try:
> service = psutil.win_service_get(server)
> status = service.as_dict()
> print("%s (%s)" % (status['name'], status['display_name']))
> print("status: %s, start: %s, username: %s, pid: %s" % (
> status['status'], status['start_type'], status['username'], 
> status['pid']))
> print("binpath: %s" % status['binpath'])
> print(" ")
> except Exception:
> pass
> return status
> 
> checkServiceStatus('Tomcat9')
> checkServiceStatus('AdobeARMservice')

ignore this for now.
-- 
https://mail.python.org/mailman/listinfo/python-list


exception should not stop program.

2017-10-07 Thread Prabu T.S.
I would like to continue to second function invocation 
"checkServiceStatus('AdobeARMservice')" even if the first 
   checkServiceStatus('Tomcat9')  has any exception.Please advice.Second 
function invocation not getting executed if any exception occurs in 
first.Please advice.


import psutil

def checkServiceStatus(server):
status = None
try:
service = psutil.win_service_get(server)
status = service.as_dict()
print("%s (%s)" % (status['name'], status['display_name']))
print("status: %s, start: %s, username: %s, pid: %s" % (
status['status'], status['start_type'], status['username'], 
status['pid']))
print("binpath: %s" % status['binpath'])
print(" ")
except Exception:
pass
return status

checkServiceStatus('Tomcat9')
checkServiceStatus('AdobeARMservice')

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


[issue31723] refleaks in zipimport when calling zipimporter.__init__() more than once

2017-10-07 Thread Oren Milman

Change by Oren Milman :


--
keywords: +patch
pull_requests: +3892
stage:  -> patch review

___
Python tracker 

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



Re: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sun, 8 Oct 2017 01:15 am, bartc wrote:

> On 07/10/2017 14:19, Steve D'Aprano wrote:
>> On Sat, 7 Oct 2017 11:06 pm, bartc wrote:
> 
>>> So I have to copy 33,000 lines from a document,
>> 
>> Don't be daft. Nobody says that stdin is a sufficient interface for a
>> heavy-weight task like that. With 33000 lines of text, I absolutely would
>> save them to a permanent file on disk, because I wouldn't want to risk
>> having the application crash or the power go off just as I've typed line
>> 32999 and lose the lot.
> 
> You're missing something I think. The 33K lines already exist elsewhere,
> and have been copied to the clipboard. So you won't lose anything if the
> power goes off, assuming the original are secure.

If I have the 33K lines in a file already, why would I copy them and paste
them into stdin (possibly overflowing the input buffer in the terminal) when
I can just call sort on the file?

I can even sort in place:

sort -o filename filename

You seem to have decided that it is our position that the one and only
acceptable way to use the sort command is to launch it with no options, then
laboriously type (or copy and paste) all the lines into stdin.

We're not idiots. We have many options, and we use the one which is most
appropriate for the task at hand.


>> [...]
>>> Put that way, it doesn't sound very sophisticated does it?
>> 
>> Nobody said it was sophisticated. That's the whole point: having sort read
>> from stdin as you type into the terminal is the LEAST sophisticated,
>> simplest, most bare-bones, basic technique that works.
> 
> You do remember this was about using programs /like/ sort as a model for
> writing true interactive scrolling text apps?

I don't remember any such thing. I remember you *claiming* that, but if anyone
actually did make that claim, I haven't seen it.

There are reasons why sort defaults to not providing a richer UI. Its not
intended as a "Sort Stuff App". It is designed to be used in Unix command
pipelines, where an introductory message would be a nuisance.

sort *could* detect when it is reading from stdin interactively and give an
introductory message. I already said this. The fact that it doesn't is a
matter of the personal taste of the author, who presumably doesn't think it
is necessary. Simplicity is itself a virtue, although not necessarily to
beginners.



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

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


[issue25862] TextIOWrapper assertion failure after read() and SEEK_CUR

2017-10-07 Thread Zackery Spytz

Change by Zackery Spytz :


--
keywords: +patch
pull_requests: +3891
stage: needs patch -> patch review

___
Python tracker 

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



[issue31701] faulthandler dumps 'Windows fatal exception: code 0xe06d7363'

2017-10-07 Thread Steve Dower

Steve Dower  added the comment:

Okay, just tested taking out the C++ handler and it goes straight to an error 
report. Not ideal, especially since the error is logged against "python.exe" 
and "ucrtbase.dll" (which is going to make my life harder when reviewing the 
submitted crash reports), but since it can only be caused by user code, it's 
probably better than spamming on every handled exception.

E06D7363 (msc) and E0434352 (CCR) at least should be ignored. I think there's a 
third, but don't remember what it is right now.

--

___
Python tracker 

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



[issue31701] faulthandler dumps 'Windows fatal exception: code 0xe06d7363'

2017-10-07 Thread Steve Dower

Steve Dower  added the comment:

Haven't had a chance to test this, but I suspect our change should depend on 
what happens when a C++ exception is actually unhandled.

In this case, the following sequence has occurred:
* exception is raised
* debug event is raised (if a debugger is attached)
* stack-based handlers get first-chance to ignore the exception
 * there is a stack-based handler that says "let it be raised" and the search 
stops
* vector-based handlers are called
* stack unwind begins, and when the handler is reached it allows execution to 
continue

Unfortunately, I don't think there's going to be any difference between the 
unhandled and handled cases at the point where our handler exists - at worst, 
the OS is going to say that it is "handled" and its handler will kill the 
process. The first chance lookup is actually there to continue execution and 
ignore the exception (possibly after fixing an argument or allocating a new 
page, etc.).

So I think our choices are:
* report no C++/CLR exceptions via faulthandler
* report all C++/CLR exceptions via faulthandler (current behaviour)

I'm inclined towards changing to the first option. The runtime is going to dump 
a more useful message than us if the exception makes it that far, and a C++ 
exception can never be caused by CPython itself.

--

___
Python tracker 

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



Re: The "loop and a half"

2017-10-07 Thread Michael Torrie
On 10/06/2017 07:24 AM, bartc wrote:
> On 06/10/2017 14:11, Peter J. Holzer wrote:
>> I regularly use at least cat, wc and od this way (plus a few of my own
>> utilities like utf8dump). I'm sure I've used sort this way, too, though
>> rather rarely. I usually don't type the input but paste it in,
> 
> Exactly. Probably no one ever uses these programs with actual live input 
> with the possibility of uncorrectable errors getting through.

I regularly use cat in an interactive way. Most Unix users do.

cat >somefile.txt
sometext
^D

It's a very fast way of moving stuff from the clipboard to a file
without having to fire up an editor.

I'm not sure a prompt would benefit very much here, since this is such a
common operation once you learn it.

In MS-DOS to create a file you do "copy con: file" and then you also get
a blinking cursor with no prompt. Yet this was just something we did
with MS-DOS.  Not sure a prompt would have gained much.


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


Re: The "loop and a half"

2017-10-07 Thread Chris Angelico
On Sun, Oct 8, 2017 at 2:06 AM, bartc  wrote:
> On 07/10/2017 15:45, Grant Edwards wrote:
>> Admit it, you're just trolling.
>
> FFS, NOW what's wrong?
>
> IF you DO redefine those names, then you DO have to use other means to
> terminate. I happen to call those means 'crashing out', because it's like
> yanking the plug rather than using the on/off switch. Especially on Windows
> where the usual Ctrl C doesn't work, so you resort to Ctrl-Break will which
> actually abort it. Ctrl Z is uncommon.
>
> I suspect it's you trying to deliberately wind ME up.
>
> I'm getting fed up with this thread now.

It's when you call that "crashing out" that people think you're just
trolling. Why on earth would that be a crash? Don't you know of any
other way to perform an orderly shutdown in a Python script? You talk
about Ctrl-C/Ctrl-Break as if it were an orderly shutdown, yet ignore
all of the other methods and call them "crashing".

Is there any surprise that people call you out for that?

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


[issue31720] msilib.MSIError is spelled MsiError in documentation

2017-10-07 Thread Mariatta Wijaya

Mariatta Wijaya  added the comment:

Thanks!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions:  -Python 3.4, Python 3.5, Python 3.8

___
Python tracker 

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



[issue31720] msilib.MSIError is spelled MsiError in documentation

2017-10-07 Thread Mariatta Wijaya

Mariatta Wijaya  added the comment:


New changeset 5f396dba1d11356ab18e3bec130596197e741a64 by Mariatta (Miss 
Islington (bot)) in branch '3.6':
bpo-31720: msilib documentation, change MsiError into MSIError (GH-3914) 
(GH-3917)
https://github.com/python/cpython/commit/5f396dba1d11356ab18e3bec130596197e741a64


--
nosy: +Mariatta

___
Python tracker 

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



[issue31695] Improve bigmem tests

2017-10-07 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

+1 to all this :-)

--
nosy: +pitrou

___
Python tracker 

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



[issue31340] Use VS 2017 compiler for build

2017-10-07 Thread Steve Dower

Steve Dower  added the comment:

No, but if we need to do 3.6.4 quickly for another reason, let me know and I'll 
make this change.

It only affects people who are trying to share intermediate build files (which 
for MSVC purposes, includes static libraries) between their 3.6.2 and 3.6.3 
builds. Full builds are going to be fine, and incremental builds should detect 
the changed tools and be able to rebuild everything. 

So it's solely cases where people are trying to manage the build around 
distutils rather than letting distutils handle it all that are problematic (and 
hey, both of these are terrible options! This is why we're discussing how to 
get people to just stop depending on distutils). I don't think it's worth 
churning the entire ecosystem just for that.

--

___
Python tracker 

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



[issue31723] refleaks in zipimport when calling zipimporter.__init__() more than once

2017-10-07 Thread Oren Milman

New submission from Oren Milman :

The following code causes refleaks:
import zipimport
zi = zipimport.zipimporter.__new__(zipimport.zipimporter)
zi.__init__('bar.zip')
zi.__init__('bar.zip')
zi.__init__('bar.zip\\foo')

This is because zipimport_zipimporter___init___impl() (in Modules/zipimport.c)
doesn't decref (if needed) before assigning to `self->files`, `self->archive`
and `self->prefix`.

I would open a PR to fix this soon.

Should i add a test to test_zipimport?
If yes, could you point out some similar refcount test to help me write this
test?

--
components: Extension Modules
messages: 303883
nosy: Oren Milman
priority: normal
severity: normal
status: open
title: refleaks in zipimport when calling zipimporter.__init__() more than once
type: resource usage
versions: Python 3.7

___
Python tracker 

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



[issue31165] list_slice() does crash if the list is mutated indirectly by PyList_New()

2017-10-07 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> I think than changing the Garbage Collector would be easier.

What does "changing" mean exactly?  What will be the effects on normal code?  
How do you know that it will not create new problems that didn't exist before?

--

___
Python tracker 

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



Re: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sun, 8 Oct 2017 12:49 am, bartc wrote:

> On 07/10/2017 14:19, Steve D'Aprano wrote:
>> On Sat, 7 Oct 2017 11:06 pm, bartc wrote:
> 
>> Ctrl-K to enter "operate on selected text" mode;
>> Y to Delete
>> Ctrl-K to enter "operate on selected text" mode;
>> R to Read from a file (at last an actual mnemonic command!)
>> enter a file name
>> 
>> That's five steps.
> 
> Are we counting steps or keystrokes?

Steps. If I was counting keystrokes, entering the filename "file" would have
counted as five. It didn't.


>> And now you have two "temporary" files, file and file2, which need to be
>> deleted. Two more steps that you conveniently don't count.
> 
> Actually I keep a set of 9 scratch file names just for such purposes.

So that's yet another thing for you to memorise rather than Ctrl-D for EOF.

Bart, its cool that you have your own personal, idiosyncratic way of working
that suits you. (I'm not being sarcastic.) If it works for you, great. Nobody
says you have to change your own personal workflow. You've got a bunch of
personal habits and customised tools that do just what you want them to do
and how YOU want them to do, and that's great for you. We accept that.

Please have the decency to return the favour.

Just because other people follow a different workflow and use tools that make
other choices than yours, doesn't make them wrong, and it doesn't make those
other tools substandard.

You're old enough and supposedly mature enough that you ought to know that
before you criticise a technical solution, you should at least try to
understand what problem it is solving before deciding it is wrong.


[...]
>> And you think that memorising these non-standard keyboard shortcuts Ctrl-KW
>> Ctrl-KY Ctrl-KR
> 
> I believe these used to be WordStar commands, if anyone can remember that.

Never used it, but I remember when WordPerfect for Mac came with a keyboard
overlay with WordStar commands on it.

But WordStar or not, you still have to memorise a bunch of commands to get a
task done, commands which don't work anywhere else. You're happy to do it,
which is great. Vim and Emacs users make the same choice, to memorise many
special, idiosyncratic ways of working in a text editor which don't apply
anywhere else. We don't judge: some people love Vim, some love Emacs, some
prefer lightweight GUI editors, some use heavy-duty IDEs.



>> [...]
>>> However, how hard would it for the editor to do its own sorting?
>> 
>> Yes, it is a mystery to me why so few editors include a "sort lines"
>> function.
> 
> I don't know if you're being sarcastic here or not, so I don't know if
> you mean few editors have 'sort' or most of them do. Neither do I get
> the point you're making.

I'm not being sarcastic, and I'm agreeing with you.

Sorting a few lines is not a hard task, and yet not one of my GUI editors have
it as either a built-in command or even a default plug-in. (There may be
third-party plugins I don't know of.)

I daresay that Emacs, at least, will have a sort command, but as they say
about Emacs, it would be the perfect operating system if only its standard
text editor wasn't so bad.

(Hey, just because I respect the right of people to choose Emacs, doesn't mean
I can't make fun of its size and bloatedness.)



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

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


Re: The "loop and a half"

2017-10-07 Thread bartc

On 07/10/2017 15:45, Grant Edwards wrote:

On 2017-10-07, bartc  wrote:


Interactive Python requires quit() or exit(), complete with parentheses.


Nonsense.  On Unix you can just press ctrl-D (or whatever you have
configured as eof) at the command prompt. On windows, it's Ctrl-Z
.


Steve spoke about the 'usual quit/exit/bye' commands.

If you type 'quit' in interactive Python, then it says:

  Use quit() or Ctrl-Z plus Return to exit

Same for exit. So in Python, IF you want to use quit or exit to 
terminate, you have to use quit() or exit() instead.


So please explain how what I wrote was nonsense.


Unless you've redefined quit and exit as something else, then you have
to crash out by other means.)


Admit it, you're just trolling.


FFS, NOW what's wrong?

IF you DO redefine those names, then you DO have to use other means to 
terminate. I happen to call those means 'crashing out', because it's 
like yanking the plug rather than using the on/off switch. Especially on 
Windows where the usual Ctrl C doesn't work, so you resort to Ctrl-Break 
will which actually abort it. Ctrl Z is uncommon.


I suspect it's you trying to deliberately wind ME up.

I'm getting fed up with this thread now.


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


Re: The "loop and a half"

2017-10-07 Thread eryk sun
On Sat, Oct 7, 2017 at 1:06 PM, bartc  wrote:
>
> So I have to copy 33,000 lines from a document, get to the terminal (keeping
> that document open because I'm not done with it), start 'sort', and paste
> those 33,000 lines into the console, then type Ctrl-D. Which then promptly
> prints the newly sorted 33,000 lines onto the console. Then you have to
> select those 33,000 lines (not easy as you now have find the midpoint of
> 66,000 lines of output), copy it, and paste it back into the app.

Just redirect sort's output to the clipboard. In X11 a common program
for this is xclip, e.g. `sort | xclip`, which defaults to the
"primary" clipboard but can also use the "secondary" and "clipboard"
clipboards.

In Windows it's clip.exe, e.g. `sort /u /c | clip`, where /u and /c
are undocumented sort switches to use UTF-16 output and a
case-sensitive sort.

That said, I wouldn't use sort.exe to read input from the Windows
console since it uses the legacy codepage. Instead I'd use the new
Linux subsystem in Windows 10, which as of the Creators update
supports piping between Linux and Windows programs and reads Unicode
from the console. Run `bash` and then `sort | clip.exe`. Finish with
Ctrl+D, and Bob's your uncle. Using MSYS bash.exe and sort.exe (e.g.
from Git for Windows) is another option.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue31720] msilib.MSIError is spelled MsiError in documentation

2017-10-07 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +3890

___
Python tracker 

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



[issue31165] list_slice() does crash if the list is mutated indirectly by PyList_New()

2017-10-07 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

See a4dd011259fa6f3079bd0efd95b3a136c0e3c190. The commit message:

Tentative fix for a problem that Tim discovered at the last moment,
and reported to python-dev: because we were calling dict_resize() in
PyDict_Next(), and because GC's dict_traverse() uses PyDict_Next(),
and because PyTuple_New() can cause GC, and because dict_items() calls
PyTuple_New(), it was possible for dict_items() to have the dict
resized right under its nose.

The solution is convoluted, and touches several places: keys(),
values(), items(), popitem(), PyDict_Next(), and PyDict_SetItem().

There are two parts to it. First, we no longer call dict_resize() in
PyDict_Next(), which seems to solve the immediate problem.  But then
PyDict_SetItem() must have a different policy about when *it* calls
dict_resize(), because we want to guarantee (e.g. for an algorithm
that Jeremy uses in the compiler) that you can loop over a dict using
PyDict_Next() and make changes to the dict as long as those changes
are only value replacements for existing keys using PyDict_SetItem().
This is done by resizing *after* the insertion instead of before, and
by remembering the size before we insert the item, and if the size is
still the same, we don't bother to even check if we might need to
resize.  An additional detail is that if the dict starts out empty, we
must still resize it before the insertion.

That was the first part. :-)

The second part is to make keys(), values(), items(), and popitem()
safe against side effects on the dict caused by allocations, under the
assumption that if the GC can cause arbitrary Python code to run, it
can cause other threads to run, and it's not inconceivable that our
dict could be resized -- it would be insane to write code that relies
on this, but not all code is sane.

Now, I have this nagging feeling that the loops in lookdict probably
are blissfully assuming that doing a simple key comparison does not
change the dict's size.  This is not necessarily true (the keys could
be class instances after all).  But that's a battle for another day.

We have the same issue with lists. PR 3915 tries to fix it by applying the same 
solution -- calling PyList_New() again if the source container was resized. 
list_slice() no longer can be considered safe, because it uses the size 
calculated before calling PyList_New(). Added _PyList_Copy() for copying the 
list for replacing unsafe PyList_GetSlice(). PyList_SetSlice() is not safe too 
(the PR still not fixes this). The code that uses the combination of 
PyList_GetSlice() and PyList_SetSlice() for safety (like in _asynciomodule.c) 
is not safe. Many code, including most implementations of slicing, should be 
rewritten if we go this way. PR 3915 shows only small example of such changes.

I think than changing the Garbage Collector would be easier.

--

___
Python tracker 

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



[issue31720] msilib.MSIError is spelled MsiError in documentation

2017-10-07 Thread Roundup Robot

Change by Roundup Robot :


--
pull_requests: +3889

___
Python tracker 

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



Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-07 Thread Grant Edwards
On 2017-10-07, Steve D'Aprano  wrote:

> They're probably to busy re-doing working programs from scratch every
> few versions, with a brand new "improved" UI (almost invariably
> including a kool new design that uses light grey text on an ever so
> slightly lighter grey background)

Yes!  That!

> and deleting any useful functionality that the lead developer
> personally doesn't use, because "nobody uses that".
>
> https://www.jwz.org/doc/cadt.html

>From the above:

   "Why not be honest and resign yourself to the fact that version 0.8 is
followed by version 0.8, which is then followed by version 0.8?"

I think he's being overly optimistic.  If you want to be honest about
a lot of open-source GUI stuff, version 0.8 should generally be
followed by 0.7.

It seems that the state of affairs in non-GUI open source programs is
far, far better -- maintainers often actually care whether the program
works correclty and does useful things.

-- 
Grant



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


[issue31165] list_slice() does crash if the list is mutated indirectly by PyList_New()

2017-10-07 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
pull_requests: +3888

___
Python tracker 

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



Re: The "loop and a half"

2017-10-07 Thread Grant Edwards
On 2017-10-07, bartc  wrote:

> Interactive Python requires quit() or exit(), complete with parentheses.

Nonsense.  On Unix you can just press ctrl-D (or whatever you have
configured as eof) at the command prompt. On windows, it's Ctrl-Z
.

> Unless you've redefined quit and exit as something else, then you have 
> to crash out by other means.)

Admit it, you're just trolling.

Plonk.


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


Re: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sat, 7 Oct 2017 11:54 pm, bartc wrote:

> So my programs that use Escape on Windows needed
> to use Escape Escape on Linux to get around that.


Or you could just follow the expected Unix interface instead of inventing your
own.


Back in the days when I used a Mac (long before OS X), I used to hate it when
Windows developers would port their software to Mac. With the exception of a
few big software companies like Microsoft, who had actual Mac teams, they
would do what you do: completely ignore the Apple UI guidelines and port
their unfamiliar and arbitrary user interfaces to the Mac software, making it
essentially unusable.


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

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


[issue31722] _io.IncrementalNewlineDecoder doesn't inherit codecs.IncrementalDecoder

2017-10-07 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

As a consequence, _io.IncrementalNewlineDecoder doesn't have the error 
attribute.

--

___
Python tracker 

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



[issue31718] some methods of uninitialized io.IncrementalNewlineDecoder objects raise SystemError

2017-10-07 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
nosy: +benjamin.peterson, stutzbach
versions: +Python 2.7, Python 3.6

___
Python tracker 

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



[issue31722] _io.IncrementalNewlineDecoder doesn't inherit codecs.IncrementalDecoder

2017-10-07 Thread Serhiy Storchaka

New submission from Serhiy Storchaka :

It is documented that io.IncrementalNewlineDecoder inherits 
codecs.IncrementalDecoder. And the Python implementation does. But the C 
implementation doesn't.

>>> issubclass(_pyio.IncrementalNewlineDecoder, codecs.IncrementalDecoder)
True
>>> issubclass(_io.IncrementalNewlineDecoder, codecs.IncrementalDecoder)
False
>>> issubclass(io.IncrementalNewlineDecoder, codecs.IncrementalDecoder)
False

--
components: IO, Library (Lib)
messages: 303879
nosy: benjamin.peterson, serhiy.storchaka, stutzbach
priority: normal
severity: normal
status: open
title: _io.IncrementalNewlineDecoder doesn't inherit codecs.IncrementalDecoder
type: behavior
versions: Python 2.7, 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



Re: The "loop and a half"

2017-10-07 Thread bartc

On 07/10/2017 14:19, Steve D'Aprano wrote:

On Sat, 7 Oct 2017 11:06 pm, bartc wrote:



So I have to copy 33,000 lines from a document,


Don't be daft. Nobody says that stdin is a sufficient interface for a
heavy-weight task like that. With 33000 lines of text, I absolutely would
save them to a permanent file on disk, because I wouldn't want to risk having
the application crash or the power go off just as I've typed line 32999 and
lose the lot.


You're missing something I think. The 33K lines already exist elsewhere, 
and have been copied to the clipboard. So you won't lose anything if the 
power goes off, assuming the original are secure.



For 33000 lines, having one extra temporary file floating around is a cost
worth paying. For 33 lines, it is not.


I was demonstrating the crudeness of copying and pasting to a console 
window rather than between proper applications. That was easier to show 
with a larger example which highlighted some of the practical aspects.



You want a one-size fits all solution. Are you capable of understanding that
different tasks and different scenarios are often best solved using different
techniques?


[...]

Put that way, it doesn't sound very sophisticated does it?


Nobody said it was sophisticated. That's the whole point: having sort read
from stdin as you type into the terminal is the LEAST sophisticated,
simplest, most bare-bones, basic technique that works.


You do remember this was about using programs /like/ sort as a model for 
writing true interactive scrolling text apps?


I said it was a poor model because sort is normally used with files and 
pipes. You're trying to keep it as a viable model because, sometimes, 
sort can also be used with pasted text which sort reads as as though it 
had been typed in real time (not from a pipe or file anyway).


OK, I'm not suggesting doing away with that.

But it is still a bad model of text application to use elsewhere, even 
if extra prompts were added. For one thing, it only reads one block of 
data, then it stops. A more typical text application will be doing 
different things requiring different entry modes.


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


[issue31721] assertion failure in FutureObj_finalize() after setting _log_traceback to True

2017-10-07 Thread Oren Milman

New submission from Oren Milman :

The following code causes an assertion failure in FutureObj_finalize() (in
Modules/_asynciomodule.c):

import asyncio
asyncio.Future()._log_traceback = True


Maybe we should allow Python code to only set it to False, and raise a
ValueError in case Python code tries to set it to True?

(PR 2050 made _log_traceback writable. Are there any usecases for setting it to
True from Python code?)

--
components: asyncio
messages: 303878
nosy: Oren Milman, yselivanov
priority: normal
severity: normal
status: open
title: assertion failure in FutureObj_finalize() after setting _log_traceback 
to True
type: crash
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



python multiprocessing

2017-10-07 Thread Xristos Xristoou
I have three functions in the python that each one puts an image (image path) 
as input and makes a simple image processing and creates a new image (image 
path) as output.
in the example below, one function depends on the other, ie: the function of 
alg2 takes as input the image that generates the function of alg and the 
function of alg3 assign as input the image that generates the function of alg2 
which depends on the function of alg1.
(I hope you do not mind basically)
because of their relatively high execution time (image processing is that) I 
would like to ask if I can to parallelize them using python multiprocessing. I 
have read about multiprocessing map and pool but I was pretty confused .
whenever I summarize I have three interdependent functions and I would like to 
run them together if done. I would also like to know how I would perform these 
three functions in a contemporary way if they were not interdependent, ie each 
was autonomous.

def alg1(input_path_image,output_path_image):
start = timeit.default_timer()
###processing###)
stop = timeit.default_timer()
print stop - start
return output_path_image

def alg1(output_path_image,output_path_image1):
start = timeit.default_timer()
###processing###
stop = timeit.default_timer()
print stop - start
return output_path_image1

def alg3(output_path_image1,output_path_image2):
start = timeit.default_timer()
###processing###
stop = timeit.default_timer()
print stop - start
return output_path_image2

if __name__ == '__main__':
   alg1(output_path_image,output_path_image)
   alg2(output_path_image1,output_path_image1)
   alg3(output_path_image2,output_path_image2)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: callable values

2017-10-07 Thread Thomas Jollans
On 07/10/17 01:58, Steve D'Aprano wrote:
> On Sat, 7 Oct 2017 03:25 am, Stefan Ram wrote:
>
>>   FWIW, in my course notes, I have coined a special word for
>>   this:
>>
>>   A /prelate/ (German: "Prälat") is a callable value (object).
>
> In English, prelate is a kind of priest, a senior clergyman and dignitary.

... which is, of course, exactly what „Prälat“ means.

>
> I don't know whether German makes a practice of taking arbitrary verbs and
> adjectives and turning them into nouns, but English does, and so a callable
> object is just called a "callable".
>
>
>

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


Re: The "loop and a half"

2017-10-07 Thread bartc

On 07/10/2017 14:19, Steve D'Aprano wrote:

On Sat, 7 Oct 2017 11:06 pm, bartc wrote:



Ctrl-K to enter "operate on selected text" mode;
Y to Delete
Ctrl-K to enter "operate on selected text" mode;
R to Read from a file (at last an actual mnemonic command!)
enter a file name

That's five steps.


Are we counting steps or keystrokes?


And now you have two "temporary" files, file and file2, which need to be
deleted. Two more steps that you conveniently don't count.


Actually I keep a set of 9 scratch file names just for such purposes. So 
overwriting and deleting don't matter. (Apparently the names are 
offensive to some so I won't mention them, but they're easy to type.)



And you think that memorising these non-standard keyboard shortcuts Ctrl-KW
Ctrl-KY Ctrl-KR


I believe these used to be WordStar commands, if anyone can remember that.

 is better than memorising Ctrl-D which works across thousands

of applications? Good for you. You probably would love Emacs, except other
people use it, and therefore you will hate it.


[...]

However, how hard would it for the editor to do its own sorting?


Yes, it is a mystery to me why so few editors include a "sort lines" function.


I don't know if you're being sarcastic here or not, so I don't know if 
you mean few editors have 'sort' or most of them do. Neither do I get 
the point you're making.


But it's a little ironic that it took less time to add such a feature 
than I spent writing about it in a post!


--
bart

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


[issue31720] msilib.MSIError is spelled MsiError in documentation

2017-10-07 Thread Tzu-ping Chung

Change by Tzu-ping Chung :


--
keywords: +patch
pull_requests: +3887
stage:  -> patch review

___
Python tracker 

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



[issue31720] msilib.MSIError is spelled MsiError in documentation

2017-10-07 Thread Tzu-ping Chung

New submission from Tzu-ping Chung :

The title describes it all.

--
assignee: docs@python
components: Documentation
messages: 303877
nosy: docs@python, uranusjr
priority: normal
severity: normal
status: open
title: msilib.MSIError is spelled MsiError in documentation
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



Re: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sat, 7 Oct 2017 11:06 pm, bartc wrote:

> That's not entering the data interactively (such as typing 'sort' then
> it sits silently recording lines of text (you hope) until it sees EOF).

I manually hit paste, that's just as much a form of data entry as typing
characters one at a time. And then I hit Ctrl-D, and the program responds by
sorting the input. That's a manual, interactive process.

My example only specified copying data out of another application because
that's my usual use-case. Perhaps I'm writing an email, or using a news
reader (as I'm doing now).

But that part isn't critical. Perhaps I haven't typed them yet. Since there's
only a few of them, a dozen or so, its trivial to type or paste them into
stdin. Because I'm not a caveman, I use all the tools at my disposal, and
that includes the ability to copy and paste from one application to another.

Maybe I even type some lines, and paste others. Its 2017 and I've been using
computers long enough to know how to copy and paste from one application to
another like a Boss. You ought to see me, I drag the mouse over text like a
virtuoso, and middle-click like a world-champion.

The fact that stdin is a pretty feature-poor line based editor is neither in
dispute nor is it a problem. If I make a mistake, its no big deal. I just
re-type the line, sort the lot including the erroneous line, then edit out
the bad line after I've pasted it into the email.

YOU, not me, is the one talking in absolutes: according to you, nobody could
possibly need anything less than a full-featured user-friendly application
with prompts and all the bells and whistles in order to sort even half a
dozen lines of text. You make absolute statements about how we ought to work:

"You use a text editor to create your data. Then use existing 
file-based sort."

No we don't. Not always. Sometimes we might, but its not compulsory and
sometimes the task is small enough that having sort read from stdin is all we
need. There's no need for saving text into a file.

I've given you a real-world actual use-case where your solution is
inconvenient, complicated and difficult. This is a case where I don't need
all the bells and whistles you claim are indispensable.

I'm not saying there's "never" a use for such an application. Of course there
are cases where entering data into stdin is inconvenient and underpowered.
Nobody disputes that. YOU are arguing against some imaginary, exaggerated
position where we say that nobody ever, under any circumstances, needs a UI
more friendly than bare-bones stdin.

Nobody said that. You are projecting your own absolutism onto us. We're
explaining why the sort program is designed the way it is. That doesn't mean
that other designs don't have their uses too.


> You say the lines already exist in a text editor. 

I said "whatever application I'm using", which is not necessarily a text
editor. Perhaps it is my email client. Perhaps it is a graphics program, and
I want to enter some sorted text. Perhaps its a web form.

Or perhaps I haven't actually typed the lines yet.


> Exactly what I said; 
> you start with text that has already been entered or generated by other
> means.

Unless I don't.


> However it does seem to expose a flaw in the ability of command line
> tools to work with non-command line tools.
> 
> So I have to copy 33,000 lines from a document, 

Don't be daft. Nobody says that stdin is a sufficient interface for a
heavy-weight task like that. With 33000 lines of text, I absolutely would
save them to a permanent file on disk, because I wouldn't want to risk having
the application crash or the power go off just as I've typed line 32999 and
lose the lot.

For 33000 lines, having one extra temporary file floating around is a cost
worth paying. For 33 lines, it is not.

You want a one-size fits all solution. Are you capable of understanding that
different tasks and different scenarios are often best solved using different
techniques?


[...]
> Put that way, it doesn't sound very sophisticated does it?

Nobody said it was sophisticated. That's the whole point: having sort read
from stdin as you type into the terminal is the LEAST sophisticated,
simplest, most bare-bones, basic technique that works.

If I want to prise open the lid of a paint can, a screwdriver will do the job.
I don't need to purchase a $50 gold-plated electric paint lid opening machine
that requires ten minutes to set up. Now maybe if I needed to open 33000
paint tins, it would be worth using a more heavyweight solution. But I only
need to open two tins. A screwdriver is fine.


> (Now I expect you're going to bombard with workarounds to fix all those
> issues.)

Not at all. 



[...]
> 

You've got data in an email client. You've already typed it out, and then you
think "I want this sorted". What do you do?

You have to copy the lines into a text editor, save to disk, then launch your
file-based sort program, tell it to sort the saved file, reload the saved
file, copy 

Re: The "loop and a half"

2017-10-07 Thread bartc

On 07/10/2017 09:35, Steve D'Aprano wrote:

On Sat, 7 Oct 2017 11:05 am, bartc wrote:



Um, that actually follows what interactive Python does.



What is "that" to which you refer?

If you mean, "what I, Bart C, suggested, namely having the program exit on a
blank line", then you are wrong. In the Python interactive interpreter, you
can enter blank lines, and the interpreter doesn't exit.



There's one priviso: blank lines are only ignored at the primary prompt >>>
not the secondary prompt ... where a blank line is used to end the block. But
the interpreter doesn't exit. A slight compromise for the sake of convenience
at the interactive prompt.


That's what I mean. Enter is used to end one state and get back to another.

The same thing with my loop evaluating expressions. When you're done 
with with expressions, you might exit in the trivial example, or you 
might get back to a main command loop. Just like Python.





(Most of my real interactive programs with a command line interface
programs use Escape, quit, exit, q or x to finish.


And how do you distinguish between calling quit from inside the function, and
using quit inside the function?


Huh? Most interactive programs aren't language interpreters like Python, 
where everything needs to be considered to be a line in the language syntax.



Unfortunately ESCAPE is already used. VT100 (the terminal emulation which is
used in just about all terminals) all control sequences begin with ESC. So
every time you do something like press an arrow key, the terminal sends ESC
followed by other stuff. It would be painful if every time you hit an arrow
key, the interpreter took it as "Exit".


Yes, I discovered this. So my programs that use Escape on Windows needed 
to use Escape Escape on Linux to get around that.



Interactive Python requires quit() or exit(), complete with parentheses.
Unless you've redefined quit and exit as something else, then you have
to crash out by other means.)


"Crash out", he says.

If your intention is to prove that you're a know-nothing ignoramus, you're
doing an excellent job of it.


Yes, crash out. I've always considered control sequences as something 
out of the ordinary used when things go wrong. Eg:


 <<< while 1:
 <<< pass
 <<<

Here it appears to hang, and nothing you type does anything except (on 
Windows) Ctrl-C. That's what I call crashing out. Although that stays 
within the interpreter. If I press Ctrl-Break instead, it aborts the 
interpreter too.


What exactly is your problem, that anyone who has a different take on 
things must be an 'ignoramus'? And, to boot, an ignoramus who knows nothing?


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


Re: The "loop and a half"

2017-10-07 Thread bartc

On 07/10/2017 03:18, Chris Angelico wrote:

On Sat, Oct 7, 2017 at 12:50 PM, Steve D'Aprano
 wrote:

On Sat, 7 Oct 2017 06:21 am, Chris Angelico wrote:


I'm not sure what printing to a window or image would mean, or how
it's useful, but sure.


Print to window: Print Preview.

Print to image: export to pdf or jpg or png.


Except that that isn't what you get in his programming language. What
you seem to get (judging from his response to the post you're quoting)
is something that lets you treat a GUI window as if it were a console,
printing text to it in some sort of "glass teletype" way. Leaves me
wondering if he's ever taken one of his apps to a system that uses a
different default font, or anything like that. Unless all his GUIs are
built in HTML?


(That particular language was one I was using over 20 years ago and it 
was an integrated part of a CAD application (and it started off 
pre-Windows).


The app also supported printer/plotter/image destinations including 
PostScript. The same language could take a marked-up text file, convert 
it to a series of drawing elements, then render and print that page on a 
PS printer. Then the same with the next page. I think I did a 350-page 
manual like that. With pictures.


My current language doesn't link its 'print' to graphic displays or images.)

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


Re: The "loop and a half"

2017-10-07 Thread bartc

On 07/10/2017 02:46, Steve D'Aprano wrote:

On Sat, 7 Oct 2017 06:18 am, bartc wrote:


For sort, there is no real need. You use a text editor to create your
data. Then use existing file-based sort.


What you mean is, *you* see no need for sorting interactively, or sorting as
part of a pipeline of functions. That speaks more of your lack of imagination
and closed-mindedness than any real lack.


Where did I say that?

The 'existing file-based sort' works from files and pipes.

It's capturing the data to start with that it would be ludicrous to do 
interactively using such a crude interface.



Personally, if I have a few (say, a dozen or so) lines I want sorted, it is
much easier to:

- select text from whatever application I'm using;

- bring up a terminal (I almost always have one already open);

- type `sort ENTER`;

- middle-click to paste the lines;

- type Ctrl-D;

- select the output lines;

- paste back into the original application;



That's not entering the data interactively (such as typing 'sort' then 
it sits silently recording lines of text (you hope) until it sees EOF). 
You say the lines already exist in a text editor. Exactly what I said; 
you start with text that has already been entered or generated by other 
means.


However it does seem to expose a flaw in the ability of command line 
tools to work with non-command line tools.


So I have to copy 33,000 lines from a document, get to the terminal 
(keeping that document open because I'm not done with it), start 'sort', 
and paste those 33,000 lines into the console, then type Ctrl-D. Which 
then promptly prints the newly sorted 33,000 lines onto the console. 
Then you have to select those 33,000 lines (not easy as you now have 
find the midpoint of 66,000 lines of output), copy it, and paste it back 
into the app.


Put that way, it doesn't sound very sophisticated does it?

(Now I expect you're going to bombard with workarounds to fix all those 
issues.)



(seven steps)


versus:




That's not what I meant at all, which is about creating the data from 
scratch. Here, the data STILL already magically exists somewhere!


Is it possible that you guys have never had to create anything original?

(How would /I/ sort a block of text in my editor? There's no built-in 
function, so using your approach:


 * Select the block

 * Ctrl KWfileEnter to write it to 'file'

 * Elsewhere, sort file2

 * Back in editor, Ctrl KY Ctrl KRfile2Enter to delete then insert file2

Only four steps? Something went amiss in your analysis I think. And even 
these could be simplified by Using Ctrl KS and Ctrl KL to use a 
predefined clipboard-like filename for the intermediate.


However, how hard would it for the editor to do its own sorting? Not 
very, as it turns out, only half a dozen lines of code (see below after 
sig). Now the sequence is:


  * Select the block

  * Ctrl KH

How many steps did you have, seven?)


I forget... it is "work harder, not smarter"? Being inefficient is a good
thing, right?


Okay

--
bartc

--
proc cmd_ctrlkh <"med:*ck*ch "> (td) =
if td.blockstart then
isort(td.text[td.blockstart..td.blockend])
pageupdate(td)
fi
end
--
https://mail.python.org/mailman/listinfo/python-list


[issue31712] subprocess with stderr=subprocess.STDOUT hang

2017-10-07 Thread l4mer

l4mer  added the comment:

confirm, OpenSSH_7.3p1 solve the problem.
Thanks for help.

--
resolution:  -> third party
status:  -> closed

___
Python tracker 

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



[issue31718] some methods of uninitialized io.IncrementalNewlineDecoder objects raise SystemError

2017-10-07 Thread Oren Milman

Oren Milman  added the comment:

With regard to refleaks in __init__() methods, i started looking for similar 
refleaks
in the codebase, and hope to open an issue to fix them soon.

--

___
Python tracker 

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



Re: Warnings (was Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"])

2017-10-07 Thread Steve D'Aprano
On Sat, 7 Oct 2017 12:09 pm, Chris Angelico wrote:

> So the question is: is it right for a library to raise
> console warnings like that? Under what circumstances and to what
> destinations should a library report on potential problems?

Of course they should -- and applications should be free to disable the
warnings.

Personally, I think Python gets it right: by default, warnings are only
printed once each. Instead of getting a million

WARNING: 32x32 icon missing, using 16x16 icon

you only see it once.



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

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


Re: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sat, 7 Oct 2017 07:01 am, bartc wrote:

> On 06/10/2017 20:38, Grant Edwards wrote:
>> On 2017-10-06, bartc  wrote:
>> 
>>> For sort, there is no real need. You use a text editor to create
>>> your data. Then use existing file-based sort.
>> 
>> I sort streams on stdin far more often than I sort named files.
> 
> So what's been established is that 'sort' is useful for a text stream
> that already exists as a file or is the output of another process.

Indeed. And "another process" can just as easily be a human at the keyboard,
although we must keep in mind the primitive line-oriented editing facilities
of stdin (basically backspace and that's it).

 
> What hasn't been established is why how this works this has to influence
> the design of simple text-based dialogues, real ones where there will
> likely be an actual user tapping the keys in real time.

Obviously it doesn't, and as far as I can see, nobody has suggested that such
primitive facilities should be treated as the archetype of *user-oriented*
application programming. There are other kinds of programs than those aimed
primarily at direct use by users.

As I interpret what people have been saying in this thread, the claim is far
more modest:

- sort is designed for use in pipelines, as a typical Unix tool;

- the way to exit sort is the same way you exit pretty much everything
  in the Unix command line, using EOF (Ctrl-D);

- Unix admins and even Unix end users learn Ctrl-D just as Windows users
  learn ESC and Ctrl-Q and Alt-F4 and the other myriad standard ways to
  exit an application in the Windows world;

- as a Unix tool rather than a text-based application with a rich
  user-interface, it doesn't need verbose output, introduction messages, 
  help screens, and all the other bells and whistles;

- although there is a valid argument to be made that sort could be a little
  more user-friendly in interactive use without badly compromising its 
  primary purpose. But that's a matter of taste.


Besides, we know what the nirvana of user-interfaces should look like:

https://www.gnu.org/fun/jokes/ed-msg.html



> The only tenuous connection I can see, is that if 'sort' is run without
> any piped or redirected input, it will resort to the keyboard.

It doesn't "resort to the keyboard", that's just how stdin works.

If you have a car built to drive on roads, and you drive it up onto the lawn,
the car doesn't need a special mode that detects the missing road
and "resorts to driving on the lawn". It just happens. Stdin is like that.




> Even though that method is not user-friendly 

True enough. `sort` is not designed to be a end-user application, although it
can be used by the end-user.


> and hardly anyone ever uses it in that mode.

Translation: "I don't use it in that mode".


> So that same unfriendly technique should be the model for 
> text dialogues everywhere.

I'm pretty sure that nobody said that.




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

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


[issue31712] subprocess with stderr=subprocess.STDOUT hang

2017-10-07 Thread Martin Panter

Martin Panter  added the comment:

Scanning over the Open SSH commits for 7.3p1

https://github.com/openssh/openssh-portable/compare/V_7_2_P2...V_7_3_P1

it looks like this commit

https://github.com/openssh/openssh-portable/commit/d2d6bf864e52af8491a60dd507f85b74361f5da3

may fix your problem. It points to

https://bugzilla.mindrot.org/show_bug.cgi?id=1988

--
resolution:  -> third party
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-07 Thread Terry Reedy

On 10/6/2017 8:19 PM, Steve D'Aprano wrote:

On Sat, 7 Oct 2017 05:33 am, Grant Edwards wrote:


On 2017-10-06, Marko Rauhamaa  wrote:


The reason a daemon usually opens dummy file descriptors for the 0, 1
and 2 slots is to avoid accidents. Some library might assume the
existence of those file descriptors. For example, I often see GTK print
out diagnositic messages.


I run a lot of GTK programs from the command line, and I would say 90%
or more of them spew a steady stream of meaningless (to the user)
diagnostic messages.  That's pretty sloppy programming if you ask
me...


Indeed.

If you ever start to doubt that the average quality of software is "crap", try
running GUI applications from the command line and watch the stream of
warnings and errors flow by. They range from relatively trivial warnings that
correctly sized icons are missing, to scary looking warnings about
uninitialised pointers.


IDLE does not do that because tkinter and the other stdlib modules it 
uses does not do that.  There are occasionally extraneous messages from 
tcl when shutting down.



Developers: why do you bother to log warnings if you're never going to fix the
damn things?

They're probably to busy re-doing working programs from scratch every few
versions, with a brand new "improved" UI (almost invariably including a kool
new design that uses light grey text on an ever so slightly lighter grey
background) and deleting any useful functionality that the lead developer
personally doesn't use, because "nobody uses that".

https://www.jwz.org/doc/cadt.html






--
Terry Jan Reedy

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


Re: Introducing the "for" loop

2017-10-07 Thread Steve D'Aprano
On Fri, 6 Oct 2017 11:44 pm, ROGER GRAYDON CHRISTMAN wrote:

> Despite the documentation, I would still be tempted to say that range is a
> function.
> Taking duck-typing to the meta-level, every time I use range, I use its name
> followed
> by a pair of parentheses enclosing one to three parameters, and I get back
> an
> immutable sequence object.   It sure looks like a function to me.

I agree -- range() is a function in the (almost) mathematical sense, something
which takes arguments and returns a value. It's also a type (class), in the
OOP sense:


py> type(range)



The term "function" is ambiguous but normally clear from context. Often, the
differences make no difference, but when they are important, we can discuss
them:

- range is a callable (a callable object);

- it is also a type/class, and calling it returns an instance;

- it looks like, and behaves like, a function;

- and is, conceptually, a function;

- but it is *not* an instance of FunctionType:


py> from types import FunctionType
py> def function():
... pass
...
py> isinstance(function, FunctionType)
True
py> isinstance(range, FunctionType)
False


It is this last sense (an instance of FunctionType) which people are thinking
of when they state that range is not a function.



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

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


[issue31718] some methods of uninitialized io.IncrementalNewlineDecoder objects raise SystemError

2017-10-07 Thread Oren Milman

Change by Oren Milman :


--
keywords: +patch
pull_requests: +3886
stage:  -> patch review

___
Python tracker 

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



Re: Interactive scripts (back on topic for once) [was Re: The "loop and a half"]

2017-10-07 Thread Steve D'Aprano
On Sat, 7 Oct 2017 12:12 am, Paul Moore wrote:

> What really bugs me is colour settings that default to dark blues on
> a black background.

Amen to that!

Between the very low contrast, and the stereopsis whereby blues appear to
recede into the distance (and bright red pull forward, appearing to float on
top of the terminal), dark blue text on the background is nearly unreadable.

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


[...]
> Add the fact that
> I work on shared admin accounts, where setting non-default preferences
> is considered an antisocial act (even when they are "better" ;-)) and
> I spend my life squinting at screens, or typing "unalias ls" to remove
> the --color setting. Luckily (for everyone who has to listen to me
> rant), this is "just" annoyingly badly configured systems, and not
> baked in program defaults.

At my previous job, the solution to that was to ban changing the default
settings, but allow admins to create their own personalised defaults.

Fred would log in to the shared account, and run 

source fred

to get his personalised settings. When George logged in to the shared account,
he'd see the defaults, not Fred's settings, and could run

source george

to get his own settings.

(Obviously Fred and George would have to create the "fred" and "george" config
files first.)

I don't know if Windows shells have something like bash's `source` command,
but if it does, this would be one solution.


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

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


[issue31712] subprocess with stderr=subprocess.STDOUT hang

2017-10-07 Thread l4mer

l4mer  added the comment:

Interesting when using faster machine with newer ssh don't see this problem :)

janusz@t560:~$ ssh -V
OpenSSH_7.3p1 Ubuntu-1ubuntu0.1, OpenSSL 1.0.2g  1 Mar 2016

janusz@t560:~$ ssh root@localhost -O exit; strace python test.py

getrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=4*1024}) = 0
close(3)= 0
pipe2([3, 4], O_CLOEXEC)= 0
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl(3, F_GETFL)   = 0 (flags O_RDONLY)
pipe2([5, 6], O_CLOEXEC)= 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0x7fb7ba6fc9d0) = 22284
close(6)= 0
close(4)= 0
brk(0xca73792000)   = 0xca73792000
read(5, "", 5)  = 0
brk(0xca73786000)   = 0xca73786000
close(5)= 0
fstat(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
lseek(3, 0, SEEK_CUR)   = -1 ESPIPE (Illegal seek)
read(3, "root\n", 6)= 5
read(3, "", 1)  = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=22284, si_uid=1000, 
si_status=0, si_utime=1, si_stime=0} ---
close(3)= 0
wait4(22284, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0, NULL) = 22284
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fb7ba2f1630}, {0xca720ef1a0, 
[], SA_RESTORER, 0x7fb7ba2f1630}, 8) = 0
exit_group(0)   = ?
+++ exited with 0 +++

So, two options here:
- new version of ssh
- faster CPU

Will try to update ssh on the old/slow machine.

--

___
Python tracker 

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



[issue31712] subprocess with stderr=subprocess.STDOUT hang

2017-10-07 Thread l4mer

l4mer  added the comment:

I) Manual test for subprocess32:

janusz@nc6120:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess32
>>> cmd = ["ssh", "root@localhost", "-p", "50494", "whoami"]
>>> buf = subprocess32.check_output(cmd, stderr=subprocess32.STDOUT)
>>> print buf
root

>>>
janusz@nc6120:~$ ssh root@localhost -p 50494 -O exit
Exit request sent.
janusz@nc6120:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess32
>>> cmd = ["ssh", "root@localhost", "-p", "50494", "whoami"]
>>> buf = subprocess32.check_output(cmd, stderr=subprocess32.STDOUT)
after 20 seconds
^CTraceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 628, in 
check_output
output, unused_err = process.communicate(timeout=timeout)
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 915, in 
communicate
stdout = _eintr_retry_call(self.stdout.read)
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 543, in 
_eintr_retry_call
return func(*args)
KeyboardInterrupt
>>>

II) When omit stderr:

janusz@nc6120:~$ ssh root@localhost -p 50494 -O exit
Exit request sent.
janusz@nc6120:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess32
>>> cmd = ["ssh", "root@localhost", "-p", "50494", "whoami"]
>>> buf = subprocess32.check_output(cmd)
>>> print buf
root

>>>

Strace for stderr=None:

mmap2(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb7071000
close(6)= 0
close(5)= 0
close(4)= 0
ugetrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=64*1024}) = 0
close(3)= 0
pipe2([3, 4], O_CLOEXEC)= 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl64(3, F_GETFL) = 0 (flags O_RDONLY)
pipe2([5, 6], O_CLOEXEC)= 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0xb74e3768) = 2728
close(6)= 0
close(4)= 0
brk(0x93d2000)  = 0x93d2000
read(5, "", 5)  = 0
brk(0x93c6000)  = 0x93c6000
close(5)= 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
_llseek(3, 0, 0xbfe23f90, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(3, "root\n", 6)= 5
read(3, "", 1)  = 0
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2728, si_uid=1000, 
si_status=0, si_utime=6, si_stime=0} ---
close(3)= 0
waitpid(2728, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 2728
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x8183c10, [], 0}, 8) = 0
brk(0x93c4000)  = 0x93c4000
exit_group(0)   = ?
+++ exited with 0 +++

--

___
Python tracker 

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



Re: The "loop and a half"

2017-10-07 Thread Steve D'Aprano
On Sat, 7 Oct 2017 11:05 am, bartc wrote:

> On 07/10/2017 00:43, Steve D'Aprano wrote:
>> On Sat, 7 Oct 2017 12:24 am, bartc wrote:
>> 
>>> print ("Enter blank expression to quit.")
>> 
>> 
>> I *despise* programs that do that, and would cheerfully and
>> unapologetically take their designers, disguise them as a lettuce, and
>> stake them out to be nibbled to death by snails.
>> 
>> At the interactive prompt, I am frequently hitting Enter on a blank line,
>> either by accident, or deliberately to break up the calculations into
>> groups, or just to give myself time to think.
>> 
>> Blank lines should be treated as "do nothing" and simply ignored, and there
>> should be an explicit QUIT command.
> 
> 
> Um, that actually follows what interactive Python does.


What is "that" to which you refer?

If you mean, "what I, Bart C, suggested, namely having the program exit on a
blank line", then you are wrong. In the Python interactive interpreter, you
can enter blank lines, and the interpreter doesn't exit.

If you mean "what Steven suggests, namely ignoring blank lines and requiring
either an explicit EOF (Ctrl-D on Unix) or quit() or exit() command to exit",
then you are correct, Python does do that.

There's one priviso: blank lines are only ignored at the primary prompt >>>
not the secondary prompt ... where a blank line is used to end the block. But
the interpreter doesn't exit. A slight compromise for the sake of convenience
at the interactive prompt.


> (Most of my real interactive programs with a command line interface
> programs use Escape, quit, exit, q or x to finish.

And how do you distinguish between calling quit from inside the function, and
using quit inside the function?

def foo():
pass
quit
# or exit, q or x for that matter

would be a perfectly legal (although rather pointless) function.

If typing the letter x alone was enough to exit the block, how do you type
`x=1` when the instance you press `x` the interpreter helpfully exits the
block?

If you require `x` followed by ENTER, then that prohibits legal lines which
consist of nothing but `x`.

Unfortunately ESCAPE is already used. VT100 (the terminal emulation which is
used in just about all terminals) all control sequences begin with ESC. So
every time you do something like press an arrow key, the terminal sends ESC
followed by other stuff. It would be painful if every time you hit an arrow
key, the interpreter took it as "Exit".


> Interactive Python requires quit() or exit(), complete with parentheses.
> Unless you've redefined quit and exit as something else, then you have
> to crash out by other means.)

"Crash out", he says.

If your intention is to prove that you're a know-nothing ignoramus, you're
doing an excellent job of it.

 

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

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


[issue1104] msilib.SummaryInfo.GetProperty() truncates the string by one character

2017-10-07 Thread Tzu-ping Chung

Change by Tzu-ping Chung :


--
nosy: +uranusjr

___
Python tracker 

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



[issue31712] subprocess with stderr=subprocess.STDOUT hang

2017-10-07 Thread l4mer

l4mer  added the comment:

janusz@nc6120:~$ ssh -V
OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
janusz@nc6120:~$

I) manual check

janusz@nc6120:~$ ssh root@localhost -p 50494 -O exit
janusz@nc6120:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess
>>> cmd = ["ssh", "root@localhost", "-p", "50494"]
>>> buf = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
Terminated

janusz@nc6120:~$ ssh root@localhost -p 50494 -O exit
Exit request sent.
janusz@nc6120:~$ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import subprocess32
>>> cmd= ["ssh", "root@localhost", "-p", "50494"]
>>> buf = subprocess32.check_output(cmd, stderr=subprocess32.STDOUT)
Terminated

II) strace 

Correct case (mux exist):
pipe2([3, 4], O_CLOEXEC)= 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl64(3, F_GETFL) = 0 (flags O_RDONLY)
pipe2([5, 6], O_CLOEXEC)= 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0xb747a768) = 2207
close(6)= 0
close(4)= 0
brk(0x9741000)  = 0x9741000
read(5, "", 5)  = 0
brk(0x9735000)  = 0x9735000
close(5)= 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
_llseek(3, 0, 0xbfc1d350, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(3, "root\n", 6)= 5
read(3, "", 1)  = 0
close(3)= 0
waitpid(2207, [{WIFEXITED(s) && WEXITSTATUS(s) == 0}], 0) = 2207
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2207, si_uid=1000, 
si_status=0, si_utime=0, si_stime=0} ---
rt_sigaction(SIGINT, {SIG_DFL, [], 0}, {0x8183c10, [], 0}, 8) = 0
brk(0x9733000)  = 0x9733000
exit_group(0)   = ?
+++ exited with 0 +++

Fail case:
read(7, "menting schedulers (this is what"..., 8192) = 8192
read(7, "\0\0\0_lent\1\0\0\0ht\10\0\0\0h_appendt\5\0\0\0i"..., 4096) = 2240
read(7, "", 4096)   = 0
close(7)= 0
mmap2(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0xb70c7000
close(6)= 0
close(5)= 0
close(4)= 0
ugetrlimit(RLIMIT_NOFILE, {rlim_cur=1024, rlim_max=64*1024}) = 0
close(3)= 0
pipe2([3, 4], O_CLOEXEC)= 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
fcntl64(3, F_GETFL) = 0 (flags O_RDONLY)
pipe2([5, 6], O_CLOEXEC)= 0
clone(child_stack=0, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, 
child_tidptr=0xb7539768) = 2238
close(6)= 0
close(4)= 0
brk(0xa30e000)  = 0xa30e000
read(5, "", 5)  = 0
brk(0xa302000)  = 0xa302000
close(5)= 0
fstat64(3, {st_mode=S_IFIFO|0600, st_size=0, ...}) = 0
_llseek(3, 0, 0xbf8a0600, SEEK_CUR) = -1 ESPIPE (Illegal seek)
read(3, "root\n", 6)= 5
read(3, 0xb710db19, 1)  = ? ERESTARTSYS (To be restarted if 
SA_RESTART is set)
--- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=2238, si_uid=1000, 
si_status=0, si_utime=4, si_stime=1} ---
read(3,
d(3, ^Cstrace: Process 2237 detached
 
janusz@nc6120:~$ Traceback (most recent call last):
  File "test.py", line 6, in 
buf = subprocess32.check_output(cmd, stderr=subprocess32.STDOUT)
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 628, in 
check_output
output, unused_err = process.communicate(timeout=timeout)
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 915, in 
communicate
stdout = _eintr_retry_call(self.stdout.read)
  File "/usr/lib/python2.7/dist-packages/subprocess32.py", line 543, in 
_eintr_retry_call
return func(*args)
KeyboardInterrupt

When hang:
janusz@nc6120:~$ ls -l "/proc/$(pgrep python)/fd/3"
lr-x-- 1 janusz janusz 64 paź  7 10:25 /proc/2336/fd/3 -> pipe:[29858]
janusz@nc6120:~$ lsof |grep 29858
lsof: WARNING: can't stat() fuse.gvfsd-fuse file system /run/user/108/gvfs
  Output information may be incomplete.
python2336janusz3r FIFO   0,10  0t0  
29858 pipe
ssh   2342janusz2w FIFO   0,10  0t0  
29858 pipe
janusz@nc6120:~$

--

___
Python tracker