Re: Help on PyImport_Import(pNAme)

2018-02-04 Thread dieter
Jason Qian via Python-list  writes:

>   This only works when loading  modules from the current directory.
>   Is there a way I can load from somewhere else ?

Have a look at the module `importlib` and especially its function
`import_module`.

Python knows about two forms of "import": "absolute import"
and "relative import".
An "absolute import" tries (in the usual case) to import from a list
of directories, maintained in "sys.path"; a "relative import"
(recognized via the module name starting with a .") relative to
a package.

Section 31.5.6.3 of
"https://docs.python.org/3/library/importlib.html#module-importlib.util;
tells you how to import a source file directly (independent from
any context).

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


Why no '|' operator for dict?

2018-02-04 Thread Frank Millman

Hi all

I recently learned that you can create a set 'on-the-fly' from two existing 
sets using the '|' operator -


Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit 
(AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.


set_1 = set(('a', 'b', 'c'))
set_2 = set(('d',))
set_1 | set_2

{'d', 'a', 'c', 'b'}




I was hoping that I could do the same with a dictionary, but it does not 
work -



dict_1 = {1: 'one', 2: 'two'}
dict_2 = {3: 'three'}
dict_1 | dict_2

Traceback (most recent call last):
 File "", line 1, in 
TypeError: unsupported operand type(s) for |: 'dict' and 'dict'




The best that I can come up with is -

dict([(k, v) for k, v in dict_1.items()] + [(k, v) for k, v in 
dict_2.items()])

{1: 'one', 2: 'two', 3: 'three'}




So I have 2 questions -

1. Is there any particular reason why '|' is not supported?

2. Is there a better way to do what I want?

Thanks

Frank Millman


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


Re: auto-correct a speech-to-text output and relate to of the words based on syllables

2018-02-04 Thread dieter
"Peter J. Holzer"  writes:
> On 2018-02-03 09:34:57 +0100, dieter wrote:
> ...
> The difficulty is to *recognise* it correctly. Was that tangle of sound
> waves an "l" or an "r"? This not as unambiguous as you seem to think.
> So a speech-to-text program may hear "right" when the speaker was really
> saying "light". If you have only the output from that program you must
> determine whether "right" is correct or must be corrected to "light".

The primary recommendation from my first response has been:
determine the step in the process chain that made the error.
If already the first step ("speech-to-text") has wrongly interpreted
"light" as "right", then obviously context is necessary to determine
that this was wrong.

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


[issue31356] Add context manager to temporarily disable GC

2018-02-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

1. The used approach was broken in the presence of multiple threads too. It 
didn't guarantee even that GC will be disabled in the next line.

2. What is a sense of disabling GC in a single thread? Objects in Python are 
not thread local, they are accessible from all threads, and collecting garbage 
in one thread affects other threads.

For truly disabling GC globally you need to use a counted semaphore or other 
synchronization primitives, and this can be implemented at Python level. But 
what are use cases for this context manager? Isn't naive approach enough?

--

___
Python tracker 

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



[issue30928] Copy modified blurbs to idlelib/NEWS.txt

2018-02-04 Thread Terry J. Reedy

Change by Terry J. Reedy :


--
pull_requests: +5371

___
Python tracker 

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



[issue31961] subprocess._execute_child doesn't accept a single PathLike argument for args

2018-02-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

The bug itself can be easily fixed. But I think this PR shouldn't be merged at 
first place. Not all functions should accept path-like objects for arbitrary 
arguments. Only if the argument semantically is a path, a path-like object 
should be accepted. Several similar propositions already were rejected for this 
reason.

--

___
Python tracker 

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



[issue20632] Define a new __key__ protocol

2018-02-04 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
nosy: +rhettinger

___
Python tracker 

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



[issue32394] socket lib beahavior change in 3.6.4

2018-02-04 Thread INADA Naoki

INADA Naoki  added the comment:

It seems Linux has TCP_KEEPCNT from very old ages and
just checking it's existence was OK for many years.
So I'm +0.5 on this Python-side fix.

--

___
Python tracker 

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



[issue32770] collections.counter examples are misleading

2018-02-04 Thread Raymond Hettinger

Raymond Hettinger  added the comment:

Thanks for the suggestion.  I respectfully disagree.  The "core" functionality 
of Counter is the ability to write c['x'] += 1 without risking a KeyError.  The 
add-on capability is to process an entire iterable all at once.   This is 
analogous to the list() builtin- where the core ability is to write s.append(e) 
and there is a convenience of calling list(iterable).

Another reason the first example goes first because it is simple.  It shows 
counting in isolation with no other distractions (an in-vitro example).

The second example is in a more complex environment incorporating file access 
and regular expressions (an in-vivo example).

FWIW, there are plenty of examples of using the += style.  Here's one I use in 
my Python courses:

'Scan a log file from a NASA server'

import collections, re, pprint

visited = collections.Counter()
with open('notes/nasa_19950801.log') as f:
for line in f:
mo = re.search(r'GET\s+(\S+)\s+200', line)
if mo is not None:
url = mo.group(1)
visited[url] += 1

pprint.pprint(visited.most_common(20))

I've had good luck with people understanding the docs as-is, so I'm going to 
decline the suggestion.  I do appreciate you taking the time to share your 
thoughts.

--
assignee: docs@python -> rhettinger
nosy: +rhettinger
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue32394] socket lib beahavior change in 3.6.4

2018-02-04 Thread INADA Naoki

INADA Naoki  added the comment:

> On Linux/Unix, the compile-time headers always consist with the system, so 
> there should not has this problem.
> Correct me if I'm wrong.

No.  Compile-time and run-time system is not always consist.
Kernel version may be upgraded / downgraded after Python is built.
And header version may not be consistent with kernel version.

There are some cases that system may return error for unsupported setsockopt() 
on Linux.

So I think websocket-client should catch OSError for setsockopt.

But if there are many broken libraries in the world, it's considerable
that hide it on Python side.

Kamil said "This behavior breaks many libraries that i use."
But I saw only websocket-client.  How many other libraries?

--
nosy: +inada.naoki

___
Python tracker 

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



Re: Parsing Nested List

2018-02-04 Thread Stanley Denman
On Sunday, February 4, 2018 at 5:32:51 PM UTC-6, Stanley Denman wrote:
> On Sunday, February 4, 2018 at 4:26:24 PM UTC-6, Stanley Denman wrote:
> > I am trying to parse a Python nested list that is the result of the 
> > getOutlines() function of module PyPFD2 using pyparsing module. This is the 
> > result I get. what in the world are 'expandtabs' and why is that making a 
> > difference to my parse attempt?
> > 
> > Python Code
> > 7
> > import PPDF2,pyparsing
> > from pyparsing import Word, alphas, nums
> > pdfFileObj=open('x.pdf','rb')
> > pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
> > List=pdfReader.getOutlines()
> > myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
> > myparser.parseString(List)
> > 
> > This is the error I get:
> > 
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > myparser.parseString(List)
> >   File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
> > instring = instring.expandtabs()
> > AttributeError: 'list' object has no attribute 'expandtabs'
> > 
> > Thanks so much, not getting any helpful responses from 
> > https://python-forum.io.

I have found that I can use the index values in the list to print out the 
section I need.  So print(MyList[7]) get me to section f taht I want.  
print(MyList[9][1]) for example give me a string that is the bookmark entry for 
Exhibit 1F.  But this index value would presumeably be different for each pdf 
file - that is there may not always be Section A-E, but there will always be a 
Section F. In ther words, the index values that get me to the right section 
would be different in each pdf file.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32394] socket lib beahavior change in 3.6.4

2018-02-04 Thread Ma Lin

Ma Lin  added the comment:

> We don't remove unsupported socket flags on Unix, why should we do it for 
> Windows?

We have this problem because: compile with new Windows SDK, but run on old 
version Windows.
On Linux/Unix, the compile-time headers always consist with the system, so 
there should not has this problem.
Correct me if I'm wrong.

> The other option would be to always hide the new constant on Windows in 3.6, 
> and make it unconditionally available on 3.7.

