[issue33725] High Sierra hang when using multi-processing

2018-05-31 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

A better solution is to avoid using fork mode for multiprocessing. The spawn 
and fork server modes should work fine. 

The underlying problem is that macOS system frameworks (basically anything 
higher level than libc) are not save wrt fork(2) and fixing that appears to 
have no priority at all at Apple.

--

___
Python tracker 

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



[issue33727] Server.wait_closed() doesn't always wait for its transports to fihish

2018-05-31 Thread Yury Selivanov


New submission from Yury Selivanov :

Server.wait_closed() currently does two checks:

1. if _sockets is None -- means that Server.close() was called
2. if self._waiters is None -- means that Server._wakeup() was called

if (1) *or* (2) is true, wait_closed() just returns without waiting on anything.

However, when Server.close() is called there might be still active transports 
serving requests.  Server.wait_closed() should wait until all of them are 
detached, even if Server._sockets is already reset.

So the below implementation:

async def wait_closed(self):
if self._sockets is None or self._waiters is None:
return
waiter = self._loop.create_future()
self._waiters.append(waiter)
await waiter

should be changed to:

async def wait_closed(self):
if self._waiters is None:
assert self._active_count == 0
return
waiter = self._loop.create_future()
self._waiters.append(waiter)
await waiter

--
components: asyncio
messages: 318360
nosy: asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: Server.wait_closed() doesn't always wait for its transports to fihish
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



Re: version

2018-05-31 Thread Ralf Schoenian

Hi Mike,

you can check for the major version with

import sys
sys.version_info.major


On 01.06.2018 04:44, Mike McClain wrote:

 OK so I installed python 3.2, which is the latest available as a
package in Debian Wheezy, because I've seen so many folks say it's a
waste of time to play with Py2.7.
 Immediately my python playground 'my.python.py' failed as soon as
I changes the '#!' line to python3.2.
 Most of the errors were because I had used 'print' without parens
which 2.7 liked but 3.2 doesn't.
Is there a way in a script to know which version of python is being
run so I can write:
 If (version == 2.7):
 do it this way
 elsif (version == 3.2):
 do it another way

Thanks,
Mike
--
I Don't care how little your country is, you got a right to run it like
you want to. When big nations quit meddling then the world will have peace.
 - Will Rogers


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


Re: Python library to break text into words

2018-05-31 Thread Abdur-Rahmaan Janhangeer
Dietmar's answer is the best, piggybacking on search engines' algorithms

and probably instead of a dictionary of english words, we'd need a
dictionary of titles, making search much more efficient

regards,

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ

No need to re-invent the wheel:
>
> import webbrowswer
> webbrowser.open(
> "https://www.google.com/search?q=%s"%"atomicaccidents.pdf"+"+amazon;,
> new=0)
>
> Copy the title from the browser window and paste it into your script's
> window which will read it with input() and rename the file.
>
> Regards,
>
> Dietmar
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Attachments? Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-31 Thread Paul
I gave it a different subject line.

On Fri, Jun 1, 2018 at 2:45 AM, Abdur-Rahmaan Janhangeer <
arj.pyt...@gmail.com> wrote:

> as this sig file is a common occurance, attaching the topic to the data
> blocks thread is not really necessary
>
> Abdur-Rahmaan Janhangeer
> https://github.com/Abdur-rahmaanJ
>
> On Fri, 1 Jun 2018, 01:49 Paul,  wrote:
>
>> I have heard that attachments to messages are not allowed on this list,
>> which makes sense. However I notice that messages from Peter do have an
>> attachment, i.e., a signature.asc file.
>>
>> I'm just curious; why and how do those particular attachments get through?
>> And should they get through, I guess? E.G., what if I attach a malicious
>> file labeled as .asc?
>>
>> [Peter, I am not suggesting anything about you!  ;). ]
>>
>> Paul C.
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python library to break text into words

2018-05-31 Thread Abdur-Rahmaan Janhangeer
1-> search in dict, identify all words example :

meaningsofoffers

.. identified words :

me
an
mean
in
meaning
meanings
so
of
of
offer
offers

2-> next filter duplicates, i.e. of above in a new list as the original
list serves as chronological reference

3-> next chose the words whose lengths make up the length of the string

4-> if several solutions choose non-overlapping and chronologically sound
ones

5-> unused letters are treated as words where non-natural words are
included, that can be problematic if sub words are found in it and point 7
might be the way to go

6-> in the case of non-regular words included, the program returns the best
solutions for the user to choose from

i have branded the above 6 points algorithm as the Arj.mu Algorithm of Word
Extraction in Connected Letters

7-> if machine learning is enacted, the above point (6) serves as training
(on an everyday usage app) or it can directly train on predefined examples

8-> if typos are assumed to be found titles, then the title should be
assumed to have the corrected words and a new search is done on this
assumed title. in which case the results are added to the non corrected
version and then point 6 above is executed

8.1-> for assumptions in 8, Natural Language modules might be used

9-> titles can contain numbers, dates, author names and others and as such
is not covered by the points above


Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: version

2018-05-31 Thread Jorge Gimeno
Look at the six module

On Thu, May 31, 2018, 7:57 PM Mike McClain  wrote:

> OK so I installed python 3.2, which is the latest available as a
> package in Debian Wheezy, because I've seen so many folks say it's a
> waste of time to play with Py2.7.
> Immediately my python playground 'my.python.py' failed as soon as
> I changes the '#!' line to python3.2.
> Most of the errors were because I had used 'print' without parens
> which 2.7 liked but 3.2 doesn't.
> Is there a way in a script to know which version of python is being
> run so I can write:
> If (version == 2.7):
> do it this way
> elsif (version == 3.2):
> do it another way
>
> Thanks,
> Mike
> --
> I Don't care how little your country is, you got a right to run it like
> you want to. When big nations quit meddling then the world will have peace.
> - Will Rogers
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33726] Add short descriptions to PEP references in seealso

2018-05-31 Thread Andrés Delfino

Change by Andrés Delfino :


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

___
Python tracker 

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



Re: ... (ellipsis)

2018-05-31 Thread Terry Reedy

On 5/31/2018 10:26 PM, Mike McClain wrote:

 I'm having understanding the use if the ellipsis.
I keep reading that it is used in slices


By numpy for numpy multidimensional arrays, which have their own 
__getitem__, which recognizes and gives meaning to ...


--
Terry Jan Reedy

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


[issue33726] Add short descriptions to PEP references in seealso

2018-05-31 Thread Andrés Delfino

New submission from Andrés Delfino :

There are a couple of PEP references with no description in Simple/Compound 
Statements.

Attached PR fixes this.

--
assignee: docs@python
components: Documentation
messages: 318359
nosy: adelfino, docs@python
priority: normal
severity: normal
status: open
title: Add short descriptions to PEP references in seealso
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



version

2018-05-31 Thread Mike McClain
OK so I installed python 3.2, which is the latest available as a
package in Debian Wheezy, because I've seen so many folks say it's a
waste of time to play with Py2.7.
Immediately my python playground 'my.python.py' failed as soon as
I changes the '#!' line to python3.2.
Most of the errors were because I had used 'print' without parens
which 2.7 liked but 3.2 doesn't.
Is there a way in a script to know which version of python is being
run so I can write:
If (version == 2.7):
do it this way
elsif (version == 3.2):
do it another way

Thanks,
Mike
--
I Don't care how little your country is, you got a right to run it like
you want to. When big nations quit meddling then the world will have peace.
- Will Rogers
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33610] IDLE: Make multiple improvements to CodeContext

2018-05-31 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

19. idle.rst doc change
20. What's New for 3.6.6 and 3.7.0
These could be patches on this issue.
21. idlelib/NEWS.txt entries

--

___
Python tracker 

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



Re: Attachments? Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-31 Thread Abdur-Rahmaan Janhangeer
as this sig file is a common occurance, attaching the topic to the data
blocks thread is not really necessary

Abdur-Rahmaan Janhangeer
https://github.com/Abdur-rahmaanJ

On Fri, 1 Jun 2018, 01:49 Paul,  wrote:

> I have heard that attachments to messages are not allowed on this list,
> which makes sense. However I notice that messages from Peter do have an
> attachment, i.e., a signature.asc file.
>
> I'm just curious; why and how do those particular attachments get through?
> And should they get through, I guess? E.G., what if I attach a malicious
> file labeled as .asc?
>
> [Peter, I am not suggesting anything about you!  ;). ]
>
> Paul C.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


... (ellipsis)

2018-05-31 Thread Mike McClain
I'm having understanding the use if the ellipsis.
I keep reading that it is used in slices but every time I use it I get
'Syntax error' in 2.7 if 'Type error' in 3.2.

In python2.7:
l=range(15)
l[...:11]
Syntax error
l[3:...]
Syntax error
l[3:...:11]
Syntax error

In python3.2 it becomes 'Type error'  but still doesn't give me
anything usable.

Is the ellipsis really useable in anything other than documentation or
does it actually have a function in python?
If the latter would someone please provide an example showing how it
is used?

Thanks,
Mike
--
I Don't care how little your country is, you got a right to run it like
you want to. When big nations quit meddling then the world will have peace.
- Will Rogers
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How do I list only the methods I define in a class?

2018-05-31 Thread bob gailer

On 5/31/2018 3:49 PM, bruceg113...@gmail.com wrote:
> How do I list only the methods I define in a class?
Here's a class with some method, defined in various ways:

>>> class x():
... a=3
... def f():pass
... g = lambda: None
...

