[issue28647] python --help: -u is misdocumented as binary mode

2017-01-06 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +berker.peksag
stage:  -> patch review
type:  -> behavior
versions: +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 hardest problem in computer science...

2017-01-06 Thread Steve D'Aprano
On Sat, 7 Jan 2017 12:03 am, Steve D'Aprano wrote:

> The second hardest problem in computer science is cache invalidation.
> 
> The *hardest* problem is naming things.

Thanks everyone who answered, but I think some of you misunderstood my
question. I know that the individual characters themselves are called some
variation of "line drawing characters", or "box drawing characters". But
the important part of the question was given by the Python code:

> XXX = namedtuple("XXX", "vline tee corner")
> 
> default_YYY = XXX("│  ", "├─ ", "└─ ")
> bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
> ascii_YYY = XXX("|  ", "|- ", "+- ")
> 
> def draw_tree(tree, YYY=default_YYY):
> ...
> 
> 
> but what do I call XXX and YYY?

After puzzling over this for three days, it suddenly hit me:

Theme = namedtuple("Theme", "vline tee corner")

DEFAULT = Theme("│  ", "├─ ", "└─ ")
BOLD = Theme("┃  ", "┣━ ", "┗━ ")
ASCII = Theme("|  ", "|- ", "+- ")
 
def draw_tree(tree, theme=DEFAULT):
...



Ethan's idea of "style" is also good.


Thanks for all your ideas!



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


[issue29145] failing overflow checks in replace_*

2017-01-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The code in PyUnicode_Join() checks on overflow after making an addition.

sz += PyUnicode_GET_LENGTH(item);
item_maxchar = PyUnicode_MAX_CHAR_VALUE(item);
maxchar = Py_MAX(maxchar, item_maxchar);
if (i != 0)
sz += seplen;
if (sz < old_sz || sz > PY_SSIZE_T_MAX) {
PyErr_SetString(PyExc_OverflowError,
"join() result is too long for a Python string");
goto onError;
}

Maybe there are other cases.

--

___
Python tracker 

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



[issue29186] TimeoutError isn't being raised?

2017-01-06 Thread Xiang Zhang

Changes by Xiang Zhang :


--
stage:  -> resolved

___
Python tracker 

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



[issue29187] Pickle failure is raising AttributeError and not PicklingError

2017-01-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Python implementation of pickle still raises PicklingError. Seems this was not 
intentional change.

>>> pickle._dumps(func()())
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 918, in save_global
obj2, parent = _getattribute(module, name)
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 266, in _getattribute
.format(name, obj))
AttributeError: Can't get local attribute 'func..C' on 

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 1, in 
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 1544, in _dumps
_Pickler(f, protocol, fix_imports=fix_imports).dump(obj)
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 409, in dump
self.save(obj)
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 521, in save
self.save_reduce(obj=obj, *rv)
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 605, in save_reduce
save(cls)
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 476, in save
f(self, obj) # Call unbound method with explicit self
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 978, in save_type
return self.save_global(obj)
  File "/home/serhiy/py/cpython/Lib/pickle.py", line 922, in save_global
(obj, module_name, name))
_pickle.PicklingError: Can't pickle .C'>: it's 
not found as __main__.func..C

--
components: +Extension Modules -Library (Lib)
nosy: +alexandre.vassalotti, serhiy.storchaka
stage:  -> patch review
type:  -> behavior
versions: +Python 3.7 -Python 3.4

___
Python tracker 

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



Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Rustom Mody
On Saturday, January 7, 2017 at 12:26:04 PM UTC+5:30, Jussi Piitulainen wrote:
> Paul Rubin writes:
> 
> > Peter Otten writes:
> >> How would you implement stopmin()?
> >
> > Use itertools.takewhile
> 
> How? It consumes the crucial stop element:
> 
>it = iter('what?')
>list(takewhile(str.isalpha, it)) # ==> ['w', 'h', 'a', 't']
>next(it, 42) # ==> 42

I was also wondering how…
In a lazy language (eg haskell) with non-strict foldr (reduce but rightwards)
supplied non-strict operator this is trivial.
ie in python idiom with reduce being right_reduce
reduce(operator.mul, [1,2,0,4,...], 1)
the reduction would stop at the 0
Not sure how to simulate this in a strict language like python
Making fold(r) non-strict by using generators is ok
How to pass a non-strict operator?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29190] Avoid possible errors in comparing strings

2017-01-06 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

PyUnicode_Compare() and PyUnicode_RichCompare() can raise an exception if one 
of arguments is not ready unicode object. The result is not always checked for 
error. Proposed patch gets rid of possible bugs. PyUnicode_Compare() and 
PyUnicode_RichCompare() in Modules/_pickle.c are replaced with 
_PyUnicode_EqualToASCIIString() and _PyUnicode_EqualToASCIIId() which never 
fail. Additional check is added in Modules/_decimal/_decimal.c to ensure that 
the string which is came from a user code is ready.

All other occurrences of PyUnicode_Compare() seems are called only with ready 
unicode objects.

--
components: Extension Modules
files: unicode_compare.patch
keywords: patch
messages: 284895
nosy: serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Avoid possible errors in comparing strings
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file46184/unicode_compare.patch

___
Python tracker 

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



Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Jussi Piitulainen
Paul Rubin writes:

> Peter Otten writes:
>> How would you implement stopmin()?
>
> Use itertools.takewhile

How? It consumes the crucial stop element:

   it = iter('what?')
   list(takewhile(str.isalpha, it)) # ==> ['w', 'h', 'a', 't']
   next(it, 42) # ==> 42
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29133] Minor inaccuracy in shlex.shlex punctuation_chars example

2017-01-06 Thread Berker Peksag

Berker Peksag added the comment:

I'd probably write it without the for loop:

text = "a && b; c && d || e; f >'abc'; (def \"ghi\")"

result = shlex.shlex(text)
print(f"Old behavior: {list(result)}")

result = shlex.shlex(text, punctuation_chars=True)
print(f"New behavior: {list(result)}")

Or just:

>>> import shlex
>>> text = "a && b; c && d || e; f >'abc'; (def \"ghi\")"
>>> list(shlex.shlex(text))
['a', '&', '&', 'b', ';', 'c', '&', '&', 'd', '|', '|', 'e', ';', 'f', '>', 
"'abc'", ';', '(', 'def', '"ghi"', ')']
>>> list(shlex.shlex(text, punctuation_chars=True))
['a', '&&', 'b', ';', 'c', '&&', 'd', '||', 'e', ';', 'f', '>', "'abc'", 
';', '(', 'def', '"ghi"', ')']

(Adding Vinay to nosy list to get his feedback since he wrote the original 
example.)

--
nosy: +berker.peksag, vinay.sajip
stage:  -> patch review
type:  -> behavior

___
Python tracker 

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



[issue16026] csv.DictReader argument names documented incorrectly

2017-01-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 198edd926751 by Berker Peksag in branch '3.6':
Issue #16026: Fix parameter names of DictReader and DictWriter
https://hg.python.org/cpython/rev/198edd926751

New changeset 63c5531cfdf7 by Berker Peksag in branch 'default':
Issue #16026: Merge from 3.6
https://hg.python.org/cpython/rev/63c5531cfdf7

--
nosy: +python-dev

___
Python tracker 

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



[issue16026] csv.DictReader argument names documented incorrectly

2017-01-06 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the patches James and Greg!

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

___
Python tracker 

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



[issue29189] Broken indentation in FancyURLopener documentation

2017-01-06 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the review, Senthil.

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



RE: Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Deborah Swanson
Chris Angelico wrote, on January 06, 2017 9:14 PM
> 
> On Sat, Jan 7, 2017 at 4:07 PM, Deborah Swanson 
>  wrote:
> >
> > I really don't know how long it would've taken me to think of that,
so 
> > thank you!
> 
> I have a well-trained crystal ball :)
> 
> ChrisA

More like a very experienced eye. I keep hoping I'll get one of those,
but it takes time.

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


[issue29189] Broken indentation in FancyURLopener documentation

2017-01-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 31172ecb9e40 by Berker Peksag in branch '2.7':
Issue #29189: Fix broken indentation in FancyURLopener documentation
https://hg.python.org/cpython/rev/31172ecb9e40

--
nosy: +python-dev

___
Python tracker 

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



[issue29189] Broken indentation in FancyURLopener documentation

2017-01-06 Thread Senthil Kumaran

Senthil Kumaran added the comment:

The patch looks good to me, and can committed. Thanks!

--

___
Python tracker 

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



[issue29189] Broken indentation in FancyURLopener documentation

2017-01-06 Thread Berker Peksag

New submission from Berker Peksag:

I noticed this while taking a look at urllib docs for issue 29182. Indentation 
of prompt_user_passwd() is broken and it looks like it's part of the note 
directive: 
https://docs.python.org/2/library/urllib.html#urllib.FancyURLopener.prompt_user_passwd

Python 3 version renders fine: 
https://docs.python.org/3/library/urllib.request.html#urllib.request.FancyURLopener.prompt_user_passwd

Here is a patch.

--
assignee: docs@python
components: Documentation
files: docfix.diff
keywords: patch
messages: 284888
nosy: berker.peksag, docs@python, orsenthil
priority: normal
severity: normal
stage: patch review
status: open
title: Broken indentation in FancyURLopener documentation
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file46183/docfix.diff

___
Python tracker 

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



[issue29182] Remove the warning in urllib docs that it doesn't do certificate validate by default.

2017-01-06 Thread Berker Peksag

Changes by Berker Peksag :


--
stage: patch review -> commit review

___
Python tracker 

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



[issue28180] sys.getfilesystemencoding() should default to utf-8

2017-01-06 Thread INADA Naoki

INADA Naoki added the comment:

>> stderr is used to log errors. Getting a new error when trying to log
>> an error is kind of annoying.
>
> Hm, what bad surprise/error could appear that would not appear with 
> backslashescape?

$ cat badfilename.py 
badfn = "こんにちは".encode('euc-jp').decode('utf-8', 'surrogateescape')
print("bad filename:", badfn)

$ PYTHONIOENCODING=utf-8:backslashreplace python3 badfilename.py 
bad filename: \udca4\udcb3\udca4\udcf3\udca4ˤ\udcc1\udca4\udccf

$ PYTHONIOENCODING=utf-8:surrogateescape python3 badfilename.py 
bad filename: �ˤ���

--

___
Python tracker 

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



Re: Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Chris Angelico
On Sat, Jan 7, 2017 at 4:07 PM, Deborah Swanson
 wrote:
> And you would be precisely correct. I have a variable named 'map', and I
> intended to delete it and the code that used it, but totally forgot
> about it. It's still in there somewhere, but a simple search will find
> it.
>
> I really don't know how long it would've taken me to think of that, so
> thank you!

I have a well-trained crystal ball :)

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


[issue28180] sys.getfilesystemencoding() should default to utf-8

2017-01-06 Thread Sworddragon

Sworddragon added the comment:

> What do you mean by "make the C locale"?

I was pointing to the Platform Support Changes of PEP 538.


> I'm not sure of the name of each mode yet.
>
> After having written the "Use Cases" section and especially the
> Mojibake column of results, I consider the option of renaming the
> "UTF-8 mode" to "YOLO mode".

Assumingly YOLO is meant to be negative: Things are whirling in my mind. 
Eventually you want to save your joker :>


> Using surrogateescape means that you pass through undecodable bytes
> from inputs to stderr which can cause various kinds of bad surprises.
>
> stderr is used to log errors. Getting a new error when trying to log
> an error is kind of annoying.

Hm, what bad surprise/error could appear that would not appear with 
backslashescape?

--

___
Python tracker 

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