Search on GitHub [1], most people only check whether `socket` has such flags, 
like this:
if hasattr(socket, "TCP_KEEPCNT"):
...

Most of they don't check platform or Python version, so I'm -1 on this option.

-
TCP_KEEPIDLE and TCP_KEEPINTVL were added in Windows 10 1709. [2]
The master branch on AppVeyor is using 10.0.16229 (1709) SDK. [3]
While 3.6 branch is using 10.0.15062 (1703) SDK. [4]
If you agree the way of PR 5523, maybe we should remove these two flags as well.

[1] 
https://github.com/search?l=Python=1=TCP_KEEPCNT=Code=%E2%9C%93
[2] https://msdn.microsoft.com/en-us/library/windows/desktop/ms738596.aspx
[3] https://github.com/isuruf/cpython/blob/master/PCbuild/python.props#L78
[4] https://github.com/isuruf/cpython/blob/3.6/PCbuild/python.props#L77

--

___
Python tracker 

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



[issue8722] Documentation for __getattr__

2018-02-04 Thread Nick Coghlan

Nick Coghlan  added the comment:

Thanks for the patch Cheryl, and for the reviews Terry!

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



[issue31961] subprocess._execute_child doesn't accept a single PathLike argument for args

2018-02-04 Thread Gregory P. Smith

Gregory P. Smith  added the comment:

Don't revert something just because you found a bug, we can fix it.  fwiw, the 
PR passed appveyor's Windows run: 
https://ci.appveyor.com/project/python/cpython/build/3.7build11551

So if there's a bug, we're missing some kind of test coverage.

--

___
Python tracker 

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



[issue8722] Documentation for __getattr__

2018-02-04 Thread Nick Coghlan

Nick Coghlan  added the comment:


New changeset fea0a12f6bee4a36b2c9533003e33a12c58d2d91 by Nick Coghlan (Miss 
Islington (bot)) in branch '3.7':
[3.7] bpo-8722: Document __getattr__ behavior with AttributeError in property 
(GH-5543)
https://github.com/python/cpython/commit/fea0a12f6bee4a36b2c9533003e33a12c58d2d91


--

___
Python tracker 

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



[issue32720] Format mini-language integer definition is incorrect

2018-02-04 Thread Mariatta Wijaya

Change by Mariatta Wijaya :


--
pull_requests: +5370

___
Python tracker 

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



[issue8722] Documentation for __getattr__

2018-02-04 Thread Nick Coghlan

Nick Coghlan  added the comment:


New changeset a8c25d1c7f0d395861cc3e10dd01989150891c95 by Nick Coghlan (Miss 
Islington (bot)) in branch '3.6':
[3.6] bpo-8722: Document __getattr__ behavior with AttributeError in property 
(GH-5542)
https://github.com/python/cpython/commit/a8c25d1c7f0d395861cc3e10dd01989150891c95


--

___
Python tracker 

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



[issue8722] Documentation for __getattr__

2018-02-04 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5369

___
Python tracker 

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



[issue8722] Documentation for __getattr__

2018-02-04 Thread miss-islington

Change by miss-islington :


--
keywords: +patch
pull_requests: +5368

___
Python tracker 

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



[issue32691] "pdb -m " sets __main__.__package__ incorrectly

2018-02-04 Thread Nick Coghlan

Change by Nick Coghlan :


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



[issue32720] Format mini-language integer definition is incorrect

2018-02-04 Thread Nick Coghlan

Nick Coghlan  added the comment:

I didn't think to check those - it looks like they have the same problem with 
the same fix (i.e. the actual syntax is "digit+").

--

___
Python tracker 

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



[issue31356] Add context manager to temporarily disable GC

2018-02-04 Thread Nick Coghlan

Nick Coghlan  added the comment:

If I recall the discussion correctly, it was:

1. That this was worth doing precisely because the naive approach is likely to 
be broken in the presence of multiple threads;
2. It was only worth doing either as a true global disable that accounted for 
multi-threading (e.g. backed by a counted semaphore or the functional 
equivalent), or else by making gc enable/disable status have a thread local 
toggle in addition to the global one (so the context manager can ensure "GC is 
off *in this thread*, regardless of the global status").

Either of those two options requires changes to the main GC machinery though, 
as otherwise you basically *can't* write a correct context manager for this use 
case, since a direct call to gc.enable() in another thread would always be 
problematic.

--

___
Python tracker 

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



[issue32771] merge the underlying data stores of unicodedata and the str type

2018-02-04 Thread Benjamin Peterson

New submission from Benjamin Peterson :

Both Objects/unicodeobject.c and Modules/unicodedatamodule.c rely on large 
generated databases (Objects/unicodetype_db.h, Modules/unicodename_db.h, 
Modules/unicodedata_db.h). This separation made sense in Python 2 where Unicode 
was less of an important part of the language than Python3-recall Python 2's 
configure script has --without-unicode!. However, in Python 3, Unicode is a 
core language concept and literally baked into the syntax of the language. I 
therefore propose moving all of unicodedata's tables and algorithms into the 
interpreter core proper and converting Modules/unicodedata.c into a facade. 
This will remove awkward maneuvers like ast.c importing unicodedata in order to 
perform normalization. Having unicodedata readily accessible to the str type 
would also permit higher a fidelity unicode implementation. For example, 
implementing language-tailored str.lower() requires having canonical combining 
class of a character available. This data lives only in unicodedata currently.

--
components: Unicode
messages: 311634
nosy: benjamin.peterson, ezio.melotti, vstinner
priority: normal
severity: normal
stage: needs patch
status: open
title: merge the underlying data stores of unicodedata and the str type
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: 3.6.4 IDLE

2018-02-04 Thread MRAB

On 2018-02-04 21:09, Rob Alspach wrote:

Hi Everybody! I just installed python 3.6.4 it was a fresh install (no
former versions). I have never used python but have some IS background. The
videos I am seeing online all show the IDE / IDLE; however, it does not
install for me. I am installing from the download
python-3.6.4-embed-amd64.zip. I am running windows 10. I also have Oracle
on this laptop.

The file does not have an installer and also does not write to the file
path. I have already uninstalled and reinstalled the problem remains. I can
update the path no problem but where can I get the IDLE / IDE to follow
along with the videos on youtube? I am using notepad currently but have no
way to execute any files I write. If I save a file in notepad and open
through python the python window terminates when the operation is complete
(much to fast for these old eyes).

python-3.6.4-embed-amd64.zip is for "embedded, small or minimal hardware 
devices". I think you probably don't want that one!


I always use the "executable installer".
--
https://mail.python.org/mailman/listinfo/python-list


[issue8722] Documentation for __getattr__

2018-02-04 Thread Nick Coghlan

Nick Coghlan  added the comment:


New changeset d1f318105b8781b01f3507d5cb0fd841b977d5f2 by Nick Coghlan (Cheryl 
Sabella) in branch 'master':
bpo-8722: Document __getattr__ behavior with AttributeError in property 
(GH-4754)
https://github.com/python/cpython/commit/d1f318105b8781b01f3507d5cb0fd841b977d5f2


--

___
Python tracker 

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



Re: 3.6.4 IDLE

2018-02-04 Thread Terry Reedy

On 2/4/2018 4:09 PM, Rob Alspach wrote:

Hi Everybody! I just installed python 3.6.4 it was a fresh install (no
former versions). I have never used python but have some IS background. The
videos I am seeing online all show the IDE / IDLE; however, it does not
install for me. I am installing from the download
python-3.6.4-embed-amd64.zip.


This is for people who want to embed Python in a C program, or something 
like that.  Go back to

https://www.python.org/downloads/release/python-364/
and get either a 32-bit x86 or 64-bit x86-64 installer.
I suggest the 64-bit if your Win10 is 64-bit, as is likely.
I suggest the 'executable' versus the 'web-based' installer, as one can 
read something else while downloading (less than a minute), and one will 
have the installer to repair or revise, but that is up to you.


--
Terry Jan Reedy

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


Re: Why not have a recvall method?

2018-02-04 Thread 陶青云
Thank you, it's very helpful.
I think the recvall should builtin to the _socket module like sendall.
 
 
-- Original --
From:  "Dan Stromberg";
Date:  Mon, Feb 5, 2018 06:01 AM
To:  "陶青云";
Cc:  "python-list";
Subject:  Re: Why not have a recvall method?
 
On Sun, Feb 4, 2018 at 5:26 AM, 陶青云  wrote:
> Hello, all
> The socket object has a `sendall` method that can send all bytes you 
> specified.
> Oppositely, socket only has a recv method. I wonder why there is not a 
> `recvall` method?
> To workaround this, I use `f = socket.makefile('rb')`, then all `f.read(n)`
> Thanks.

You're probably good with socket.makefile('rb').

An alternative that allows things like reading null-terminated input:
http://stromberg.dnsalias.org/~strombrg/bufsock.html

I wrote it and have been using it in production for years.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue5594] IDLE startup configuration