>>> l=[v for v in x.__dict__.items()]; print(l)
[('a', 3), ('f', ), ('__module__', 
'__main__'), ('__dict__', ), 
('__doc__', None), ('__weakref__', objects>)]


>>> import inspect
>>> [(key, value) for key, value in l if inspect.isfunction(i[1])]
[('f', ), ('g',  
at 0x01DEDD693620>)]


HTH

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


[issue33610] IDLE: Make multiple improvements to CodeContext

2018-05-31 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

18. Error or bounds checking for maxlines entry.  I believe this really a 
config dialog issue that applies to everything, but maxlines should be at least 
1, with some reasonable max.  In the meanwhile, we could check whether crazy 
entries (text, negatives, super high) can crash IDLE.

--

___
Python tracker 

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



[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

2018-05-31 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

ISTM the only way dir(self) would make a difference would be if functions we 
being assigned to instances rather than the class.   Also, it's uncleaar why 
setattr() is at issue -- it works the same way as regular attribute assignment 
using the dot operator.

--
nosy: +rhettinger

___
Python tracker 

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



[issue33610] IDLE: Make multiple improvements to CodeContext

2018-05-31 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

5, reformulated. Now that 'Code Context' on the Options menu only toggles a 
feature for the current window, like 'Zoom Height' on the Window menu, both 
should appear together on the same menu.  My current inclination is to move 
'Code Context' to Window because a) it is the feature be that will be changed 
and discussed in What's New, and b) 'Window' otherwise lists individual windows 
so it more clearly implies that toggles are for the current window without 
adding a fake menu entry.  Agree?

--

___
Python tracker 

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



[issue33597] Compact PyGC_Head

2018-05-31 Thread INADA Naoki


INADA Naoki  added the comment:

https://github.com/python/cpython/pull/7043/commits/053111f321d792fb26f8be10abba24a980f3590f

I added one micro optimization.
Although it is not relating to two-word-gc directly, it makes gc_collect faster 
than master on the microbench (without importing tkinter.tix, because no GUI on 
my Linux environment).

$ ./python -m perf timeit --compare-to ./python-master -s "import gc, doctest, 
ftplib, asyncio, email, http.client, pydoc, pdb, fractions, decimal, difflib, 
textwrap, statistics, shutil, shelve, lzma, concurrent.futures, telnetlib, 
smtpd, trace, distutils, pkgutil, tabnanny, pickletools, dis, argparse" 
"gc.collect()"
python-master: . 1.66 ms +- 0.08 ms
python: . 1.58 ms +- 0.00 ms

Mean +- std dev: [python-master] 1.66 ms +- 0.08 ms -> [python] 1.58 ms +- 0.00 
ms: 1.05x faster (-5%)

--

___
Python tracker 

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



[issue33642] IDLE: Use variable number of lines in CodeContext

2018-05-31 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

On Windows, I observe the following behaviors.

1. When Code Context is enabled on a windows still at its initial height, 
context lines are added to code lines to increase the window height.

2. When the window height is changed with a mouse, that becomes the fixed 
height, which is partitioned between context and code lines.  In other words, 
context lines are taken from and given back to code lines.

3. When height is maximized either with ZoomHeight or WindowMaximize, the 
behavior is as with 2.  When height is un-maximized, behavior reverts to what 
it was, either 1 or 2.

What do you see on Linux?

--

___
Python tracker 

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



[issue33725] High Sierra hang when using multi-processing

2018-05-31 Thread Kapil Thangavelu


New submission from Kapil Thangavelu :

This issue seems to be reported a few times on various githubs projects. I've 
also reproduced using a brew install of python 2.7.15. I haven't been able to 
reproduce with python 3.6. Note this requires a framework build of python.

Background on the underlying issue cause due to a change in high Sierra 
http://sealiesoftware.com/blog/archive/2017/6/5/Objective-C_and_fork_in_macOS_1013.html
A ruby perspective on the same issue exhibiting for some apps
https://blog.phusion.nl/2017/10/13/why-ruby-app-servers-break-on-macos-high-sierra-and-what-can-be-done-about-it/


The work around seems to be setting an environment variable 
OBJC_DISABLE_INITIALIZE_FORK_SAFETY prior to executing python.

Other reports

https://bugs.python.org/issue30837
https://github.com/ansible/ansible/issues/32499
https://github.com/imWildCat/scylla/issues/22
https://github.com/elastic/beats-tester/pull/73
https://github.com/jhaals/ansible-vault/issues/60

--
components: macOS
messages: 318352
nosy: kapilt, ned.deily, ronaldoussoren
priority: normal
severity: normal
status: open
title: High Sierra hang when using multi-processing
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



[issue33610] IDLE: Make multiple improvements to CodeContext

2018-05-31 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The release candidate has been re-scheduled for June 11.  So we should be able 
to merge the minimal upgrade before that and get it in 3.7.0 and 3.6.6.  (The 
latter will come out at the same time as the former.)

Variable lines is about ready.  Colors looks like it should be, with a final 
test needed after variable lines is merged (or maybe I will reverse the order). 
 That leaves line alignment.  If you are working on it, but don't have a PR 
ready yet, please say so.

--
dependencies:  -IDLE: Configurable color on code context

___
Python tracker 

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



Re: Override built in types... possible? or proposal.

2018-05-31 Thread Steven D'Aprano
On Thu, 31 May 2018 09:51:30 -0700, Rob Gaddi wrote:

> On 05/31/2018 07:49 AM, Dan Strohl wrote:
>> Is it possible to override the assignment of built in types to the
>> shorthand representations?   And if not, is it a reasonable thought to
>> consider adding?
[...]

> My problem with this idea is that it breaks expectations.

No worse than shadowing builtin names.



> If I know one
> thing as a Python programmer, it's that 'Bob' is a str.

True. But if there were such a feature as Dan asked for, you would learn 
that "Bob" might be anything, depending on the current state of the 
module. That's not much worse than the idea that int("123") might return 
anything, depending on the current state of the module and builtins.

Still, I agree that this is probably a tad too much dynamism even for a 
language as dynamic as Python.


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

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


[issue33692] Chinese characters issue with input() function

2018-05-31 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +6920

___
Python tracker 

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



[issue33692] Chinese characters issue with input() function

2018-05-31 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +6920, 6921

___
Python tracker 

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



[issue33718] Enhance regrtest: meta-ticket for multiple changes

2018-05-31 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +6919

___
Python tracker 

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



[issue33718] Enhance regrtest: meta-ticket for multiple changes

2018-05-31 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 9e24930dfdc28e16dabbfd7dd1ead1336b7b0d6c by Victor Stinner in 
branch 'master':
bpo-33718: regrtest keeps filters to re-run fails (GH-7291)
https://github.com/python/cpython/commit/9e24930dfdc28e16dabbfd7dd1ead1336b7b0d6c


--

___
Python tracker 

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



[issue33615] test__xxsubinterpreters crashed on x86 Gentoo Refleaks 3.x

2018-05-31 Thread Eric Snow


Eric Snow  added the comment:

FYI, I plan on closing this issue only *after* I've re-enabled the crashing 
test and it passes. :)

--

___
Python tracker 

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



[issue33724] test__xxsubinterpreters failed on ARMv7 Ubuntu 3.x

2018-05-31 Thread Eric Snow


Eric Snow  added the comment:

Thanks, Victor.  I'll take a look.  FYI, it seems that the same 3 buildbots 
from bpo-33615 are seeing these same test failures.

--

___
Python tracker 

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



[issue33717] Enhance test.pythoninfo: meta-ticket for multiple changes

