[issue26103] Contradiction in definition of "data descriptor" between (dotted lookup behavior/datamodel documentation) and (inspect lib/descriptor how-to)

2017-06-07 Thread Aaron Hall

Aaron Hall added the comment:

I tweaked the docs a little more this morning, but I believe I am done making 
any further changes unless so requested.

This issue doesn't say it's assigned to anyone. Is there anything else that 
needs to happen here?

--

___
Python tracker 

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



Re: Access flles on a Android device from Windows PC << YES! Thanks

2017-06-07 Thread Fred Fishbin
Yup, that seems to be the deal, and there doesn't seem tpo be a really simple 
way to deal with this.  ...but at least I know what I need to look for.

thanks!  Freddie

eryk sun  wrote:
>On Tue, Jun 6, 2017 at 7:36 PM, Fred Fishbin  wrote:
>>
>> I want to write little program that my friend can run - he'll plug a USB 
>>drive
>> into his Windows 7 PC, plug his phone in a USB port on same PC, then run my
>> program and it'll xfer some audiobook files over for him.
>>
>> I plugged the USB drive in and it became "G:\", but the phone plugged in and
>> became just "SAMSUNG-SM-G930V", no drive designation, just a Portable Media
>> Device.  Windows Explore can go there so the files are accessible, the phone
>> isn't looking him out, but what do I use for a path?  I tried several 
>>different
>> listdir()'s nothing worked.
>
>The shell is probably mounting the device via the Windows Portable
>Devices (WPD) API. It isn't mounted as a USB disk with a file system,
>so it won't be assigned a drive letter that you can simply use via
>file-system APIs such as open (CreateFile), listdir (FindFirstFile),
>etc. You can look into using WPD Automation via win32com [1]. I
>haven't used WPD, so I can't offer specific help.
>
>https://msdn.microsoft.com/library/dd389295

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


Re: Hello from a super noob!

2017-06-07 Thread Steve D'Aprano
On Thu, 8 Jun 2017 09:56 am, CB wrote:

> Can anyone try to run it?


Yes, you can.

Doctor to patient: "So, what seems to be the problem?"

Patient: "You're the doctor, you tell me."




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

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


Re: New to Python - Career question

2017-06-07 Thread Matt
On Tuesday, June 6, 2017 at 3:37:56 PM UTC-7, Marko Rauhamaa wrote:
> pta...@gmail.com:
> 
> > New to Python and have been at it for about a month now. I'm doing
> > well and like it very much. Considering a career change down the road
> > and have been wondering... What are the job prospects for a middle age
> > entry level programmer. Just trying to get a better understanding
> > where I stand career wise. Appreciate all feed back. Thanks!
> 
> Different employers hire differently. I have hired several people for my
> employer, and age has never been a concern. Python is also an important
> tool where I work.
> 
> However, the problem in our field is that you have to be quite good to
> be truly useful. Unfortunately, it seems that only a minority with a
> formal degree are good enough. On the other hand, I work with some great
> software developers who don't have a degree at all.
> 
> One good way to become a good developer and also test oneself is to pick
> a free software project online a become a contributor. Your commit log
> entries on GitHub advertise you much better than any pretty-printed
> résumé.
> 
> 
> Marko



Marko,

Thanks, appreciate your input.  I'll check out Github and follow your 
suggestions.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30589] With forkserver, Process.exitcode does not get signal number

2017-06-07 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
pull_requests: +2055

___
Python tracker 

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



Re: Hello from a super noob!

2017-06-07 Thread MRAB

On 2017-06-08 00:56, CB wrote:

Hi everyone,
I am taking a python class and I'm stuck in an exercise.

what am i doing wrong? Can anyone try to run it? Thanks so much!

#Description:Input validation and while loops.