2018-02-04 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
keywords: +patch
pull_requests: +5366
stage: test needed -> patch review

___
Python tracker 

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



[issue30928] Copy modified blurbs to idlelib/NEWS.txt

2018-02-04 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5365

___
Python tracker 

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



[issue5594] IDLE startup configuration

2018-02-04 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

I created a pull request for this ticket.  I did not include any of the other 
issues/tickets for using the command line information on restart or any of the 
issues with running certain code.

I also added template code to be used in a new editor window.  It made the 
Startup tab look nicer.   :-)

--
nosy: +csabella

___
Python tracker 

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



[issue5594] IDLE startup configuration

2018-02-04 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
dependencies: +IDLE: Add docstrings and tests for editor.py reload functions

___
Python tracker 

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



[issue30928] Copy modified blurbs to idlelib/NEWS.txt

2018-02-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:


New changeset 4abcbc0f0de8dc3c245950e118cd9d374dbfe42b by Terry Jan Reedy (Miss 
Islington (bot)) in branch '3.7':
bpo-30928: IDLE - update NEWS.txt. (GH-5539) (GH-5540)
https://github.com/python/cpython/commit/4abcbc0f0de8dc3c245950e118cd9d374dbfe42b


--

___
Python tracker 

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



[issue5594] IDLE startup configuration

2018-02-04 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
keywords: +patch, patch
pull_requests: +5366, 5367
stage: test needed -> patch review

___
Python tracker 

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



[RELEASED] Python 3.4.8 and Python 3.5.5 are now available

2018-02-04 Thread Larry Hastings


On behalf of the Python development community, I'm happy to announce the 
availability of Python 3.4.8 and Python 3.5.5.


Both Python 3.4 and 3.5 are in "security fixes only" mode.  Both 
versions only accept security fixes, not conventional bug fixes, and 
both releases are source-only.



You can find Python 3.4.8 here:

   https://www.python.org/downloads/release/python-348/


And you can find Python 3.5.5 here:

   https://www.python.org/downloads/release/python-355/



Happy Pythoning,


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


[issue32770] collections.counter examples are misleading

2018-02-04 Thread Anthony Flury

New submission from Anthony Flury :

The first example given for collections.Counter is misleading - the 
documentation ideally should show the 'best' (one and only one) way to do 
something and the example is this : 

>>> # Tally occurrences of words in a list
>>> cnt = Counter()
>>> for word in ['red', 'blue', 'red', 'green', 'blue', 'blue']:
... cnt[word] += 1
>>> cnt
Counter({'blue': 3, 'red': 2, 'green': 1})

clearly this could simply be : 

>>> # Tally occurrences of words in a list
>>> cnt = Counter(['red', 'blue', 'red', 'green', 'blue', 'blue'])
>>> cnt
Counter({'blue': 3, 'red': 2, 'green': 1})

(i.e. the iteration through the array is unneeded in this example).

The 2nd example is better in showing the 'entry-level' use of the Counter class.

There possibly does need to be a simple example of when you might manually 
increment the Counter class - but I don't think that the examples given 
illustrate that in a useful way; and I personally haven't come across a 
use-case for manually incrementing the Counter class entires that couldn't be 
accomplished with a comprehension or generator expression passed directly to 
the Counter constructor.

--
assignee: docs@python
components: Documentation
messages: 311630
nosy: anthony-flury, docs@python
priority: normal
severity: normal
status: open
title: collections.counter examples are misleading
versions: Python 2.7, 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