2018-05-31 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 56013218864d5eb81baab4665fcae13400934078 by Victor Stinner in 
branch 'master':
bpo-33717: pythoninfo: add CC --version (#7290)
https://github.com/python/cpython/commit/56013218864d5eb81baab4665fcae13400934078


--

___
Python tracker 

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



[issue33718] Enhance regrtest: meta-ticket for multiple changes

2018-05-31 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



Re: Python library to break text into words

2018-05-31 Thread beliavsky--- via Python-list
On Thursday, May 31, 2018 at 5:31:48 PM UTC-4, Dietmar Schwertberger wrote:
> On 5/31/2018 10:26 PM, beliavsky--- via Python-list wrote:
> > Is there a Python library that uses intelligent guesses to break sequences 
> > of characters into words? The general strategy would be to break strings 
> > into the longest words possible. The library would need to "know" a sizable 
> > subset of words in English.
> 
> No need to re-invent the wheel:
> 
> import webbrowswer
> webbrowser.open( 
> "https://www.google.com/search?q=%s"%"atomicaccidents.pdf"+"+amazon;, new=0)
> 
> 
> Copy the title from the browser window and paste it into your script's 
> window which will read it with input() and rename the file.
> 
> Regards,
> 
> Dietmar

Thanks to both of you.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33717] Enhance test.pythoninfo: meta-ticket for multiple changes

2018-05-31 Thread STINNER Victor


Change by STINNER Victor :


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

___
Python tracker 

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



[issue33615] test__xxsubinterpreters crashed on x86 Gentoo Refleaks 3.x

2018-05-31 Thread STINNER Victor


STINNER Victor  added the comment:

Now the test runs but doesn't crash anymore: bpo-33724.

--

___
Python tracker 

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



[issue33724] test__xxsubinterpreters failed on ARMv7 Ubuntu 3.x

2018-05-31 Thread STINNER Victor


New submission from STINNER Victor :

Follow-up of bpo-33615.

ARMv7 Ubuntu 3.x:

http://buildbot.python.org/all/#/builders/106/builds/1118

Re-running test 'test__xxsubinterpreters' in verbose mode
test_bad_id (test.test__xxsubinterpreters.ChannelIDTests) ... ok
test_bad_kwargs (test.test__xxsubinterpreters.ChannelIDTests) ... ok
test_coerce_id (test.test__xxsubinterpreters.ChannelIDTests) ... ok
test_default_kwargs (test.test__xxsubinterpreters.ChannelIDTests) ... ok
test_does_not_exist (test.test__xxsubinterpreters.ChannelIDTests) ... ok
test_equality (test.test__xxsubinterpreters.ChannelIDTests) ... ok
test_repr (test.test__xxsubinterpreters.ChannelIDTests) ... ok
test_str (test.test__xxsubinterpreters.ChannelIDTests) ... FAIL
test_with_kwargs (test.test__xxsubinterpreters.ChannelIDTests) ... ok
test_by_unassociated_interp (test.test__xxsubinterpreters.ChannelReleaseTests) 
... ERROR
test_close_if_unassociated (test.test__xxsubinterpreters.ChannelReleaseTests) 
... ERROR
test_multiple_times (test.test__xxsubinterpreters.ChannelReleaseTests) ... ok
test_multiple_users (test.test__xxsubinterpreters.ChannelReleaseTests) ... ERROR
test_never_used (test.test__xxsubinterpreters.ChannelReleaseTests) ... ok
test_no_kwargs (test.test__xxsubinterpreters.ChannelReleaseTests) ... ok
test_partially (test.test__xxsubinterpreters.ChannelReleaseTests) ... ok
test_single_user (test.test__xxsubinterpreters.ChannelReleaseTests) ... ok
test_used_multiple_times_by_single_user 
(test.test__xxsubinterpreters.ChannelReleaseTests) ... ok
test_with_unused_items (test.test__xxsubinterpreters.ChannelReleaseTests) ... ok
test_close_both_with_unused_items_forced 
(test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_both_with_unused_items_unforced 
(test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_by_unassociated_interp (test.test__xxsubinterpreters.ChannelTests) 
... ERROR
test_close_defaults_with_unused_items 
(test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_empty (test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_multiple_times (test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_multiple_users (test.test__xxsubinterpreters.ChannelTests) ... ERROR
test_close_never_used (test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_recv_with_unused_items_forced 
(test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_recv_with_unused_items_unforced 
(test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_send_with_unused_items_forced 
(test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_send_with_unused_items_unforced 
(test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_single_user (test.test__xxsubinterpreters.ChannelTests) ... ok
test_close_used_multiple_times_by_single_user 
(test.test__xxsubinterpreters.ChannelTests) ... ok
test_create_cid (test.test__xxsubinterpreters.ChannelTests) ... ok
test_ids_global (test.test__xxsubinterpreters.ChannelTests) ... FAIL
test_recv_empty (test.test__xxsubinterpreters.ChannelTests) ... ok
test_recv_not_found (test.test__xxsubinterpreters.ChannelTests) ... ok
test_run_string_arg_resolved (test.test__xxsubinterpreters.ChannelTests) ... 
skipped 'bpo-33615: triggering crashes so temporarily disabled'
test_run_string_arg_unresolved (test.test__xxsubinterpreters.ChannelTests) ... 
ok
test_send_not_found (test.test__xxsubinterpreters.ChannelTests) ... ok
test_send_recv_different_interpreters 
(test.test__xxsubinterpreters.ChannelTests) ... ERROR
Exception in thread Thread-9:
Traceback (most recent call last):
  File 
"/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/threading.py", 
line 917, in _bootstrap_inner
self.run()
  File 
"/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/threading.py", 
line 865, in run
self._target(*self._args, **self._kwargs)
  File 
"/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/test__xxsubinterpreters.py",
 line 1280, in f
"""))
  File 
"/ssd/buildbot/buildarea/3.x.gps-ubuntu-exynos5-armv7l/build/Lib/test/test__xxsubinterpreters.py",
 line 42, in _run_output
interpreters.run_string(interp, script, shared)
_xxsubinterpreters.RunFailedError: : channel 1103095676 not found

test_send_recv_different_interpreters_and_threads 
(test.test__xxsubinterpreters.ChannelTests) ... FAIL
test_send_recv_different_threads (test.test__xxsubinterpreters.ChannelTests) 
... ok
test_send_recv_main (test.test__xxsubinterpreters.ChannelTests) ... ok
test_send_recv_same_interpreter (test.test__xxsubinterpreters.ChannelTests) ... 
ok
test_sequential_ids (test.test__xxsubinterpreters.ChannelTests) ... ok
test_after_destroy_all (test.test__xxsubinterpreters.CreateTests) ... ok
test_after_destroy_some (test.test__xxsubinterpreters.CreateTests) ... ok
test_in_main (test.test__xxsubinterpreters.CreateTests) ... ok
test_in_subinterpreter (test.test__xxsubinterpreters.CreateTests) ... FAIL
test_in_thread (test.test__xxsubinterpreters.CreateTests) 

Attachments? Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-31 Thread Paul
I have heard that attachments to messages are not allowed on this list,
which makes sense. However I notice that messages from Peter do have an
attachment, i.e., a signature.asc file.

I'm just curious; why and how do those particular attachments get through?
And should they get through, I guess? E.G., what if I attach a malicious
file labeled as .asc?

[Peter, I am not suggesting anything about you!  ;). ]

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


Re: Python library to break text into words

2018-05-31 Thread Chris Angelico
On Fri, Jun 1, 2018 at 7:09 AM, Dietmar Schwertberger
 wrote:
> On 5/31/2018 10:26 PM, beliavsky--- via Python-list wrote:
>>
>> Is there a Python library that uses intelligent guesses to break sequences
>> of characters into words? The general strategy would be to break strings
>> into the longest words possible. The library would need to "know" a sizable
>> subset of words in English.
>
>
> No need to re-invent the wheel:
>
> import webbrowswer
> webbrowser.open(
> "https://www.google.com/search?q=%s"%"atomicaccidents.pdf"+"+amazon;, new=0)
>
>
> Copy the title from the browser window and paste it into your script's
> window which will read it with input() and rename the file.

10/10 for grin-worthy solutions :)

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


[issue33723] test_time.test_thread_time() failed on AMD64 Debian root 3.x

2018-05-31 Thread STINNER Victor


New submission from STINNER Victor :

AMD64 Debian root 3.x:

http://buildbot.python.org/all/#/builders/27/builds/1067

==
FAIL: test_thread_time (test.test_time.TimeTestCase)
--
Traceback (most recent call last):
  File "/root/buildarea/3.x.angelico-debian-amd64/build/Lib/test/test_time.py", 
line 536, in test_thread_time
self.assertGreaterEqual(stop - start, 0.020)  # machine busy?
AssertionError: 0.01994311399984 not greater than or equal to 0.02

--
components: Tests
messages: 318344
nosy: pitrou, vstinner
priority: normal
severity: normal
status: open
title: test_time.test_thread_time() failed on AMD64 Debian root 3.x
versions: Python 3.8

___
Python tracker 

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



Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-31 Thread Chris Angelico
On Fri, Jun 1, 2018 at 7:05 AM, Peter J. Holzer  wrote:
> [Strange: I didn't get this mail through the list, only directly]
>
> On 2018-05-31 14:39:17 +, Dan Strohl wrote:
>> The outdent method could look like:
>>
>> string.outdent(size=None)
>> """
>> :param size : The number of spaces to remove from the beginning of
>> each line in the string.  Non space characters will not be
>> removed.  IF this is None, the number of characters in the first
>> line of the string will be used.
>
> The default should be the minimum number of leading spaces on non-empty
> lines, I think. This is compatible with PEP 257. And in fact it allows
> all lines to start with whitespace if the string ends with a newline
> (which is a weird dependency, but probably not much of a restriction in
> practice).

Exactly. The default will be the most commonly used option when
working with string literals; explicitly setting it is there if you
need it, but won't be the normal way you do things.

Either way, if attached to a string literal, with either no parameter
or a literal integer, this would be a valid candidate for constant
folding. (There's no way to monkeypatch or shadow anything.) At that
point, we would have all the benefits of a new string literal type,
with no syntactic changes, just the creation of the method.

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


Re: Sorting and spaces.

2018-05-31 Thread Chris Angelico
On Fri, Jun 1, 2018 at 6:51 AM, Paul  wrote:
> In the US, at least, spaces should sort before letters.
>
> MRAB brought up an important point. It depends on your purpose, of course,
> but having all the capitalized-beginning items appear separately from all
> of the lower-cased-beginning items can be very annoying to a user.

And that's why locale-based sorting exists. You can't set a single
definition of sorting and expect it to work for everyone. In fact,
even within a language, there can be different sorting rules for
different types of data (a list of names might be sorted one way, but
a list of book titles differently). Peter's recommendation covers most
of that, modulo the types-of-data complexity; you should be able to
sort German text according to German rules, and Dutch text according
to Dutch rules.

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


Re: Python library to break text into words

2018-05-31 Thread Dietmar Schwertberger

On 5/31/2018 10:26 PM, beliavsky--- via Python-list wrote:

Is there a Python library that uses intelligent guesses to break sequences of characters 
into words? The general strategy would be to break strings into the longest words 
possible. The library would need to "know" a sizable subset of words in English.


No need to re-invent the wheel:

import webbrowswer
webbrowser.open( 
"https://www.google.com/search?q=%s"%"atomicaccidents.pdf"+"+amazon;, new=0)



Copy the title from the browser window and paste it into your script's 
window which will read it with input() and rename the file.


Regards,

Dietmar


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


Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-31 Thread Peter J. Holzer
On 2018-05-31 23:05:35 +0200, Peter J. Holzer wrote:
> [Strange: I didn't get this mail through the list, only directly]

Found it. For some reason "Avoid duplicate copies of messages" was
enabled. I normally always disable this when I subscribe to a
mailinglist and I'm surprised that I haven't noticed it before.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Indented multi-line strings

2018-05-31 Thread Peter J. Holzer
On 2018-05-31 16:44:10 +0100, MRAB wrote:
> I was also thinking that it could take the indentation from the first line,
> but that if you wanted the first line to have a larger indent than the
> remaining lines, you could replace the first space that you want to keep
> with a non-whitespace character and then pass that character to the method.
> 
> For example:
> 
> Test = """\
>  _   Hello, this is a
>   Multiline indented
>  String
>  """.outdent(padding='_')
> 
> Outdent so that the first line is flush to the margin:
> 
> _   Hello, this is a
>  Multiline indented
> String
> 
> The padding argument tells it to replace the initial '_':
> 
> Hello, this is a
>  Multiline indented
> String

I would prefer to remove the padding, like this:

Test = """
|Hello, this is a
| Multiline indented
|String
""".outdent(padding='|')

Or write it like this?

Test = """|Hello, this is a
  | Multiline indented
  |String
  """.outdent(padding='|')

Hmm, the sign of Zorro! :-)

I'm starting to like outdent(), but that may be my TIMTOWTDIism
speaking.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-31 Thread Peter J. Holzer
[Strange: I didn't get this mail through the list, only directly]

On 2018-05-31 14:39:17 +, Dan Strohl wrote:
> > This is of course not a problem if the *trailing* quote determines the
> > indentation:
> > 
> > a_multi_line_string = i'''
> >Py-
> >   thon
> > '''
> 
> I get the point, but it feels like it would be a pain to use, and it
> "Feels" different from the other python indenting, which is something
> that I would want to stay away from changing.

Yes, it's the wrong way around. The indentation should be determined by
the start quote. That's why I initially wrote that the quotes must
line up vertically.

Unfortunately you can't write 

a_multi_line_string = 
i'''
Py-
   thon
 '''

although you can write 

a_multi_line_string = \
i'''
Py-
   thon
 '''

which is visually not much worse.

> > > In any case, Chris made a good point that I agree with. This doesn't
> > > really need to be syntax at all, but could just be implemented as a
> > > new string method.
> > 
> > Depending on the details, not quite. A method wouldn't get the horizontal
> > position of the leading quote. It could infer the position of the trailing 
> > quote,
> > though.
> > 
> 
> What about if we used Chris's approach, but added a parameter to the
> method to handle the indent? 
> 
> For example, 
> 
> Test = """
> Hello, this is a
>  Multiline indented
> String
> """.outdent(4)

Eek! No, I don't think that's a good idea. It means that the programmer
has to count spaces and has to remember to adjust the parameter if the
indentation changes (e.g. because the block is wrapped in a loop or
factored out to a function).


> The outdent method could look like:
> 
> string.outdent(size=None)
> """
> :param size : The number of spaces to remove from the beginning of
> each line in the string.  Non space characters will not be
> removed.  IF this is None, the number of characters in the first
> line of the string will be used.

The default should be the minimum number of leading spaces on non-empty
lines, I think. This is compatible with PEP 257. And in fact it allows
all lines to start with whitespace if the string ends with a newline
(which is a weird dependency, but probably not much of a restriction in
practice).


> If this is an iterable, the numbers returned from each iteration
> will be used for their respective lines.  If there are more lines
> than iterations, the last iteration will be used for subsequent
> lines.

This looks like overkill to me. What would be the use case?

> This solves the problem in a very pythonic way,

Everybody has their own definition of "pythonic", I guess.

hp

-- 
   _  | Peter J. Holzer| we build much bigger, better disasters now
|_|_) || because we have much more sophisticated
| |   | h...@hjp.at | management tools.
__/   | http://www.hjp.at/ | -- Ross Anderson 


signature.asc
Description: PGP signature
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Sorting and spaces.

2018-05-31 Thread Paul
In the US, at least, spaces should sort before letters.

MRAB brought up an important point. It depends on your purpose, of course,
but having all the capitalized-beginning items appear separately from all
of the lower-cased-beginning items can be very annoying to a user.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue33470] Changes from GH-1638 (GH-3575, bpo-28411) are not documented in Porting to Python 3.7

2018-05-31 Thread Ned Deily


Change by Ned Deily :


--
nosy:  -ned.deily
priority: release blocker -> 
versions:  -Python 3.7

___
Python tracker 

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



Re: Python library to break text into words

2018-05-31 Thread Chris Angelico
On Fri, Jun 1, 2018 at 6:26 AM, beliavsky--- via Python-list
 wrote:
> I bought some e-books in a Humble Bundle. The file names are shown below. I 
> would like to hyphenate words within the file names, so that the first three 
> titles are
>
> a_devils_chaplain.pdf
> atomic_accidents.pdf
> chaos_making_a_new_science.pdf
>
> Is there a Python library that uses intelligent guesses to break sequences of 
> characters into words? The general strategy would be to break strings into 
> the longest words possible. The library would need to "know" a sizable subset 
> of words in English.
>
> adevilschaplain.pdf
> atomicaccidents.pdf
> chaos_makinganewscience.pdf

Let's start with the easy bit. On many MANY Unix-like systems, you can
find a dictionary of words in the user's language (not necessarily
English, but that's appropriate here - it means your script will work
on a French or German or Turkish or Russian system as well) at
/usr/share/dict/words. All you have to do is:

with open("/usr/share/dict/words") as f:
words = f.read().strip().split("\n")

Tada! That'll give you somewhere between 50K and 650K words, for
English. (I have eight English dictionaries installed, ranging from
american-english-small and british-english-small at 51K all the way up
to their corresponding -insane variants at 650K.) Most likely you'll
have about 100K words, which is a good number to be working with. If
you're on Windows, see if you can just download something from
wordlist.sourceforge.net or similar; it should be in the same format.

So! Now for the next step. You need to split a pile of letters such
that each of the resulting pieces is a word. You're probably going to
find some that just don't work ("x-15diary" seems dubious), but for
the most part, you should get at least _some_ result. You suggested a
general strategy of breaking strings into the longest words possible,
which would be easy enough to code. A basic algorithm of "take as many
letters as you can while still finding a word" is likely to give you
fairly decent results. You'll need a way of backtracking in the event
that the rest of the letters don't work ("theedgeofphysics" will take
a first word of "thee", but then "dgeofphysics" isn't going to work
out well), but otherwise, I think your basic idea is sound.

Should be a fun project!

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


[issue33710] Deprecate gettext.lgettext()

2018-05-31 Thread Barry A. Warsaw


Barry A. Warsaw  added the comment:

+1 - I'm actually surprise it's still there. ;)  Given that the docs have a big 
red warning to avoid these in Python 3, let's start the process of removal.

Don't forget to also deprecate ldgettext(), lngettext(), and ldngettext()

https://docs.python.org/3/library/gettext.html#gettext.lgettext

--

___
Python tracker 

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



[issue33701] test_datetime crashed (SIGSEGV) on Travis CI

2018-05-31 Thread Stefan Krah


Stefan Krah  added the comment:

A wild theory: Because of the new pervasive includes 
(-I/home/travis/multissl/openssl/1.1.0h/include -O3 
-I/home/travis/multissl/openssl/1.1.0h/include) some module picks up a wrong 
header.


But I just rebuilt https://travis-ci.org/python/cpython/jobs/385458840 and a 
different random seed is fine.


If the includes are responsible, I'd expect the crash to be independent of the 
random seed.

--

___
Python tracker 

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



[issue33470] Changes from GH-1638 (GH-3575, bpo-28411) are not documented in Porting to Python 3.7

2018-05-31 Thread Paul Koning


Paul Koning  added the comment:

FYI, I'm the one who created this problem back in 2012.  I just submitted a GDB 
patch for this, using PyImport_AppendInittab to define the built-in module at 
startup.  I'm not sure how I missed this originally; perhaps the documentation 
was not as clear back then or maybe I just overlooked the information.  The 
patch eliminates the call to _PyImport_FixBuiltins.

--
nosy: +pkoning

___
Python tracker 

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



Python library to break text into words

2018-05-31 Thread beliavsky--- via Python-list
I bought some e-books in a Humble Bundle. The file names are shown below. I 
would like to hyphenate words within the file names, so that the first three 
titles are

a_devils_chaplain.pdf
atomic_accidents.pdf
chaos_making_a_new_science.pdf

Is there a Python library that uses intelligent guesses to break sequences of 
characters into words? The general strategy would be to break strings into the 
longest words possible. The library would need to "know" a sizable subset of 
words in English.

adevilschaplain.pdf
atomicaccidents.pdf
chaos_makinganewscience.pdf
dinosaurswithoutbones.pdf
essaysinscience.pdf
genius_thelifeandscienceofrichardfeynman.pdf
louisagassiz_creatorofamericanscience.pdf
martiansummer.pdf
mind_aunifiedtheoryoflifeandintelligence.pdf
noturningback.pdf
onshakyground.pdf
scienceandphilosophy.pdf
sevenelementsthatchangedtheworld.pdf
strangeangel.pdf
theboywhoplayedwithfusion.pdf
thecanon.pdf
theedgeofphysics.pdf
thegenome.pdf
thegoldilocksenigma.pdf
thesphinxatdawn.pdf
unnaturalselection.pdf
water_thefateofourmostpreciousresource.pdf
x-15diary.pdf
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32392] subprocess.run documentation does not have **kwargs

2018-05-31 Thread Tobias Kunze


Change by Tobias Kunze :


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

___
Python tracker 

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



[issue33701] test_datetime crashed (SIGSEGV) on Travis CI

2018-05-31 Thread STINNER Victor


STINNER Victor  added the comment:

> test_datetime passes here with nearly identical conditions as on the CI 
> (Ubuntu 14.04, clang, same random seed):

I tried to reproduce the issue on a Ubuntu Trusty *VM* using clang 5.0, using 
the same random seed: I failed to reproduce the bug.

I ran test_numeric_tower with GCC USBAN, but there is no warning (I'm not sure 
that I enabled correctly USBAN!).

I tested test_numeric_tower in Valgrind: no obvious memory error.

--

___
Python tracker 

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



[issue33701] test_datetime crashed (SIGSEGV) on Travis CI

2018-05-31 Thread Stefan Krah


Stefan Krah  added the comment:

test_datetime passes here with nearly identical conditions as on the CI (Ubuntu 
14.04, clang, same random seed):

Using random seed 987845
Run tests in parallel using 4 child processes
0:00:01 load avg: 1.70 [  1/415] test_html passed
0:00:01 load avg: 1.88 [  2/415] test_unicode_file_functions passed
0:00:02 load avg: 1.88 [  3/415] test_rlcompleter passed
0:00:03 load avg: 1.88 [  4/415] test_xml_etree passed
0:00:03 load avg: 1.88 [  5/415] test_codecencodings_kr passed
0:00:03 load avg: 1.88 [  6/415] test_dummy_thread passed
0:00:04 load avg: 1.88 [  7/415] test_source_encoding passed
0:00:05 load avg: 1.88 [  8/415] test_code passed
0:00:05 load avg: 1.88 [  9/415] test_curses passed
0:00:06 load avg: 1.88 [ 10/415] test_sys_setprofile passed
0:00:07 load avg: 2.05 [ 11/415] test_getopt passed
0:00:08 load avg: 2.05 [ 12/415] test_atexit passed
0:00:09 load avg: 2.05 [ 13/415] test_shlex passed
0:00:13 load avg: 2.13 [ 14/415] test_epoll passed
0:00:14 load avg: 2.13 [ 15/415] test_fileinput passed
0:00:26 load avg: 2.42 [ 16/415] test_embed passed
0:00:30 load avg: 2.54 [ 17/415] test_resource passed
0:00:31 load avg: 2.54 [ 18/415] test_augassign passed
0:00:36 load avg: 2.77 [ 19/415] test_gc passed -- running: test_io (33 sec)
0:00:38 load avg: 2.77 [ 20/415] test_multibytecodec passed -- running: test_io 
(35 sec)
0:00:38 load avg: 2.77 [ 21/415] test_contextlib passed -- running: test_io (35 
sec)
0:00:39 load avg: 2.77 [ 22/415] test_code_module passed -- running: test_io 
(36 sec)
0:00:50 load avg: 2.80 [ 23/415] test_select passed -- running: 
test_unicodedata (36 sec), test_io (47 sec)
0:00:51 load avg: 2.90 [ 24/415] test_posixpath passed -- running: 
test_unicodedata (37 sec), test_io (48 sec)
0:01:05 load avg: 3.07 [ 25/415] test_capi passed -- running: test_unicodedata 
(50 sec), test_io (62 sec)
0:01:06 load avg: 3.07 [ 26/415] test_string passed -- running: 
test_unicodedata (52 sec), test_io (63 sec)
0:01:08 load avg: 3.06 [ 27/415] test_unicodedata passed (52 sec) -- running: 
test_io (65 sec)
0:01:09 load avg: 3.06 [ 28/415] test_iter passed -- running: test_io (66 sec)
0:01:09 load avg: 3.06 [ 29/415] test_largefile passed -- running: test_io (66 
sec)
0:01:10 load avg: 3.06 [ 30/415] test_xxtestfuzz passed -- running: test_io (67 
sec), test_datetime (30 sec)
0:01:10 load avg: 3.06 [ 31/415] test_pkg passed -- running: test_io (67 sec), 
test_datetime (31 sec)
0:01:11 load avg: 3.06 [ 32/415] test_datetime passed (30 sec) -- running: 
test_io (67 sec)

--

___
Python tracker 

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



How do I list only the methods I define in a class?

2018-05-31 Thread bruceg113355
How do I list only the methods I define in a class?

For example:

class Produce():
def __init__ (self):
print (dir (Produce))

def apples(self):
pass

def peaches(self):
pass

def pumpkin (self):
pass

The print (dir(Produce)) statement displays:
['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', 
'__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', 
'__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', 
'__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', 
'__str__', '__subclasshook__', '__weakref__', 'apples', 'peaches', 'pumpkin']

I am only interested in 'apples', 'peaches', 'pumpkin'

The above is only an example.
In my real code there are methods with and without leading "__". 

Can I assume methods after __weakref__ are the methods I defined?
Is there a Python function to do what I need?

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


[issue33721] os.path.exists() ought to return False if pathname contains NUL

2018-05-31 Thread Matthew Barnett


Matthew Barnett  added the comment:

It also raises a ValueError on Windows. For other invalid paths on Windows it 
returns False.

--
nosy: +mrabarnett

___
Python tracker 

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



[issue33722] Document builtins in mock_open

2018-05-31 Thread Jay Crotts


New submission from Jay Crotts :

The examples on using mock_open only include instances where objects are mocked 
in the REPL, so '__main__'.open is replaced. Commonly objects are mocked for 
use in other test modules, so builtins.open would be used instead.

A note about this in the documentation would be useful not familiar with python 
internals. I'm happy to do a PR for it.

--
assignee: docs@python
components: Documentation
messages: 318337
nosy: docs@python, jcrotts
priority: normal
severity: normal
status: open
title: Document builtins in mock_open
type: enhancement
versions: Python 3.8

___
Python tracker 

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



Re: Override built in types... possible? or proposal.

2018-05-31 Thread Terry Reedy

On 5/31/2018 10:49 AM, Dan Strohl via Python-list wrote:

Is it possible to override the assignment of built in types to the shorthand 
representations?


By which I presume you mean literals and overt (non-comprehension) 
displays.  So you wish that Python should be even more dynamic.  (Some 
wish it were less so ;-)


The CPython parser is generated by a parser-generator program from the 
python grammar and a table of non-default functions to call when the 
parser recognizes certain grammatical productions.  For instance, 
*stringliteral* is mapped to str.  I assume that the mapping is 
currently direct, and not routed through the builtins dict.  I don't 
know what other implementations do.


To change this, I believe you would have to introduce indirect mapping 
functions.  One possibility would be C equivalents of functions like


def get_str(): return builtins['str']

Then you could change future parsing by executing
  builtins['str'] = mystr\

However, this would affect the parsing of imported modules, if and when 
they are parsed, and exec and eval calls made within imported functions. 
 This would not be good.


So I believe you would also need to introduce a module copy of a subset 
of builtins, call it '__modclass__', whose keys would be the classes 
called by the parser, and use that in the get_xyz functions.  Then I 
believe you could change parsing within a module by executing

   __modclass__['str'] = mystr


and yes, I know I could simply not do [] and always do my_list('item1', 
'item2', 'item3')


I think we should stick with this.


This would only be scoped to the current module and would not be imported when 
that module was imported.


The harder part, I think, is "and not affect parsing of imported modules 
if they are not already parsed and not affect exec and eval calls in 
imported modules.



--
Terry Jan Reedy

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


[issue33668] Wrong behavior of help function on module

2018-05-31 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

Adding Yury as an inspect expert. I don't think this is something urgent, we 
can probably postpone this to 3.7.1.

--
nosy: +yselivanov

___
Python tracker 

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



[issue33668] Wrong behavior of help function on module

2018-05-31 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

Hm, replacing the return with a random string, this leads to another crash:

Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/ilevkivskyi/src/cpython/Lib/_sitebuiltins.py", line 103, in 
__call__
return pydoc.help(*args, **kwds)
  File "/Users/ilevkivskyi/src/cpython/Lib/pydoc.py", line 1895, in __call__
self.help(request)
  File "/Users/ilevkivskyi/src/cpython/Lib/pydoc.py", line 1954, in help
else: doc(request, 'Help on %s:', output=self._output)
  File "/Users/ilevkivskyi/src/cpython/Lib/pydoc.py", line 1674, in doc
pager(render_doc(thing, title, forceload))
  File "/Users/ilevkivskyi/src/cpython/Lib/pydoc.py", line 1667, in render_doc
return title % desc + '\n\n' + renderer.document(object, name)
  File "/Users/ilevkivskyi/src/cpython/Lib/pydoc.py", line 385, in document
if inspect.ismodule(object): return self.docmodule(*args)
  File "/Users/ilevkivskyi/src/cpython/Lib/pydoc.py", line 1157, in docmodule
for importer, modname, ispkg in pkgutil.iter_modules(object.__path__):
  File "/Users/ilevkivskyi/src/cpython/Lib/pkgutil.py", line 123, in 
iter_modules
raise ValueError("path must be None or list of paths to look for "
ValueError: path must be None or list of paths to look for modules in

The reason is that `__getattr__` is also triggered when a special attribute is 
looked up. I am not sure what to do with this. This is a bit inconsistent with 
how classes behave, where e.g. `__len__` is never searched on an instance. But 
modules are special in many other ways, so maybe we can just fix pydoc (and 
other tools like inspect) to expect some ill-typed values in special module 
attributes and fail gracefully?

--

___
Python tracker 

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



Re: Indented multi-line strings (was: "Data blocks" syntax specification draft)

2018-05-31 Thread Chris Angelico
On Fri, Jun 1, 2018 at 12:39 AM, Dan Strohl via Python-list
 wrote:
>> This is of course not a problem if the *trailing* quote determines the
>> indentation:
>>
>> a_multi_line_string = i'''
>>Py-
>>   thon
>> '''
>
> I get the point, but it feels like it would be a pain to use, and it "Feels" 
> different from the other python indenting, which is something that I would 
> want to stay away from changing.
>
>> > In any case, Chris made a good point that I agree with. This doesn't
>> > really need to be syntax at all, but could just be implemented as a
>> > new string method.
>>
>> Depending on the details, not quite. A method wouldn't get the horizontal
>> position of the leading quote. It could infer the position of the trailing 
>> quote,
>> though.
>>
>
> What about if we used Chris's approach, but added a parameter to the method 
> to handle the indent?
>
> For example,
>
> Test = """
> Hello, this is a
>  Multiline indented
> String
> """.outdent(4)
>
>
> The outdent method could look like:
>
> string.outdent(size=None)
> """
> :param size : The number of spaces to remove from the beginning of each 
> line in the string.  Non space characters will not be removed.  IF this is 
> None, the number of characters in the first line of the string will be used.  
> If this is an iterable, the numbers returned from each iteration will be used 
> for their respective lines.  If there are more lines than iterations, the 
> last iteration will be used for subsequent lines.
>
> This solves the problem in a very pythonic way, while allowing the 
> flexibility to handle different needs.
>

Sure! Though I'd drop the iterable option - YAGNI. Keep the basic API
simple. Just an integer or None, where None's is defined in terms of
the string itself.

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


Re: Why exception from os.path.exists()?

2018-05-31 Thread Grant Edwards
On 2018-05-31, Paul Moore  wrote:
> On 31 May 2018 at 15:01, Chris Angelico  wrote:
>> Can someone on Windows see if there are other path names that raise
>> ValueError there? Windows has a whole lot more invalid characters, and
>> invalid names as well.
>
> On Windows:
>
 os.path.exists('\0')
> ValueError: stat: embedded null character in path
>
 os.path.exists('?')
> False
>
 os.path.exists('\u77412')
> False
>
 os.path.exists('\t')
> False
>
> Honestly, I think the OP's point is correct. os.path.exists should
> simply return False if the filename has an embedded \0 - at least on
> Unix.

Except on the platform in quetion filenames _don't_ contain an
embedded \0.  What was passed was _not_ a path/filename.

You might as well have passed a floating point number or a dict.

> Although I wouldn't consider this as anything even remotely like a
> significant issue...

Agreed, but the thread will continue for months and generate hundreds
of followup.

-- 
Grant Edwards   grant.b.edwardsYow! You were s'posed
  at   to laugh!
  gmail.com

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


Re: Problem with OrderedDict - progress report

2018-05-31 Thread Chris Angelico
On Fri, Jun 1, 2018 at 12:37 AM, Frank Millman  wrote:
> "Steven D'Aprano"  wrote in message news:peorib$1f4$2...@blaine.gmane.org...
>>
>>
>> On Thu, 31 May 2018 10:05:43 +0200, Frank Millman wrote:
>>
>> > From the interpreter session below, you will see that adding a key while
>> > processing the *last* key in an OrderedDict does not give rise to an
>> > exception.
>>
>> If you mutate the dict, and then stop iterating over it, there is no
>> check that the dict was mutated.
>>
>> It isn't an error to mutate the dict. It is an error to mutate it while
>> it is being iterated over. If you stop the iteration, there's no problem.
>>
>
> Agreed, but my gut feel, and the following example, suggest that when
> processing the last key in a dictionary while iterating over it, you have
> not yet stopped iterating.

If it's easier to understand, here's an alternative wording:

It is an error to mutate the dictionary *and then continue to iterate over it*.

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


Re: Why exception from os.path.exists()?

2018-05-31 Thread Chris Angelico
On Fri, Jun 1, 2018 at 12:51 AM, MRAB  wrote:
> On 2018-05-31 14:38, Marko Rauhamaa wrote:
>>
>> Chris Angelico :
>>>
>>> Do you have an actual use-case where it is correct for an invalid path
>>> to be treated as not existing?
>>
>>
>> Note that os.path.exists() returns False for other types of errors
>> including:
>>
>>   * File might exist but you have no access rights
>>
>>   * The pathname is too long for the file system
>>
>>   * The pathname is a broken symbolic link
>>
>>   * The pathname is a circular symbolic link
>>
>>   * The hard disk ball bearings are chipped
>>
>> I'm not aware of any other kind of a string argument that would trigger
>> an exception except the presence of a NUL byte.
>>
>> The reason for the different treatment is that the former errors are
>> caught by the kernel and converted to False by os.path.exists(). The NUL
>> byte check is carried out by Python's standard library.
>>
> On Windows, the path '<' is invalid, but os.path.exists('<') returns False,
> not an error.
>
> The path '' is also invalid, but os.path.exists('') returns False, not an
> error.
>
> I don't see why '\0' should behave any differently.

Okay, if it's just returning False for all the Windows invalid paths,
then sure, the Unix invalid paths can behave the same way.

Thanks for checking that (you and Paul equally).

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


RE: Override built in types... possible? or proposal.

2018-05-31 Thread Dan Strohl via Python-list
> >
> > I am envisioning something in the header like an import statement
> > where I could do;
> >
> > override str=my_string
> > override list=my_list
> >
> > This would only be scoped to the current module and would not be
> imported when that module was imported.
> >
> > Thoughts?
> >
> > Dan Strohl
> >
> 
> My problem with this idea is that it breaks expectations.  If I know one 
> thing as
> a Python programmer, it's that 'Bob' is a str.  Each time and every time.  If 
> you
> could override the meaning of basic constant identifiers to where I have no
> idea how they behave, that creates an easy thing to miss that changes the
> entire meaning of the things you've written.
> 

True, though, to determine what almost anything is, you should look at the 
imports anyway, just in case I happened to do something like;

Import my_sys as sys

> What's the use case here?  And why is that use case better than, for instance,
> simply defining a function in the module that does the things you want done
> to strings?  Not everything has to be an object method.

It's not necessarily better, it simply provides more flexibility in how things 
are approached.  In most cases I would probably define a function for something 
as you suggested, or define a new class and just instantiate that  object 
instead when needed, but I can see a time when it would be nice to be able to 
simply say, "I really want to handle all of my dictionaries in this module in a 
certain way", then not have to worry about it.

To me, one of the things I like about Python is that I can override many of the 
way things are handled via sub-classes, magic methods, importing "as" etc... 
this is simply an extension of that existing flexibility.

And yes, it gives developers another tool they can shoot themselves pretty 
easily in the foot with if they aren't careful in how they use it, but so many 
of the good tools do that already.

Honestly, I am not so locked into this that I would scream about it not 
working, but there have been times when it would have been helpful in the past, 
so I figured I would bring it up and see what others thought.

Dan



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


Re: Why exception from os.path.exists()?

2018-05-31 Thread Marko Rauhamaa
Terry Reedy :

> On 5/31/2018 8:03 AM, Marko Rauhamaa wrote:
>> Is the behavior a bug? Shouldn't it be:
>>
>> >>> os.path.exists("\0")
>> False
>
> Please open an issue on the tracker if there is not one for this
> already.

issue 33721 created


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


[issue33721] os.path.exists() ought to return False if pathname contains NUL

2018-05-31 Thread pacujo


New submission from pacujo :

os.path.exists() returns True or False for all imaginable string arguments 
except for one that contains NUL ("\0") (Linux). This behavior is not 
documented in the library. Moreover, it can easily lead to accidents if  an 
externally supplied pathname were to contain a NUL because most test suites 
would not try to cover such a pathname.

I propose os.path.exists() should return False even in this case.

--
components: Library (Lib)
messages: 318334
nosy: pacujo
priority: normal
severity: normal
status: open
title: os.path.exists() ought to return False if pathname contains NUL
type: behavior
versions: Python 3.6

___
Python tracker 

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



Re: Indented multi-line strings

2018-05-31 Thread Terry Reedy

On 5/31/2018 10:39 AM, Dan Strohl via Python-list wrote:

This is of course not a problem if the *trailing* quote determines the
indentation:

 a_multi_line_string = i'''
Py-
   thon
 '''


I get the point, but it feels like it would be a pain to use, and it "Feels" 
different from the other python indenting, which is something that I would want to stay 
away from changing.


In any case, Chris made a good point that I agree with. This doesn't
really need to be syntax at all, but could just be implemented as a
new string method.


Depending on the details, not quite. A method wouldn't get the horizontal
position of the leading quote. It could infer the position of the trailing 
quote,
though.



What about if we used Chris's approach, but added a parameter to the method to 
handle the indent?

For example,

Test = """
 Hello, this is a
  Multiline indented
 String
 """.outdent(4)


The outdent method could look like:

string.outdent(size=None)
 """
 :param size : The number of spaces to remove from the beginning of each 
line in the string.  Non space characters will not be removed.  IF this is 
None, the number of characters in the first line of the string will be used.  
If this is an iterable, the numbers returned from each iteration will be used 
for their respective lines.  If there are more lines than iterations, the last 
iteration will be used for subsequent lines.

This solves the problem in a very pythonic way, while allowing the flexibility 
to handle different needs.


string = (
" Hello, this is a concatenated   \n"
"   multiline variably indented   \n"
"string with variable trailing blanks.\n"
"It works now and always has! ")

--
Terry Jan Reedy

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


Re: Why exception from os.path.exists()?

2018-05-31 Thread Terry Reedy

On 5/31/2018 8:03 AM, Marko Rauhamaa wrote:


This surprising exception can even be a security issue:

>>> os.path.exists("\0")
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/lib64/python3.6/genericpath.py", line 19, in exists
os.stat(path)
ValueError: embedded null byte

Most other analogous reasons *don't* generate an exception, nor is that
possibility mentioned in the specification:

https://docs.python.org/3/library/os.path.html?#os.path.exists

Is the behavior a bug? Shouldn't it be:

>>> os.path.exists("\0")
False


Please open an issue on the tracker if there is not one for this already.


--
Terry Jan Reedy

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


Re: Override built in types... possible? or proposal.

2018-05-31 Thread Rob Gaddi

On 05/31/2018 07:49 AM, Dan Strohl wrote:

Is it possible to override the assignment of built in types to the shorthand 
representations?   And if not, is it a reasonable thought to consider adding?

For example, right now, if I do:

test = "this is a string",

I get back str("this is a string").  What if I want to return this as 
my_string("this is a string")  (OK, I know I have a recursive issue in my example, but 
hopefully you get the point).

Or;

Test = ['item1', 'item2', 'item3'] returns a list, what if I want to add 
functionality to all lists in my module?  (and yes, I know I could simply not 
do [] and always do my_list('item1', 'item2', 'item3']

I am envisioning something in the header like an import statement where I could 
do;

override str=my_string
override list=my_list

This would only be scoped to the current module and would not be imported when 
that module was imported.

Thoughts?

Dan Strohl



My problem with this idea is that it breaks expectations.  If I know one 
thing as a Python programmer, it's that 'Bob' is a str.  Each time and 
every time.  If you could override the meaning of basic constant 
identifiers to where I have no idea how they behave, that creates an 
easy thing to miss that changes the entire meaning of the things you've 
written.


What's the use case here?  And why is that use case better than, for 
instance, simply defining a function in the module that does the things 
you want done to strings?  Not everything has to be an object method.


--
Rob Gaddi, Highland Technology -- www.highlandtechnology.com
Email address domain is currently out of order.  See above to fix.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Sorting and spaces.

2018-05-31 Thread Peter Otten
Tobiah wrote:

> I had a case today where I needed to sort two string:
> 
> ['Awards', 'Award Winners']
> 
> I consulted a few sources to get a suggestion as to
> what would be correct.  My first idea was to throw them
> through a Linux command line sort:
> 
> Awards
> Award Winners
> 
> Then I did some Googling, and found that most US systems seem
> to prefer that one ignore spaces when alphabetizing.  The sort
> program seemed to agree.
> 
> I put the items into the database that way, but I had forgotten
> that my applications used python to sort them anyway.  The result
> was different:
> 
> >>> a = ['Awards', 'Award Winners']
> >>> sorted(a)
> ['Award Winners', 'Awards']
> 
> So python evaluated the space as a lower ASCII value.
> 
> Thoughts?  Are there separate tools for alphabetizing
> rather then sorting?

>>> items = ["Awards", "Award Winners", "awards"]
>>> sorted(items)
['Award Winners', 'Awards', 'awards']
>>> import locale
>>> locale.setlocale(locale.LC_ALL, "en_US.UTF-8")
'en_US.UTF-8'
>>> sorted(items, key=locale.strxfrm)
['awards', 'Awards', 'Award Winners']
>>> locale.setlocale(locale.LC_ALL, "C")
'C'
>>> sorted(items, key=locale.strxfrm)
['Award Winners', 'Awards', 'awards']


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


Re: Re: Re: The PIL show() method looks for the default viewer. How do I change this to a different viewer (of my choice)?

2018-05-31 Thread Paul St George
That's what I wanted! But, I didn't know the question because I didn't 
know the answer.



On 30/05/2018 23:09, Karsten Hilbert wrote:

On Wed, May 30, 2018 at 11:01:17PM +0200, Peter J. Holzer wrote:


On 2018-05-30 22:08:45 +0200, Paul St George wrote:

Ha! No, my question was clumsy.

If I know the name of the viewer that I want to use (say for example:
‘ImageMagick’), where do I find the argument that should be used in a line
of code such as this:

ImageShow.register(MyViewer("gwenview"), -1)

$> man -k ImageMagick
$> man whatever_you_found_with_the_above

Karsten


--
Paul St George
http://www.paulstgeorge.com
http://www.devices-of-wonder.com

+44(0)7595 37 1302

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


[issue33668] Wrong behavior of help function on module

2018-05-31 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +levkivskyi

___
Python tracker 

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



[issue33711] Could not find externals/db-* in msi.py on license generation

2018-05-31 Thread Ned Deily


Change by Ned Deily :


--
nosy: +steve.dower, zach.ware

___
Python tracker 

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



[issue32604] Expose the subinterpreters C-API in Python for testing use.

2018-05-31 Thread Eric Snow


Eric Snow  added the comment:


New changeset 110bc01407ac8c75545d0386577c6e17254d97d9 by Eric Snow in branch 
'master':
bpo-33615: Temporarily disable a test that is triggering crashes on a few 
buildbots. (gh-7288)
https://github.com/python/cpython/commit/110bc01407ac8c75545d0386577c6e17254d97d9


--

___
Python tracker 

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



[issue33615] test__xxsubinterpreters crashed on x86 Gentoo Refleaks 3.x

2018-05-31 Thread Eric Snow


Eric Snow  added the comment:


New changeset 110bc01407ac8c75545d0386577c6e17254d97d9 by Eric Snow in branch 
'master':
bpo-33615: Temporarily disable a test that is triggering crashes on a few 
buildbots. (gh-7288)
https://github.com/python/cpython/commit/110bc01407ac8c75545d0386577c6e17254d97d9


--

___
Python tracker 

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



[issue30618] readlink for pathlib paths

2018-05-31 Thread Timo Furrer


Change by Timo Furrer :


--
nosy: +tuxtimo

___
Python tracker 

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



[issue33668] Wrong behavior of help function on module

2018-05-31 Thread Timo Furrer


Change by Timo Furrer :


--
nosy: +tuxtimo

___
Python tracker 

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



[issue28657] cmd.Cmd.get_help() implementation can't see do_*() methods added dynamically by setattr()

2018-05-31 Thread Timo Furrer


Change by Timo Furrer :


--
nosy: +tuxtimo

___
Python tracker 

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



[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread Steve Dower


Steve Dower  added the comment:

I need to stop working on this right now, but here's the locals layout in a 
normal release build in r_object:

@rdi  @rdip = 0x0034`655ea3d0
0034`65403f60 @rsp+0x0080 v = 0x`
0034`65403fc0 @rsp+0x00e0   buf = char [256] ""
0034`654040c0 @rsp+0x01e0   buf = char [256] ""

In the PGO build, it looks like this:
00be`1e003b50 @rsp+0x0080 v = 0x`
00be`1e003b58 @rsp+0x0088   is_interned = 0n0
00be`1e003ef0 @rsp+0x0420   buf = char [256] ""
00be`1e003ff0 @rsp+0x0520   buf = char [256] ""

I need to ping the team and figure out why the buffers are so far removed from 
the rest of the stack, and figure out what's in the gap. That seems to be the 
core of the problem.

--

___
Python tracker 

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



[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread Steve Dower


Steve Dower  added the comment:

A crash in the test suite should be fixed, especially since we have protection 
against this crash (and a test that validates it).

In this case, apparently the stack allocation for each frame of r_object grew 
and now there isn't room for 2000 calls (the value of MAX_MARSHAL_STACK_DEPTH). 
This isn't really a robust way of handling it anyway, so I'll check out whether 
there's an easy way to safely probe the stack before recursing, otherwise we'll 
just have to cut the number a bit further.

--

___
Python tracker 

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



Re: Indented multi-line strings

2018-05-31 Thread MRAB

On 2018-05-31 15:39, Dan Strohl via Python-list wrote:

This is of course not a problem if the *trailing* quote determines the
indentation:

a_multi_line_string = i'''
   Py-
  thon
'''


I get the point, but it feels like it would be a pain to use, and it "Feels" 
different from the other python indenting, which is something that I would want to stay 
away from changing.


> In any case, Chris made a good point that I agree with. This doesn't
> really need to be syntax at all, but could just be implemented as a
> new string method.

Depending on the details, not quite. A method wouldn't get the horizontal
position of the leading quote. It could infer the position of the trailing 
quote,
though.



What about if we used Chris's approach, but added a parameter to the method to 
handle the indent?

For example,

Test = """
 Hello, this is a
  Multiline indented
 String
 """.outdent(4)


The outdent method could look like:

string.outdent(size=None)
 """
 :param size : The number of spaces to remove from the beginning of each 
line in the string.  Non space characters will not be removed.  IF this is 
None, the number of characters in the first line of the string will be used.  
If this is an iterable, the numbers returned from each iteration will be used 
for their respective lines.  If there are more lines than iterations, the last 
iteration will be used for subsequent lines.

This solves the problem in a very pythonic way, while allowing the flexibility 
to handle different needs.


That string starts with a blank line, after the initial quotes.

I was also thinking that it could take the indentation from the first 
line, but that if you wanted the first line to have a larger indent than 
the remaining lines, you could replace the first space that you want to 
keep with a non-whitespace character and then pass that character to the 
method.


For example:

Test = """\
 _   Hello, this is a
  Multiline indented
 String
 """.outdent(padding='_')

Outdent so that the first line is flush to the margin:

_   Hello, this is a
 Multiline indented
String

The padding argument tells it to replace the initial '_':

Hello, this is a
 Multiline indented
String
--
https://mail.python.org/mailman/listinfo/python-list


Re: Sorting and spaces.

2018-05-31 Thread MRAB

On 2018-05-31 15:18, Tobiah wrote:

I had a case today where I needed to sort two string:

['Awards', 'Award Winners']

I consulted a few sources to get a suggestion as to
what would be correct.  My first idea was to throw them
through a Linux command line sort:

Awards
Award Winners

Then I did some Googling, and found that most US systems seem
to prefer that one ignore spaces when alphabetizing.  The sort
program seemed to agree.

I put the items into the database that way, but I had forgotten
that my applications used python to sort them anyway.  The result
was different:

>>> a = ['Awards', 'Award Winners']
>>> sorted(a)
['Award Winners', 'Awards']

So python evaluated the space as a lower ASCII value.

Thoughts?  Are there separate tools for alphabetizing
rather then sorting?


You could split the string first:
>>> a = ['Awards', 'Award Winners']
>>> sorted(a, key=str.split)
['Award Winners', 'Awards']

If you want it to be case-insensitive:

>>> sorted(a, key=lambda s: s.lower().split())
['Award Winners', 'Awards']
--
https://mail.python.org/mailman/listinfo/python-list


[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread STINNER Victor


STINNER Victor  added the comment:

> priority: normal -> release blocker

I don't think that it's a release blocker. test_marshal does only crash on 
corner cases which should not occur on usual "valid" data.

--

___
Python tracker 

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



[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread Steve Dower


Steve Dower  added the comment:

Ned, FYI

--
nosy: +ned.deily
priority: normal -> release blocker
versions: +Python 3.8

___
Python tracker 

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



[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread Steve Dower


Steve Dower  added the comment:

The uploaded binary is compiled with PGO enabled (and trained on most of the 
test suite). I'll check it out - hopefully we don't need to do anything drastic 
and can get away with either a compiler update or disabling optimizations on a 
single function.

--
assignee:  -> steve.dower

___
Python tracker 

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



Re: Why exception from os.path.exists()?

2018-05-31 Thread Paul Moore
On 31 May 2018 at 16:11, Steven D'Aprano
 wrote:
> On Thu, 31 May 2018 22:46:35 +1000, Chris Angelico wrote:
> [...]
>>> Most other analogous reasons *don't* generate an exception, nor is that
>>> possibility mentioned in the specification:
>>>
>>>https://docs.python.org/3/library/os.path.html?#os.path.exists
>>>
>>> Is the behavior a bug? Shouldn't it be:
>>>
>>>>>> os.path.exists("\0")
>>>False
>>
>> A Unix path name cannot contain a null byte, so what you have is a
>> fundamentally invalid name. ValueError is perfectly acceptable.
>
> It should still be documented.
>
> What does it do on Windows if the path is illegal?

Returns False (confirmed with paths of '?' and ':', among others).

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


[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread STINNER Victor


STINNER Victor  added the comment:

> I compiled the master branch of Python in release mode using VS2015 (MSC 
> v.1912 64 bit) and I failed to reproduce the crash

I also failed to reproduce the crash in the 3.7 branch.

I guess that the python.org binary has been compiled differently.

--

___
Python tracker 

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



[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread STINNER Victor


Change by STINNER Victor :


--
versions: +Python 3.7 -Python 3.8

___
Python tracker 

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



[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread STINNER Victor


Change by STINNER Victor :


--
type:  -> crash

___
Python tracker 

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



[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread STINNER Victor


STINNER Victor  added the comment:

I compiled the master branch of Python in release mode using VS2015 (MSC v.1912 
64 bit) and I failed to reproduce the crash:

* PCbuild/build.bat -e -p x64
* python -m test -v test_marshal
* no crash

--

___
Python tracker 

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



Re: Why exception from os.path.exists()?

2018-05-31 Thread Steven D'Aprano
On Thu, 31 May 2018 22:46:35 +1000, Chris Angelico wrote:
[...]
>> Most other analogous reasons *don't* generate an exception, nor is that
>> possibility mentioned in the specification:
>>
>>https://docs.python.org/3/library/os.path.html?#os.path.exists
>>
>> Is the behavior a bug? Shouldn't it be:
>>
>>>>> os.path.exists("\0")
>>False
> 
> A Unix path name cannot contain a null byte, so what you have is a
> fundamentally invalid name. ValueError is perfectly acceptable.

It should still be documented.

What does it do on Windows if the path is illegal?



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

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


[issue33719] Test failures on Python 3.7 beta 5 and Windows 10

2018-05-31 Thread STINNER Victor


STINNER Victor  added the comment:

> test_marshal.test_loads_2x_code(): Windows fatal exception: stack overflow

I created bpo-33720: "test_marshal: crash in Python 3.7b5 on Windows 10".

--

___
Python tracker 

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



[issue33720] test_marshal: crash in Python 3.7b5 on Windows 10

2018-05-31 Thread STINNER Victor


New submission from STINNER Victor :

Follow-up of bpo-33719.

C:\Users\vstinner\AppData\Local\Programs\Python\Python37>python.exe -m test 
test_marshal -v
== CPython 3.7.0b5 (v3.7.0b5:abb8802389, May 31 2018, 01:54:01) [MSC v.1913 64 
bit (AMD64)]
== Windows-10-10.0.16299-SP0 little-endian
== cwd: C:\Users\vstinner\AppData\Local\Temp\test_python_3836
== CPU count: 2
== encodings: locale=cp1252, FS=utf-8
Run tests sequentially
0:00:00 [1/1] test_marshal
(...)
test_loads_2x_code (test.test_marshal.BugsTestCase) ... Windows fatal 
exception: stack overflow

Current thread 0x03a0 (most recent call first):
  File 
"C:\Users\vstinner\AppData\Local\Programs\Python\Python37\lib\unittest\case.py",
 line 178 in handle
  File 
"C:\Users\vstinner\AppData\Local\Programs\Python\Python37\lib\unittest\case.py",
 line 743 in assertRaises
  File 
"C:\Users\vstinner\AppData\Local\Programs\Python\Python37\lib\test\test_marshal.py",
 line 215 in test_loads_2x_code
  (...)

Crashes in test_marshal is on old topic:

* bpo-1050
* bpo-2286
* bpo-25264
* bpo-22734
* bpo-27019

Current stack size: 2 million bytes (1.9 MiB)

PCbuild/python.vcxproj:  200
PCbuild/pythonw.vcxproj:  200

--
components: Tests, Windows
messages: 318323
nosy: paul.moore, steve.dower, tim.golden, vstinner, zach.ware
priority: normal
severity: normal
status: open
title: test_marshal: crash in Python 3.7b5 on Windows 10
versions: Python 3.8

___
Python tracker 

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



[issue12029] Allow catching virtual subclasses in except clauses

2018-05-31 Thread Eric Snow


Change by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue32604] Expose the subinterpreters C-API in Python for testing use.

2018-05-31 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +6915

___
Python tracker 

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



[issue33615] test__xxsubinterpreters crashed on x86 Gentoo Refleaks 3.x

2018-05-31 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +6914

___
Python tracker 

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



[issue33479] Document tkinter and threads

2018-05-31 Thread Mark Roseman


Change by Mark Roseman :


--
pull_requests: +6913

___
Python tracker 

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



Override built in types... possible? or proposal.

2018-05-31 Thread Dan Strohl via Python-list
Is it possible to override the assignment of built in types to the shorthand 
representations?   And if not, is it a reasonable thought to consider adding?

For example, right now, if I do:

test = "this is a string",

I get back str("this is a string").  What if I want to return this as 
my_string("this is a string")  (OK, I know I have a recursive issue in my 
example, but hopefully you get the point).

Or;

Test = ['item1', 'item2', 'item3'] returns a list, what if I want to add 
functionality to all lists in my module?  (and yes, I know I could simply not 
do [] and always do my_list('item1', 'item2', 'item3']

I am envisioning something in the header like an import statement where I could 
do;

override str=my_string
override list=my_list

This would only be scoped to the current module and would not be imported when 
that module was imported.

Thoughts?

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


Re: Why exception from os.path.exists()?

2018-05-31 Thread Paul Moore
On 31 May 2018 at 15:01, Chris Angelico  wrote:
> Can someone on Windows see if there are other path names that raise
> ValueError there? Windows has a whole lot more invalid characters, and
> invalid names as well.

On Windows:

>>> os.path.exists('\0')
ValueError: stat: embedded null character in path

>>> os.path.exists('?')
False

>>> os.path.exists('\u77412')
False

>>> os.path.exists('\t')
False

Honestly, I think the OP's point is correct. os.path.exists should
simply return False if the filename has an embedded \0 - at least on
Unix. I don't know if Windows allows \0 in filenames, but if it does,
then os.path.exists should respect that...

Although I wouldn't consider this as anything even remotely like a
significant issue...

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


  1   2   3   >