import random
def main(): #main function need in all programs for automated testing
 


 #your program goes here
 
 print()




 
 print("This program will help us practice input validation and while loops.")

 print("The user will be asked to enter two numbers which will both be 
validated. ")
 print("The sum of the numbers will then be displayed in a complex print 
statement ")
 print("and the user will be asked if they would like to run the program 
again."
)
 print()
 print()
 
 while True:

 FirstNumber = input ("Please enter the first number: ")
 if FirstNumber.isdigit ():
 FirstNumber = int(FirstNumber)
 break
 else:
   print ("Invalid response. Please enter a whole number. " )
 
 while True:
 
 SecondNumber = input ("Please enter the second number: " )

 if SecondNumber.isdigit():
 SecondNumber= int(SecondNumber)

 break
 else:
 print("Invalid response. Please enter a whole number." )
 
 print()

 print (str(FirstNumber) + " + " + str(SecondNumber)+ " = " + 
str(FirstNumber + SecondNumber))
 print()
 
 while True:
 
 ans= input('Would you like to run the program again (Y/N) : ')

 if ans== 'Y' or ans== 'N':
 break

 else:
 print(" lnvalid response. Please answer with 'Y' or 'N' ")

 if ans== 'N':
 break
   


You haven't said what the problem is.

It looks OK, apart from the indentation, which is important to get right 
in Python.


Also, you've defined a function 'main' but not called it, and imported a 
module but not used it, which is pointless.

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


[issue30589] With forkserver, Process.exitcode does not get signal number

2017-06-07 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
stage:  -> patch review

___
Python tracker 

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



Hello from a super noob!

2017-06-07 Thread CB
Hi everyone,
I am taking a python class and I'm stuck in an exercise.

what am i doing wrong? Can anyone try to run it? Thanks so much! 

#Description:Input validation and while loops.


import random
def main(): #main function need in all programs for automated testing


#your program goes here

print()




print("This program will help us practice input validation and while 
loops.")
print("The user will be asked to enter two numbers which will both be 
validated. ")
print("The sum of the numbers will then be displayed in a complex print 
statement ")
print("and the user will be asked if they would like to run the program 
again."
)
print()
print()

while True:
FirstNumber = input ("Please enter the first number: ")
if FirstNumber.isdigit ():
FirstNumber = int(FirstNumber)
break 
else:
  print ("Invalid response. Please enter a whole number. " )

while True:

SecondNumber = input ("Please enter the second number: " )
if SecondNumber.isdigit():
SecondNumber= int(SecondNumber)

break
else:
print("Invalid response. Please enter a whole number." )

print()
print (str(FirstNumber) + " + " + str(SecondNumber)+ " = " + 
str(FirstNumber + SecondNumber))
print()

while True:

ans= input('Would you like to run the program again (Y/N) : ')
if ans== 'Y' or ans== 'N':
break

else:
print(" lnvalid response. Please answer with 'Y' or 'N' ")

if ans== 'N':
break
  

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


[issue30581] os.cpu_count() returns wrong number of processors on system with > 64 logical processors

2017-06-07 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Nobody has AFAIK.

--

___
Python tracker 

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



[issue30593] sqlite3 executescript does not respect isolation_level?

2017-06-07 Thread Noah Levitt

New submission from Noah Levitt:

As far as I can tell, sqlite3 executescript() does not respect isolation_level. 
Is that true? If so, I think it's worth mentioning in the doc. Or maybe it 
should respect isolation_level, not sure there's any particular reason not to.

--
components: Library (Lib)
messages: 295376
nosy: Noah Levitt
priority: normal
severity: normal
status: open
title: sqlite3 executescript does not respect isolation_level?
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



[issue30579] Allow traceback objects to be instantiated/mutated/annotated

2017-06-07 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
stage:  -> needs patch

___
Python tracker 

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



Time Calculation to Tag a Sentence/File

2017-06-07 Thread subhabangalore
I am trying to calculate the time required to tag one sentence/file by one 
trained NLTK HMM Tagger.
To do this I am writing the following code, please suggest if I need to revise 
anything here.

import nltk
from nltk.corpus.reader import TaggedCorpusReader
import time
#HMM 
reader = TaggedCorpusReader('/python27/', r'.*\.pos')
f1=reader.fileids()
print f1
sents=reader.tagged_sents()
ls=len(sents)
print "Total No of Sentences:",ls
train_sents=sents[0:40]
test_sents=sents[41:46]
#TRAINING & TESTING
hmm_tagger=nltk.HiddenMarkovModelTagger.train(train_sents)
test=hmm_tagger.test(test_sents)
appli_sent1=reader.sents(fileids='minicv.pos')[0]
print "SAMPLE INPUT:",appli_sent1
#TIME CALCULATION 
start_time = time.clock()
application=hmm_tagger.tag(appli_sent1) #I MAY REPLACE WITH ONE DOCUMENT 
print "ENTITY RECOGNIZED",application 
print "Time Taken Is:",time.clock() - start_time, "seconds"

NB: This is a toy kind example and I did not follow much of training/testing 
size parameters. 

My question is only for the time calculation part. It is not a forum for 
Machine Learning, but as there are many people who has very high level 
knowledge on it, any one is most welcome to give his/her valuable feedback 
which may improve my knowledge. 

As the code is pasted here from IDLE (with Python2.7 on MS-Windows 7) I could 
not maintain proper indentation, apology for the same. 
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30542] test_files() of test_tools.test_unparse.DirectoryTestCase leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

Attached test_unparse.py file should be copied to 
Lib/test/test_tools/test_unparse.py to run:

./python -m test -R 1:2 -m test_files test_tools

With this change, I get this output:
---
haypo@selma$ ./python -m test -R 1:2 -m test_files test_tools
Run tests sequentially
0:00:00 load avg: 0.12 [1/1] test_tools
beginning 3 repetitions
123
...
test_tools leaked [6, 19] references, sum=25
test_tools leaked [3, 5] memory blocks, sum=8
test_tools failed

1 test failed:
test_tools

Total duration: 223 ms
Tests result: FAILURE
---

--
Added file: http://bugs.python.org/file46931/test_unparse.py

___
Python tracker 

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



[issue1207613] Idle Editor: Bottom Scroll Bar

2017-06-07 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Output Window definitely needs a scrollbar available on screens where it cannot 
be stretched to 160 chars or so.  Thinking about it, if one greps idlelib in a 
local install, with a url something like 
C:/users/somename/appdata/local/python/lib/idlelib/*.py, one only needs 100 
chars to pick up the idlelib file name and code, but needs the scrollbar to 
display the last 100 chars instead of the first 100 chars.

To add to msg16443: the fact that one can stretch the window much wider than 80 
chars means that omitting a scrollbar does not enforce an 80-char limit.

--

___
Python tracker 

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



[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for catching this bug SylvainDe. This is a regression caused by 
issue30534. I added "()" after the function name for unifying with other error 
messages but missed that _PyArg_NoKeywords() often is called with argument 
containing "()", e.g. _PyArg_NoKeywords("bool()", kwds).

There are two ways to solve this issue:

1. Remove "()" from all calls of _PyArg_NoKeywords(), _PyArg_NoStackKeywords() 
and _PyArg_NoPositional() and let these functions to add "()" automatically. 
This will change almost all manually calls of _PyArg_NoKeywords(). And may be 
in some cases "()" shouldn't be added.

2. Make _PyArg_NoKeywords(), _PyArg_NoStackKeywords() and _PyArg_NoPositional() 
not adding "()" automatically, but always pass a name with "()" if it is 
needed. Argument Clinic should be changed to add "()" in arguments of these 
functions. This is large patch, but mostly generated.

I don't know what the way is better.

--

___
Python tracker 

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



[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread SylvainDe

SylvainDe added the comment:

The issue seems to be in:

int
_PyArg_NoKeywords(const char *funcname, PyObject *kwargs)


I'm happy to submit a PR if needed.

--

___
Python tracker 

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



[issue30542] test_files() of test_tools.test_unparse.DirectoryTestCase leaks references

2017-06-07 Thread STINNER Victor

Changes by STINNER Victor :


--
keywords:  -easy (C)

___
Python tracker 

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



[issue30542] test_files() of test_tools.test_unparse.DirectoryTestCase leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

Sorry, I tagged the issue too early as "[EASY]" while it's a super complex 
bug... I'm unable to say if the issue is a real leak or not...

--
title: [EASY] test_files() of test_tools.test_unparse.DirectoryTestCase leaks 
references -> test_files() of test_tools.test_unparse.DirectoryTestCase leaks 
references

___
Python tracker 

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



[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread SylvainDe

SylvainDe added the comment:

Reproduced locally using unit tests:

+def test_varargs0_kw(self):
+msg = r"bool\(\) takes no keyword arguments"
+self.assertRaisesRegex(TypeError, msg, bool, x=2)
+


giving:

Traceback (most recent call last):
  File "/home/josay/Geekage/PythonRgr/cpython/Lib/test/test_call.py", line 136, 
in test_varargs0_kw
self.assertRaisesRegex(TypeError, msg, bool, x=2)
AssertionError: "bool\(\) takes no keyword arguments" does not match "bool()() 
takes no keyword arguments"

--

___
Python tracker 

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



Re: Error in initialization of IDLE.

2017-06-07 Thread Terry Reedy

On 6/7/2017 7:59 AM, Mohit Soni via Python-list wrote:


I have python 3.5.2 installed and recently I installed python 3.6 and after 
installing the problem seems to occur.


What OS are you using?
Did IDLE run correctly before adding 3.6?
How did you start IDLE?


Whenever I start IDLE it shows an error message like "IDLE can't create a sub 
process or windows firewall might be blocking it"


See https://bugs.python.org/issue25514#msg258498 for at least 7 possible 
causes.



--
Terry Jan Reedy

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


[issue25514] Improve IDLE's "subprocess didn't make connection" message

2017-06-07 Thread Terry J. Reedy

Terry J. Reedy added the comment:

#26413 is about fixing shadowing problem.

Current thought for this issue: add a section to IDLE doc listing known 
possible causes (message above).  Reference section in message, giving web link.

--

___
Python tracker 

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



[issue30591] textwrap: placeholder backtracking special case lacks test coverage

2017-06-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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



[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> serhiy.storchaka
components: +Interpreter Core
nosy: +serhiy.storchaka
type: enhancement -> behavior
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



[issue30591] textwrap: placeholder backtracking special case lacks test coverage

2017-06-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 5edf827c8052958b9d293f75ce8d93b66c1d58da by Serhiy Storchaka 
(Jonathan Eunice) in branch 'master':
bpo-30591: Added test for textwrap backtracking. (#1988)
https://github.com/python/cpython/commit/5edf827c8052958b9d293f75ce8d93b66c1d58da


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue30542] [EASY] test_files() of test_tools.test_unparse.DirectoryTestCase leaks references

2017-06-07 Thread Nikhil Patel

Nikhil Patel added the comment:

I'd like to respectfully disagree with the suggestions/conclusions mentioned 
here. I'll explain my reasoning and conclusions below.

First the short version - I'm fairly confident the leak actually has to do 
with: 
https://github.com/python/cpython/blob/master/Lib/test/test_tools/test_unparse.py#L282


my approach:

It was initially implied that we can begin to pinpoint the leak from within the 
test_files() method in test_tools.test_unparse.DirectoryTestCase.

I ran the tests using the command:
python_d -m test -R 3:3 test_tools.test_unparse -m test_files

I had test_files() print the files selected in line 282 (and limited sample 
size to 1).

Result:
(note: i shortened printed pathnames manually after the fact, as it printed the 
absolute paths)

python_d -m test -R 3:3 test_tools.test_unparse -m test_files
Run tests sequentially
0:00:00 [1/1] test_tools.test_unparse
Testing cpython\Lib\test\test_spwd.py
beginning 6 repetitions
123456
Testing cpython\Lib\copy.py
.Testing cpython\Lib\test\test_isinstance.py
.Testing cpython\Lib\test\test_bytes.py
.Testing cpython\Lib\test\test_csv.py
.Testing cpython\Lib\test\test_dynamic.py
.Testing cpython\Lib\test\test_xml_etree.py
.
test_tools.test_unparse leaked [3, 0, 13] references, sum=16
test_tools.test_unparse leaked [6, 2, 4] memory blocks, sum=12
test_tools.test_unparse failed

1 test failed:
test_tools.test_unparse

Total duration: 4 sec
Tests result: FAILURE

Then I made a slight modification: I replaced random.sample(names,1) on line 
282 with a list containing the absolute paths to each of those files it tested 
in the run I described above. That means each of those files would be loaded, 
compiled and their tests run 6 times.

Result:

python_d -m test -R 3:3 test_tools.test_unparse -m test_files
Run tests sequentially
0:00:00 [1/1] test_tools.test_unparse
beginning 6 repetitions
123456
..
1 test OK.

Total duration: 24 sec
Tests result: SUCCESS


Conclusion:
If the same source files are being read, compiled, and their tests run - with 
different results - then I do not believe the leak can be associated with the 
self.checkRoundTrip() method or the compile() method


I don't have an in-depth explanation why this is the case. But removing the 
call to random.sample() fixes the issue, I am reasonably sure of it. 

I presume to say this because I commented out lines 280-282 and instead I made 
it instead iterate through subsets of size 50 using slicing (so names[:50] etc) 
in line 284. I went through the entire set of files, 50 at a time. All ran 
successfully.

--
nosy: +npatel

___
Python tracker 

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



!RE: Namedtuple problem #32.11.d

2017-06-07 Thread Deborah Swanson
Neil Cerutti wrote, on Wednesday, June 07, 2017 10:36 AM
> 
> On 2017-06-06, Deborah Swanson  wrote:
> >> I too have sometimes started with a namedtuple and then found I 
> >> needed to make changes to the records. I typically abandon 
> namedtuple 
> >> at this point, after only one bad experience trying to 
> work around my 
> >> choice of container.
> >
> > I can appreciate that reaction.
> >
> > Guess I'm a bit of a bulldog though (right ot wrong), and the
concept 
> > of namedtuples is so ideally suited for the Excel spreadsheet 
> > conversions I'm working on, I'll keep on pushing the boundaries to
see 
> > how they can be made to work.  ;)
> 
> The namedtuple has found a happy place in my repertoire as 
> the return value of functions that transform external 
> read-only tabular data into a convenient form for lookup.
> 
> I agree pushing a language feature beyond its preferable use 
> cases is a good way to learn concepts and illuminate dark 
> corners of both my own skill and Python's features.

I certainly have learned a lot by doing exactly that. Sometimes it isn't
so much people giving the solution to a problem, though that's
definitely to the good, but the alternate solutions that are proposed
can also be highly instructive.

> An Excel spreadsheet that represents a table of data is 
> fairly simple to map onto a Python dict. One nearly codeless 
> way is to export it from Excel as a csv file and then read it 
> with csv.DictReader.
> 
> -- 
> Neil Cerutti

csv.DictReader! I didn't know there was one! I've been thinking about
how a spreadsheet could be put into a dict, but wasn't quite coming up
with a good way. But a csv.DictReader would be perfect, and I imagine
the keys would be the column names, which is also perfect.

Thanks for the lead on csv.DictReader. I suppose if I'd known one
existed it would be easy to find, but when you don't know, and you don't
think of it...

Deborah

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


[issue30592] Bad error message 'bool()() takes no keyword arguments'

2017-06-07 Thread SylvainDe

New submission from SylvainDe:

Very recent "regression". Issue found because of a pet project trying to parse 
error messages using regexps : more on 
https://github.com/SylvainDe/DidYouMean-Python/issues/31 .

On recent Cron builds on Jenkins, running the following code

bool(this_doesnt_exist=2)

fails with the following error message

'bool()() takes no keyword arguments'

instead of the expected error message

'bool() takes no keyword arguments'.


Having a quick look at the recent commits, I suspect with no guarantee 
whatsoever the issue got introduced with 
https://github.com/python/cpython/commit/5eb788bf7f54a8e04429e18fc332db858edd64b6
 / http://bugs.python.org/issue30534 .

I haven't tried to reproduce the issue locally yet and add the findinds if any 
later on.

--
messages: 295366
nosy: SylvainDe
priority: normal
severity: normal
status: open
title: Bad error message 'bool()() takes no keyword arguments'
type: enhancement

___
Python tracker 

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



[issue30591] textwrap: placeholder backtracking special case lacks test coverage

2017-06-07 Thread Jonathan Eunice

Changes by Jonathan Eunice :


--
pull_requests: +2054

___
Python tracker 

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



[issue30581] os.cpu_count() returns wrong number of processors on system with > 64 logical processors

2017-06-07 Thread Chris Wilcox

Chris Wilcox added the comment:

I am going to work on this if no one else has started.

--
nosy: +crwilcox

___
Python tracker 

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



[issue29981] Update Index for set, dict, and generator 'comprehensions'

2017-06-07 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


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



Re: Generator and return value

2017-06-07 Thread Ian Kelly
On Wed, Jun 7, 2017 at 10:00 AM, Rob Gaddi
 wrote:
>
> On 06/06/2017 11:13 PM, Frank Millman wrote:
>>
>> Hi all
>>
>> It would be nice to write a generator in such a way that, in addition to
'yielding' each value, it performs some additional work and then 'returns'
a final result at the end.
>>
>>> From Python 3.3, anything 'returned' becomes the value of the
StopIteration
>>
>> exception, so it is possible, but not pretty.
>>
>> Instead of -
>> my_gen = generator()
>> for item in my_gen():
>> do_something(item)
>> [how to get the final result?]
>>
>> you can write -
>> my_gen = generator()
>> while True:
>> try:
>> item = next(my_gen())
>> do_something(item)
>> except StopIteration as e:
>> final_result = e.value
>>
>> Is this the best way to achieve it, or is there a nicer alternative?
>>
>> Thanks
>>
>> Frank Millman
>
> class MyGeneration:
>   def __iter__(self):
> yield from ('people', 'try', 'to', 'put', 'us', 'down')
> self.final = 'talking about'
>
> mygen = MyGeneration()
> for item in mygen:
>   print(item)
> print(mygen.final)


Or as a generic wrapper:

class CaptureValue:
  def __init__(self, iterable):
self._iter = iter(iterable)

  def __iter__(self):
return self

  def __next__(self):
try:
  return next(self._iter)
except StopIteration as e:
  self.value = e.value
  raise

capture = CaptureValue(generator())
print(list(capture))
print(capture.value)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30590] str.format no longer accepts unpacked defaultdict for default values

2017-06-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There was a bug (see issue18531). It was fixed in 3.6.

Use str.format_map() for formatting with arbitrary mapping.

--
nosy: +serhiy.storchaka
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



[issue28686] py.exe ignored PATH when using python3 shebang

2017-06-07 Thread Riccardo Polignieri

Riccardo Polignieri added the comment:

@Jens Lindgren

I know, pretty annoying right? But see previous answer by Paul here 
http://bugs.python.org/issue28686#msg287181

> The Unix ability to have 2 different versions of Python on PATH 
> and select which you use based on executable name doesn't exist 
> on Windows, and so there's no equivalent of the 
> Unix "#!/usr/bin/env pythonX[.Y]"

Now if you ask me, I would expect py.exe to handle all common types of shebang 
you may find in the wild. 
But I assume that the correct answer instead is that "#!/usr/bin/env 
pythonX[.Y]" is not a portable shebang, and you just should stop using it. If 
you happen to find such a shebang in someone else's script, file a bug report 
there.

--

___
Python tracker 

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



[issue30353] ctypes: pass by value for structs broken on Cygwin/MinGW 64-bit

2017-06-07 Thread Vinay Sajip

Vinay Sajip added the comment:


New changeset 9ba3aa4d02a110d1a1ea464a8aff3be7dd9c63c3 by Vinay Sajip (Erik 
Bray) in branch 'master':
bpo-30353: Fix pass by value for structs on 64-bit Cygwin/MinGW (GH-1559)
https://github.com/python/cpython/commit/9ba3aa4d02a110d1a1ea464a8aff3be7dd9c63c3


--

___
Python tracker 

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



Re: Namedtuple problem #32.11.d

2017-06-07 Thread Neil Cerutti
On 2017-06-06, Deborah Swanson  wrote:
>> I too have sometimes started with a namedtuple and then found
>> I needed to make changes to the records. I typically abandon
>> namedtuple at this point, after only one bad experience trying
>> to work around my choice of container.
>
> I can appreciate that reaction.
>
> Guess I'm a bit of a bulldog though (right ot wrong), and the
> concept of namedtuples is so ideally suited for the Excel
> spreadsheet conversions I'm working on, I'll keep on pushing
> the boundaries to see how they can be made to work.  ;)

The namedtuple has found a happy place in my repertoire as the
return value of functions that transform external read-only
tabular data into a convenient form for lookup.

I agree pushing a language feature beyond its preferable use
cases is a good way to learn concepts and illuminate dark corners
of both my own skill and Python's features.

An Excel spreadsheet that represents a table of data is fairly
simple to map onto a Python dict. One nearly codeless way is to
export it from Excel as a csv file and then read it with
csv.DictReader.

-- 
Neil Cerutti

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


Re: Bug or intended behavior?

2017-06-07 Thread Chris Angelico
On Thu, Jun 8, 2017 at 2:27 AM, Peter Pearson  wrote:
> More seriously, I thought "format" was the Cool New Thing toward which
> all the cool kids were moving.  But here I tried to be cool and put in a
> plug for "format", and the hip community seems to be sticking up for
> "%".  Can I never get with the times?

The times aren't moving. Both percent formatting and .format are here
to stay. Python is not JavaScript, and you don't have to "move with
the times"; we don't have eight major versions in seven years, or four
in five years, or ten in... I don't know how many years, but it's an
npm-installable module, so not more than seven or eight.

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


[issue30584] test_os fails on non-English (Russian) Windows

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

I merged your fix. Thanks!

Let's wait for Windows buildbots. If tests pass on buildbots, the change should 
be backported to other branches impacted by the bug.

http://buildbot.python.org/all/waterfall?category=3.x.stable=3.x.unstable

--

___
Python tracker 

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



[issue30177] pathlib.resolve(strict=False) only includes first child

2017-06-07 Thread Steve Dower

Steve Dower added the comment:

Good point about not needing 3.5.

Buildbots were clean, so I merged it. Thanks Antoine!

--
resolution:  -> fixed
stage: backport needed -> resolved
status: open -> closed
versions:  -Python 3.5

___
Python tracker 

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



Re: Bug or intended behavior?

2017-06-07 Thread Skip Montanaro
On Wed, Jun 7, 2017 at 11:27 AM, Peter Pearson
 wrote:
> I thought "format" was the Cool New Thing toward which
> all the cool kids were moving.  But here I tried to be cool and put in a
> plug for "format", and the hip community seems to be sticking up for
> "%".

The f"..." string is pretty new. Only the hippest of the hip (>=
Python 3.6) are using it at this point. I only recently started using
"...".format() to ease some anticipated far-in-the-future switch to
Python 3 for some of my work. It's grown on me a bit. As an old C
programmer, I've been pretty married to printf-style formatting.

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


[issue30177] pathlib.resolve(strict=False) only includes first child

2017-06-07 Thread Steve Dower

Steve Dower added the comment:


New changeset ceabf9acf03f9bbe660d856bff90ecab475ab543 by Steve Dower (Antoine 
Pietri) in branch '3.6':
bpo-30177: pathlib: include the full path in resolve(strict=False) (#1893) 
(#1985)
https://github.com/python/cpython/commit/ceabf9acf03f9bbe660d856bff90ecab475ab543


--

___
Python tracker 

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



[issue30584] test_os fails on non-English (Russian) Windows

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:


New changeset 897bba75632dfce87c355e3cd4700468357715a7 by Victor Stinner (Denis 
Osipov) in branch 'master':
bpo-30584: Fix test_os fails on non-English Windows (#1980)
https://github.com/python/cpython/commit/897bba75632dfce87c355e3cd4700468357715a7


--

___
Python tracker 

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



[issue30542] [EASY] test_files() of test_tools.test_unparse.DirectoryTestCase leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

It seems like compile() only leaks when using PyCF_ONLY_AST:

compile(source, "filename", "exec", ast.PyCF_ONLY_AST)

It's maybe a leak in the PyAST_mod2obj() function when creating dictionaries of 
created AST objects. But in ast_dealloc() of Python/Python-ast.c, I see that a 
"DECREF" (Py_CLEAR) for the dict. Maybe it's something else.

--

___
Python tracker 

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



Re: plot time on X axis

2017-06-07 Thread Peter Pearson
On Wed, 07 Jun 2017 09:20:25 -0300, jorge.conr...@cptec.inpe.br wrote:
[snip]
> I was an IDL user and I'm using Python. I have several meteorological 
> daily time seriee for several years. Please can someone help me. I would 
> like to plot on X axis only the values o the year.

Is matplotlib allowed?  Example (Python 2.7)(Note that most of
this example is just parsing data, not plotting:):

from matplotlib import pyplot as plt
from datetime import date
import re

dwcd = """
2014-06-01:  82.00% ( 1)  89.50% ( 2)  39.00% ( 1)  0.259
2014-07-01: 100.00% ( 1)  89.00% ( 3)   0.00% ( 1)  0.264
2014-08-01:  79.50% ( 2)  85.50% ( 4)  53.00% ( 1)  0.273
2014-09-01:  85.00% ( 3)  98.00% ( 6)  87.00% ( 3)  0.495
2014-10-01:  86.00% ( 7)  97.00% (10)  82.50% ( 4)  0.553
2014-11-01:  93.50% (10)  98.50% (10)  39.00% ( 6)  0.215
2014-12-01:  97.00% (10) 100.00% (10)  66.50% ( 6)  0.025
2015-01-01:  72.50% (12)  94.00% (11)  39.00% ( 6)  0.025
2015-02-01:  66.00% (12)  88.50% (12)  58.50% ( 8)  0.248
2015-03-01:  79.00% (15)  95.50% (12)  77.00% ( 9)  0.360
2015-04-01:  87.00% (15)  95.50% (12)  68.00% ( 9)  0.039
2015-05-01:  85.50% (18)  90.00% (12)  87.00% ( 9)  0.479
"""

def get_time(r):
r = r.strip()
return date(year=int(r[0:4]),
month=int(r[5:7]),
day=int(r[8:10]))

def get_field(r, field_name):
m = re.match(r"(?P[^:]+): +"
 r"(?P[0-9.]+)% +"
 r"\( *(?P[0-9]+)\) +"
 r"(?P[0-9.]+)% +"
 r"\( *(?P[0-9]+)\) +"
 r"(?P[0-9.]+)% +"
 r"\( *(?P[0-9]+)\) +"
 r"(?P[0-9.]+)", r.strip())
return m.group(field_name)

x = [get_time(r) for r in dwcd.split("\n") if r]
y_a = [float(get_field(r, "value_a")) for r in dwcd.split("\n") if r]
y_b = [float(get_field(r, "value_b")) for r in dwcd.split("\n") if r]
y_c = [float(get_field(r, "value_c")) for r in dwcd.split("\n") if r]

plt.plot(x, y_a, color="red", label="Group A")
plt.plot(x, y_b, color="green", label="Group B")
plt.plot(x, y_c, color="blue", label="Group C")

plt.plot(date(2015,5,20), 101, marker="x", color="white")  

plt.ylabel("Y label")
plt.legend(loc="upper left")
fig = plt.gcf()
fig.autofmt_xdate()
plt.show()


-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30590] str.format no longer accepts unpacked defaultdict for default values

2017-06-07 Thread Eric V. Smith

Changes by Eric V. Smith :


--
nosy: +eric.smith

___
Python tracker 

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



[issue30542] [EASY] test_files() of test_tools.test_unparse.DirectoryTestCase leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

(Oops, I modified the file while uploading here. I reuploaded the correct 
bug.py.)

--
Added file: http://bugs.python.org/file46930/bug.py

___
Python tracker 

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



[issue30542] [EASY] test_files() of test_tools.test_unparse.DirectoryTestCase leaks references

2017-06-07 Thread STINNER Victor

Changes by STINNER Victor :


Removed file: http://bugs.python.org/file46929/bug.py

___
Python tracker 

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



[issue30542] [EASY] test_files() of test_tools.test_unparse.DirectoryTestCase leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

I isolated the leak to attached bug.py script. Output:
---
haypo@selma$ ./python bug.py 
[ Top 10 differences ]
bug.py:40: size=6728 B (+6728 B), count=80 (+80), average=84 B
bug.py:46: size=2464 B (+2464 B), count=28 (+28), average=88 B
bug.py:43: size=2464 B (+2464 B), count=28 (+28), average=88 B
---

It seems like compiling a Python source to AST causes the leak. The Python 
source uses the following bytecodes:

 25 170 LOAD_DEREF   0 (trace)
172 LOAD_METHOD  0 (append)
174 LOAD_CONST   0 (None)
176 CALL_METHOD  1
178 POP_TOP

AST of the code:

Expr(value=Call(func=Attribute(value=Name(id='trace', ctx=Load()), 
attr='append', ctx=Load()), args=[NameConstant(value=None)], keywords=[]))

--
Added file: http://bugs.python.org/file46929/bug.py

___
Python tracker 

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



Re: Psycopg2 pool clarification

2017-06-07 Thread israel

On 2017-06-06 22:53, dieter wrote:

israel  writes:

Since I've gotten no replies to this, I was wondering if someone could
at least confirm which behavior (my expected or my observed) is
*supposed* to be the correct? Should a psycopg2 pool keep connections
open when returned to the pool (if closed is False), or should it
close them as long as there is more than minconn open? i.e is my
observed behavior a bug or a feature?


You should ask the author[s] of "psycopg2" about the supposed behavior.


From my point of view, everything depends on the meaning of the "min"
and "max" parameters for the pool.

You seem to interprete "max" as "keep as many connections as this 
open".

But it can also be a hard limit in the form "never open more than this
number of connections". In the latter case, "min" may mean "keep this
many connections open at all time".


You are right about my interpretation of "max", and also about the 
actual meaning. Thus the reason I was asking :-). I did post on the bug 
report forum, and was informed that the observed behavior was the 
correct behavior. As such, using psycopg2's pool is essentially 
worthless for me (plenty of use for it, i'm sure, just not for me/my use 
case).


So let me ask a different, but related, question: Is there a Python 
library available that gives me the behavior I described in my first 
post, where connections are "cached" for future use for a time? Or 
should I just write my own? I didn't find anything with some quick 
googling, other than middleware servers like pgpool which, while they 
have the behavior I want (at least from my reading), will still require 
the overhead of making a connection (perhaps less than direct to 
postgres? Any performance comparisons out there?), not to mention 
keeping yet another service configured/running. I would prefer to keep 
the pool internal to my application, if possible, and simply reuse 
existing connections rather than making new ones. Thanks!

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


[issue30591] textwrap: placeholder backtracking special case lacks test coverage

2017-06-07 Thread Jonathan Eunice

New submission from Jonathan Eunice:

A rare case in textwrap when max_lines insufficient and textwrap needs to 
backtrack to a previous line to add the placeholder seems to lack test coverage.

This issue added as prereq for suggesting an additional test. PR imminent.

Code: Lib/textwrap.py (as is)
Test: Lib/test/test_textwrap.py (extended)

--
components: Tests
messages: 295354
nosy: jonathaneunice
priority: normal
severity: normal
status: open
title: textwrap: placeholder backtracking special case lacks test coverage
type: enhancement
versions: Python 3.6

___
Python tracker 

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



[issue30590] str.format no longer accepts unpacked defaultdict for default values

2017-06-07 Thread Carmen Bianca Bakker

New submission from Carmen Bianca Bakker:

As brief as can be, the following script works in Python 3.4 and Python 3.5:

from collections import defaultdict

mydict = defaultdict(lambda: 'default')

print('{foo}'.format(**mydict))

And prints "default".

In Python 3.6, you get a KeyError for foo.

--
components: Library (Lib)
messages: 295353
nosy: carmenbianca
priority: normal
severity: normal
status: open
title: str.format no longer accepts unpacked defaultdict for default values
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: Bug or intended behavior?

2017-06-07 Thread Peter Pearson
On Tue, 6 Jun 2017 13:16:00 -0400, Terry Reedy  wrote:
> On 6/5/2017 1:01 PM, Peter Pearson wrote:
>> On Fri, 2 Jun 2017 10:17:05 -0700 (PDT), sean.diza...@gmail.com wrote:
>> [snip]
>> print "foo %s" % 1-2
>>> Traceback (most recent call last):
>>>File "", line 1, in 
>>> TypeError: unsupported operand type(s) for -: 'str' and 'int'
>> 
>> Others have already pointed out that you're assuming the
>> wrong precedence:
>> 
>> Say
>>  "foo %s" % (1-2)
>> not
>>  ("foo %s" % 1) - 2
>> .
>> 
>> Personally I prefer a less compact but more explicit alternative:
>> 
>>  "foo {}".format(1-2)
>
> More compact:
> >>> f'foo {1-2}'
> 'foo -1'

Sarcastic thanks, dude.  Excuse me while I scrub my screen with Clorox.
Or maybe my eyeballs.

More seriously, I thought "format" was the Cool New Thing toward which
all the cool kids were moving.  But here I tried to be cool and put in a
plug for "format", and the hip community seems to be sticking up for
"%".  Can I never get with the times?

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30566] punycode codec raises IndexError in decode_generalized_number()

2017-06-07 Thread Vikram Hegde

Changes by Vikram Hegde :


--
pull_requests: +2053

___
Python tracker 

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



Re: Generator and return value

2017-06-07 Thread Rob Gaddi

On 06/06/2017 11:13 PM, Frank Millman wrote:

Hi all

It would be nice to write a generator in such a way that, in addition to 
'yielding' each value, it performs some additional work and then 
'returns' a final result at the end.


From Python 3.3, anything 'returned' becomes the value of the 
StopIteration 

exception, so it is possible, but not pretty.

Instead of -
my_gen = generator()
for item in my_gen():
do_something(item)
[how to get the final result?]

you can write -
my_gen = generator()
while True:
try:
item = next(my_gen())
do_something(item)
except StopIteration as e:
final_result = e.value

Is this the best way to achieve it, or is there a nicer alternative?

Thanks

Frank Millman




class MyGeneration:
  def __iter__(self):
yield from ('people', 'try', 'to', 'put', 'us', 'down')
self.final = 'talking about'

mygen = MyGeneration()
for item in mygen:
  print(item)
print(mygen.final)


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


[issue30586] Encode to EBCDIC doesn't take into account conversion table irregularities

2017-06-07 Thread Vladimir Filippov

Vladimir Filippov added the comment:

According to 
ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/EBCDIC/CP037.TXT symbols [ 
and ] have other codes (instead of 0xAD and 0xBD):
0xBA0x005B  #LEFT SQUARE BRACKET
0xBB0x005D  #RIGHT SQUARE BRACKET

Looks like 
ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/EBCDIC/CP500.TXT was 
created based on 
https://www.ibm.com/support/knowledgecenter/SSZJPZ_11.3.0/com.ibm.swg.im.iis.ds.parjob.adref.doc/topics/r_deeadvrf_ASCII_to_EBCDIC.html
But this information "This translation is not bidirectional. Some EBCDIC 
characters cannot be translated to ASCII and some conversion irregularities 
exist in the table. For more information, see Conversion table irregularities." 
was ignored. Additional, this line from CP500.TXT:
0xBB0x007C  #VERTICAL LINE
haven't any source in IBM's table.

Example from z/OS mainframe:
---
bash-4.3$ iconv -f 819 -t 1047 -T ascii.txt > ebcdic.txt
bash-4.3$ ls -T *.txt
t ISO8859-1   T=on  ascii.txt
t IBM-1047T=on  ebcdic.txt
bash-4.3$ cat ascii.txt
![]|bash-4.3$ od -h ascii.txt
0021  5B  5D  7C
04
bash-4.3$ cat ebcdic.txt
![]|bash-4.3$ od -h ebcdic.txt
005A  AD  BD  4F
04
---

--
status: pending -> open

___
Python tracker 

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



[issue30546] [EASY][Windows] test_uname_win32_ARCHITEW6432() of test_platform leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

Ok, this issue was a duplicate of bpo-30567 which was already fixed.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Leak in sys.getwindowsversion

___
Python tracker 

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



[issue30567] Leak in sys.getwindowsversion

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

The issue 30546 has been marked as a duplicate of this issue.

--
nosy: +haypo

___
Python tracker 

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



[issue30177] pathlib.resolve(strict=False) only includes first child

2017-06-07 Thread Antoine Pietri

Antoine Pietri added the comment:

The only backport was for 3.6 as the previous versions don't have the strict= 
parameter. PR submitted here: https://github.com/python/cpython/pull/1985

--

___
Python tracker 

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



[issue30345] test_gdb fails on Python 3.6 when built with LTO+PGO

2017-06-07 Thread Mikhail

Mikhail added the comment:

So, I tried the modified patch (see 
http://aldan.algebra.com/~mi/tmp/patch-issue30345) -- and now I simply get a 
different variable name in the error-message:

(gdb) py-bt
Python Exception  Variable 'func' not found.: 
Error occurred in Python command: Variable 'func' not found.

However, the older version of the patch only referenced "func_obj" in 
test_gdb.py -- not in libpython.py -- so I may have misunderstood Jeremy's 
suggestion entirely...

--

___
Python tracker 

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



[issue30177] pathlib.resolve(strict=False) only includes first child

2017-06-07 Thread Antoine Pietri

Changes by Antoine Pietri :


--
pull_requests: +2052

___
Python tracker 

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



[issue30588] Missing documentation for codecs.escape_decode

2017-06-07 Thread Matthieu Dartiailh

Matthieu Dartiailh added the comment:

The issue is that unicode_escape will not properly handle strings mixing
unicode character and escaped character as it assumes latin-1 compatible
characters only. For example, given the literal string 'Δ\nΔ', one
cannot encode using latin-1 and encoding it using utf-8 then using
unicode _escape produces a wrong output: 'Î\x94\nÎ\x94'. However using
codecs.escape_decode(r'Δ\nΔ'.encode('utf-8'))[0].decode('utf-8') gives
the proper output. Internally the Python parser handle this case but I
was unable to find where and this is the closest solution I found. I
guess it may be possible using error handlers but it seems much more
cumbersome.

Best regards

Matthieu

--

___
Python tracker 

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



[issue30580] WSGI examples raise AttributeError: __exit__

2017-06-07 Thread R. David Murray

Changes by R. David Murray :


--
resolution:  -> not a bug

___
Python tracker 

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



[issue30177] pathlib.resolve(strict=False) only includes first child

2017-06-07 Thread Steve Dower

Steve Dower added the comment:


New changeset add98eb4fe41baeaa70fbd4ccc020833740609a4 by Steve Dower (Antoine 
Pietri) in branch 'master':
bpo-30177: pathlib: include the full path in resolve(strict=False) (#1893)
https://github.com/python/cpython/commit/add98eb4fe41baeaa70fbd4ccc020833740609a4


--

___
Python tracker 

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



[issue30177] pathlib.resolve(strict=False) only includes first child

2017-06-07 Thread Steve Dower

Steve Dower added the comment:

As usual, I can easily hit merge but may not be able to get to the backport 
immediately. Someone else can feel free to cherrypick and submit the PRs and 
I'll hit merge on them.

We should also watch the buildbots for failures though before backporting. 
Particularly in this area, they should have better coverage than the PR checks.

--
stage:  -> backport needed

___
Python tracker 

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



[issue30588] Missing documentation for codecs.escape_decode

2017-06-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

This is an internal function kept for compatibility. It is used only for 
decoding pickle protocol 0 data created in Python 2. Look at unicode_escape and 
raw_unicode_escape codecs for doing similar decoding to strings in Python 3.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue30589] With forkserver, Process.exitcode does not get signal number

2017-06-07 Thread Antoine Pitrou

New submission from Antoine Pitrou:

The documentation for multiprocessing.exitcode says:
"""
The child’s exit code. This will be None if the process has not yet 
terminated. A negative value -N indicates that the child was terminated by 
signal N.
"""

This is true for the "fork" method, but not "forkserver" where a child 
terminated by a signal will get an exitcode of 255.  This is because forkserver 
relies on the child writing its own exit code in a pipe, which obviously 
doesn't work if it was killed (255 is simply a fallback value).

See forkserver's Popen.poll():

def poll(self, flag=os.WNOHANG):
if self.returncode is None:
from multiprocessing.connection import wait
timeout = 0 if flag == os.WNOHANG else None
if not wait([self.sentinel], timeout):
return None
try:
self.returncode = forkserver.read_unsigned(self.sentinel)
except (OSError, EOFError):
# The process ended abnormally perhaps because of a signal
self.returncode = 255
return self.returncode

--
components: Library (Lib)
messages: 295343
nosy: davin, pitrou, sbt
priority: normal
severity: normal
status: open
title: With forkserver, Process.exitcode does not get signal number
type: behavior
versions: Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue30588] Missing documentation for codecs.escape_decode

2017-06-07 Thread Matthieu Dartiailh

New submission from Matthieu Dartiailh:

codecs.escape_decode does not appear in the codecs documentation. This function 
is to my knowledge the only convenient way to process the escaped characters in 
a literal string (actually found here 
https://stackoverflow.com/questions/4020539/process-escape-sequences-in-a-string-in-python).
 It is most useful when implementing a parser for a language extending python 
semantic while retaining python processing of string (cf 
https://github.com/MatthieuDartiailh/enaml).

Is there a reason for that function not being documented ?

--
assignee: docs@python
components: Documentation
messages: 295342
nosy: docs@python, mdartiailh
priority: normal
severity: normal
status: open
title: Missing documentation for codecs.escape_decode
versions: Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue30345] test_gdb fails on Python 3.6 when built with LTO+PGO

2017-06-07 Thread Jeremy Kloth

Jeremy Kloth added the comment:

It seems that commit 
(https://github.com/python/cpython/commit/c52572319cbd50adff85050a54122c25239a516d)
 changed the parameter name in the definition of _PyCFunction_FastCallDict().  
I believe that changing 'func_obj' to just 'func' should fix it (in 
Tools/gdb/libpython.py).

--
nosy: +jkloth

___
Python tracker 

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



[issue28686] py.exe ignored PATH when using python3 shebang

2017-06-07 Thread Jens Lindgren

Jens Lindgren added the comment:

Sorry I need to clarify.
On Linux both python and python3 works as there is a symlink created from 
python to python3 in the venv folder.
On Windows only python.exe is created. I copied it to python3.exe. Now I can 
use python3 script.py to start but py-launcher and shebang still didn't work 
with '/usr/bin/env python3'.
I expect this to work the same on Windows as it does on Linux.

--

___
Python tracker 

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



[issue30345] test_gdb fails on Python 3.6 when built with LTO+PGO

2017-06-07 Thread Mikhail

Mikhail added the comment:

The actual stack, which I'm trying to debug, begins like this:

#0  0xbfbfd34e in ?? ()
#1  0x2a9ec81e in ?? () from /opt/lib/qt5/libQt5WebKit.so.5
#2  0x2acf0efe in ?? () from /opt/lib/qt5/libQt5WebKit.so.5
#3  0x2acd8b74 in ?? () from /opt/lib/qt5/libQt5WebKit.so.5
#4  0x2acd5d60 in ?? () from /opt/lib/qt5/libQt5WebKit.so.5
#5  0x2acd87ae in ?? () from /opt/lib/qt5/libQt5WebKit.so.5
#6  0x2a9fe2e3 in QWebFrameAdapter::load(QNetworkRequest const&, 
QNetworkAccessManager::Operation, QByteArray const&) () from 
/opt/lib/qt5/libQt5WebKit.so.5
#7  0x2d7a18dd in QWebFrame::setUrl(QUrl const&) () from 
/opt/lib/qt5/libQt5WebKitWidgets.so.5
#8  0x2d7ad5eb in QWebView::setUrl(QUrl const&) () from 
/opt/lib/qt5/libQt5WebKitWidgets.so.5
#9  0x2d75efd4 in meth_QWebView_setUrl(_object*, _object*) ()
   from /opt/lib/python3.6/site-packages/PyQt5/QtWebKitWidgets.so
#10 0x28125151 in _PyCFunction_FastCallDict () from 
/opt/lib/libpython3.6m.so.1.0
#11 0x28125326 in _PyCFunction_FastCallKeywords () from 
/opt/lib/libpython3.6m.so.1.0
#12 0x2819a458 in ?? () from /opt/lib/libpython3.6m.so.1.0
#13 0x28193ab2 in _PyEval_EvalFrameDefault () from /opt/lib/libpython3.6m.so.1.0
#14 0x2819b790 in ?? () from /opt/lib/libpython3.6m.so.1.0
#15 0x2819a425 in ?? () from /opt/lib/libpython3.6m.so.1.0
#16 0x28193ab2 in _PyEval_EvalFrameDefault () from /opt/lib/libpython3.6m.so.1.0
[...]

Maybe, it is "too deep" into the native (not Python) code for the feature to 
work?

--

___
Python tracker 

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



[issue30014] Speedup DefaultSelectors.modify() by 2x

2017-06-07 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

OK, https://github.com/python/cpython/pull/1030 should be good to go.

--

___
Python tracker 

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



[issue12815] Coverage of smtpd.py

2017-06-07 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue28686] py.exe ignored PATH when using python3 shebang

2017-06-07 Thread Jens Lindgren

Jens Lindgren added the comment:

I just got hit by this bug and would like to add my thoughts on this.
If you are in an activated venv, no matter if you launch with command python or 
python3, it will launch the version in venv (version 3.6.1 in this case).
I expect the py-launcher and shebang to work the same way. In fact it works as 
expected on Linux and '#! /usr/bin/env pyton3' are in fact using the venv 
version.
This is a pretty major bug that needs to be fixed asap in my opinion.

--
nosy: +Jens Lindgren

___
Python tracker 

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



Re: script output appears correct but still raises, AssertionError

2017-06-07 Thread john polo

ChrisA,

Thank you for pointing out my error: using print() when I should have 
used return().


John

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


Re: how to decrypt encrypted text to a clear text

2017-06-07 Thread blue
Test again your chain programming way , because :
>>> dir(RSA.importKey)
['__call__', '__class__', '__cmp__', '__delattr__', '__doc__', '__format__', 
'__func__', '__get__', '__getattribute__', '__hash__', '__init__', '__new__', 
'__reduce__', '__reduce_ex__', '__repr__', '__self__', '__setattr__', 
'__sizeof__', '__str__', '__subclasshook__', 'im_class', 'im_func', 'im_self']
>>> dir(RSA.importKey.decrypt())
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'function' object has no attribute 'decrypt'


On Tuesday, June 6, 2017 at 9:29:52 AM UTC+3, Ho Yeung Lee wrote:
> i use wb to write pubic and private key 
> and succeed to import private, but after decrypt, it return hex number 
> not a clear text 
> is there any more key needed?
> or do wb influence the result?
> 
> from Crypto.PublicKey import RSA 
> keypair = RSA.generate(2048) 
> alice_privkey = keypair.exportKey('PEM', 'mysecret', pkcs=1) 
> #alice_privkey = keypair.exportKey() 
> alice_pubkey = keypair.publickey().exportKey() 
> 
> text_file = open("alice_pubkey.txt", "wb") 
> text_file.write(alice_pubkey) 
> text_file.close() 
> 
> keypair = RSA.generate(2048) 
> bob_privkey = keypair.exportKey('PEM', 'mysecret2', pkcs=1) 
> #bob_privkey = keypair.exportKey() 
> bob_pubkey = keypair.publickey().exportKey() 
> 
> text_file = open("bob_pubkey.txt", "wb") 
> text_file.write(bob_pubkey) 
> text_file.close() 
> 
> text_file = open("alice_privkey.pem", "wb") 
> text_file.write(alice_privkey) 
> text_file.close() 
> text_file = open("bob_privkey.pem", "wb") 
> text_file.write(bob_privkey) 
> text_file.close() 
> 
> 
> #step 2 
> #use alice public key to encrypt 
> pubkey = RSA.importKey(alice_pubkey) 
> alice_masterkey = pubkey.encrypt("i am Martin", None) 
> 
> text_file = open("alice_masterkey.txt", "w") 
> text_file.write(bob_pubkey) 
> text_file.close() 
> 
> quit() 
> python 
> text_file = open("alice_masterkey.txt", "r") 
> alice_masterkey=text_file.read() 
> text_file.close() 
> text_file = open("alice_privkey.pem", "r") 
> alice_privkey=text_file.read() 
> text_file.close() 
> text_file = open("alice_pubkey.txt", "r") 
> alice_pubkey=text_file.read() 
> text_file.close() 
> 
> from Crypto.PublicKey import RSA 
> pubkey = RSA.importKey(alice_pubkey) 
> privkey = RSA.importKey(alice_privkey,passphrase="mysecret") 
> encryption_key = privkey.decrypt(alice_masterkey) 
> encryption_key 
> 
> quit() 
> python 
> text_file = open("alice_masterkey.txt", "r") 
> alice_masterkey=text_file.read() 
> text_file.close() 
> text_file = open("alice_privkey.pem", "r") 
> alice_privkey=text_file.read() 
> text_file.close() 
> text_file = open("alice_pubkey.txt", "r") 
> alice_pubkey=text_file.read() 
> text_file.close() 
> 
> from Crypto.PublicKey import RSA 
> pubkey = RSA.importKey(alice_pubkey) 
> privkey = RSA.importKey(alice_privkey,passphrase="mysecret") 
> encryption_key = privkey.decrypt(alice_masterkey) 
> encryption_key 
> 
> >>> encryption_key 
> 'o\x94\xaeC\xe0S\x81\x05t\xd8\\A\x10?\xd2\xe5\x8c5\xc9\x1d\x14\xc7\xfd)Cs\x8b"cg\x16y\xe2\xf2L\xf1-\x08qHt\x99\xbc\xb5\xf6_\x17c\xd2\x0b\xc5t\t\xe0\x8b\x03G\x10\xce\xd6\xcd\x86\xfc!\xc9i\xa2\xab\x9d\x8a\x92\xfc7
>  
> g\xa5$\x91\x85\xa2L]I\xd6\xc6\xaez\xed\x01\x95\xee)8z\x18\xc9aag\x97\x97\xb0\\)\xec"\xe4\xbez\xd3\xa8\'k%\x12\x1d\xf9\xf0\x0e\x0c\xcb\xa8\xb1\xe7}\x90\xd3\xcfs@\xc2m\x1a^\x1b0\xa7\xdd\xcd\xea\x1f\xd5\x08\x13+y"]vu\xe3\x9e\xba\x97\x10\x90S\xea\xae1=r4Yp,\xe3\xa9\xc66H\xa7\x95[M|n\x91\x98\x9c,\xc4\xf5\x7f\x8cJ\x03\xba\x04Z0lV\xe1\xd6d\xeec@\xe1\xa0\xec\x81]\xef5\r\x12\x88\xbe/\xfc\xe01\xaacn,\x8a\xe1\x14\x8a\xf4\xd85\xd8\xabD\x137\xe7T\xc4\xc1\x84b.\xd9RZ\x0e\x03#\x1e\x8dl\xe8\xe4N^\r\xf0\x1d\x8c'

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


Re: plot time on X axis

2017-06-07 Thread Paul Barry
Take a look at Jake VanderPlas's book, which is available online as
free-to-read: https://github.com/jakevdp/PythonDataScienceHandbook

See Chapter 3 (and 4).

On 7 June 2017 at 13:20,  wrote:

>
> Hi,
>
> I was an IDL user and I'm using Python. I have several meteorological
> daily time seriee for several years. Please can someone help me. I would
> like to plot on X axis only the values o the year.
>
> Thanks,
>
> Conrado
> --
> https://mail.python.org/mailman/listinfo/python-list
>



-- 
Paul Barry, t: @barrypj  - w:
http://paulbarry.itcarlow.ie - e: paul.ba...@itcarlow.ie
Lecturer, Computer Networking: Institute of Technology, Carlow, Ireland.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Generator and return value

2017-06-07 Thread Cameron Simpson

On 07Jun2017 19:19, Steve D'Aprano  wrote:

Frank Millman writes:

It would be nice to write a generator in such a way that, in addition
to 'yielding' each value, it performs some additional work and then
'returns' a final result at the end.


From Python 3.3, anything 'returned' becomes the value of the
StopIteration

exception, so it is possible, but not pretty.

Instead of -
   my_gen = generator()
   for item in my_gen():
   do_something(item)
   [how to get the final result?]


Currently, I don't believe there is a way.


I sometimes yield what would be a return value as the final item. Not very 
happy with it though.


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


[issue30586] Encode to EBCDIC doesn't take into account conversion table irregularities

2017-06-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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

___
Python tracker 

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



plot time on X axis

2017-06-07 Thread jorge . conrado


Hi,

I was an IDL user and I'm using Python. I have several meteorological 
daily time seriee for several years. Please can someone help me. I would 
like to plot on X axis only the values o the year.


Thanks,

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


[issue30586] Encode to EBCDIC doesn't take into account conversion table irregularities

2017-06-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The cp500 codec in Python is generated from the table 
ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/EBCDIC/CP500.TXT .

There are several EBCDIC code pages. EBCDIC-compatible encodings supported in 
Python are: cp037, cp273, cp424, cp500, cp875, cp1026 and cp1140. Three of 
them, cp037, cp424 and cp1140, encode '!' to b'\x5A' and '|' to b'\x4F'.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue30587] Mock with spec object does not ensure method call signatures

2017-06-07 Thread Claudiu Belu

New submission from Claudiu Belu:

Mock can accept a spec object / class as argument, making sure that accessing 
attributes that do not exist in the spec will cause an AttributeError to be 
raised, but there is no guarantee that the spec's methods signatures are 
respected in any way. This creates the possibility to have faulty code with 
passing unittests and assertions.

Steps to reproduce:

>>> import mock
>>>
>>> class Something(object):
... def foo(self, a, b, c, d):
... pass
...
>>>
>>> m = mock.Mock(spec=Something)
>>> m.foo()

>>> # TypeError should be raised, but it isn't.
...
>>> m.foo.assert_called_once_with()


Expected behaviour: It should have raised a TypeError, since the method 
signature is: def meth(self, a, b, c, d):

Actual behaviour: No error.

--
components: Library (Lib)
messages: 295335
nosy: cbelu
priority: normal
pull_requests: 2051
severity: normal
status: open
title: Mock with spec object does not ensure method call signatures
type: behavior
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



Re: Error in initialization of IDLE.

2017-06-07 Thread Mohit Soni via Python-list


Sent from Yahoo Mail on Android
  I have python 3.5.2 installed and recently I installed python 3.6 and after 
installing the problem seems to occur.
Whenever I start IDLE it shows an error message like "IDLE can't create a sub 
process or windows firewall might be blocking it"
I did a fresh installation of both versions separately (almost all the 
combinations) but nothing concluded.
It's pissing me off since 2 days. Please help me out!!
Thank you!  
-- 
https://mail.python.org/mailman/listinfo/python-list



[issue30359] Annotating a function as returning an (async) context manager?

2017-06-07 Thread Nick Coghlan

Nick Coghlan added the comment:

As far as whether or not this usage fits within the guidelines at 
https://www.python.org/dev/peps/pep-0008/#function-annotations, it would 
definitely be worth bringing up in a python-dev thread before going ahead with 
it.

I think it's a good dynamic use of annotations that fits within the spirit of 
PEP 484 without requiring sphinxcontrib-trio to rely on a static typechecker 
like mypy, but others may have a different perspective.

--

___
Python tracker 

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



[issue30359] Annotating a function as returning an (async) context manager?

2017-06-07 Thread Nick Coghlan

Nick Coghlan added the comment:

Even Python 2 functions support setting arbitrary attributes, so 
contextlib2.contextmanager can always just add an __annotations__ dict to 
decorated functions if it doesn't already exist.

```
>>> def f():
... pass
... 
>>> f.__annotations__
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'function' object has no attribute '__annotations__'
>>> f.__annotations__ = {}
>>> f.__annotations__
{}
```

--

___
Python tracker 

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



[issue1207613] Idle Editor: Bottom Scroll Bar

2017-06-07 Thread Cheryl Sabella

Cheryl Sabella added the comment:

I hope you don't mind that I made a change for this.  I was working with 'Find 
in files' and couldn't see the full line, so I figured out where to add the 
scroll bar.  I only found this ticket after the fact.

If it's not appropriate, I can withdraw the PR.

--
nosy: +csabella

___
Python tracker 

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



[issue1207613] Idle Editor: Bottom Scroll Bar

2017-06-07 Thread Cheryl Sabella

Changes by Cheryl Sabella :


--
pull_requests: +2050

___
Python tracker 

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



[issue22898] segfault during shutdown attempting to log ResourceWarning

2017-06-07 Thread Xavier de Gaye

Xavier de Gaye added the comment:

With PR 1981, a ResourceWarning is printed when a RecursionError occurs while 
normalizing another exception and its traceback holds a reference to a 
non-closed file object.

For information, issue 5437 removed the MemoryError singleton for the same 
reasons as PR 1981 does.

--
versions: +Python 3.6, Python 3.7 -Python 3.4

___
Python tracker 

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



[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-07 Thread Will Roberts

Will Roberts added the comment:

Github PR adds simple test, as well as an entry in Misc/NEWS.

--

___
Python tracker 

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



[issue30586] Encode to EBCDIC doesn't take into account conversion table irregularities

2017-06-07 Thread Vladimir Filippov

New submission from Vladimir Filippov:

These 4 symbols were encoded incorrectly to EBCDIC (codec cp500): "![]|". 
Correct table of conversation for these symbols described in 
https://www.ibm.com/support/knowledgecenter/SSZJPZ_11.3.0/com.ibm.swg.im.iis.ds.parjob.adref.doc/topics/r_deeadvrf_Conversion_Table_Irregularities.html

This code:

ascii = '![]|';
print("ASCII:  " + bytes(ascii, 'ascii').hex())
res = ascii.encode('cp500')
print ("EBCDIC: " +res.hex())

on Python 3.6.1 produce this output:

ASCII:  215b5d7c
EBCDIC: 4f4a5abb


Expected encoding (from IBM's table):
! - 5A
[ - AD
] - BD
| - 4F

Workaround: use this translation after encoding
bytes.maketrans(b'\x4F\x4A\x5A\xBB', b'\x5A\xAD\xBD\x4F')

--
components: Unicode
messages: 295329
nosy: Vladimir Filippov, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Encode to EBCDIC doesn't take into account conversion table 
irregularities
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



[issue22898] segfault during shutdown attempting to log ResourceWarning

2017-06-07 Thread Xavier de Gaye

Changes by Xavier de Gaye :


--
pull_requests: +2049

___
Python tracker 

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



[issue12815] Coverage of smtpd.py

2017-06-07 Thread Milan Oberkirch

Changes by Milan Oberkirch :


--
nosy:  -zvyn

___
Python tracker 

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



[issue30359] Annotating a function as returning an (async) context manager?

2017-06-07 Thread Nathaniel Smith

Nathaniel Smith added the comment:

I can think of two downsides to using __annotations__ for this:

1) Obviously contextlib itself isn't going to add any kind of annotation in any 
versions before 3.7, but third-party projects might (like contextlib2, say). 
And these projects have been known to be used on Python versions that don't 
have __annotations__ support. At the moment I personally don't have to care 
about this because sphinxcontrib-trio doesn't support anything before 3.5, but 
I suspect this will eventually change. (E.g. sphinx has expressed some interest 
in having these changes upstreamed.) So this would mean that we'd still need 
some other ad hoc mechanism to use when running on old Pythons, and have to 
check for both that and the __annotations__. But that's probably doable, so eh. 
It'd be helpful if contextlib2 could join in on whatever protocol, though.

2) sphinxcontrib-trio actually interacts very poorly with __annotations__ right 
now [1]. But I mean, I need to figure out how to fix this anyway, so... not 
really your problem :-).

Neither of these downsides seems very compelling :-). So I guess contextlib 
should add some appropriate __annotations__, and *maybe* also add something 
like __returns_contextmanager__ = True if that's useful to maintain consistency 
with contextlib2 or similar?

(Wasn't there some discussion about keeping type hints out of the stdlib for 
now? is this likely to ruffle any figures on those grounds?)

[1] https://github.com/python-trio/sphinxcontrib-trio/issues/4

--

___
Python tracker 

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



[issue30537] Using PyNumber_AsSsize_t in itertools.islice

2017-06-07 Thread Sven Marnach

Sven Marnach added the comment:

The current behaviour of islice() seems inconsistent with the rest of Python.  
All other functions taking start, stop and step arguments like slice(), range() 
and itertools.count() do accept integer-like objects.  The code given as 
"roughly equivalent" in the documentation of islice() accepts integer-like 
objects, and so does regular list slicing.  In fact, the __index__() method was 
introduced in PEP 357 specifically for slicing.  In Python 2, islice() 
supported it as well.  I think the expectation that islice() in Python 3 also 
supports it is entirely reasonable, and I can't see any strong arguments for 
breaking that assumption.

--
nosy: +smarnach

___
Python tracker 

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



[issue30080] Add the --duplicate option for timeit

2017-06-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ah, I even didn't know that "perf timeit" supports -n since it doesn't report 
the number of loops. And seems it runs the benchmark much more times, since 
even with -n1 it is slow. If the number of loops is determined automatically, 
it would do not matter.

I choose the meaning of --duplicate so that it almost not affect the total time 
of the benchmarking. Larger value just decreases the overhead of the iteration.

--

___
Python tracker 

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



[issue30546] [EASY][Windows] test_uname_win32_ARCHITEW6432() of test_platform leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

It seems like the bug was already fixed last days!

--

___
Python tracker 

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



Re: Generator and return value

2017-06-07 Thread Steve D'Aprano
On Wed, 7 Jun 2017 05:09 pm, Jussi Piitulainen wrote:

> Frank Millman writes:
> 
>> It would be nice to write a generator in such a way that, in addition
>> to 'yielding' each value, it performs some additional work and then
>> 'returns' a final result at the end.
>>
>>> From Python 3.3, anything 'returned' becomes the value of the
>>> StopIteration
>> exception, so it is possible, but not pretty.
>>
>> Instead of -
>>my_gen = generator()
>>for item in my_gen():
>>do_something(item)
>>[how to get the final result?]


Currently, I don't believe there is a way.


>> you can write -
>>my_gen = generator()
>>while True:
>>try:
>>item = next(my_gen())
>>do_something(item)
>>except StopIteration as e:
>>final_result = e.value
>>
>> Is this the best way to achieve it, or is there a nicer alternative?

I don't think there are currently any nice alternatives.



> Like this, and imagination is the limit:
> 
> def generator(box):
> yield 1
> box.append('won')
> yield 2
> box.append('too')
> yield 3
> box.append('tree')
> 
> mabox = []
> for item in generator(mabox): pass
> print(*mabox)
> # prints: won too tree

Well, that's a little bit better than using a global variable, but it's still
pretty ugly, and it doesn't capture the return value so you've answered a
completely different question.


Here is why I think it is an ugly solution. There are three obvious alternatives
to this API:


Alternative one: force the caller to provide the "box" argument, whether they
care about these extra values or not.

for item in generator([]):  # argument is ignored, and garbage collected
process(item)

That's not *too* bad, but still a bit manky.


Alternative two: provide a default value for box:

def generator(box=[]): ...


Pros: now the caller doesn't need to care about box if they don't care about it.

Cons: it will leak memory. Every call to generator() with no box argument will
collect values in the default list.


Alternative three: provide a non-mutable default for box:

def generator(box=None): ...


Procs: the caller doesn't need to care about box.

Cons: writing generator is a lot more complex, you have to check for box is None
before appending. There may be clever ways around this, but either way, the
complexity of the generator is significantly increased.


I'm not saying I'd *never* use this solution. I've used a similar solution
myself, treating the argument as a "pass by reference" output parameter,
similar to "var" arguments in Pascal. But not often, because it feels ugly.

Otherwise, I guess using a while loop is the least-worst existing solution. But
here's a neat solution for a feature request:


# this doesn't actually work, yet
it = generator()
for value in it:
# run the generator through to completion, as normal
process(value)

extra_value = it.result

where the property lookup it.result:


- captures the return value, if the generator has returned;

- raise an exception if the generator is still running.



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

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


[issue30547] [EASY][Windows] SubinterpreterTest.test_callbacks_leak() of test_atexit leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

> At the end, you should get the commit 
> 6b4be195cd8868b76eb6fbe166acc39beee8ce36.

The commit is a giant change. So let me help you, the following change is 
strange. value is replaced whereas its value is non-NULL... Maybe it's the 
regression? ;-)

diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index 90f8551..03601ea 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -291,6 +291,9 @@ import_init(PyInterpreterState *interp, PyObject *sysmod)
 
 /* Install importlib as the implementation of import */
 value = PyObject_CallMethod(importlib, "_install", "OO", sysmod, impmod);
+if (value != NULL)
+value = PyObject_CallMethod(importlib,
+"_install_external_importers", "");
 if (value == NULL) {
 PyErr_Print();
 Py_FatalError("Py_Initialize: importlib install failed");


Stéphane Wirtel (matrixise): "this issue can be executed on Linux, I think I am 
going to work on this one."

Would you like to work on a patch?

--

___
Python tracker 

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



[issue30547] [EASY][Windows] SubinterpreterTest.test_callbacks_leak() of test_atexit leaks references

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

The failing unit test was added by:

commit 2d350fd8af29eada0c3f264a91df6ab4af4a05fd
Author: Antoine Pitrou 
Date:   Thu Aug 1 20:56:12 2013 +0200

Issue #18619: Fix atexit leaking callbacks registered from 
sub-interpreters, and make it GC-aware.


Using git bisect, I found that the leak was introduced by:

commit 6b4be195cd8868b76eb6fbe166acc39beee8ce36
Author: Eric Snow 
Date:   Mon May 22 21:36:03 2017 -0700

bpo-22257: Small changes for PEP 432. (#1728)

PEP 432 specifies a number of large changes to interpreter startup code, 
including exposing a cleaner C-API. The major changes depend on a number of 
smaller changes. This patch includes all those smaller changes.


To run a git bisection, start with an old commit, 1 month ago: 
5d7a8d0c13737fd531b722ad76c505ef47aac96a (May, 1). Spoiler: the test doesn't 
leak at this bisection.

git bisect reset
git bisect start

git checkout master
make && ./python -m test -R 3:3 -m test_callbacks_leak test_atexit
# test fails
git bisect bad  # bad=test fails (ref leak)

git checkout 5d7a8d0c13737fd531b722ad76c505ef47aac96a
make && ./python -m test -R 3:3 -m test_callbacks_leak test_atexit
# test pass
git bisect good  # good=test pass (no leak)

make && ./python -m test -R 3:3 -m test_callbacks_leak test_atexit
# git bisect good or bad depending on the test result

# ... continue until git bisect finds the commit ...

At the end, you should get the commit 6b4be195cd8868b76eb6fbe166acc39beee8ce36.


@Eric Snow: Please don't fix the bug, please explain how to fix it ;-)

--
nosy: +eric.snow

___
Python tracker 

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



[issue30584] test_os fails on non-English (Russian) Windows

2017-06-07 Thread Denis Osipov

Denis Osipov added the comment:

Using the numeric SID instead of localized name in test_access_denied works for 
me (I've made PR).

--

___
Python tracker 

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



[issue30500] [security] urllib connects to a wrong host

2017-06-07 Thread STINNER Victor

Changes by STINNER Victor :


--
title: urllib connects to a wrong host -> [security] urllib connects to a wrong 
host

___
Python tracker 

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



[issue30585] [security][3.3] Backport smtplib fix for TLS stripping vulnerability, CVE-2016-0772

2017-06-07 Thread STINNER Victor

STINNER Victor added the comment:

PEP 398: Python 3.3 Release Schedule

Python 3.3 branch end of support is expected to be at 2017-09-29, in 4 months.

--
assignee:  -> georg.brandl

___
Python tracker 

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



  1   2   >