[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Thanks for catching this.

--

___
Python tracker 

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



Re: Parsing Nested List

2018-02-04 Thread Stanley Denman
On Sunday, February 4, 2018 at 5:06:26 PM UTC-6, Steven D'Aprano wrote:
> On Sun, 04 Feb 2018 14:26:10 -0800, Stanley Denman wrote:
> 
> > I am trying to parse a Python nested list that is the result of the
> > getOutlines() function of module PyPFD2 using pyparsing module.
> 
> pyparsing parses strings, not lists.
> 
> I fear that you have completely misunderstood what pyparsing does: it 
> isn't a general-purpose parser of arbitrary Python objects like lists. 
> Like most parsers (actually, all parsers that I know of...) it takes text 
> as input and produces some sort of machine representation:
> 
> https://en.wikipedia.org/wiki/Parsing#Computer_languages
> 
> 
> So your code is not working because you are calling parseString() with a 
> list argument:
> 
> myparser.parseString(List)
> 
> 
> The name of the function, parseString(), should have been a hint that it 
> requires a *string* as argument.
> 
> You have generated an outline:
> 
> List = pdfReader.getOutlines()
> 
> but do you know what the format of that list is? I'm going to assume that 
> it looks something like this:
> 
> ['ABCD 01 of 99', 'EFGH 02 of 99', 'IJKL 03 of 99', ...]
> 
> since that matches the template you gave to pyparsing. Notice that:
> 
> - words are separated by spaces;
> 
> - the first word is any arbitrary word, made up of just letters;
> 
> - followed by EXACTLY two digits;
> 
> - followed by the word "of";
> 
> - followed by EXACTLY two digits.
> 
> Furthermore, I'm assuming it is a simple, non-nested list. If that is not 
> the case, you will need to explain precisely what the format of the 
> outline actually is.
> 
> To parse this list is simple and pyparsing is not required:
> 
> for item in List:
> words = item.split()
> if len(words) != 4:
> raise ValueError('bad input data: %r' % item)
> first, number, x, total = words
> number = int(number)
> assert x == 'of'
> total = int(total)
> print(first, number, total)
> 
> 
> 
> 
> Hope this helps.
> 
> (Please keep any replies on the list.)
> 
> 
> 
> -- 
> Steve

Thank you so much Steve.  I do seem to be barking up the wrong tree.  The 
result of running getOutlines() is indeed a nested list: it is the pdfs 
bookmarks.  There are 3 levels: level 1 is the section from A-F. When a section 
there are exhibits, so in Section A we have exhibits 1A to nA. Finally there 
are bookmarks for individual pages in an exhibit.   So we have this for Section 
A:

[{'/Title': 'Section A.  Payment Documents/Decisions', '/Page': 
IndirectObject(1, 0), '/Type': '/FitB'}, [{'/Title': '1A:  Disability 
Determination Transmittal (831) Dec. Dt.:  05/27/2016 (1 page)', '/Page': 
IndirectObject(1, 0), '/Type': '/FitB'}, [{'/Title': '1A (Page 1 of 1)', 
'/Page': IndirectObject(1, 0), '/Type': '/FitB'}], {'/Title': '2A:  Disability 
Determination Explanation (DDE) Dec. Dt.:  05/27/2016 (10 pages)', '/Page': 
IndirectObject(6, 0), '/Type': '/FitB'}, [{'/Title': '2A (Page 1 of 10)', 
'/Page': IndirectObject(6, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 2 of 
10)', '/Page': IndirectObject(10, 0), '/Type': '/FitB'}, {'/Title': '2A (Page 3 
of 10)', '/Page': IndirectObject(14, 0), '/Type': '/FitB'}, {'/Title': '2A 
(Page 4 of 10)', '/Page': IndirectObject(18, 0), '/Type': '/FitB'}, {'/Title': 
'2A (Page 5 of 10)', '/Page': IndirectObject(22, 0), '/Type': '/FitB'}, 
{'/Title': '2A (Page 6 of 10)', '/Page': IndirectObject(26, 0), '/Type': 
'/FitB'}, {'/Title': '2A (Page 7 
 of 10)', '/Page': IndirectObject(30, 0), '/Type': '/FitB'}, {'/Title': '2A 
(Page 8 of 10)', '/Page': IndirectObject(34, 0), '/Type': '/FitB'}, {'/Title': 
'2A (Page 9 of 10)', '/Page': IndirectObject(38, 0), '/Type': '/FitB'}, 
{'/Title': '2A (Page 10 of 10)', '/Page': IndirectObject(42, 0), '/Type': 
'/FitB'}], {'/Title': '3A:  ALJ Hearing Decision (ALJDEC) Dec. Dt.:  12/17/2012 
(22 pages)', '/Page': IndirectObject(47, 0), '/Type': '/FitB'}, [{'/Title': '3A 
(Page 1 of 22)', '/Page': IndirectObject(47, 0), '/Type': '/FitB'}, {'/Title': 
'3A (Page 2 of 22)', '/Page': IndirectObject(51, 0), '/Type': '/FitB'}, 
{'/Title': '3A (Page 3 of 22)', '/Page': IndirectObject(55, 0), '/Type': 
'/FitB'}, {'/Title': '3A (Page 4 of 22)', '/Page': IndirectObject(59, 0), 
'/Type': '/FitB'}, {'/Title': '3A (Page 5 of 22)', '/Page': IndirectObject(63, 
0), '/Type': '/FitB'}, {'/Title': '3A (Page 6 of 22)', '/Page': 
IndirectObject(67, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 7 of 22)', 
'/Page': IndirectObjec
 t(71, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 8 of 22)', '/Page': 
IndirectObject(75, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 9 of 22)', 
'/Page': IndirectObject(79, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 10 of 
22)', '/Page': IndirectObject(83, 0), '/Type': '/FitB'}, {'/Title': '3A (Page 
11 of 22)', '/Page': IndirectObject(88, 0), '/Type': '/FitB'}, {'/Title': '3A 
(Page 12 of 22)', '/Page': IndirectObject(92, 0), '/Type': '/FitB'}, {'/Title': 
'3A (Page 13 of 22)', '/Page': 

[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread Terry J. Reedy

Change by Terry J. Reedy :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type: enhancement -> behavior

___
Python tracker 

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



[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:


New changeset 1c2b138671656abf8563a0cd7ef27c8c2e0be4e6 by Terry Jan Reedy (Miss 
Islington (bot)) in branch '3.6':
bpo-32765: Update configdialog General tab create page docstring (GH-5529) 
(GH-5538)
https://github.com/python/cpython/commit/1c2b138671656abf8563a0cd7ef27c8c2e0be4e6


--

___
Python tracker 

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



[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:


New changeset 5b933aa8ec8b1c04488c26b3d61b813e237f55d9 by Terry Jan Reedy (Miss 
Islington (bot)) in branch '3.7':
bpo-32765: Update configdialog General tab create page docstring (GH-5529) 
(GH-5537)
https://github.com/python/cpython/commit/5b933aa8ec8b1c04488c26b3d61b813e237f55d9


--

___
Python tracker 

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



[issue30928] Copy modified blurbs to idlelib/NEWS.txt

2018-02-04 Thread Terry J. Reedy

Change by Terry J. Reedy :


--
pull_requests: +5364

___
Python tracker 

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



Re: Parsing Nested List

2018-02-04 Thread Stanley Denman
On Sunday, February 4, 2018 at 4:26:24 PM UTC-6, Stanley Denman wrote:
> I am trying to parse a Python nested list that is the result of the 
> getOutlines() function of module PyPFD2 using pyparsing module. This is the 
> result I get. what in the world are 'expandtabs' and why is that making a 
> difference to my parse attempt?
> 
> Python Code
> 7
> import PPDF2,pyparsing
> from pyparsing import Word, alphas, nums
> pdfFileObj=open('x.pdf','rb')
> pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
> List=pdfReader.getOutlines()
> myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
> myparser.parseString(List)
> 
> This is the error I get:
> 
> Traceback (most recent call last):
>   File "", line 1, in 
> myparser.parseString(List)
>   File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
> instring = instring.expandtabs()
> AttributeError: 'list' object has no attribute 'expandtabs'
> 
> Thanks so much, not getting any helpful responses from 
> https://python-forum.io.

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


[issue30928] Copy modified blurbs to idlelib/NEWS.txt

2018-02-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Correction: entries currently go under "What's New in IDLE 3.7.0" for both 
master and 3.7 branches.  Each "What's New in IDLE 3.x.0" is "since 3.(x-1).0 
was released.  (We used to not branch off x+1 until the first x.0rc1, instead 
of at x.0b1, so the overlap was much less.)  I will edit to make that explicit. 
 So only 3.6 should have conflicts.

--

___
Python tracker 

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



Re: 3.6.4 IDLE

2018-02-04 Thread Chris Angelico
On Mon, Feb 5, 2018 at 8:09 AM, Rob Alspach  wrote:
> Hi Everybody! I just installed python 3.6.4 it was a fresh install (no
> former versions). I have never used python but have some IS background. The
> videos I am seeing online all show the IDE / IDLE; however, it does not
> install for me. I am installing from the download
> python-3.6.4-embed-amd64.zip. I am running windows 10. I also have Oracle
> on this laptop.
>
> The file does not have an installer and also does not write to the file
> path. I have already uninstalled and reinstalled the problem remains. I can
> update the path no problem but where can I get the IDLE / IDE to follow
> along with the videos on youtube? I am using notepad currently but have no
> way to execute any files I write. If I save a file in notepad and open
> through python the python window terminates when the operation is complete
> (much to fast for these old eyes).

What you'll normally want to do is get the regular installer. Go to
python.org and look at the download links right there on the front
page; that'll give you a much more normal way of getting hold of the
full Python suite.

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


[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5362

___
Python tracker 

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



[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5363

___
Python tracker 

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



[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:


New changeset 845d86485e35a26478aedb3dc127d632fdc65759 by Terry Jan Reedy 
(Cheryl Sabella) in branch 'master':
bpo-32765: Update configdialog General tab create page docstring (GH-5529)
https://github.com/python/cpython/commit/845d86485e35a26478aedb3dc127d632fdc65759


--

___
Python tracker 

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



[issue32769] Add 'annotations' to the glossary

2018-02-04 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
assignee: docs@python
components: Documentation
keywords: easy
nosy: csabella, docs@python
priority: normal
severity: normal
status: open
title: Add 'annotations' to the glossary
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



[issue30928] Copy modified blurbs to idlelib/NEWS.txt

2018-02-04 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Add 1 new entry to all 3 versions.  There will likely be merge conflicts to be 
resolved because the lower context is not the same, but this should establish a 
uniform lower context for the immediate future.

--
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: Parsing Nested List

2018-02-04 Thread Steven D'Aprano
On Sun, 04 Feb 2018 14:26:10 -0800, Stanley Denman wrote:

> I am trying to parse a Python nested list that is the result of the
> getOutlines() function of module PyPFD2 using pyparsing module.

pyparsing parses strings, not lists.

I fear that you have completely misunderstood what pyparsing does: it 
isn't a general-purpose parser of arbitrary Python objects like lists. 
Like most parsers (actually, all parsers that I know of...) it takes text 
as input and produces some sort of machine representation:

https://en.wikipedia.org/wiki/Parsing#Computer_languages


So your code is not working because you are calling parseString() with a 
list argument:

myparser.parseString(List)


The name of the function, parseString(), should have been a hint that it 
requires a *string* as argument.

You have generated an outline:

List = pdfReader.getOutlines()

but do you know what the format of that list is? I'm going to assume that 
it looks something like this:

['ABCD 01 of 99', 'EFGH 02 of 99', 'IJKL 03 of 99', ...]

since that matches the template you gave to pyparsing. Notice that:

- words are separated by spaces;

- the first word is any arbitrary word, made up of just letters;

- followed by EXACTLY two digits;

- followed by the word "of";

- followed by EXACTLY two digits.

Furthermore, I'm assuming it is a simple, non-nested list. If that is not 
the case, you will need to explain precisely what the format of the 
outline actually is.

To parse this list is simple and pyparsing is not required:

for item in List:
words = item.split()
if len(words) != 4:
raise ValueError('bad input data: %r' % item)
first, number, x, total = words
number = int(number)
assert x == 'of'
total = int(total)
print(first, number, total)




Hope this helps.

(Please keep any replies on the list.)



-- 
Steve

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


[issue31529] IDLE: Add docstrings and tests for editor.py reload functions

2018-02-04 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

Hi Terry,

Could you put this one on your radar for review?  Thanks!

--

___
Python tracker 

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



Can't load Python program on my HP ENVY computer

2018-02-04 Thread Bernard via Python-list



I have an HP ENVY TouchSmart 17 Notebook PC.
Windows 8.1.
Intel(R) Core(TM) i7-4700 mQ cpu @ 2.40 ghz 2.40ghz
64-bit operation system x64 based processor
Full Windows touch support with 10 touch points

Can you send me the link to the correct Python version that will run on this 
computer.  I have tried to install Python several times and it just keeps 
hanging up in the initialization phase.

Thanks,
B

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


3.6.4 IDLE

2018-02-04 Thread Rob Alspach
Hi Everybody! I just installed python 3.6.4 it was a fresh install (no
former versions). I have never used python but have some IS background. The
videos I am seeing online all show the IDE / IDLE; however, it does not
install for me. I am installing from the download
python-3.6.4-embed-amd64.zip. I am running windows 10. I also have Oracle
on this laptop.

The file does not have an installer and also does not write to the file
path. I have already uninstalled and reinstalled the problem remains. I can
update the path no problem but where can I get the IDLE / IDE to follow
along with the videos on youtube? I am using notepad currently but have no
way to execute any files I write. If I save a file in notepad and open
through python the python window terminates when the operation is complete
(much to fast for these old eyes).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Parsing Nested List

2018-02-04 Thread Chris Angelico
On Mon, Feb 5, 2018 at 9:26 AM, Stanley Denman
 wrote:
> I am trying to parse a Python nested list that is the result of the 
> getOutlines() function of module PyPFD2 using pyparsing module. This is the 
> result I get. what in the world are 'expandtabs' and why is that making a 
> difference to my parse attempt?
>
> Python Code
> 7
> import PPDF2,pyparsing
> from pyparsing import Word, alphas, nums
> pdfFileObj=open('x.pdf','rb')
> pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
> List=pdfReader.getOutlines()
> myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
> myparser.parseString(List)
>
> This is the error I get:
>
> Traceback (most recent call last):
>   File "", line 1, in 
> myparser.parseString(List)
>   File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
> instring = instring.expandtabs()
> AttributeError: 'list' object has no attribute 'expandtabs'
>
> Thanks so much, not getting any helpful responses from 
> https://python-forum.io.

By the look of this code, it's expecting a string. (The variable name
"instring" is suggestive of this, and strings DO have an expandtabs
method.) You're calling a method named "parseString", and presumably
giving it a list. I don't know what you mean by "nested" though.

Maybe you want to iterate over the list and parse each of the strings in it?

More info about what you're trying to do here would help.

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


Parsing Nested List

2018-02-04 Thread Stanley Denman
I am trying to parse a Python nested list that is the result of the 
getOutlines() function of module PyPFD2 using pyparsing module. This is the 
result I get. what in the world are 'expandtabs' and why is that making a 
difference to my parse attempt?

Python Code
7
import PPDF2,pyparsing
from pyparsing import Word, alphas, nums
pdfFileObj=open('x.pdf','rb')
pdfReader=PyPDF2.PdfFileReader(pdfFileObj)
List=pdfReader.getOutlines()
myparser = Word( alphas ) + Word(nums, exact=2) +"of" + Word(nums, exact=2)
myparser.parseString(List)

This is the error I get:

Traceback (most recent call last):
  File "", line 1, in 
myparser.parseString(List)
  File "C:\python\lib\site-packages\pyparsing.py", line 1620, in parseString
instring = instring.expandtabs()
AttributeError: 'list' object has no attribute 'expandtabs'

Thanks so much, not getting any helpful responses from https://python-forum.io.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32739] collections.deque rotate(n=1) default value not documented

2018-02-04 Thread Raymond Hettinger

Change by Raymond Hettinger :


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



[issue32768] object.__new__ does not accept arguments if __bases__ is changed

2018-02-04 Thread VA

New submission from VA :

object.__new__ takes only the class argument, but it still accepts extra 
arguments if a class doesn't override __new__, and rejects them otherwise. 
(This is because __new__ will receive the same arguments as __init__ but 
__new__ shouldn't need to be overridden just to remove args)

However, if a class has a custom __new__ at one point (in a parent class), and 
at a later point __bases__ is changed, object.__new__ will still reject 
arguments, although __new__ may not be overridden anymore at that point. See 
attached file.

I can't check with all Python 3 versions, but the same code works fine in 
Python 2.

--
files: bases.py
messages: 311622
nosy: VA
priority: normal
severity: normal
status: open
title: object.__new__ does not accept arguments if __bases__ is changed
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file47425/bases.py

___
Python tracker 

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



Re: Why not have a recvall method?

2018-02-04 Thread Dan Stromberg
On Sun, Feb 4, 2018 at 5:26 AM, 陶青云  wrote:
> Hello, all
> The socket object has a `sendall` method that can send all bytes you 
> specified.
> Oppositely, socket only has a recv method. I wonder why there is not a 
> `recvall` method?
> To workaround this, I use `f = socket.makefile('rb')`, then all `f.read(n)`
> Thanks.

You're probably good with socket.makefile('rb').

An alternative that allows things like reading null-terminated input:
http://stromberg.dnsalias.org/~strombrg/bufsock.html

I wrote it and have been using it in production for years.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32394] socket lib beahavior change in 3.6.4

2018-02-04 Thread Nathaniel Smith

Nathaniel Smith  added the comment:

The other option would be to always hide the new constant on Windows in 3.6, 
and make it unconditionally available on 3.7.

--
nosy: +njs

___
Python tracker 

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



[issue32394] socket lib beahavior change in 3.6.4

2018-02-04 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

Socket constants a compile time values, obviously concrete operation system 
might not support a flag -- but we do nothing with it in runtime.

All flags available on compile time are exposed, it's true for modules like 
socket, os, select etc.

--

___
Python tracker 

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



[issue32394] socket lib beahavior change in 3.6.4

2018-02-04 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

We don't remove unsupported socket flags on Unix, why should we do it for 
Windows?

--
nosy: +asvetlov

___
Python tracker 

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



Help on PyImport_Import(pNAme)

2018-02-04 Thread Jason Qian via Python-list
Hi,

  This only works when loading  modules from the current directory.
  Is there a way I can load from somewhere else ?

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


[issue32706] test_check_hostname() of test_ftplib started to fail randomly

2018-02-04 Thread Christian Heimes

Christian Heimes  added the comment:

poplib is also affected, see #32753

--
priority: normal -> high
stage: patch review -> needs patch
type:  -> behavior
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



[issue32728] Extend zipfile's compression level support to LZMA

2018-02-04 Thread bbayles

Change by bbayles :


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

___
Python tracker 

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



[issue30528] ipaddress.IPv{4,6}Network.reverse_pointer is broken

2018-02-04 Thread Cheryl Sabella

Change by Cheryl Sabella :


--
nosy: +pmoody

___
Python tracker 

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



[issue32620] [3.5] Travis CI fails on Python 3.5 with "pyenv: version `3.5' not installed"

2018-02-04 Thread Larry Hastings

Larry Hastings  added the comment:

I wanted it in 3.4 too, it was breaking CI.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior
versions: +Python 3.4

___
Python tracker 

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



[issue32620] [3.5] Travis CI fails on Python 3.5 with "pyenv: version `3.5' not installed"

2018-02-04 Thread Larry Hastings

Larry Hastings  added the comment:


New changeset 71b94e30b1d63c789908482b3b808cc613e57267 by larryhastings in 
branch '3.4':
[3.4] [3.5] bpo-32620: Remove failing pyenv call from CI config (GH-5274) 
(#5533)
https://github.com/python/cpython/commit/71b94e30b1d63c789908482b3b808cc613e57267


--

___
Python tracker 

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



[issue32753] ssl.SSLError exceptions in test_poplib

2018-02-04 Thread Christian Heimes

Christian Heimes  added the comment:

It's a duplicate of #32706. The new cert validation code causes the handshake 
to terminate properly. The old asyncore based test routine is not able to 
handle this correctly when the machine is under heavy load.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> test_check_hostname() of test_ftplib started to fail randomly

___
Python tracker 

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



[issue32767] Mutating a list while iterating: clarify the docs

2018-02-04 Thread Tim Peters

New submission from Tim Peters :

This has come up repeatedly, and the docs should be updated to resolve it:

https://stackoverflow.com/questions/48603998/python-iterating-over-a-list-but-i-want-to-add-to-that-list-while-in-the-loop/48604036#48604036

Seemingly the only relevant documentation is in the reference manual, but it's 
flawed:

https://docs.python.org/3.7/reference/compound_stmts.html#the-for-statement

- The behavior it's describing is specific to list iterators, but it pretends 
to apply to "mutable sequences" in general (which may or may not mimic list 
iterators in relevant respects).

- It's not clear that the "length of the sequence" (list!) is evaluated anew on 
each iteration (not, e.g., captured once at the start of the `for` loop).

- While it describes things that can go wrong, it doesn't describe the common 
useful case:  appending to a list during iteration (for example, in a 
breadth-first search).

--
assignee: docs@python
components: Documentation
messages: 311614
nosy: docs@python, tim.peters
priority: normal
severity: normal
stage: needs patch
status: open
title: Mutating a list while iterating:  clarify the docs
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



Re: Help on convert PyObject to string (c) Python 3.6

2018-02-04 Thread Jason Qian via Python-list
Hi Chris,

   Thanks a lot ! Using PyUnicode_DecodeUTF8 fix the problem.



On Sun, Feb 4, 2018 at 12:02 PM, Chris Angelico  wrote:

> On Mon, Feb 5, 2018 at 3:52 AM, Jason Qian via Python-list
>  wrote:
> > Hi,
> >
> >This is the case of calling python from c and the python function
> will
> > return a string.
> >
> >It seems python been called correctly, but got error when convert the
> > python string to c string.
> >
> > -- c --
> >
> >PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
> >
> >
> > -- python --
> >
> > import string, random
> > def StringGen(argv):
> > out_string_size=int(argv);
> > output_data=''.join(random.choice(string.ascii_lowercase) for x in
> > range(out_string_size))
> > return output_data
> >
> >
> > I try:
> >
> >  PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
> > const char* sp = 0;
> > if (!PyArg_ParseTuple(pValue, "s", )) {
> > }
> >
> > and got
> >
> > "SystemError: new style getargs format but argument is not a tuple"
> >
>
> You're using something that is specifically for parsing *arguments*
> (as indicated by the "PyArg" prefix). If you want to get a 'const char
> *' from a Python string, you probably want to encode it UTF-8. There's
> a convenience function for that:
>
> https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUTF8AndSize
>
> And if you know for sure that there won't be any \0 in the string, you
> can use the next function in the docs, which doesn't bother returning
> the size. (It'll always be null-terminated.)
>
> ChrisA
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32620] [3.5] Travis CI fails on Python 3.5 with "pyenv: version `3.5' not installed"

2018-02-04 Thread Larry Hastings

Change by Larry Hastings :


--
pull_requests: +5360

___
Python tracker 

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



[issue32764] Popen doesn't work on Windows when args is a list

2018-02-04 Thread Anders Lorentsen

Anders Lorentsen  added the comment:

Wait a minute. The failing test is test_nonexisting_with_pipes, and it fails 
because args[0] is a tuple - how can that be? Nobody is supposed to pass 
cmd=sequence-where-first-element-is-a-tuple!

Is everything all right with the test itself?

--

___
Python tracker 

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



[issue32766] 4.7.7. Function Annotations

2018-02-04 Thread John Hossbach

New submission from John Hossbach :

https://docs.python.org/3.5/tutorial/controlflow.html#function-annotations

The end of the first paragraph states, "The following example has a positional 
argument, a keyword argument, and the return value annotated:"

However, the only function call is f('spam') which has a single positional 
argument.

I believe the author was referencing the output of print("Annotations:", 
f.__annotations__) which was:
Annotations: {'ham': , 'return': , 'eggs': }

and then confused that with 4.7.2. Keyword Arguments 
(https://docs.python.org/3.5/tutorial/controlflow.html#keyword-arguments) where 
it points out that keyword arguments follow positional arguments.  However, the 
difference between identifying a positional argument vs keyword argument is 
done at the function CALL, not the function DEFINITION since any argument can 
be both positional or keyword, depending on how it is referenced.

Moreover, the last sentence in 4.7.2. Keyword Arguments, points out that the 
order of unsorted sequences is undefined, which would then explain why 'return' 
appears in the middle here instead of at the end.

--
assignee: docs@python
components: Documentation
messages: 311612
nosy: John Hossbach, docs@python
priority: normal
severity: normal
status: open
title: 4.7.7. Function Annotations
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



[issue31961] subprocess._execute_child doesn't accept a single PathLike argument for args

2018-02-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Actually this feature looks wrong to me. The args argument is either a sequence 
containing a program name and arguments, or a command line string. In the first 
case supporting path-like objects makes sense, and this was supported. But the 
command line is not a path-like object. It is a concatenation of quoted program 
name and arguments. Neither operation for path-like objects makes sense for a 
command line.

I think this change should be reverted.

--
status: closed -> open

___
Python tracker 

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



[issue32739] collections.deque rotate(n=1) default value not documented

2018-02-04 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
pull_requests: +5359

___
Python tracker 

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



[issue32739] collections.deque rotate(n=1) default value not documented

2018-02-04 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5358

___
Python tracker 

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



[issue32739] collections.deque rotate(n=1) default value not documented

2018-02-04 Thread miss-islington

Change by miss-islington :


--
pull_requests: +5357

___
Python tracker 

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



[issue32761] IDLE Keymap for Cntl-A

2018-02-04 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

That's interesting.  I've always thought of Control+A to be 'select all'.

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


Do you think a new keybinding theme should be added for bash/emacs?  I don't 
know how well emacs would work without allowing combinations like Control+X, 
Control-F.

--
nosy: +csabella

___
Python tracker 

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



[issue32764] Popen doesn't work on Windows when args is a list

2018-02-04 Thread Anders Lorentsen

Anders Lorentsen  added the comment:

Also, isn't there continuous integration testing? Everything passed on the PR, 
so where does this come from?

--

___
Python tracker 

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



[issue30569] Tutorial section 2.1 has *nix example at 3.7, but Windows at 3.6

2018-02-04 Thread Cheryl Sabella

Cheryl Sabella  added the comment:

This is still an issue.  Since it's more than updating the release version, I 
think someone more knowledgeable than me should fix it.  I wouldn't want to 
miss something that should be included.

--
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: Help on convert PyObject to string (c) Python 3.6

2018-02-04 Thread Chris Angelico
On Mon, Feb 5, 2018 at 3:52 AM, Jason Qian via Python-list
 wrote:
> Hi,
>
>This is the case of calling python from c and the python function  will
> return a string.
>
>It seems python been called correctly, but got error when convert the
> python string to c string.
>
> -- c --
>
>PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
>
>
> -- python --
>
> import string, random
> def StringGen(argv):
> out_string_size=int(argv);
> output_data=''.join(random.choice(string.ascii_lowercase) for x in
> range(out_string_size))
> return output_data
>
>
> I try:
>
>  PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
> const char* sp = 0;
> if (!PyArg_ParseTuple(pValue, "s", )) {
> }
>
> and got
>
> "SystemError: new style getargs format but argument is not a tuple"
>

You're using something that is specifically for parsing *arguments*
(as indicated by the "PyArg" prefix). If you want to get a 'const char
*' from a Python string, you probably want to encode it UTF-8. There's
a convenience function for that:

https://docs.python.org/3/c-api/unicode.html#c.PyUnicode_AsUTF8AndSize

And if you know for sure that there won't be any \0 in the string, you
can use the next function in the docs, which doesn't bother returning
the size. (It'll always be null-terminated.)

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


[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread Cheryl Sabella

Change by Cheryl Sabella :


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

___
Python tracker 

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



[issue32764] Popen doesn't work on Windows when args is a list

2018-02-04 Thread Anders Lorentsen

Anders Lorentsen  added the comment:

This is strange, because _execute_child calls os.fsdecode with `args` as the 
argument, which may be a list. os.fsdecode calls fspath. Now, the python 
docstring of _fspath, as defined in Lib/os.py on line 1031, clearly states that 
it will raise a TypeError if the argument is not of type bytes, str or is a 
os.PathLike object, and that's probably why I wrote the initial code the way I 
did (catching TypeError from os.fsdecode).

Doesn't the try-except block actually catch this TypeError? I don't understand 
off the top of my head why my code doesn't catch this exception..

--

___
Python tracker 

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



[issue32765] IDLE: Update configdialog docstrings to reflect extension integration

2018-02-04 Thread Cheryl Sabella

New submission from Cheryl Sabella :

The layout of the general tab changed with #27099, but the docstrings weren't 
updated with the new widgets.

--
assignee: terry.reedy
components: IDLE
messages: 311606
nosy: csabella, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE: Update configdialog docstrings to reflect extension integration
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



Help on convert PyObject to string (c) Python 3.6

2018-02-04 Thread Jason Qian via Python-list
Hi,

   This is the case of calling python from c and the python function  will
return a string.

   It seems python been called correctly, but got error when convert the
python string to c string.

-- c --

   PyObject* pValue = PyObject_CallObject(pFunc, pArgs);


-- python --

import string, random
def StringGen(argv):
out_string_size=int(argv);
output_data=''.join(random.choice(string.ascii_lowercase) for x in
range(out_string_size))
return output_data


I try:

 PyObject* pValue = PyObject_CallObject(pFunc, pArgs);
const char* sp = 0;
if (!PyArg_ParseTuple(pValue, "s", )) {
}

and got

"SystemError: new style getargs format but argument is not a tuple"



Thanks for the help
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue32739] collections.deque rotate(n=1) default value not documented

2018-02-04 Thread Raymond Hettinger

Change by Raymond Hettinger :


--
pull_requests: +5355
stage: resolved -> patch review

___
Python tracker 

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



[issue31961] subprocess._execute_child doesn't accept a single PathLike argument for args

2018-02-04 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
stage: needs patch -> 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



[issue30693] tarfile add uses random order

2018-02-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

Tests are failing on Windows.

==
ERROR: test_ordered_recursion (test.test_tarfile.Bz2WriteTest)
--
Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\unittest\mock.py", line 1191, in patched
return func(*args, **keywargs)
  File "C:\py\cpython3.7\lib\test\test_tarfile.py", line 1152, in 
test_ordered_recursion
support.unlink(os.path.join(path, "1"))
  File "C:\py\cpython3.7\lib\test\support\__init__.py", line 394, in unlink
_unlink(filename)
  File "C:\py\cpython3.7\lib\test\support\__init__.py", line 344, in _unlink
_waitfor(os.unlink, filename)
  File "C:\py\cpython3.7\lib\test\support\__init__.py", line 341, in _waitfor
RuntimeWarning, stacklevel=4)
RuntimeWarning: tests may fail, delete still pending for 
C:\py\cpython3.7\build\test_python_8504\@test_8504_tmp-tardir\directory\1

==
ERROR: test_directory_size (test.test_tarfile.GzipWriteTest)
--
Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\test\test_tarfile.py", line 1121, in 
test_directory_size
os.mkdir(path)
FileExistsError: [WinError 183] Cannot create a file when that file already 
exists: 
'C:\\py\\cpython3.7\\build\\test_python_8504\\@test_8504_tmp-tardir\\directory'

==
ERROR: test_ordered_recursion (test.test_tarfile.GzipWriteTest)
--
Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\unittest\mock.py", line 1191, in patched
return func(*args, **keywargs)
  File "C:\py\cpython3.7\lib\test\test_tarfile.py", line 1137, in 
test_ordered_recursion
os.mkdir(path)
FileExistsError: [WinError 183] Cannot create a file when that file already 
exists: 
'C:\\py\\cpython3.7\\build\\test_python_8504\\@test_8504_tmp-tardir\\directory'

==
ERROR: test_directory_size (test.test_tarfile.LzmaWriteTest)
--
Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\test\test_tarfile.py", line 1121, in 
test_directory_size
os.mkdir(path)
FileExistsError: [WinError 183] Cannot create a file when that file already 
exists: 
'C:\\py\\cpython3.7\\build\\test_python_8504\\@test_8504_tmp-tardir\\directory'

==
ERROR: test_ordered_recursion (test.test_tarfile.LzmaWriteTest)
--
Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\unittest\mock.py", line 1191, in patched
return func(*args, **keywargs)
  File "C:\py\cpython3.7\lib\test\test_tarfile.py", line 1137, in 
test_ordered_recursion
os.mkdir(path)
FileExistsError: [WinError 183] Cannot create a file when that file already 
exists: 
'C:\\py\\cpython3.7\\build\\test_python_8504\\@test_8504_tmp-tardir\\directory'

==
ERROR: test_directory_size (test.test_tarfile.WriteTest)
--
Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\test\test_tarfile.py", line 1121, in 
test_directory_size
os.mkdir(path)
FileExistsError: [WinError 183] Cannot create a file when that file already 
exists: 
'C:\\py\\cpython3.7\\build\\test_python_8504\\@test_8504_tmp-tardir\\directory'

==
ERROR: test_ordered_recursion (test.test_tarfile.WriteTest)
--
Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\unittest\mock.py", line 1191, in patched
return func(*args, **keywargs)
  File "C:\py\cpython3.7\lib\test\test_tarfile.py", line 1137, in 
test_ordered_recursion
os.mkdir(path)
FileExistsError: [WinError 183] Cannot create a file when that file already 
exists: 
'C:\\py\\cpython3.7\\build\\test_python_8504\\@test_8504_tmp-tardir\\directory'

--

--
stage: patch review -> needs patch

___
Python tracker 

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



[issue32764] Popen doesn't work on Windows when args is a list

2018-02-04 Thread Serhiy Storchaka

New submission from Serhiy Storchaka :

test_subprocess is failing on Windows.

C:\py\cpython3.7>./python -m test -uall -v -m test_nonexisting_with_pipes 
test_subprocess
Running Debug|Win32 interpreter...
== CPython 3.7.0b1+ (heads/3.7:1a0239e, Feb 4 2018, 16:19:37) [MSC v.1911 32 
bit (Intel)]
== Windows-10-10.0.16299-SP0 little-endian
== cwd: C:\py\cpython3.7\build\test_python_11092
== CPU count: 2
== encodings: locale=cp1251, FS=utf-8
Run tests sequentially
0:00:00 [1/1] test_subprocess
test_nonexisting_with_pipes (test.test_subprocess.ProcessTestCase) ... FAIL
test_nonexisting_with_pipes (test.test_subprocess.ProcessTestCaseNoPoll) ... 
skipped 'Test needs selectors.PollSelector'

==
FAIL: test_nonexisting_with_pipes (test.test_subprocess.ProcessTestCase)
--
Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\test\test_subprocess.py", line 1194, in 
test_nonexisting_with_pipes
self.assertEqual(stderr, "")
AssertionError: 'Traceback (most recent call last):\n  Fil[923 chars]le\n' != ''
Diff is 965 characters long. Set self.maxDiff to None to see it.

--
Ran 2 tests in 0.171s

FAILED (failures=1, skipped=1)
test test_subprocess failed
test_subprocess failed

1 test failed:
test_subprocess

Total duration: 391 ms
Tests result: FAILURE


Here stderr is:

Traceback (most recent call last):
  File "C:\py\cpython3.7\lib\subprocess.py", line 1101, in _execute_child
args = os.fsdecode(args)  # os.PathLike -> str
  File "C:\py\cpython3.7\\lib\os.py", line 821, in fsdecode
filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not list

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "", line 16, in 
  File "C:\py\cpython3.7\lib\subprocess.py", line 756, in __init__
restore_signals, start_new_session)
  File "C:\py\cpython3.7\lib\subprocess.py", line 1104, in _execute_child
args[0] = os.fsdecode(args[0])  # os.PathLike -> str
  File "C:\py\cpython3.7\\lib\os.py", line 821, in fsdecode
filename = fspath(filename)  # Does type-checking of `filename`.
TypeError: expected str, bytes or os.PathLike object, not tuple

In _execute_child args is passed to os.fsdecode() unless it is a string. In 
this case args is a list. os.fsdecode() doesn't accept a list.

The regression was introduced in issue31961.

--
components: Library (Lib), Windows
messages: 311603
nosy: Phaqui, gregory.p.smith, paul.moore, serhiy.storchaka, steve.dower, 
tim.golden, zach.ware
priority: normal
severity: normal
stage: needs patch
status: open
title: Popen doesn't work on Windows when args is a list
type: behavior
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



[issue31961] subprocess._execute_child doesn't accept a single PathLike argument for args

2018-02-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

This made tests failing on Windows. See issue32764.

--
nosy: +serhiy.storchaka
stage: commit review -> needs patch
status: closed -> open

___
Python tracker 

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



[issue31851] test_subprocess hangs randomly on Windows with Python 3.x

2018-02-04 Thread Serhiy Storchaka

Serhiy Storchaka  added the comment:

When ran tests in 3.8 on Windows I got a number of dialpog windows with the 
following text:

---
Microsoft Visual C++ Runtime Library
---
Debug Assertion Failed!

Program: C:\py\cpython3.8\PCBuild\win32\python_d.exe
File: minkernel\crts\ucrt\src\appcrt\lowio\osfinfo.cpp
Line: 258

Expression: _osfile(fh) & FOPEN

For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.

(Press Retry to debug the application)

And tests are hung.

When ran tests in 3.7 on Windows I got multiple messages 
"minkernel\crts\ucrt\src\appcrt\lowio\write.cpp(49) : Assertion failed: 
(_osfile(fh) & FOPEN)" on output. This may be related.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue32763] write() method in Transport should not buffer data

2018-02-04 Thread Andrew Svetlov

Andrew Svetlov  added the comment:

Transport buffers writes if kernel buffer is full, the behavior is intentional 
and present starting from very beginning of asyncio development.

Moreover, two plain socket.send() calls can be joined into single TCP packet, 
TCP protocol is a STREAM of data by design, not a sequence of packets.

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

___
Python tracker 

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



[issue32763] write() method in Transport should not buffer data

2018-02-04 Thread Boss Kwei

New submission from Boss Kwei :

write() method implemented in 
https://github.com/python/cpython/blob/master/Lib/asyncio/selector_events.py#L830
 is not stable in somecases. If this method was called too quickly, separate 
data will be packed and sent in same tcp package, which may be considered as 
unexpected behavior.

--
components: asyncio
messages: 311600
nosy: Boss Kwei, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: write() method in Transport should not buffer data
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



[issue32227] singledispatch support for type annotations

2018-02-04 Thread Ivan Levkivskyi

Ivan Levkivskyi  added the comment:

> Do you think it should be added to the What's New? page for 3.7?

I leave this up to Łukasz.

--

___
Python tracker 

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



Re: 2.6.7: Does socket.gethostbyaddr truncate?

2018-02-04 Thread Chris Angelico
On Tue, Jan 30, 2018 at 11:05 PM, Antoon Pardon  wrote:
> I am using python 2.6.7 to do a little network programming, but it seems I 
> don't
> get all the results.
>
> When I call socket.gethostbyaddr(IP) entry [1] of the result is a list of 34 
> addresses.
>
> However when I use: dig -x IP I get a list of 46 addresses.
>
> Am I using the wrong function? Is this a bug? If the latter, is there a work 
> around?
>

Can you post the full output of dig? Maybe it's switched to TCP.

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


Re: Why not have a recvall method?

2018-02-04 Thread 陶青云
makefile('rb') return a  io.BufferedReader and the 
doc(https://docs.python.org/3/library/io.html#io.BufferedIOBase.read) says:
If the argument is positive, and the underlying raw stream is not 
interactive, multiple raw reads may be issued to satisfy the byte count (unless 
EOF is reached first).

 
-- Original --
From:  "Steven D'Aprano";
Date:  Sun, Feb 4, 2018 09:31 PM
To:  "python-list";
Subject:  Re: Why not have a recvall method?
 
On Sun, 04 Feb 2018 19:26:36 +0800, 陶青云 wrote:

> Hello, allThe socket object has a `sendall` method that can send all
> bytes you specified. Oppositely, socket only has a recv method. I wonder
> why there is not a `recvall` method? To workaround this, I use `f =
> socket.makefile('rb')`, then `call f.read(n)` Thanks.

I am not an expert on sockets, but since f.read(n) will read a maximum of 
n bytes, isn't that the same as socket_obj.recv(n)?



-- 
Steve

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


Re: Why not have a recvall method?

2018-02-04 Thread Steven D'Aprano
On Sun, 04 Feb 2018 19:26:36 +0800, 陶青云 wrote:

> Hello, allThe socket object has a `sendall` method that can send all
> bytes you specified. Oppositely, socket only has a recv method. I wonder
> why there is not a `recvall` method? To workaround this, I use `f =
> socket.makefile('rb')`, then `call f.read(n)` Thanks.

I am not an expert on sockets, but since f.read(n) will read a maximum of 
n bytes, isn't that the same as socket_obj.recv(n)?



-- 
Steve

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


Why not have a recvall method?

2018-02-04 Thread 陶青云
Hello, all  
The socket object has a `sendall` method that can send all bytes you specified. 
 
Oppositely, socket only has a recv method. I wonder why there is not a 
`recvall` method?  
To workaround this, I use `f = socket.makefile('rb')`, then all `f.read(n)` 
Thanks.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30688] support named Unicode escapes (\N{name}) in re

2018-02-04 Thread Serhiy Storchaka

Change by Serhiy Storchaka :


--
versions: +Python 3.8 -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: 2.6.7: Does socket.gethostbyaddr truncate?

2018-02-04 Thread Emil Natan
On Sat, Feb 3, 2018 at 1:11 PM, Peter J. Holzer  wrote:

> On 2018-01-30 08:56:16 -0800, Dan Stromberg wrote:
> > dig -x should return a single PTR in all cases, shouldn't it?
>
> No. dig -x should return *all* PTR records. There is usually at most one
> of them, but there may be several. (46 seems a bit much, but there
> really isn't any limit).
>
> > What IP are you using?
>
> Yup. I want to see an address with 46 PTR records, too ;-).
>
> > On Tue, Jan 30, 2018 at 4:05 AM, Antoon Pardon 
> wrote:
> > > I am using python 2.6.7 to do a little network programming, but it
> seems I don't
> > > get all the results.
> > >
> > > When I call socket.gethostbyaddr(IP) entry [1] of the result is a list
> of 34 addresses.
>
> gethostbyaddr just calls the underlying C library function. It is
> possibly that this has a limit (either on the number of names or more
> likely on the packet size).
>
> 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 
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
>
I would guess it's the packet size limitation. Using EDNS0 you can have
packet size of up 4096 bytes, but it's the underlying IP protocol which
limits further the amount of data in a single packet. Given the 20 bytes
IPv4 header and 8 bytes DNS header, that leaves 1472 bytes for data. Bigger
payload leads to IP fragmentation which in many cases is blocked by
firewalls or other network devices on the way.

In your case dig -x runs on the same machine where the Python code runs? If
yes, then it's not network issue.

What's the size of the response containing 34 addresses? What's the size of
the response from dig when all 46 addresses are returned?

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


  1   2   >