RE: Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Deborah Swanson
Chris Angelico wrote, on January 06, 2017 8:05 PM
> To: python-list@python.org
> Subject: Re: Namedtuples: TypeError: 'str' object is not callable
> 
> 
> On Sat, Jan 7, 2017 at 2:46 PM, Deborah Swanson 
>  wrote:
> > And here's the Traceback in PyCharm:
> >   File "E:/Coding projects/Pycharm/Moving/moving_numberedtuples.py",
> > line 139, in moving()
> > for lst in map(listings._make, csv.reader(open('E:\\Coding 
> > projects\\Pycharm\\Moving\\Moving 2017 in.csv',"r"))):
> > TypeError: 'str' object is not callable
> >
> > What str object is not callable, and how do I fix it?
> 
> Toss in a 'print' above that. You're calling map and open 
> (and csv.reader, but I doubt you've shadowed that). My money 
> would be on 'map' having been assigned something.
> 
> ChrisA

And you would be precisely correct. I have a variable named 'map', and I
intended to delete it and the code that used it, but totally forgot
about it. It's still in there somewhere, but a simple search will find
it.

I really don't know how long it would've taken me to think of that, so
thank you!

Deborah

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


[issue28961] unittest.mock._Call ignores `name` parameter

2017-01-06 Thread Berker Peksag

Berker Peksag added the comment:

IIRC 3.5.3rc1 is already tagged so the 3.5 branch is open for 3.5.4. Anything 
that needs to be in 3.5.3 should be cherry-picked by the RM at this point if 
I'm not mistaken (and note that I don't have time check, but 3.5.3 may be the 
last bugfix release of 3.5 series so you may just skip 3.5 :))

Like I already said in msg284589, the test code doesn't follow the current 
style in Lib/unittest/test/testmock/testhelpers.py and it can be simplified 
like the following patch:

 def test_call_with_name(self):
-self.assertEqual(
-'foo',
-_Call((), 'foo')[0],
-)
-self.assertEqual(
-'',
-_Call((('bar', 'barz'), ), )[0]
-)
-self.assertEqual(
-'',
-_Call((('bar', 'barz'), {'hello': 'world'}), )[0]
-)
+self.assertEqual(_Call((), 'foo')[0], 'foo')
+self.assertEqual(_Call((('bar', 'barz'),),)[0], '')
+self.assertEqual(_Call((('bar', 'barz'), {'hello': 'world'}),)[0], '')

--

___
Python tracker 

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



Re: Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Chris Angelico
On Sat, Jan 7, 2017 at 2:46 PM, Deborah Swanson
 wrote:
> And here's the Traceback in PyCharm:
>   File "E:/Coding projects/Pycharm/Moving/moving_numberedtuples.py",
> line 139, in moving()
> for lst in map(listings._make, csv.reader(open('E:\\Coding
> projects\\Pycharm\\Moving\\Moving 2017 in.csv',"r"))):
> TypeError: 'str' object is not callable
>
> What str object is not callable, and how do I fix it?

Toss in a 'print' above that. You're calling map and open (and
csv.reader, but I doubt you've shadowed that). My money would be on
'map' having been assigned something.

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


Namedtuples: TypeError: 'str' object is not callable

2017-01-06 Thread Deborah Swanson
I'm not sure what Python is complaining about here, or why.
 
Here's the example from the Python docs: 
https://docs.python.org/3/library/collections.html#collections.namedtupl
e

EmployeeRecord = namedtuple('EmployeeRecord', 'name, age, title,
department, paygrade')

import csv
for emp in map(EmployeeRecord._make, csv.reader(open("employees.csv",
"rb"))):
print(emp.name, emp.title)

And here's my code:

listings = namedtuple('listings', ['CLDesc', 'url', 'desc',
'Description',  'Location', 'STco', 'miles', 'Kind', 'Rent', 'Date',
'br', 'Notes', 
'yesno', 'mark', 'arc'])
for lst in map(listings._make, csv.reader(open('Moving 2017.csv',
"r"))):
.
.

(['x', 'y'] is a valid format for the field names, and there are no
errors when the definition for listings executes.)


And here's the Traceback in PyCharm:
  File "E:/Coding projects/Pycharm/Moving/moving_numberedtuples.py",
line 139, in moving()
for lst in map(listings._make, csv.reader(open('E:\\Coding
projects\\Pycharm\\Moving\\Moving 2017 in.csv',"r"))):
TypeError: 'str' object is not callable

What str object is not callable, and how do I fix it?  I see an
iteration variable (lst), a namedtuples method call(listings._make,
which makes a new instance of listings) and a csv.reader call, a
variable and 2 method calls, none of which are bare strings, except
possibly 'listings._make', but there's no str it might be trying to call
that I can see. My 'for' statement looks like a good copy of the example
from the docs to me, and the example in the docs uses
'EmployeeRecord._make' with no parentheses.

Is the example from the docs possibly in error? I don't see any other
possibility, but maybe I'm not looking in the right place. 

I don't know enough about classes in Python yet to know if this is ok or
not. And when I tried again with 'listings._make()', I got:

TypeError: _make() missing 1 required positional argument: 'iterable'.

This suggests that maybe 'listings._make' is wrong, but if it should be
'listings._make()', what should the iterable be? 'listings'?

'listings._make(listings)' looks awfully redundant for Python, so 
'_make(listings)' would make more sense (pun not intended), and seems to
be what the error thinks it is. But when I change it to
'_make(listings)', I get:

NameError: name '_make' is not defined

'listings._make(listings)' gets "TypeError: 'type' object is not
iterable", which answers the question of whether a namedtuple instance
(if that's what 'listings' is) is an iterable. It isn't.

There might be a version problem here. I'm using Python 3.4.3, and the
url for this page simply indicates version 3. As most of us know,
there's a lot of variance between dot versions of 3, and quite possibly
not all of the changes are documented correctly. In 3.4.3 the usage
might be slightly different, or the code broken.

Any help with this would be hugely appreciated.


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


Re: The hardest problem in computer science...

2017-01-06 Thread Larry Hudson via Python-list

On 01/06/2017 05:03 AM, Steve D'Aprano wrote:

The second hardest problem in computer science is cache invalidation.

The *hardest* problem is naming things.

In a hierarchical tree view widget that displays items like this:


Fiction
├─ Fantasy
│  ├─ Terry Pratchett
│  │  ├─ Discworld

[snip]


but what do I call XXX and YYY?


Seriously-considering-just-hard-coding-them-as-magic-constants-ly y'rs,


I don't know if this is helpful or even relevant, but here is a class for using these 
box-drawing characters that I wrote for my own use.  (I'm just a hobby programmer...)
It's not very elegant and not particularly convenient to use, but it is usable.  And I hesitate 
to post it because it is so long (approx 90 line docstring to explain its use, and ending with 
some test code).  In any case, here it is...



#   boxch.py

"""
BoxChr class to handle box-drawing characters.

The character is selected by a two-character string:
'tl', 'tm', 'tr' -- Top Left, Top Mid, Top Right:  ┌ ┬ ┐
'ml', 'mm', 'mr' -- Mid Left, Mid Mid, Mid Right:  ├ ┼ ┤
'bl', 'bm', 'br' -- Bot Left, Bot Mid, Bot Right:  └ ┴ ┘
'hz', 'vt'   -- Horizontal and Vertical lines: ─ │
Case is ignored.  Invalid selection string returns a dot:  '·'
NOTE:  It is currently disabled, but the code is still
available to handle small and large dots with 'dt' and 'dd'.
These both ignore the style.

The style is selected by a two-character string:
The characters are 's', 'd' and 'b' for single, double and bold.
The first character defines the horizontal components,
the second defines the vertical components.
The valid styles are 'ss', 'sd', 'sb', 'ds', 'dd', 'bs', 'bb'.
The potential styles 'db' and 'bd' are invalid.
The class defaults to 'ss' -- single horizontal, single vertical.
Case is ignored.  Invalid style string raises ValueError.

NOTE:  The following examples assume bc has been set to a BoxChr class.
bc = BoxChr()   #   Style defaults to 'ss'
  or
bc = BoxChr('sd')   #   Style set to single/double, or whatever desired.
(Examples assume 'ss' style.)

Attributes:
style:  set or return the style-code string.
Case is ignored.  Invalid style raises ValueError.
Examples:  bc.style = 'ds' -- sets style to double/single.
st = bc.style -- sets variable st to current style code.

Methods:
[] (__getitem__):  Returns selected box character.
Case is ignored.  Invalid selector returns a dot:  '·'
Example:  bc['tm'] returns '┬'

bxstr():   Returns a string created from a sequence of box character codes
and 'normal' characters.  (in this description 'selector' refers
to the two-character codes as defined above.)

Each element of the given sequence (list or tuple) must be a
string, either a series of selector codes, or a 'normal' string
(one without any box selectors).  The box character selector string
must start with 'BX' followed by the selector codes, separated by
spaces.  The 'BX' must be upper case, but the case of the selector
codes is ignored.  A space between the 'BX' prefix and the first
selector code is optional.  This selector string can only contain
selector codes.  'Normal' characters are simply given as normal
strings, interspersed with the selector strings in the given
sequence.

If the selection is only box characters, it can opionally be passed
as a single string rather than enclosing it in a list.
Example:
seq = ['BX ml hz', ' TEXT ', 'BX hz mr']
bc.bxstr(seq) returns '├─ TEXT ─┤'
Note:
If you need a string beginning with 'BX' it has to be given
as a single-character string 'B' followed by a string containing
the remaining text.  Example 'BX etc' must be given as:
['B', 'X etc'].

boxtext():  Create boxed text, returned as a single string with
embedded newlines.

Parameters:
txt The text to use
tsize   Expand tabs to specified number of spaces,  Default is 4
just'<', '^' or '>' as left/center/right justification.
Default is '<' — left-justified.
tallIf True, inserts a blank line above and below the text.
If False, no extra blank lines are used.
Default is True.

Text can be either a single string with embedded newlines (ie. a
triple-quoted string) or list of strings.  Trailing blank lines
are removed.  Center and right justification will strip whitespace
from both ends of the lines.  Left justification (the default)
only strips trailing whitespace.

Width is based on the length of the longest line, plus two 

[issue28180] sys.getfilesystemencoding() should default to utf-8

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

Sworddragon added the comment:
> (for me and maybe others that is explicitly preferred but maybe this depends 
> on each individual)

That's why the PEP 540 has options to enable to disable its UTF-8 mode(s).

> If I'm not wrong PEP 538 improves this for the output too but input handling 
> will still suffer from the overall issue while PEP 540 does also solve this 
> case.

The PEP 538 works fine if all inputs and outputs are encoded to UTF-8.
I understand that it's a deliberate choice to fail on
decoding/encoding error (to not use surrogateescape), but I can be
wrong.

> Also PEP 540 would not make the C locale and thus eventually some systems 
> potentially unsupported (but it might be an acceptable trade-off if we should 
> really go PEP 538).

What do you mean by "make the C locale"?

> Specific for PEP 540:
>
>> The POSIX locale enables the UTF-8 mode
>
> Non-strict I assume?

Yes, non strict.

I'm not sure of the name of each mode yet.

After having written the "Use Cases" section and especially the
Mojibake column of results, I consider the option of renaming the
"UTF-8 mode" to "YOLO mode".

>> UTF-8 /backslashreplace
>
> Was/is the reason to use backslashreplace for sys.stderr to guarantee that 
> the developer/user sees the error messages?

Yes.

> Might it make sense to also use surrogateescape instead of backslashescape 
> for sys.stderr in UTF-8 non-strict mode to be consistent here?

Using surrogateescape means that you pass through undecodable bytes
from inputs to stderr which can cause various kinds of bad surprises.

stderr is used to log errors. Getting a new error when trying to log
an error is kind of annoying.

Victor

--

___
Python tracker 

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



[issue29174] 'NoneType' object is not callable in subprocess.py

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

Martin Panter:
> Victor opened Issue 27068 about adding a Popen.detach() method, which such 
> code could use to opt out of the warning.

I opened the issue because you asked me to open it, but I'm not
convinced yet that the design would work. I don't understand yet who
is responsible of the pipes for example, especially pipes opened by
the Popen object itself (ex: stdout=PIPE), not passed to Popen
constructor. It's not as simple as getting a file descriptor as
file.detach() or socket.detach(), a Popen object is made of multiple
resources (pid and pipes at least).

> 2. Revert the warning, and in a future release (e.g. 3.7), add it back along 
> with a way to opt out of the warning.

For this specific issue, the ResourceWarning is correct. I don't
understand the use case of explicitly turning this warning off on this
specific example?

If your output is flooded by ResourceWarning warnings, it's easy to
configure Python to ignore them. Example, simplest option: python3
-Wignore script.py. But you are only going to hide a real issue in
your code. ResourceWarning exists to help you to reduce your resource
consumption.

--

___
Python tracker 

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



[issue28180] sys.getfilesystemencoding() should default to utf-8

2017-01-06 Thread Sworddragon

Sworddragon added the comment:

On looking into PEP 538 and PEP 540 I think PEP 540 is the way to go. It 
provides an option for a stronger encapsulation for the de-/encoding logic 
between the interpreter and the developer. Instead of caring about error 
handling the developer has now to care about mojibake handling (for me and 
maybe others that is explicitly preferred but maybe this depends on each 
individual). If I'm not wrong PEP 538 improves this for the output too but 
input handling will still suffer from the overall issue while PEP 540 does also 
solve this case. Also PEP 540 would not make the C locale and thus eventually 
some systems potentially unsupported (but it might be an acceptable trade-off 
if we should really go PEP 538).


Specific for PEP 540:

> The POSIX locale enables the UTF-8 mode

Non-strict I assume?


> UTF-8 /backslashreplace

Was/is the reason to use backslashreplace for sys.stderr to guarantee that the 
developer/user sees the error messages? Might it make sense to also use 
surrogateescape instead of backslashescape for sys.stderr in UTF-8 non-strict 
mode to be consistent here?

--

___
Python tracker 

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



[issue29174] 'NoneType' object is not callable in subprocess.py

2017-01-06 Thread Martin Panter

Martin Panter added the comment:

The ResourceWarning was added by Issue 26741.

I agree that there are legitimate reasons why pre-3.6 code may avoid calling 
Popen.wait() and equivalent. Victor opened Issue 27068 about adding a 
Popen.detach() method, which such code could use to opt out of the warning.

I don’t think there should be a special exemption for the warning at shutdown 
time. I think we should either:

1. Accept that you should never destroy a 3.6 Popen object without first 
“waiting” on its child (or zombie), or:

2. Revert the warning, and in a future release (e.g. 3.7), add it back along 
with a way to opt out of the warning.

--

___
Python tracker 

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



Re: Using sudo with pip3?

2017-01-06 Thread Cameron Simpson

On 06Jan2017 23:03, Clint Moyer  wrote:

Packages supplied by your distribution can be trusted more than packages
from PyPi. Just my two cents.
Most distros offer nearly all the useful Python modules directly from the
repo.


I would agree with this on the whole. And also that it is generally better to 
add modules to your system python via the distro's repo because that bring 
benefit to every user on the system, not just yourself.



Virtual environments are great, but if you want to add libraries to your
system interpreter I'd recommend a simple sync through your repo.


I'm directly advocating _not_ adding PyPI packages to the system interpreter.  
If nothing else, they may differ in behaviour and potentially actually break 
system behaviour.


Having your on virtualenv is good for: adding packages no provided by your 
vendor, adding packages deliberately different from those from your vendor (eg 
newer versions with specific bugfixes or extra features), having an isolated 
environment for packages (you can make more than one virtual environment).


And of course it avoids interfering with your system python install.

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


Re: The hardest problem in computer science...

2017-01-06 Thread Mario R. Osorio
On Friday, January 6, 2017 at 8:45:41 PM UTC-5, Mario R. Osorio wrote:
> On Friday, January 6, 2017 at 10:37:40 AM UTC-5, Ethan Furman wrote:
> > On 01/06/2017 05:03 AM, Steve D'Aprano wrote:
> > 
> > > what do we call the vertical and horizontal line elements? I want to make
> > > them configurable, which means the user has to be able to pass an argument
> > > that specifies them. I have names for the individual components:
> > >
> > > XXX = namedtuple("XXX", "vline tee corner")
> > >
> > > default_YYY = XXX("│  ", "├─ ", "└─ ")
> > > bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
> > > ascii_YYY = XXX("|  ", "|- ", "+- ")
> > >
> > > def draw_tree(tree, YYY=default_YYY):
> > >  ...
> > >
> > > but what do I call XXX and YYY?
> > 
> > Looks like horizontal, vertical, and corner are as groups -- so I would 
> > call YYY "style" and XXX "default", "bold", and "ascii".
> > 
> > --
> > ~Ethan~
> 
> back in the days of CPM this group was referred to as "box characters", and 
> each of them were called as follows:
> 
> "│": vertical_line, v_line
> 
> "├─": left_intersection, l_intersection, left_tee, l_tee
> 
> "└─": bottom_left_corner, bl_corner
> 
> [...and son on...]
> 
> (the names also apply to the combination of lower ascii characters)



NOW ... in particular this case I'd call them:

"│": vertical_line, v_line
 
"├─": node
 
"└─": last_node, l_node

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


Re: The hardest problem in computer science...

2017-01-06 Thread Mario R. Osorio
On Friday, January 6, 2017 at 10:37:40 AM UTC-5, Ethan Furman wrote:
> On 01/06/2017 05:03 AM, Steve D'Aprano wrote:
> 
> > what do we call the vertical and horizontal line elements? I want to make
> > them configurable, which means the user has to be able to pass an argument
> > that specifies them. I have names for the individual components:
> >
> > XXX = namedtuple("XXX", "vline tee corner")
> >
> > default_YYY = XXX("│  ", "├─ ", "└─ ")
> > bold_YYY = XXX("┃  ", "┣━ ", "┗━ ")
> > ascii_YYY = XXX("|  ", "|- ", "+- ")
> >
> > def draw_tree(tree, YYY=default_YYY):
> >  ...
> >
> > but what do I call XXX and YYY?
> 
> Looks like horizontal, vertical, and corner are as groups -- so I would call 
> YYY "style" and XXX "default", "bold", and "ascii".
> 
> --
> ~Ethan~

back in the days of CPM this group was referred to as "box characters", and 
each of them were called as follows:

"│": vertical_line, v_line

"├─": left_intersection, l_intersection, left_tee, l_tee

"└─": bottom_left_corner, bl_corner

[...and son on...]

(the names also apply to the combination of lower ascii characters)


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


[issue29188] Backport random.c from Python 3.5 to Python 2.7

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

> I think it is far too late to be making these kind of changes to 2.7.

I would prefer to use the "same code" (or almost) on all maintained versions of 
Python: 2.7, 3.5, 3.6 and 3.7. It should ease the maintenance for bugfixes and 
enhancements.

It seems like we want to backport security enhancements from Python 3 to Python 
2.7: see the PEP 466. Copying random.c from Python 3 would add support for 
getrandom() which is nice to have since it avoids a private file descriptor 
(which causes many issues, even if the most important issues are already worked 
around in Python 2.7 using fstat()).

The minimum required change on Python 2.7 is to not use getentropy() on Linux 
to support the glibc 2.24: see attached getentropy_linux.patch if you don't 
want the backport.

--
keywords: +patch
Added file: http://bugs.python.org/file46182/getentropy_linux.patch

___
Python tracker 

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



Re: Search a sequence for its minimum and stop as soon as the lowest possible value is found

2017-01-06 Thread Paul Rubin
Peter Otten <__pete...@web.de> writes:
> How would you implement stopmin()?

Use itertools.takewhile
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27632] build on AIX fails when builddir != srcdir, more than bad path to ld_so_aix

2017-01-06 Thread Martin Panter

Martin Panter added the comment:

Regarding reopening Issue 10656, whatever you think is more appropriate. You 
just have to judge whether it is the same use case, the same code affected, etc.

Issue 16189 and Issue 25825 were about updating to match recent changes to 
directory names, and I thought we decided the changes were not applicable to 
2.7.

Regarding LDSHARED vs BLDSHARED, isn’t this the same as Issue 28311, which lead 
to Issue 18235? If you can try the patch I mentioned at 
, I suspect it may help. Let me 
know if you need help adapting the patch for 2.7.

--
nosy: +martin.panter

___
Python tracker 

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



[issue29179] Py_UNUSED is not documented

2017-01-06 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: docs@python -> larry
nosy: +larry

___
Python tracker 

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



[issue29188] Backport random.c from Python 3.5 to Python 2.7

2017-01-06 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I think it is far too late to be making these kind of changes to 2.7.

--
nosy: +rhettinger

___
Python tracker 

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



[issue29023] Results of random.seed() call with integer argument should be claimed deterministic.

2017-01-06 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue29023] Results of random.seed() call with integer argument should be claimed deterministic.

2017-01-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7d6ebd206cd6 by Raymond Hettinger in branch '2.7':
Issue #29023:  Clarify that ints and longs are always deterministic seeds for 
random.
https://hg.python.org/cpython/rev/7d6ebd206cd6

--
nosy: +python-dev

___
Python tracker 

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



[issue29186] TimeoutError isn't being raised?

2017-01-06 Thread YoSTEALTH

Changes by YoSTEALTH :


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

___
Python tracker 

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



Re: Using sudo with pip3?

2017-01-06 Thread Clint Moyer
>From Ubuntu, why not try:

sudo apt-get install python-matplotlib

-Clint

On Fri, Jan 6, 2017 at 3:09 PM jim  wrote:

> Setting up a new computer to run Ubuntu 16.04. Started using pip3 to
>
> install all the python stuff I had on the old machine and got this message:
>
>
>
> jfb@jims-1604:~$ sudo pip3 install matplotlib
>
> [sudo] password for jfb:
>
> The directory '/home/jfb/.cache/pip/http' or its parent directory is not
>
> owned by the current user and the cache has been disabled. Please check
>
> the permissions and owner of that directory. If executing pip with sudo,
>
> you may want sudo's -H flag.
>
>
>
> I (jfb) own the directory in question.
>
>
>
> I used sudo because I recall needing to use it on the old machine to get
>
> something to install. So is it necessary or even desirable to use sudo
>
> with pip3?
>
>
>
> Thanks,  Jim
>
>
>
> --
>
> https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29157] random.c: Prefer getrandom() over getentropy() to support glibc 2.24 on Linux

2017-01-06 Thread STINNER Victor

Changes by STINNER Victor :


--
title: random.c: Prefer getrandom() over getentropy(), handle ENOSYS in 
py_getentropy() -> random.c: Prefer getrandom() over getentropy() to support 
glibc 2.24 on Linux

___
Python tracker 

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



[issue29188] Backport random.c from Python 3.5 to Python 2.7

2017-01-06 Thread STINNER Victor

New submission from STINNER Victor:

Python 3.6 uses the new getrandom() function/syscall on Linux and Solaris to 
get random bytes with no file descriptor: it prevents EMFILE and ENFILE errors 
or surprises when opening a first file (and looking at its file descriptor).

I propose to copy and adapt Python/random.c from Python 3.5 when Python 3.5 
will be updated for the issue #29157. Python 2.7 requires extra changes:

* configure.ac: need to check linux/random.h in AC_CHECK_HEADERS()
* random.c: need to keep vms_urandom() function (Python 2.7 still supports VMS!)
* Python 2.7 doesn't implement the PEP 475 (EINTR) and so don't have functions 
like _Py_read() which handles EINTR for us.

See also the issue #29157 for the latest change in random.c: prefer getrandom() 
over getentropy() to support the glibc 2.24.

--
messages: 284876
nosy: haypo
priority: normal
severity: normal
status: open
title: Backport random.c from Python 3.5 to Python 2.7
type: security
versions: Python 2.7

___
Python tracker 

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



[issue19977] Use "surrogateescape" error handler for sys.stdin and sys.stdout on UNIX for the C locale

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

> But maybe I'm just missing something.

This issue fixed exactly one use case: "List a directory into stdout" (similar 
to the UNIX "ls" or Windows "dir" commands):
https://www.python.org/dev/peps/pep-0540/#list-a-directory-into-stdout

Your use case is more "Display Unicode characters into stdout":
https://www.python.org/dev/peps/pep-0540/#display-unicode-characters-into-stdout

This use case is not supported by the issue. It should be fixed by PEP 538 or 
PEP 540.

Please join the happy discussion on the python-ideas mailing list to discuss 
how to "force UTF-8": this issue is closed, you shouldn't add new comments 
(other people will not see your comments).

--

___
Python tracker 

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



[issue29030] argparse: choices override metavar

2017-01-06 Thread paul j3

paul j3 added the comment:

subparsers is an example of choices displaying as the metavar.  From the 
documentation example:

usage: PROG [-h] [--foo] {a,b} ...

positional arguments:
  {a,b}   sub-command help

-

To the main parser, the 'subparser' is a positional argument, with an optional 
'dest' parameter (default is SUPPRESS), and {a,b} are the choices derived from 
the define subparser names.

The 'title' and 'description' parameters are used to create an Argument_group.

So any attempt to change how the metavar is created from choices has the 
potential of changing the subparser display.

That does suggest another formatting option - put your positional argument 
(with choices) in a custom Argument_Group.

In [658]: p=argparse.ArgumentParser()
In [659]: g=p.add_argument_group(title='lengths')
In [660]: g.add_argument('length',choices=[1,2,3]);
In [661]: p.print_help()
usage: ipython3 [-h] {1,2,3}

optional arguments:
  -h, --help  show this help message and exit

lengths:
  {1,2,3}

--

___
Python tracker 

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



[issue19977] Use "surrogateescape" error handler for sys.stdin and sys.stdout on UNIX for the C locale

2017-01-06 Thread Sworddragon

Sworddragon added the comment:

The point is this ticket claims to be using the surrogateescape error handler 
for sys.stdout and sys.stdin for the C locale. I have never used 
surrogateescape explicitly before and thus have no experience for it and 
consulting the documentation mentions throwing an exception only for the strict 
error handler. I don't see anything that would make me think that 
surrogateescape would throw here an exception too. But maybe I'm just missing 
something.

--

___
Python tracker 

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



[issue29157] random.c: Prefer getrandom() over getentropy(), handle ENOSYS in py_getentropy()

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

random-py35.patch: Patch for the 3.5 branch. My prepared commit message:
---
Issue #29157: Prefer getrandom() over getentropy()

Copy and then adapt Python/random.c from default branch. Difference between 3.5
and default branches:

* Python 3.5 only uses getrandom() in non-blocking mode: flags=GRND_NONBLOCK
* If getrandom() fails with EAGAIN: py_getrandom() immediately fails and
  remembers that getrandom() doesn't work.
* Python 3.5 has no _PyOS_URandomNonblock() function: _PyOS_URandom()
  works in non-blocking mode on Python 3.5
---

It seems like Python 3.5 is close to a release, I prefer to wait after the 
release to fix this issue. I don't think that many Linux distributions are 
affected, since the issue only occurs with glibc 2.24 which is very recent.

@Larry: Do you want this change in Python 3.5.3? The change is quite large.

--
nosy: +larry
Added file: http://bugs.python.org/file46181/random-py35.patch

___
Python tracker 

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



crosstab output

2017-01-06 Thread Val Krem via Python-list
Hi all,

How do I access the rows and columns of a data frame crosstab output?


Here is code using  a sample data and output.

a= pd.read_csv("cross.dat", skipinitialspace=True)
xc=pd.crosstab(a['nam'],a['x1'],margins=True)

print(xc)

x10  1 
nam 
A13  2 
A21  4

I want to create a variable  by adding 2/(3+2) for the first row(A1)
and 4/(1+4) for the second row (A2)

Final data frame would be
A1 3 2  0.4
A2 1 4  0.8

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


Re: Pexpect

2017-01-06 Thread Cameron Simpson

On 06Jan2017 11:37, Joaquin Alzola  wrote:

Iranna Mathapati  asked:

How to match latter(caps and small) ,numbers and # symbol in python pexpect.


With a .*


Ugh. Please not. Expect() accepts a nongreedy regular expression. ".*" is the 
lazy "match absolutely anything" pattern. Generally overused and imprecise.  
Iranna Mathapati knows what to look for.


See the documentation for the re module, specificly the regular expression 
syntax:


 https://docs.python.org/3/library/re.html#regular-expression-syntax

To match letters, digits and "#", try:

 [0-9a-zA-Z#]*

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


Re: Using sudo with pip3?

2017-01-06 Thread Clint Moyer
Packages supplied by your distribution can be trusted more than packages
from PyPi. Just my two cents.

Most distros offer nearly all the useful Python modules directly from the
repo.

Virtual environments are great, but if you want to add libraries to your
system interpreter I'd recommend a simple sync through your repo.

- Clint

On Fri, Jan 6, 2017 at 3:38 PM  wrote:

> On 06Jan2017 15:44, jim  wrote:
>
> >Setting up a new computer to run Ubuntu 16.04. Started using pip3 to
>
> >install all the python stuff I had on the old machine and got this
>
> >message:
>
> >
>
> >jfb@jims-1604:~$ sudo pip3 install matplotlib
>
> >[sudo] password for jfb:
>
> >The directory '/home/jfb/.cache/pip/http' or its parent directory is
>
> >not owned by the current user and the cache has been disabled. Please
>
> >check the permissions and owner of that directory. If executing pip
>
> >with sudo, you may want sudo's -H flag.
>
> >
>
> >I (jfb) own the directory in question.
>
> >
>
> >I used sudo because I recall needing to use it on the old machine to
>
> >get something to install. So is it necessary or even desirable to use sudo
>
> >with pip3?
>
>
>
> I would not, unless I were specificly trying to install into the system's
>
> python3 libraries. That will inherently fight with any vendor (Unbuntu)
>
> supplied packages that come through apt-get.
>
>
>
> Instead I would make myself a virtualenv _based off the system python3_
> and use
>
> the venv's pip to install extra packages. Not using sudo. They will land in
>
> your virtualenv directory's lib area, be entirely owned and controlled by
> you,
>
> and not have any complications that come with sudo.
>
>
>
> Then just symlink the virtualenv's "python3" into your own $HOME/bin and
>
> whenever you invoke "python3" it will run the virtualenv one, getting all
> the
>
> package goodness you have added.
>
>
>
> An important sysadmin rule of thumb: use apt (or yum etc, depending on
> distro)
>
> as root to install vendor supplied packages. And install your owon
> packages _as
>
> you_ in another area, _not_ in the system managed area. Virtualenv makes
> this
>
> very easy to do for Python.
>
>
>
> Cheers,
>
> Cameron Simpson 
>
> --
>
> https://mail.python.org/mailman/listinfo/python-list
>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29157] random.c: Prefer getrandom() over getentropy(), handle ENOSYS in py_getentropy()

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

Christian Heimes: "I'm doing a review now."

Follow-up on #python-dev (IRC):

 haypo: yes, I looked at the patch and did not see any obvious problem 
with it. Didn't I tell you?
 haypo: maybe I forgot :)

--

___
Python tracker 

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



[issue29157] random.c: Prefer getrandom() over getentropy(), handle ENOSYS in py_getentropy()

2017-01-06 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f8e24a0a1124 by Victor Stinner in branch '3.6':
Issue #29157: Prefer getrandom() over getentropy()
https://hg.python.org/cpython/rev/f8e24a0a1124

--

___
Python tracker 

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



RE: Receiving a lot of double messages.

2017-01-06 Thread Deborah Swanson
Grant Edwards wrote, on January 06, 2017 1:56 PM
> 
> On 2017-01-05, Antoon Pardon  wrote:
> 
> > Is there something going on with the mailinglist? Because I have 
> > receive a lot
> > of double messages. One copy is fairly normal and is part 
> of the discussion 
> > thread, the other is completely seperated. -- Antoon Pardon.
> 
> Yep, there are a _lot_ of duplicate messages showing up on 
> gmane's NNTP server.  I would guess around 50-100 of them in 
> the past day. Entire chunks of long threads comprising 20-30 
> posts seem to be duplicated in some cases.  In other cases, 
> they're just individual posts that seem to be detached from 
> their original threads.
> 
> Something is seriously broken somewhere...
> 
> -- 
> Grant Edwards   grant.b.edwardsYow! I 
> want a VEGETARIAN
>   at   BURRITO to 
> go ... with
>   gmail.comEXTRA MSG!!

162 duplicate messages, as of 2:04 PM PST today, to be precise. This
same thing happened when I was on the Exchange team at Microsoft, but
that was on a pre-release dogfood mail server, not even a beta for a
pre-release. Good thing it was only in-house Microsofties who had to
field the thousands of garbage messages when that happened.

The problem then was that they had to flush the mail queue that had
become clogged up with duplicate messages because some bit of code had
looped back on itself. 

Granted, the list mail server probably isn't an enterprise version, with
mail replicating between hundreds of servers, but as Chris mentioned, it
does take a feed from the newsgroup, and there's plenty of room for that
to break. Quite likely the fix for any mail server whose mail queue has
been corrupted is to flush it.

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


[issue29187] Pickle failure is raising AttributeError and not PicklingError

2017-01-06 Thread Matt Dodge

New submission from Matt Dodge:

When failing to pickle something (like a locally scoped class) the 
documentation indicates that a PicklingError should be raised.
Doc links:
 - 
https://docs.python.org/3/library/pickle.html?highlight=pickle#pickle-picklable
 - 
https://docs.python.org/3.5/library/pickle.html#what-can-be-pickled-and-unpickled

However, instead I'm seeing AttributeError get raised instead, starting in 
Python 3.5. In Python 3.4 PicklingErrror was raised, as expected.

To reproduce, use the following file 
def func():
class C: pass
return C
import pickle
pickle.dumps(func()())

In Python 3.4 you see:
Traceback (most recent call last):
  File "pickletest.py", line 5, in 
pickle.dumps(func()())
_pickle.PicklingError: Can't pickle .C'>: 
attribute lookup C on __main__ failed

But in 3.5/3.6 you see:
Traceback (most recent call last):
  File "pickletest.py", line 5, in 
pickle.dumps(func()())
AttributeError: Can't pickle local object 'func..C'

I don't necessarily mind that a different exception is being raised, but how 
should we be handling exceptions while pickling? Catch all exceptions? That 
doesn't feel right to me, but if we're trying to pickle data out of our control 
I'm not sure what else to do.

FYI, the UnpicklingError documentation 
(https://docs.python.org/3/library/pickle.html?highlight=pickle#pickle.UnpicklingError)
 indicates that other exceptions can possibly be raised during unpickling. I 
assume that is more related to the fact that the pickled data may not fit into 
the current class/module structure though, so I think it's unrelated.

--
components: Library (Lib)
messages: 284869
nosy: Matt.Dodge
priority: normal
severity: normal
status: open
title: Pickle failure is raising AttributeError and not PicklingError
versions: Python 3.4, Python 3.5, Python 3.6

___
Python tracker 

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



[issue29186] TimeoutError isn't being raised?

2017-01-06 Thread YoSTEALTH

New submission from YoSTEALTH:

TimeoutError isn't being raised?

My Python Version: 3.5.1 (64bit, linux)

# Document:
https://docs.python.org/3/library/exceptions.html#TimeoutError
""" exception TimeoutError
Raised when a system function timed out at the system level. Corresponds to 
errno ETIMEDOUT.
New in version 3.3: All the above OSError subclasses were added.
See also PEP 3151 - Reworking the OS and IO exception hierarchy """

# PEP: According to pep-3151
link: https://www.python.org/dev/peps/pep-3151/
""" TimeoutError : connection timed out (ETIMEDOUT); this can be re-cast as a 
generic timeout exception, replacing socket.timeout and also useful for other 
types of timeout (for example in Lock.acquire()) """


# This Does NOT Work:
def Send(conn, data):
# Set Timeout.
conn.settimeout(3.0)
try:
while data:
sent = conn.send(data)
data = data[sent:]
except TimeoutError as e:
print("TimeoutError:", e)  #
close_connection()
else:
pass  # Do Stuff...


# This Works
def Send(conn, data):
# Set Timeout.
conn.settimeout(3.0)
try:
while data:
sent = conn.send(data)
data = data[sent:]
except socket.timeout as e:
print("socket.timeout:", e)  # socket.timeout: timed out
close_connection()
else:
pass  # Do Stuff...


# This Works
def Send(conn, data):
# Set Timeout.
conn.settimeout(3.0)
try:
while data:
sent = conn.send(data)
data = data[sent:]
except OSError as e:
print('ERROR Send:', e)  # ERROR Send: timed out
close_connection()
else:
pass  # Do Stuff...


According to PEP "TimeoutError" is suppose to replace "socket.timeout" but it 
doesn't seem to work! Any ideas why?

--
messages: 284868
nosy: YoSTEALTH
priority: normal
severity: normal
status: open
title: TimeoutError isn't being raised?
type: behavior
versions: Python 3.5

___
Python tracker 

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



[issue29174] 'NoneType' object is not callable in subprocess.py

2017-01-06 Thread ita1024

ita1024 added the comment:

The point #3 was referring to the new requirement for an atexit handler in 
order to not only kill the processes but to also wait for them at interpreter 
shutdown. The sub-processes (and associated resources) in the example are 
definitely freed as the parent process is terminating.

The recommended handler is not even always desirable (spawning daemon 
processes, key agents), it increases the code verbosity, impacts performance, 
and can even cause problems as child processes cannot always be waited on 
reliably (python 2 but also child -D state and platform-specific restrictions).

I suggest to disable such warnings during interpreter shutdown.

--

___
Python tracker 

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



[issue2771] Test issue

2017-01-06 Thread Brett Cannon

Changes by Brett Cannon :


--
pull_requests: +10

___
Python tracker 

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



[issue19764] subprocess: use PROC_THREAD_ATTRIBUTE_HANDLE_LIST with STARTUPINFOEX on Windows Vista

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

I dislike adding a lpAttributeList attribute: it's too close to the exact 
implementation of Windows may change in the future. I would prefer a more high 
level API.

Since the only known use case today is to pass handles, I propose to focus on 
this use case: add a new pass_handles parameter to Popen, similar to pass_fds.

I see that your patch is able to set close_fds to True on Windows: great job! 
It would be a great achievement to finally fix this last known race condition 
of subprocess on Windows!

So thank you for working on this!


> As for pass_fds: as you noted, it has it's own share of complexities and 
> issues and I think it's best to leave it to a separate patch/issue.

pass_fds would be "nice to have", but I prefer to stick first to the native and 
well supported handles on Windows. For me, using file descriptors on Windows is 
more a "hack" to be able to write code working on Windows and UNIX, but since 
it's not natively supported on Windows, it comes with own set of issues.

IMHO it's better supported to work on handles.

--

___
Python tracker 

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



[issue19764] subprocess: use PROC_THREAD_ATTRIBUTE_HANDLE_LIST with STARTUPINFOEX on Windows Vista

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

Python already has a multiprocessing module which is able to pass handles 
(maybe also FD? I don't know) to child processes on Windows. I found some code 
in Lib/multiprocessing/reduction.py:
- duplicate()
- steal_handle()
- send_handle()

But the design doesn't really fit the subprocess module, since this design 
requires that the child process communicates with the parent process. On UNIX, 
fork()+exec() is used, so we can execute a few instructions after fork, which 
allows to pass an exception from the child to the parent. On Windows, 
CreateProcess() is used which doesn't allow directly to execute code before 
running the final child process.

The PEP 446 describes a solution using a wrapper process, so 
parent+wrapper+child, 3 processes. IMHO the best design for subprocess is 
really PROC_THREAD_ATTRIBUTE_HANDLE_LIST.

--

___
Python tracker 

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



Re: Using sudo with pip3?

2017-01-06 Thread cs

On 06Jan2017 15:44, jim  wrote:
Setting up a new computer to run Ubuntu 16.04. Started using pip3 to 
install all the python stuff I had on the old machine and got this 
message:


jfb@jims-1604:~$ sudo pip3 install matplotlib
[sudo] password for jfb:
The directory '/home/jfb/.cache/pip/http' or its parent directory is 
not owned by the current user and the cache has been disabled. Please 
check the permissions and owner of that directory. If executing pip 
with sudo, you may want sudo's -H flag.


I (jfb) own the directory in question.

I used sudo because I recall needing to use it on the old machine to 
get something to install. So is it necessary or even desirable to use sudo 
with pip3?


I would not, unless I were specificly trying to install into the system's 
python3 libraries. That will inherently fight with any vendor (Unbuntu) 
supplied packages that come through apt-get.


Instead I would make myself a virtualenv _based off the system python3_ and use 
the venv's pip to install extra packages. Not using sudo. They will land in 
your virtualenv directory's lib area, be entirely owned and controlled by you, 
and not have any complications that come with sudo.


Then just symlink the virtualenv's "python3" into your own $HOME/bin and 
whenever you invoke "python3" it will run the virtualenv one, getting all the 
package goodness you have added.


An important sysadmin rule of thumb: use apt (or yum etc, depending on distro) 
as root to install vendor supplied packages. And install your owon packages _as 
you_ in another area, _not_ in the system managed area. Virtualenv makes this 
very easy to do for Python.


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


[issue29178] Adding bytes.frombuffer(byteslike) constructor

2017-01-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> Which virtually no one follows :(

Sad. But adding bytes.frombuffer() wouldn't make it magically used. If you are 
aware of the problem, you can use the above two-liner as well as 
bytes.frombuffer(). You even can use it in the current code with older Python 
releases, unlike to bytes.frombuffer() which would need 3.7.

> Any protocol parsing code has a lot of slicing.

How much code you expect to update with bytes.frombuffer()? And why not use the 
above two-liner instead?

> > There is also a problem with returned type for subclasses (this is always
> > a problem for alternate constructors).
> Good point. How do we usually solve this in CPython?

It is deemed that returning an instance of a subclass is more preferable. 
Otherwise you could use separate function rather of a class method. But it is 
not easy. You need either pass a memoryview or bytes instance to class 
constructor, or (only for mutable arrays) create an empty instance and 
concatenate a buffer to it.

--

___
Python tracker 

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



[issue19977] Use "surrogateescape" error handler for sys.stdin and sys.stdout on UNIX for the C locale

2017-01-06 Thread STINNER Victor

STINNER Victor added the comment:

"I thought with the surrogateescape error handler now being used for sys.stdout 
this would not throw an exception but I'm getting this: (...)"

Please see the two recently proposed PEP: Nick's PEP 538 and my PEP 540, both 
propose (two different) solutions to your issue, especially for the POSIX 
locale (aka "C" locale).

--

___
Python tracker 

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



[issue29116] Make str and bytes error messages on concatenation conform with other sequences

2017-01-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

You can concatenate any object supporting the buffer protocol to bytes and 
bytearray.

Current error message for bytes looks awkward too, because it says "bytes to 
othertype" instead of "othertype to bytes".

--

___
Python tracker 

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



[issue29177] skip tests of test_logging when bind() raises PermissionError (non-root user on Android)

2017-01-06 Thread Vinay Sajip

Vinay Sajip added the comment:

> including the SysLogHandlerTest, which wasn't reported

Sorry, I appear to have lost the ability to read :-(

--

___
Python tracker 

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



[issue29125] Shell injection via TIX_LIBRARY when using tkinter.tix

2017-01-06 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Yes this prevents the injection.

The injection is possible because the patch is substituted in the string 
without any escaping. Your fix is not enough. The real path to a Tix 
installation can contain special characters: '\', '{' or '}'.

My patch first sets a path to a Tcl variable (there is no an injection, because 
special API is used instead of evaluating a generated script), and then use 
this variable in the script (unlike to Unix shell Tcl doesn't reparse the 
command after substituting variables).

--

___
Python tracker 

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



Using sudo with pip3?

2017-01-06 Thread jim
Setting up a new computer to run Ubuntu 16.04. Started using pip3 to 
install all the python stuff I had on the old machine and got this message:


jfb@jims-1604:~$ sudo pip3 install matplotlib
[sudo] password for jfb:
The directory '/home/jfb/.cache/pip/http' or its parent directory is not 
owned by the current user and the cache has been disabled. Please check 
the permissions and owner of that directory. If executing pip with sudo, 
you may want sudo's -H flag.


I (jfb) own the directory in question.

I used sudo because I recall needing to use it on the old machine to get 
something to install. So is it necessary or even desirable to use sudo 
with pip3?


Thanks,  Jim

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


Re: Receiving a lot of double messages.

2017-01-06 Thread Grant Edwards
On 2017-01-05, Antoon Pardon  wrote:

> Is there something going on with the mailinglist? Because I have receive a 
> lot 
> of double messages. One copy is fairly normal and is part of the discussion 
> thread, the other is completely seperated. -- Antoon Pardon.

Yep, there are a _lot_ of duplicate messages showing up on gmane's
NNTP server.  I would guess around 50-100 of them in the past day.
Entire chunks of long threads comprising 20-30 posts seem to be
duplicated in some cases.  In other cases, they're just individual
posts that seem to be detached from their original threads.

Something is seriously broken somewhere...

-- 
Grant Edwards   grant.b.edwardsYow! I want a VEGETARIAN
  at   BURRITO to go ... with
  gmail.comEXTRA MSG!!

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


[issue29117] dir() should include dunder attributes of the unbound method

2017-01-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I tested your last claim and it is true as far as I went.

>>> C.f.__annotations__
{'a': }
>>> C().f.__annotations__
{'a': }
>>> C.f.__code__
", line 2>
>>> C().f.__code__
", line 2>

--
nosy: +terry.reedy
stage:  -> test needed
type:  -> behavior
versions: +Python 3.6, Python 3.7 -Python 3.5

___
Python tracker 

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



[issue29116] Make str and bytes error messages on concatenation conform with other sequences

2017-01-06 Thread Terry J. Reedy

Terry J. Reedy added the comment:

By default, error message wording changes are 'enhancements' that wait for the 
next x.y.0 release unless the current wording is positively wrong'.  This is 
different from doc changes because there are tests depending on error messages. 
'Inconsistent' or 'awkward' is not the same as 'wrong'.

I do agree that the clipped "must be str, not bytes' is awkward.  What (which) 
is it that must be str?  A fleshed out and positive "can only concatenate str 
(not bytes) to str." would be clearer and educate users better.

As Serhiy said, the exact equivalent cannot be said for bytes.

>>> b'a' + bytearray(b'b')
b'ab'
>>> b'a' + memoryview(b'b')
b'ab'

However "Can only concatenate bytes, bytearray, or memoryview (not x) to 
bytes." would be good if this is in fact complete. I need to be educated on 
this ;-)  I was not sure about memoryview until I tried it.

--
nosy: +terry.reedy
type: behavior -> enhancement
versions:  -Python 3.6

___
Python tracker 

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



[issue29177] skip tests of test_logging when bind() raises PermissionError (non-root user on Android)

2017-01-06 Thread Vinay Sajip

Vinay Sajip added the comment:

I've added a patch that should handle these errors (including the 
SysLogHandlerTest, which wasn't reported, but I think the same logic applies).

To simulate failure during setup, uncomment one or more of the lines which says

# raise ValueError('dummy error raised')

--
assignee:  -> vinay.sajip
keywords: +patch
stage: needs patch -> patch review
Added file: http://bugs.python.org/file46180/issue-29177-01.diff

___
Python tracker 

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



[issue29181] skip tests that raise PermissionError in test_tarfile (non-root user on Android)

2017-01-06 Thread Xavier de Gaye

Changes by Xavier de Gaye :


--
nosy: +lars.gustaebel

___
Python tracker 

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



[issue29030] argparse: choices override metavar

2017-01-06 Thread paul j3

paul j3 added the comment:

Here's the method in HelpFormatter that creates the metavar:

def _metavar_formatter(self, action, default_metavar):
if action.metavar is not None:
result = action.metavar
elif action.choices is not None:
choice_strs = [str(choice) for choice in action.choices]
result = '{%s}' % ','.join(choice_strs)
else:
result = default_metavar

def format(tuple_size):
if isinstance(result, tuple):
return result
else:
return (result, ) * tuple_size
return format

So in order of priority it uses: 

the explicit metavar parameter
formatted choices
a default metavar (normally derived from the dest)

The MetavarTypeHelpFormatter subclass changes how that default is derived.  In 
the same spirit, you could write your own Formatter subclass that changes the 
above method, and its priority order.

In your example, the use of choices in the 'usage' like looks good to me.  I 
agree that its use in the 'help' line does not look so good.  But don't forget 
that for your end user, the positional 'dest' (or name) has no value.  Only you 
as the programmer sees and uses it.

This is one of many implementation details that could be included in the 
argparse docs.  But for some users those docs are already too complex.  The 
existing docs are not a formal module reference.

--
nosy: +paul.j3

___
Python tracker 

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



[issue28401] Don't support the PEP384 stable ABI in pydebug builds

2017-01-06 Thread Dmitry Shachnev

Dmitry Shachnev added the comment:

[Matthias Klose (doko) 2016-10-27 15:45]
> I'm not sure that you really want this, because it would make it impossible 
> to build an extension for the stable ABI for a debug build.

It looks like that is already impossible:

/usr/include/python3.5dm/object.h:65:2: error: #error Py_LIMITED_API is 
incompatible with Py_DEBUG, Py_TRACE_REFS, and Py_REF_DEBUG
 #error Py_LIMITED_API is incompatible with Py_DEBUG, Py_TRACE_REFS, and 
Py_REF_DEBUG
  ^

So in my opinion Stefano's patch makes sense.

--

___
Python tracker 

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



[issue29006] 2.7.13 _sqlite more prone to "database table is locked"

2017-01-06 Thread Larry Hastings

Larry Hastings added the comment:

FYI I'm keeping an eye on this for possible cherry-picking into 3.5.3 final, 
depending on the resolution.  Reverting 030e100f048a work for me, assuming 
that's a reasonable solution.

--

___
Python tracker 

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



[issue2771] Test issue

2017-01-06 Thread Ezio Melotti

Ezio Melotti added the comment:

test

--

___
Python tracker 

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



[issue26865] Meta-issue: support of the android platform

2017-01-06 Thread Xavier de Gaye

Xavier de Gaye added the comment:

issue #29176: /tmp does not exist on Android and is used by 
curses.window.putwin()
issue #29177: skip tests of test_logging when bind() raises PermissionError 
(non-root user on Android)
issue #29180: skip tests that raise PermissionError in test_os (non-root user 
on Android)
issue #29181: skip tests that raise PermissionError in test_tarfile (non-root 
user on Android)
issue #29184: skip tests of test_socketserver when bind() raises 
PermissionError (non-root user on Android)
issue #29185: test_distutils fails on Android API level 24

--
dependencies: +/tmp does not exist on Android and is used by 
curses.window.putwin(), skip tests of test_logging when bind() raises 
PermissionError (non-root user on Android), skip tests of test_socketserver 
when bind() raises PermissionError (non-root user on Android), skip tests that 
raise PermissionError in test_os (non-root user on Android), skip tests that 
raise PermissionError in test_tarfile (non-root user on Android), 
test_distutils fails on Android API level 24

___
Python tracker 

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



Re: Choosing a Python IDE. what is your Pythonish recommendation? I do

2017-01-06 Thread Paul Rudin
Tim Johnson  writes:

> * Antonio Caminero Garcia  [170102 20:56]:
>> Guys really thank you for your answers. Basically now I am more
>> emphasizing in learning in depth a tool and get stick to it so I
>> can get a fast workflow. Eventually I will learn Vim and its
>> python developing setup, I know people who have been programming
>> using Vim for almost 20 years and they did not need to change
>> editor (that is really awesome).
>
>  Bye the way, one thing I like about the GUI based vim is that it
>  supports tabs, where emacs does not.

M-x package-install tabbar

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


RE: Receiving a lot of double messages.

2017-01-06 Thread Deborah Swanson
Antoon Pardon wrote, on January 06, 2017 2:11 AM
>
> Is there something going on with the mailinglist? Because I
> have receive a lot of double messages. One copy is fairly
> normal and is part of the discussion thread, the other is
> completely seperated. -- Antoon Pardon.

Looks to me like the mail server got backed up or jammed and they're flushing 
the mail queue. I haven't seen anything older than Jan. 2 and just started 
seeing some current ones, so I think it's almost over with.

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


Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread H Krishnan
Thanks for your help.

>
> >
> > I am working on embedding Python in my application.
>
> You forgot to tell us the version of Python that you're embedding.
>
> I am using Python2.7.


> > I have redirected sys.stdin and sys.stdout to call methods from a Qt
> TextEdit
> > widget. Everything works fine except that the Python prompt does not
> always
> > come in a new line:
> >
>  dir()
> > ['__builtins__', '__doc__', '__name__', '__package__']>>>
> >
> > Why doesn't the prompt appear in a new line as with the default stdout?
>
> Are you using code.InteractiveConsole / code.interact?
>
> I am using code.InteractiveConsole().interact().


> If not, in what mode do you compile, Py_file_input ("exec") or
> Py_single_input ("single")? The latter executes PRINT_EXPR:
>
> >>> dis.dis(compile('1', '', 'single'))
>   1   0 LOAD_CONST   0 (1)
>   3 PRINT_EXPR
>   4 LOAD_CONST   1 (None)
>   7 RETURN_VALUE
>
> PRINT_EXPR in turn calls sys.displayhook on the value it pops from the
> stack. The default hook writes the repr of the value and a newline to
> sys.stdout, and it also references the value as "_" in the builtins
> module (2.x __builtin__).
>

I tried replacing sys.displayhook with a function that does not print newline 
but the newline still got inserted. So, I am not sure where the newline is 
coming from. In any case, I could override sys.displayhook to add a newline at 
the end and that seems to resolve my problem.


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

Thanks,
Krishnan

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do

2017-01-06 Thread Steven D'Aprano
On Wednesday 04 January 2017 12:10, Cameron Simpson wrote:

> On 03Jan2017 12:57, Steve D'Aprano  wrote:
>>I dislike the Unix-style Vim/Emacs text editors, I prefer a traditional
>>GUI-based editor. So my "IDE" is:
>>- Firefox, for doing searches and looking up documentation;
>>- an GUI programmer's editor, preferably one with a tab-based
>>  interface, such as geany or kate;
>>- a tab-based terminal.
>
> "traditional GUI-based editor"
>
> For those of us who spent a lot of our earlier time on terminals (actual
> physical terminals) we consider GUIs "new fangled".
>
> Just narking,
> Cameron Simpson 


Heh, GUI editors have been around since at least 1984, if not older, which 
makes them older than half the programmers in the world.

I'm not sure what an *un*traditional GUI-based editor would look like. Maybe 
one that used a ribbon-based interface, like MS Office? Or perhaps Leo?

http://leoeditor.com/

[My resolution for 2017: stop talking about Leo and actually download the damn 
thing and try it out.]



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

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


Re: Python for WEB-page !?

2017-01-06 Thread Michael Torrie
On 01/05/2017 04:53 PM, Victor Porton wrote:
> Ionut Predoiu wrote:
>
>> I am a beginner in programming language.
>> I want to know what version of Python I must to learn to use, beside of
>> basic language, because I want to integrate in my site 1 page in which
>> users to can made calculus based on my formulas already write behind (the
>> users will only complete some field, and after push "Calculate" button
>> will see the results in form of: table, graphic, and so on ...). Please
>> take into account that behind will be more mathematical
>> equations/formulas, so the speed I think must be take into account.
>
> Consider PyPi. I never used it, but they say, it is faster than usual
> CPython interpreter.

With respect, I don't think it's appropriate to direct a python beginner to 
PyPi.  Far better to direct him to the relevant resources (like Django) and 
focus him on the standard Python interpreter, hopefully version 3.

Besides that, there's the old expression. Premature optimization is the root of 
all evil.  Until Python is shown to be too slow for a given task, it's 
premature to think about speedups like Cython or even PyPi.

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


Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread eryk sun
On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan  wrote:
> I tried replacing sys.displayhook with a function that does not print
> newline but the newline still got inserted. So, I am not sure where the
> newline is coming from. In any case, I could override sys.displayhook to add
> a newline at the end and that seems to resolve my problem.

In Python 2 the newline is written depending on the value of 
sys.stdout.softspace. sys.displayhook initially calls Py_FlushLine, which 
resets the file's softspace to 0 via PyFile_SoftSpace and writes a newline if 
the previous value was non-zero. Next displayhook writes the repr, sets the 
softspace to 1 and calls Py_FlushLine again.

The result you're seeing could occur if your filelike object doesn't have a 
dict or a property to allow setting the "softspace" attribute, as the following 
toy example demonstrates:

import sys

class File(object):
def __init__(self, file):
self._file = file
self._sp_enabled = True
self.softspace = 0

def write(self, string):
return self._file.write(string)

def __getattribute__(self, name):
value = object.__getattribute__(self, name)
if name == 'softspace':
if not self._sp_enabled:
raise AttributeError
self._file.write('[get softspace <- %d]\n' % value)
return value

def __setattr__(self, name, value):
if name == 'softspace':
if not self._sp_enabled:
raise AttributeError
self._file.write('[set softspace -> %d]\n' % value)
object.__setattr__(self, name, value)

softspace enabled:

>>> sys.stdout = File(sys.stdout)
[set softspace -> 0]
[get softspace <- 0]
[set softspace -> 0]
>>> 42
[get softspace <- 0]
[set softspace -> 0]
42[get softspace <- 0]
[set softspace -> 1]
[get softspace <- 1]
[set softspace -> 0]

[get softspace <- 0]
[set softspace -> 0]

softspace disabled:

>>> sys.stdout._sp_enabled = False
>>> 42
42>>> 42
42>>>

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


Re: Python for WEB-page !?

2017-01-06 Thread Michael Torrie
On 01/05/2017 05:57 AM, Ionut Predoiu wrote:
> Good afternoon,
>
> I am a beginner in programming language. I want to know what version
> of Python I must to learn to use, beside of basic language, because I
> want to integrate in my site 1 page in which users to can made
> calculus based on my formulas already write behind (the users will
> only complete some field, and after push "Calculate" button will see
> the results in form of: table, graphic, and so on ...). Please take
> into account that behind will be more mathematical
> equations/formulas, so the speed I think must be take into account.

While Python can do that, using a web framework to process HTTP requests and 
generate HTML to display in the browser, I don't believe Python is the 
appropriate language for the task at hand.  Most web sites that do interactive 
formula calculations like you describe do it all in the browser using 
Javascript.  No need to have a web server do all that heavy lifting at all.  A 
simple html file would contain everything you need.

Even if you want to use Python to generate the web page and process events, 
you'll still have to master Javascript at some point to make the webpages more 
interactive.

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


Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread H Krishnan
Hello Mr.Eryk,

Thanks for the detailed explanation. After I added attribute support to my 
extension class for stdio, the problem was resolved.

Regards,
Krishnan


On Fri, Jan 6, 2017 at 9:24 AM, eryk sun  wrote:

> On Fri, Jan 6, 2017 at 1:06 AM, H Krishnan  wrote:
> > I tried replacing sys.displayhook with a function that does not print
> > newline but the newline still got inserted. So, I am not sure where the
> > newline is coming from. In any case, I could override sys.displayhook to
> add
> > a newline at the end and that seems to resolve my problem.
>
> In Python 2 the newline is written depending on the value of
> sys.stdout.softspace. sys.displayhook initially calls Py_FlushLine,
> which resets the file's softspace to 0 via PyFile_SoftSpace and writes
> a newline if the previous value was non-zero. Next displayhook writes
> the repr, sets the softspace to 1 and calls Py_FlushLine again.
>
> The result you're seeing could occur if your filelike object doesn't
> have a dict or a property to allow setting the "softspace" attribute,
> as the following toy example demonstrates:
>
> import sys
>
> class File(object):
> def __init__(self, file):
> self._file = file
> self._sp_enabled = True
> self.softspace = 0
>
> def write(self, string):
> return self._file.write(string)
>
> def __getattribute__(self, name):
> value = object.__getattribute__(self, name)
> if name == 'softspace':
> if not self._sp_enabled:
> raise AttributeError
> self._file.write('[get softspace <- %d]\n' % value)
> return value
>
> def __setattr__(self, name, value):
> if name == 'softspace':
> if not self._sp_enabled:
> raise AttributeError
> self._file.write('[set softspace -> %d]\n' % value)
> object.__setattr__(self, name, value)
>
> softspace enabled:
>
> >>> sys.stdout = File(sys.stdout)
> [set softspace -> 0]
> [get softspace <- 0]
> [set softspace -> 0]
> >>> 42
> [get softspace <- 0]
> [set softspace -> 0]
> 42[get softspace <- 0]
> [set softspace -> 1]
> [get softspace <- 1]
> [set softspace -> 0]
>
> [get softspace <- 0]
> [set softspace -> 0]
>
> softspace disabled:
>
> >>> sys.stdout._sp_enabled = False
> >>> 42
> 42>>> 42
> 42>>>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


[issue29125] Shell injection via TIX_LIBRARY when using tkinter.tix

2017-01-06 Thread Larry Hastings

Larry Hastings added the comment:

I don't understand the fix.  Does this really prevent the injection?

I would fix it this way:

if tixlib is not None and os.path.exists(tixlib):

--

___
Python tracker 

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



RE: Python for WEB-page !?

2017-01-06 Thread Deborah Swanson
Ionut Predoiu wrote, on January 05, 2017 11:07 PM
>
> Good morning,
>
> Thanks to all for feedback and advice.
> Because I am a beginner I will read more about versions of
> Python recommended by you.
>
> On the other side I am interested to know if exist some sites
> which have develop platform where can be use for free Python
> from browsers, without have it installed on PC/laptop. As
> beginner I want to practice from everywhere.

There's a website called Python Tutor where you can write Python programs and 
it will show you the structures built in memory as it executes. It's  very 
useful for seeing how recursive functions work, or any function or class you 
call. It will also work for simple programs and it has an output console you 
can print to.  (Well, it's more like a print window, but it works.) Very good 
for beginners, I used it all the time when I was first learning, and I still 
use it for recursive functions, since PyCharm doesn't step through recursion in 
a clear way.

http://pythontutor.com/


> I waiting with higher interest your feedback.
>
> Thanks to all members of community for support and advice.
> Keep in touch.
> Kind regards.
>
>
>
> On Thursday, January 5, 2017 at 2:57:23 PM UTC+2, Ionut Predoiu wrote:
> > Good afternoon,
> >
> > I am a beginner in programming language.
> > I want to know what version of Python I must to learn to
> use, beside of basic language, because I want to integrate in
> my site 1 page in which users to can made calculus based on
> my formulas already write behind (the users will only
> complete some field, and after push "Calculate" button will
> see the results in form of: table, graphic, and so on ...).
> > Please take into account that behind will be more
> mathematical equations/formulas, so the speed I think must be
> take into account.
> >
> > I waiting with higher interest your feedback.
> >
> > Thanks to all members of community for support and advice. Keep in
> > touch. Kind regards.
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Wednesday, January 4, 2017 at 1:10:04 PM UTC-8, Dietmar Schwertberger wrote:
> On 04.01.2017 07:54, Antonio Caminero Garcia wrote:
> > Unfortunately most of the time I am still using print and input functions.
I know that sucks, I did not use the pdb module, I guess that IDE debuggers 
leverage such module.
> pdb is actually quite useful. On my Windows PCs I can invoke python on
> any .py file with the -i command line switch by right clicking in the
> Explorer and selecting "Debug". Now when the script crashes, I can
> inspect variables without launching a full-scale IDE or starting the
> script from the command line. For such quick fixes I have also a context
> menu entry "Edit" for editing with Pythonwin, which is still quite OK as
> editor and has no licensing restrictions or installation requirements.
> This is a nice option when you deploy your installation to many PCs over
> the network.
I am on MacOS but interesting way of debugging, I will take the idea.
>
> For the print functions vs. debugger:
> The most useful application for a debugger like Wing is not for
> bug-fixing, but to set a break point and then interactively develop on
> the debugger console and with the IDE editor's autocompletion using
> introspection on the live objects. This is very helpful for hardware
> interfacing, network protocols or GUI programs. It really boosted my
> productivity in a way I could not believe before. This is something most
> people forget when they evaluate programming languages. It's not the
> language or syntax that counts, but the overall environment. Probably
> the only other really interactive language and environment is Forth.
>
This is exactly part of the capabilities that I am looking for. I loved you 
brought that up. When I think of an ideal IDE (besides the desirable features 
that I already mentioned previously) as a coworker who is telling me the 
values,types and ids that the objects are getting as you are setting 
breakpoints. So why not use the debugger interactively to develop applications. 
As long as one sets the breakpoints in a meaningful way so you can trace your 
code in a very productive way. Is that what you mean by interactive 
environment?

> > If it happens to be Arduino I normally use a sublime plugin called Stino
> > https://github.com/Robot-Will/Stino
> > (1337 people starred that cool number :D)
> Well, it is CodeWarrior which was quite famous at the time of the 68k Macs.
> The company was bought by Motorola and the IDE is still around for
> Freescale/NXP/Qualcomm microcontrollers like the HCS08 8 bit series.
> Around ten years ago the original CodeWarrior IDE was migrated to
> something Eclipse based.
> When I last evaluated HCS08 vs. Arduino, the HCS08 won due to the better
> debug interface and native USB support. HCS08 is still quite cool, but
> when it comes to documentation, learning curve, tools etc. the Arduinos
> win
>
>
> Regards,
>
> Dietmar

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


Receiving a lot of double messages.

2017-01-06 Thread Antoon Pardon
Is there something going on with the mailinglist? Because I have receive a lot 
of double messages. One copy is fairly normal and is part of the discussion 
thread, the other is completely seperated. -- Antoon Pardon.

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


Re: Forcing prompt to be on newline when embedding Python with

2017-01-06 Thread eryk sun
On Thu, Jan 5, 2017 at 7:09 AM, H Krishnan  wrote:
>
> I am working on embedding Python in my application.

You forgot to tell us the version of Python that you're embedding.

> I have redirected sys.stdin and sys.stdout to call methods from a Qt TextEdit
> widget. Everything works fine except that the Python prompt does not always
> come in a new line:
>
 dir()
> ['__builtins__', '__doc__', '__name__', '__package__']>>>
>
> Why doesn't the prompt appear in a new line as with the default stdout?

Are you using code.InteractiveConsole / code.interact?

If not, in what mode do you compile, Py_file_input ("exec") or Py_single_input 
("single")? The latter executes PRINT_EXPR:

>>> dis.dis(compile('1', '', 'single'))
  1   0 LOAD_CONST   0 (1)
  3 PRINT_EXPR
  4 LOAD_CONST   1 (None)
  7 RETURN_VALUE

PRINT_EXPR in turn calls sys.displayhook on the value it pops from the
stack. The default hook writes the repr of the value and a newline to 
sys.stdout, and it also references the value as "_" in the builtins module (2.x 
__builtin__).

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


Re: MySQL schema sync or diff

2017-01-06 Thread Chris Angelico
On Thu, Jan 5, 2017 at 11:02 AM, Charles Heizer  wrote:
> I have a MySQL database that is not managed (yet) and I would like to get an
output or diff against my new model file. I'm using flask-sqlalchemy.
>
> Are there any modules that would help me discover the differences so that I
can script a migration to begin using flask-migrate?

I'm not specifically aware of any such tool per se, but what you may want to 
consider is a tool for generating models from existing tables. Then you could 
diff the generated models against your hand-made ones, and build your 
migrations from that. Expect a ton of noise, though.

ChrisA

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 12:32:19 PM UTC-8, fpp wrote:
> > On Thu, Jan 5, 2017 at 12:12 PM, Chris Clark 
> > wrote:
> >> I want an IDE that I can use at work and home, linux and dare I say
> >> windows.
> >> Sublime, had to remove it from my work PC as it is not licensed.
> >> Atom, loved it until it slowed down.
> >> VIM, ok the best if you know vi inside out.
> >> Any JAVA based IDE, just slows up on work PC's due to all the
> >> background stuff that corporates insist they run.
> >> Why can not someone more clever than I fork DrPython and bring it up
> >> to date.
> >> Its is fast, looks great and just does the job ?
>
> I'm suprised no one in this rich thread has even mentioned SciTE :
> http://www.scintilla.org/
>
> Admittedly it's closer to an excellent code editor than a full-blown IDE.
> But it's very lightweight and fast, cross-platform, has superb syntax
> coloring and UTF8 handling, and is highly configurable through its
> configuration file(s) and embedded LUA scripting.
> It's also well maintained : version 1.0 came out in 1999, and the latest
> (3.7.2) is just a week old...
>
> Its IDE side consists mostly of hotkeys to run the interpreter or
> compiler for the language you're editing, with the file in the current
> tab.
> A side pane shows the output (prints, exceptions, errors etc.) of the
> running script.
> A nice touch is that it understands these error messages and makes them
> clickable, taking you to the tab/module/line where the error occurred.
> Also, it can save its current tabs (and their state) to a "session" file
> for later reloading, which is close to the idea of a "project" in most
> IDEs.
> Oh, and it had multi-selection and multi-editing before most of the new
> IDEs out there :-)
>
> Personally that's about all I need for my Python activities, but it can
> be customized much further than I have done : there are "hooks" for other
> external programs than compilers/interpreters, so you can also run a
> linter, debugger or cvs from the editor.
>
> One word of warning: unlike most newer IDEs which tend to be shiny-shiny
> and ful of bells and whistles at first sight, out of the box SciTE is
> *extremely* plain looking (you could even say drab, or ugly :-).
> It is up to you to decide how it should look and what it should do or
> not, through the configuration file.
> Fortunately the documentation is very thorough, and there are a lot of
> examples lying around to be copy/pasted (like a dark theme, LUA scripts
> etc.).
>
> Did I mention it's lightweight ? The archive is about 1.5 MB and it just
> needs unzipping, no installation. May be worth a look if you haven't
> tried it yet...
> fp

Interesting thanks for the link. There are a huge diversity when it comes to 
IDEs/editors. Now I have more than enough options.

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


Re: Python for WEB-page !?

2017-01-06 Thread Victor Porton
Ionut Predoiu wrote:

> I am a beginner in programming language.
> I want to know what version of Python I must to learn to use, beside of
> basic language, because I want to integrate in my site 1 page in which
> users to can made calculus based on my formulas already write behind (the
> users will only complete some field, and after push "Calculate" button
> will see the results in form of: table, graphic, and so on ...). Please
> take into account that behind will be more mathematical
> equations/formulas, so the speed I think must be take into account.

Consider PyPi. I never used it, but they say, it is faster than usual CPython 
interpreter.

> I waiting with higher interest your feedback.
>
> Thanks to all members of community for support and advice.
> Keep in touch.
> Kind regards.

--
Victor Porton - http://portonvictor.org

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


Re: Work between multiple processes

2017-01-06 Thread Irmen de Jong
On 4-1-2017 23:14, zxpat...@gmail.com wrote:
> Hi everyone,
>
> I ran into a case that I need to create a work process of an application
(Jython so has to call using java.exe) which will collect the data based on 
what main process indicates.
>
> (1) I tried multiprocessing package, no luck. Java.exe can't be called from
Process class?
>
> (2) I tried subprocess. subprocess.communicate function will wait for the
work process to terminate so to return.
>
>
> either (1) or (2) doesn't work out well. Please suggest.  Global system
queue?
>
> Thanks,
> Patrick.
>


Is it a requirement that the workdf process is also Jython?

If not: you could spawn a Python subprocess that hosts a Pyro4 daemon. 
Utilizing the Pyrolite java client library you can call methods in it from the 
java/jython side.  (Unfortunately it is not yet possible (due to jython 
incompatibilities) to use the full Pyro4 library on the Jython side as well). 
Not sure if it meets your set of requirements but have a look at 
http://pythonhosted.org/Pyro4/
http://pythonhosted.org/Pyro4/pyrolite.html


Irmen

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


Pexpect

2017-01-06 Thread Iranna Mathapati
Hi Team,

How to match latter(caps and small) ,numbers and # symbol in python pexpect.


Thanks,
Iranna M

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


RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
Rhodri James wrote, on January 05, 2017 3:53 AM
>
> On 05/01/17 04:52, Deborah Swanson wrote:
> > My original question was in fact whether there was a way to make
> > clickable hyperlinks in a console. I was persuaded after about 10
> > replies that the answer was no,
>
> Then you were persuaded wrong; the actual answer was "this isn't a
> meaningful question since it's based on incorrect assumptions."
> Translating that to "No" is just as much a mistake as
> translating it to
> "Yes."
>
> --
> Rhodri James *-* Kynesim Ltd

Actually, your statement "this isn't a meaningful question since it's based on 
incorrect assumptions" is false. PyCharm outputs clickable links to the 
console, but they aren't web links, they simply link to lines of code. I'd seen 
that PyCharm can make links in the console that aren't web enabled, so it 
seemed, and in fact it is, reasonable to assume that it could be done for urls. 
I just wanted to know if anyone knew how to do it.

Granted, the suggestion to use tkinter to enable the links came up much later 
than in the first 10 or so replies, and since tkinter makes clickable links 
possible, that's another reason my question wasn't based on false assumptions. 
It simply appears that the early responders to my question went off on a 
tangent of what is or is not technologically possible, and all of the 
approaches under consideration were in fact dead ends.

But clickable links turns out to be just eye candy, and the real result I 
wanted, which is opening urls in a browser from my IDE, is much more quickly 
and easily done programmatically. Although I didn't see this before I asked my 
question, and only saw it after reading quite a few replies.

Perhaps though, I should have said "I was persuaded after about 10 replies that 
that no one understood what I was asking." But that just seemed plain rude, so 
I went with "the answer was no".

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I

2017-01-06 Thread Antonio Caminero Garcia
On Thursday, January 5, 2017 at 9:51:17 AM UTC-8, ArnoB wrote:
> On 02-01-17 12:38, Antonio Caminero Garcia wrote:
> > Hello, I am having a hard time deciding what IDE or IDE-like code editor
should I use. This can be overwhelming.
> >
> > So far, I have used Vim, Sublime, Atom, Eclipse with PyDev, Pycharm,
IntelliJ with Python plugin.
> >
> > The thing with the from-the-scratch full featured IDEs (Eclipse, IntelliJ,
Pycharm) is that they look like a space craft dashboard and that unwarranted 
resources consumption and the unnecessary icons. I want my IDE to be 
minimalistic but powerful. My screen should be mostly â £made of codeâ Ø as 
usually happens in Vim, Sublime or Atom. However, Pycharm is really cool and 
python oriented.
> >
> > The problem with Vim is the learning curve, so I know the very basic stuff,
but obviously not enough for coding and I do not have time to learn it, it is a 
pity because there are awesome plugins that turns Vim into a lightweight 
powerful IDE-like. So now it is not an option but I will reconsider it in the 
future, learning little by little. Also, I am not very fan GUI guy if the task 
can be accomplished through the terminal. However, I donâ Öt understand why 
people underrate GUIs, that said I normally use shortcuts for the most frequent 
tasks and when I have to do something that is not that frequent then I do it 
with the mouse, for the latter case in vim you would need to look for that 
specific command every time.
> >
> > Sublime is my current and preferred code editor. I installed Anaconda, Git
integration and a couple of additional plugins that make sublime very powerful. 
Also, what I like about sublime compared to the full featured IDEs, besides the 
minimalism, is how you can perform code navigation back and forth so fast, I 
mean this is something that you can also do with the others but for some 
subjective reason I specifically love how sublime does it. The code completion 
in sublime I do not find it very intelligence, the SublimeCodeIntel is better 
than the one that Anaconda uses but the completions are not as verbose as in 
the IDEs.
> >
> > Now, I am thinking about giving a try to Visual Studio Code Edition (take a
look, it sounds good https://marketplace.visualstudio.com/items?itemName=donjay 
amanne.python). I need an editor for professional software development. What 
would you recommend to me?
>
> Hi Antonio,
>
> Just an extra one in case you'll ever want to create
> a nice GUI, then there's also QT Creator:
> https://wiki.qt.io/QtCreator_and_PySide
>
> A very simple but powerful interface a la XCode...
>
> It integrates nicely with PySide:
> https://wiki.qt.io/QtCreator_and_PySide
>
> gr
> Arno

Thanks!

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


RE: Clickable hyperlinks

2017-01-06 Thread Deborah Swanson
Terry Reedy wrote, on January 04, 2017 10:18 PM
>
> On 1/5/2017 12:11 AM, Deborah Swanson wrote:
> > Terry Reedy wrote, on January 04, 2017 3:58 PM
>
> >> To have a string interpreted as a clickable link, you send the
string to
> >> software capable of creating a clickable link, plus the information

> >> 'this is a clickable link'*.  There are two ways to tag a string as
a
> >> link.  One is to use markup around the url in the string itself.
> >> '' and html are example.  Python provides multiple to make
this
> >> easy. The other is to tag the string with a separate argument.
> >> Python provides tkinter, which wraps tk Text widgets, which have a
> >> powerful tag system.  One can define a Link tag that will a) cause
text
> >> to be displayed, for instance, blue and underlined and b) cause
clicks on
> >> the text to generate a web request.  One could then use
> >> mytext.insert('insert', 'http://www.example.com', Link) Browser
> >> must do something similar when they encounter when they encounter
> >> html link tags.
> >
> > I've actually moved on from my original question to one of opening a

> > url in a browser with python, which seems to be a much more easily
> > achieved goal.
>
> > But someone else mentioned tkinter, and I looked at it awhile ago
but
> > haven't used it for anything. That really could be the way to go if
> > you want to make clickable links, although you still need some kind
of
> > internet engine to open the url in a browser.
>
> IDLE allows a user to add help menu entries that, when clicked on,
open
> either a local file or an internet url.  For instance, adding the pair

> 'Pillow' and "https://pillow.readthedocs.io/en/latest/; in > the
Settings
> dialog adda "Pillow" to the help menu (after the standard stuff).
> Clicking on Help => Pillow opens
> "https://pillow.readthedocs.io/en/latest/; in the default browswer.
> IDLE just used the webbrowser module to do this.  No use re-inventing
> the wheel.  If instead "Pillow" were a link in text, the click handler

> should do something similar.

Yes, unless someone suggests something better, the webbrowser module looks like 
the way to go for opening urls in a browser.
>
> > You say, "There are two ways to tag a string as a link. One is to
use
> > markup around the url in the string itself. '' and html are
> > examples.  Python provides multiple ways to make this easy."
> >
> > Can you tell me where I'd begin to look for these? Are they in the
> > core language, or in packages?
>
> I was referring to using either % or .format string formatting.  Both
> are in the core and described somewhere in the Library manual.  '%'
> should be in the Symbols page of the Index and 'format' on
> the 'F' page.
>
> --
> Terry Jan Reedy

I looked up % in the Symbols page, but I didn't see any specifier related to 
urls. It would be nice if there was something like a %u for url format, but it 
isn't in there.

I also tried

print("http//python.org")
^
but got 'SyntaxError: invalid syntax', with the red arrow pointing at the first 
angle bracket. I also tried

print("http//python.org")
^
and got the same syntax error, but I'm not sure if that's how you meant html 
should be used.

I also tried to look up 'format', but there's no such entry in the Index. There 
are a lot of entries that begin with 'format', but none of them mention urls or 
anything link related. 'format_field() (string.Formatter method)' looked like a 
possibility, but again, I didn't see anything to format a link with. Maybe I 
didn't look hard enough, or didn't see something that _would_ work.

As I've said, at this point I've moved on to directly opening a url in a 
browser with the webbrowser module. All I originally wanted to do was be able 
to open a url without leaving my IDE while I was debugging data that has urls 
in it. Clickable links are really just eye candy that I don't need if I can get 
the same result programmatically. But I was curious whether there are any ways 
to tag a string as a link in a print statement. If there are, I didn't find 
any, but thanks for your suggestions!

Deborah

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


Re: Choosing a Python IDE. what is your Pythonish recommendation? I do

2017-01-06 Thread fpp
> On Thu, Jan 5, 2017 at 12:12 PM, Chris Clark 
> wrote:
>> I want an IDE that I can use at work and home, linux and dare I say
>> windows.
>> Sublime, had to remove it from my work PC as it is not licensed.
>> Atom, loved it until it slowed down.
>> VIM, ok the best if you know vi inside out.
>> Any JAVA based IDE, just slows up on work PC's due to all the
>> background stuff that corporates insist they run.
>> Why can not someone more clever than I fork DrPython and bring it up
>> to date.
>> Its is fast, looks great and just does the job ?

I'm suprised no one in this rich thread has even mentioned SciTE : 
http://www.scintilla.org/

Admittedly it's closer to an excellent code editor than a full-blown IDE. But 
it's very lightweight and fast, cross-platform, has superb syntax coloring and 
UTF8 handling, and is highly configurable through its configuration file(s) and 
embedded LUA scripting. It's also well maintained : version 1.0 came out in 
1999, and the latest (3.7.2) is just a week old...

Its IDE side consists mostly of hotkeys to run the interpreter or compiler for 
the language you're editing, with the file in the current tab.
A side pane shows the output (prints, exceptions, errors etc.) of the running 
script.
A nice touch is that it understands these error messages and makes them 
clickable, taking you to the tab/module/line where the error occurred. Also, it 
can save its current tabs (and their state) to a "session" file for later 
reloading, which is close to the idea of a "project" in most IDEs.
Oh, and it had multi-selection and multi-editing before most of the new IDEs 
out there :-)

Personally that's about all I need for my Python activities, but it can be 
customized much further than I have done : there are "hooks" for other external 
programs than compilers/interpreters, so you can also run a linter, debugger or 
cvs from the editor.

One word of warning: unlike most newer IDEs which tend to be shiny-shiny and 
ful of bells and whistles at first sight, out of the box SciTE is
*extremely* plain looking (you could even say drab, or ugly :-).
It is up to you to decide how it should look and what it should do or not, 
through the configuration file. Fortunately the documentation is very thorough, 
and there are a lot of examples lying around to be copy/pasted (like a dark 
theme, LUA scripts etc.).

Did I mention it's lightweight ? The archive is about 1.5 MB and it just needs 
unzipping, no installation. May be worth a look if you haven't tried it yet...
fp

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


Re: Python for WEB-page !?

2017-01-06 Thread Ionut Predoiu
Good morning,

Thanks to all for feedback and advice. Because I am a beginner I will read more 
about versions of Python recommended by you.

On the other side I am interested to know if exist some sites which have 
develop platform where can be use for free Python from browsers, without have 
it installed on PC/laptop. As beginner I want to practice from everywhere.

I waiting with higher interest your feedback.

Thanks to all members of community for support and advice. Keep in touch.
Kind regards.



On Thursday, January 5, 2017 at 2:57:23 PM UTC+2, Ionut Predoiu wrote:
> Good afternoon,
>
> I am a beginner in programming language.
> I want to know what version of Python I must to learn to use, beside of basic
language, because I want to integrate in my site 1 page in which users to can 
made calculus based on my formulas already write behind (the users will only 
complete some field, and after push "Calculate" button will see the results in 
form of: table, graphic, and so on ...).
> Please take into account that behind will be more mathematical
equations/formulas, so the speed I think must be take into account.
>
> I waiting with higher interest your feedback.
>
> Thanks to all members of community for support and advice.
> Keep in touch.
> Kind regards.

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


[issue29185] test_distutils fails on Android API level 24

2017-01-06 Thread Xavier de Gaye

New submission from Xavier de Gaye:

==
ERROR: test_tarfile_vs_tar 
(distutils.tests.test_archive_util.ArchiveUtilTestCase)
--
Traceback (most recent call last):
  File 
"/sdcard/org.bitbucket.pyona/lib/python3.7/distutils/tests/test_archive_util.py",
 line 170, i
n test_tarfile_vs_tar
spawn(gzip_cmd)
  File "/sdcard/org.bitbucket.pyona/lib/python3.7/distutils/spawn.py", line 36, 
in spawn
_spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/sdcard/org.bitbucket.pyona/lib/python3.7/distutils/spawn.py", line 
159, in _spawn_posix
% (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gzip' failed with exit status 1

==
FAIL: test_copy_file_hard_link (distutils.tests.test_file_util.FileUtilTestCase)
--
Traceback (most recent call last):
  File 
"/sdcard/org.bitbucket.pyona/lib/python3.7/distutils/tests/test_file_util.py", 
line 88, in te
st_copy_file_hard_link
self.assertTrue(os.path.samestat(st2, st3), (st2, st3))
AssertionError: False is not true : (os.stat_result(st_mode=33206, 
st_ino=15948, st_dev=64800, st_nl
ink=1, st_uid=2000, st_gid=2000, st_size=12, st_atime=1483691935, 
st_mtime=1483691935, st_ctime=1483
691935), os.stat_result(st_mode=33206, st_ino=15949, st_dev=64800, st_nlink=1, 
st_uid=2000, st_gid=2
000, st_size=12, st_atime=1483691935, st_mtime=1483691935, st_ctime=1483691935))

--
Ran 236 tests in 1.885s

FAILED (failures=1, errors=1, skipped=38)
test test_distutils failed

--
assignee: xdegaye
components: Tests
messages: 284850
nosy: dstufft, eric.araujo, xdegaye
priority: normal
severity: normal
stage: needs patch
status: open
title: test_distutils fails on Android API level 24
type: behavior
versions: 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



  1   2   3   >