Re: Pylint false positives

2018-08-18 Thread Chris Angelico
On Sun, Aug 19, 2018 at 9:03 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>
>> *headscratch*
>>
>> So this is okay:
>>
>> def f():
>> for i in range(5):
>> def g(): ...
>>
>> But this isn't:
>>
>> class C:
>> for i in range(5):
>> def m(self): ...
>>
>> I've missed something here.
>
> No, you got it right.
>

Then I've completely missed the problem. Why is one of them acceptable
and the other not?

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


Re: Synax error in string assignment

2018-08-18 Thread Chris Angelico
On Sun, Aug 19, 2018 at 2:47 PM, Sharan Basappa
 wrote:
> I am not sure what the issue is with the 2nd file that assigns string to text 
> variable.
>
> Here is the code:
> # -*- coding: utf-8 -*-
> text = “this’s a sent tokenize test. this is sent two. is this sent three? 
> sent 4 is cool! Now it’s your turn.”
> from nltk.tokenize import sent_tokenize
> sent_tokenize_list = sent_tokenize(text)
> len(sent_tokenize_list)
> sent_tokenize_list
>
> Here is the error:
>  text = “this’s a sent tokenize test. this is sent two. is this sent three? 
> sent 4 is cool! Now it’s your turn.”
>^
> SyntaxError: invalid syntax
>
> BTW, the ^ operator pointing to the error is at text = and not for cool word. 
> This is due to formatting issue in google group.

Is that a curly quote character in your source code, or did it get
changed as part of posting to this list? Either way, you need to be
careful with your quote characters. Get a programmer's editor if you
need to (Sublime, Atom, VS Code, Vim, SciTE, etc, etc, etc), and make
sure you post as plain text.

(Also, if you have trouble posting properly using Google Groups,
switch to the mailing list - it's more reliable.)

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


Re: Pylint false positives

2018-08-18 Thread Marko Rauhamaa
Chris Angelico :

> *headscratch*
>
> So this is okay:
>
> def f():
> for i in range(5):
> def g(): ...
>
> But this isn't:
>
> class C:
> for i in range(5):
> def m(self): ...
>
> I've missed something here.

No, you got it right.


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


New books by O’Reilly

2018-08-18 Thread Larry Martell
https://imgur.com/gallery/tW1lwEl
-- 
https://mail.python.org/mailman/listinfo/python-list


Synax error in string assignment

2018-08-18 Thread Sharan Basappa
I am not sure what the issue is with the 2nd file that assigns string to text 
variable.

Here is the code:
# -*- coding: utf-8 -*-
text = “this’s a sent tokenize test. this is sent two. is this sent three? sent 
4 is cool! Now it’s your turn.”
from nltk.tokenize import sent_tokenize
sent_tokenize_list = sent_tokenize(text)
len(sent_tokenize_list)
sent_tokenize_list

Here is the error:
 text = “this’s a sent tokenize test. this is sent two. is this sent three? 
sent 4 is cool! Now it’s your turn.”
   ^
SyntaxError: invalid syntax 

BTW, the ^ operator pointing to the error is at text = and not for cool word. 
This is due to formatting issue in google group.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue22602] UTF-7 codec decodes ill-formed sequences starting with "+"

2018-08-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you for your PR Zackery.

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



[issue22602] UTF-7 codec decodes ill-formed sequences starting with "+"

2018-08-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset e349bf23584eef20e0d1e1b2989d9b1430f15507 by Serhiy Storchaka 
(Zackery Spytz) in branch 'master':
bpo-22602: Raise an exception in the UTF-7 decoder for ill-formed sequences 
starting with "+". (GH-8741)
https://github.com/python/cpython/commit/e349bf23584eef20e0d1e1b2989d9b1430f15507


--

___
Python tracker 

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



[issue34415] Typo in logging.Formatter docstring

2018-08-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8295

___
Python tracker 

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



[issue34415] Typo in logging.Formatter docstring

2018-08-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8294

___
Python tracker 

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



[issue34415] Typo in logging.Formatter docstring

2018-08-18 Thread Vinay Sajip


Vinay Sajip  added the comment:


New changeset d3d3171da895d8cb880f23fae6be778f0ac23be7 by Vinay Sajip in branch 
'master':
bpo-34415: Updated logging.Formatter docstring. (GH-8811)
https://github.com/python/cpython/commit/d3d3171da895d8cb880f23fae6be778f0ac23be7


--

___
Python tracker 

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



[issue34426] "__lltrace__" seems to be wrong , "__ltrace__" is correct in Misc/SpecialBuilds.txt

2018-08-18 Thread Danish Prakash


Danish Prakash  added the comment:

> however it seems to be wrong, "__ltrace__" is correct

just curious how did you figure it out?

--
nosy: +prakashdanish

___
Python tracker 

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



[issue34062] Python launcher on Windows does not work with --list or --list-paths

2018-08-18 Thread Roundup Robot


Change by Roundup Robot :


--
keywords: +patch
pull_requests: +8293
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



[issue34365] datetime's documentation refers to "comparison [...] falling back to the default scheme of comparing object addresses"

2018-08-18 Thread Danish Prakash


Change by Danish Prakash :


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

___
Python tracker 

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



Questions on PEP 440 - Version Identification and Dependency Specification

2018-08-18 Thread Ryan Holmes
Greetings all,

I currently follow PEP 440 as it relates to my application. Right now we follow 
a x.y.z scheme, with y incrementing with our normal releases, z incrementing 
for any bug fixes for that release, and x not really incrementing unless 
something major happens (for example, our conversion from python 2 to 3)

Our current release is v2.3.1. For the past several weeks, I've been working on 
a significant overhaul to one of our systems which also includes a variety of 
new features, and I now want to create a beta release for this so that folks 
can start testing it. 

Normal convention would be to version it v2.4.0b1, however I don't actually 
know if v2.4.0 will contain this refactoring / featureset (our releases are 
also tied to a third party, so if they release an update, we do too, so we 
don't have much control over the timing of our releases; so things like this 
might be delayed until 2.5.0, for example), so it would seem odd saying that 
this is a beta of 2.4.0 if 2.4.0 might not ultimately contain it. I just don't 
yet know which version this is being planned for.

I'm aware that I'm probably overthinking this, but was just curious to see what 
those in the community might think as well. :)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue34427] calling MutableSequence.extend on self produces infinite loop

2018-08-18 Thread Naris R


Change by Naris R :


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

___
Python tracker 

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



Re: How to multiply dictionary values with other values based on the dictionary's key?

2018-08-18 Thread Steven D'Aprano
On Sat, 18 Aug 2018 16:16:54 -0700, giannis.dafnomilis wrote:

> I have the results of an optimization run in the form found in the
> following pic: https://i.stack.imgur.com/pIA7i.jpg.

Unless you edit your code with Photoshop, why do you think a JPEG is a 
good idea?

That discriminates against the blind and visually impaired, who can use 
screen-readers with text but can't easily read text inside images, and 
those who have access to email but not imgur.

For the record, here's the table:

Key TypeSizeValue
FEq_(0,_0,_0,_0)float   1   1.0
FEq_(0,_0,_1,_1)float   1   1.0
FEq_(0,_0,_2,_2)float   1   1.0
FEq_(0,_0,_3,_0)float   1   1.0
FEq_(0,_0,_4,_1)float   1   1.0


It took me about 30 seconds to copy out by hand from the image. But what 
it means is a complete mystery. Optimization of what? What you show isn't 
either Python code or a Python object (like a dict or list) so it isn't 
any value to us.


> How can I multiply the dictionary values of the keys FEq_(i,_j,_k,_l)
> with preexisting values of the form A[i,j,k,l]?
> 
> For example I want the value of key 'FEq_(0,_0,_2,_2)' multiplied with
> A[0,0,2,2], the value of key 'FEq_(0,_0,_4,_1)' multiplied with
> A[0,0,4,1] etc. for all the keys present in my specific dictionary.


Sounds like you have to parse the key for the number fields:

- extract out the part between the parentheses '0,_0,_2,_2'

If you know absolutely for sure that the key format is ALWAYS going to be 
'FEq_()' then you can extract the fields using slicing, like this:

  key = 'FEq_(0,_0,_2,_2)'
  fields = key[5, -1]  # cut from char 5 to 1 back from the end

If you're concerned about that "char 5" part, it isn't an error. Python 
starts counting from 0, not 1, so char 1 is "E" not "F".



- delete any underscores
- split it on commas
- convert each field to int
- convert the list of fields to a tuple

  fields = fields.replace('_', '')
  fields = string.split(',)
  fields = tuple([int(x) for x in fields])


and then you can use that tuple as the key for A.

It might be easier and/or faster to convert A to use string keys 
"FEq_(0,_0,_2,_2)" instead. Or, depending on the size of A, simply make a 
copy:

B = {}
for (key, value) in A.items():
B['FEq(%d,_%d,_%d,_%d)' % key] = value


and then do your look ups in B rather than A.


> I have been trying to correspondingly multiply the dictionary values in
> the form of
> varsdict["FEq_({0},_{1},_{2},_{3})".format(i,j,k,l)]
> 
> but this is not working as the indexes do not iterate consequently over
> all their initial range values, they are the results of the optimization
> so some elements are missing.

I don't see why the dictionary lookup won't work just because the indexes 
aren't consistent. When you look up 

varsdict['FEq_(0,_0,_2,_2)']

it has no way of knowing whether or not 'FEq_(0,_0,_1,_2)' previously 
existed. I think you need to explain more of what you are doing rather 
than just dropping hints.

*Ah, the penny drops* ...


Are you trying to generate the keys by using nested loops?

for i in range(1000):  # up to some maximum value
for j in range(1000):
for k in range(1000):
for l in range(1000):
key = "FEq_({0},_{1},_{2},_{3})".format(i,j,k,l)
value = varsdict[key]  # this fails


That's going to be spectacularly wasteful if the majority of keys don't 
exist. Rather, you should just iterate over the ones that *do* exist:

for key in varsdict:
...



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

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


Re: Pylint false positives

2018-08-18 Thread Chris Angelico
On Sun, Aug 19, 2018 at 11:13 AM, Steven D'Aprano
 wrote:
> Obviously there is some (small) complexity cost to automating it. I
> didn't specify what a fair number of methods would be (my example showed
> four, but that was just an illustration, not real code). In practice I
> wouldn't even consider this for three methods. Six or eight seems like a
> reasonable cut-of point for me, but it depends on the specifics of the
> code and who I was writing it for.
>
> (Note that this makes me much more conservative than the usual advice
> given by system admins, when you need to do the same thing for the third
> time, write a script to automate it.)

The boundary definitely varies. I've often gone to a dozen
almost-identical blocks of code before turning them into a loop (when
the "almost" makes it a lot harder to collapse them usefully), and
sometimes, just two copies is enough to refactor. But six to eight
does seem like a reasonable point for tiny (maybe stub) functions.

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


Re: Pylint false positives

2018-08-18 Thread Steven D'Aprano
On Sun, 19 Aug 2018 00:11:30 +0300, Marko Rauhamaa wrote:

> In Python programming, I mostly run into closures through inner classes
> (as in Java).

Inner classes aren't closures.

Its also quite expensive to be populating your application with lots of 
classes used only once each, which is a common pitfall when using inner 
classes. Memory is cheap, but it's not so cheap that we ought to just 
profligately waste it needlessly.


> populating an object with fields (methods) in a loop is very 
> rarely a good idea.

Of course it is *rarely* a good idea, because it is rare for the fields 
to be either identical (except for the name) or algebraically derived 
from the loop counter. Using a dict in place of an object, it's hard to 
see any elegant way to move this into a loop:

{'a': 10, 'B': -2, 'c': 97, 'd': None, 'h': 'surprise!', 'm': []}


and so we should not. Any such loop would surely be complex, complicated, 
obscure, even obfuscated compared to writing out the dict/object 
assignments manually.

But in context, we're not discussing the millions of cases were the 
methods/fields are naturally written out manually.

So give me credit for not being a total idiot. Not once in this thread 
have I suggested that we ought to run through all our projects, changing 
every class and putting all methods inside factories. It goes without 
saying that under usual, common circumstances we write out our methods 
manually. I was speaking about one very specific case:


* You have a fair number of identical methods in a single class.


Our choices are, (1):

- write a large block of mindless boilerplate;

- even worse, have that same boilerplate but split it up,
  scattering the individual methods all around the class;

- either way, it is repetitious and error-prone, with
  obvious reliability and maintenance problems:

def foo(self):
return NotImplemented

def bar(self):
return NotImplemented

def baz(self):
return NonImplemented



or, (2):

- automate the repetitious code by moving the method 
  definitions into a loop.


Obviously there is some (small) complexity cost to automating it. I 
didn't specify what a fair number of methods would be (my example showed 
four, but that was just an illustration, not real code). In practice I 
wouldn't even consider this for three methods. Six or eight seems like a 
reasonable cut-of point for me, but it depends on the specifics of the 
code and who I was writing it for.

(Note that this makes me much more conservative than the usual advice 
given by system admins, when you need to do the same thing for the third 
time, write a script to automate it.)



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

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


[issue1648923] HP-UX: -lcurses missing for readline.so

2018-08-18 Thread Berker Peksag


Change by Berker Peksag :


--
resolution:  -> out of date
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



[issue26363] __builtins__ propagation is misleading described in exec and eval documentation

2018-08-18 Thread Berker Peksag


Berker Peksag  added the comment:

Thank you for the report, Xavier.

This is a duplicate of issue 22057.

PR 8812 clarifies the behavior when a dictionary without a "__builtins__" key 
is passed as *globals* to eval(). I think that makes the opposite case much 
easier to understand.

>>> eval("print(spam)", {'__builtins__': {'spam': 'eggs'}})
Traceback (most recent call last):
  File "", line 1, in 
  File "", line 1, in 
NameError: name 'print' is not defined

>>> eval("print(spam)", {'__builtins__': {'spam': 'eggs', 'print': print}})
eggs

Also, I never needed to pass a dictionary with a "__builtins__" key to eval() 
before, so I don't think it's an important detail to document.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage: patch review -> resolved
status: open -> closed
superseder:  -> The doc say all globals are copied on eval(), but only 
__builtins__ is copied
type:  -> behavior
versions: +Python 3.8 -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: How to multiply dictionary values with other values based on the dictionary's key?

2018-08-18 Thread MRAB

On 2018-08-19 00:16, giannis.dafnomi...@gmail.com wrote:

I have the results of an optimization run in the form found in the following 
pic: https://i.stack.imgur.com/pIA7i.jpg.

How can I multiply the dictionary values of the keys FEq_(i,_j,_k,_l) with 
preexisting values of the form A[i,j,k,l]?

For example I want the value of key 'FEq_(0,_0,_2,_2)' multiplied with 
A[0,0,2,2], the value of key 'FEq_(0,_0,_4,_1)' multiplied with A[0,0,4,1] etc. 
for all the keys present in my specific dictionary.

I have been trying to correspondingly multiply the dictionary values in the 
form of
 varsdict["FEq_({0},_{1},_{2},_{3})".format(i,j,k,l)]

but this is not working as the indexes do not iterate consequently over all 
their initial range values, they are the results of the optimization so some 
elements are missing. I also could not find something of a similar nature where 
I looked.

Thank you for the help!


Iterate over the keys in varsdict and, for each key, extract the indexes.

With an example:

>>> key = 'FEq_(0,_0,_2,_2)'
>>> key
'FEq_(0,_0,_2,_2)'
>>> key.split('(')[1]
'0,_0,_2,_2)'
>>> key.split('(')[1].split(')')[0]
'0,_0,_2,_2'
>>> key.split('(')[1].split(')')[0].split(',_')
['0', '0', '2', '2']

Now convert them to ints and assign to variables:

>>> i, j, k, l = map(int, key.split('(')[1].split(')')[0].split(',_'))

Now you can get A[i,j,k,l].
--
https://mail.python.org/mailman/listinfo/python-list


[issue5999] compile error on HP-UX 11.22 ia64 - 'mbstate_t' is used as a type, but has not been defined as a type

2018-08-18 Thread Mark Lawrence


Change 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



How to multiply dictionary values with other values based on the dictionary's key?

2018-08-18 Thread giannis . dafnomilis
I have the results of an optimization run in the form found in the following 
pic: https://i.stack.imgur.com/pIA7i.jpg.

How can I multiply the dictionary values of the keys FEq_(i,_j,_k,_l) with 
preexisting values of the form A[i,j,k,l]?

For example I want the value of key 'FEq_(0,_0,_2,_2)' multiplied with 
A[0,0,2,2], the value of key 'FEq_(0,_0,_4,_1)' multiplied with A[0,0,4,1] etc. 
for all the keys present in my specific dictionary.

I have been trying to correspondingly multiply the dictionary values in the 
form of 
varsdict["FEq_({0},_{1},_{2},_{3})".format(i,j,k,l)]

but this is not working as the indexes do not iterate consequently over all 
their initial range values, they are the results of the optimization so some 
elements are missing. I also could not find something of a similar nature where 
I looked.

Thank you for the help!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue5999] compile error on HP-UX 11.22 ia64 - 'mbstate_t' is used as a type, but has not been defined as a type

2018-08-18 Thread Michael Osipov


Michael Osipov <1983-01...@gmx.net> added the comment:

I cannot reproduce this with HP-UX 11.31 and master + 3.7.

I opt to close this one.

--
nosy: +michael-o

___
Python tracker 

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



[issue1648923] HP-UX: -lcurses missing for readline.so

2018-08-18 Thread Michael Osipov


Michael Osipov <1983-01...@gmx.net> added the comment:

I cannot reproduce this with master and 3.7 on HP-UX.

readline is linked and works with interactive python(1). curses module isn't 
buld because I don't have curses installed.

I opt to close this one.

--
nosy: +michael-o

___
Python tracker 

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



[issue22057] The doc say all globals are copied on eval(), but only __builtins__ is copied

2018-08-18 Thread Berker Peksag


Berker Peksag  added the comment:

I like Martin's suggestion in msg282262 and I've just created PR 8812 to 
implement it.

--
nosy: +berker.peksag
type:  -> behavior
versions: +Python 3.8 -Python 3.5

___
Python tracker 

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



[issue22057] The doc say all globals are copied on eval(), but only __builtins__ is copied

2018-08-18 Thread Berker Peksag


Change by Berker Peksag :


--
pull_requests: +8290

___
Python tracker 

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



[issue34381] Make tests with outbound connection optional

2018-08-18 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
versions:  -Python 2.7

___
Python tracker 

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



[issue10384] SyntaxError should contain exact location of the invalid character in identifier

2018-08-18 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

When testing how IDLE handles the examples (which it does well, see #2382 
msg323734), I discovered that while the single invisible char for msg120936 
*is* present in the posted text, the multiple invisible chars for msg228023 are 
not.  The following has them before and after the 'a':
  inv​a​lid

--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue2382] [Py3k] SyntaxError cursor shifted if multibyte character is in line.

2018-08-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

IDLE avoids the problem of calculating a location for a '^' below the bad line 
by instead asking tk to give the marked character (and maybe more) a 'ERROR' 
tag, which shows as a red background.  So it marks the '$' of 'A_I_U_E_O$' and 
the 'alid' slice of 'inv\u200balid' (from duplicate #10384).  When the marked 
character is '\n', the space following the line is tagged.  Is it possible to 
do something similar with any of the major system consoles?

--
nosy: +terry.reedy

___
Python tracker 

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



Re: Pylint false positives

2018-08-18 Thread Chris Angelico
On Sun, Aug 19, 2018 at 7:11 AM, Marko Rauhamaa  wrote:
> Chris Angelico :
>> Your acceptance of closures is a perfect proof of how magic stops
>> looking like magic once you get accustomed to it.
>
> Actually, that's a very good observation. You should stick with a
> smallish kernel of primitives and derive the universe from them.
>
> Anyway, functions as first-class objects are truly foundational in all
> high-level programming. In Python programming, I mostly run into
> closures through inner classes (as in Java).
>
>> If you can accept closures because they just DTRT, why not accept a
>> much simpler and more obvious operation like putting a 'def' statement
>> in a loop?
>
> Nothing wrong or extraordinary with putting a def statement in a loop,
> but populating an object with fields (methods) in a loop is very rarely
> a good idea.
>

*headscratch*

So this is okay:

def f():
for i in range(5):
def g(): ...

But this isn't:

class C:
for i in range(5):
def m(self): ...

I've missed something here.

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


Re: Pylint false positives

2018-08-18 Thread Marko Rauhamaa
Chris Angelico :
> Your acceptance of closures is a perfect proof of how magic stops
> looking like magic once you get accustomed to it.

Actually, that's a very good observation. You should stick with a
smallish kernel of primitives and derive the universe from them.

Anyway, functions as first-class objects are truly foundational in all
high-level programming. In Python programming, I mostly run into
closures through inner classes (as in Java).

> If you can accept closures because they just DTRT, why not accept a
> much simpler and more obvious operation like putting a 'def' statement
> in a loop?

Nothing wrong or extraordinary with putting a def statement in a loop,
but populating an object with fields (methods) in a loop is very rarely
a good idea.


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


[issue24665] CJK support for textwrap

2018-08-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

My msg323731 for #12568 refers to my msg321291 above.  I did some new 
experiments with column spacing for European characters in Windows console (as 
opposed to tk Text) and discovered that some, including some Latin1 characters 
used in English text, may also become double-width in certain fonts.  The 
problem of calculating physical line lengths is even harder than I thought 
before, and does not require non-English text.

--

___
Python tracker 

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



[issue34188] Allow dict choices to "transform" values in argpagse

2018-08-18 Thread paul j3


paul j3  added the comment:

The 'choices' mechanism is quite simple.  As noted for testing it simply uses 
an 'in' test.  

For help formating it uses

 choice_strs = [str(choice) for choice in action.choices]
 result = '{%s}' % ','.join(choice_strs)

In other words, it's treated as a iterable. 

But it is easy to produce unmanageable displays, such as with 'range(100)'.  
This has been raised in other bug/issues.  The best way around that is with the 
'metavar', which lets you customize the 'usage' and 'help'.  One thing that 
'metavar' does not help with is the error display.

I'm not privy to the original author's thinking, but I don't think 'choices' 
was ever meant to be a high power tool.  

With a custom Action you can do almost anything that you could do after parsing.

--

___
Python tracker 

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



Re: Pylint false positives

2018-08-18 Thread Chris Angelico
On Sun, Aug 19, 2018 at 6:28 AM, Marko Rauhamaa  wrote:
> Steven D'Aprano :
>>> In a word, steer clear of metaprogramming.
>>
>> [...]
>> (2) if you mean what you say, that means no decorators,
>
> Correct. I don't find decorators all that useful or tasteful.
>
>> no closures,
>
> Closures I consider ordinary programming. Nothing meta there.

So it's okay to have a function that can be created more than once,
then? Because closures usually will be.

>> no introspection ("reflection" in Java terms),
>
> Introspection is suspect in general.

So, no calling help() or using any sort of automated signature display.

>> no source-code generators.
>
> Lisp-style macros (or scheme syntax rules) are rather a clean way to do
> that, but even that mechanism should be used very sparingly and
> tastefully.

I posted something from an active project of mine earlier. Please
explain how to do it better, in your no-metaprogramming world. Show me
how my code would be improved by avoiding code generation.

>> No namedtuples, Enums, or data-classes.
>
> They don't seem all that meta to me, but coincidentally I never found
> uses for them in my Python code.

They all involve metaclasses, which you have forbidden. Ergo you
should not use them. (At least, I think namedtuple uses a metaclass.
Might be wrong there. It certainly uses exec().)

Your acceptance of closures is a perfect proof of how magic stops
looking like magic once you get accustomed to it. How do closures
actually work? Do you have any idea, or do you just accept that stuff
works the way you expect it to?

If you can accept closures because they just DTRT, why not accept a
much simpler and more obvious operation like putting a 'def' statement
in a loop?

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


[issue12568] Add functions to get the width in columns of a character

2018-08-18 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

I suggest reclosing this issue, for the same reason I suggested closure of 
#24665 in msg321291: abstract unicode 'characters' (graphemes) do not, in 
general, have fixed physical widths of 0, 1, or 2 n-pixel columns (or spaces).  
I based that fairly long message on IDLE's multiscript font sample as displayed 
on Windows 10.  In that context, for instance, the width of (fixed-pitch) East 
Asian characters is about 1.6, not 2.0, times the width of fixed-pitch Ascii 
characters.  Variable-width Tamil characters average about the same.  The exact 
ratio depends on the Latin font used.

I did more experiments with Python started from Command Prompt with code page 
437 or 65001 and characters 20 pixels high.  The Windows console only allows 
'fixed pitch' fonts.  East Asian characters, if displayed, are expanded to 
double width.

However, European characters are not reliably displayed in one column. The 
width depends on the both the font selected when a character is entered and the 
current font. The 20 latin1 characters in '¢£¥§©«®¶½ĞÀÁÂÃÄÅÇÐØß' usually 
display in 20 columns.  But if they are entered with the font set to MSGothic, 
the '§' and '¶' are each displayed in the middle of 2 columns, for 22 total.  
If the font is changed to MSGothic after entry, the '§' and '¶' are shifted 1/2 
column right to overlap the following '©' or '½' without changing the total 
width.  Greek and Cyrillic characters also sometimes take two columns.

I did not test whether the font size (pixel height) affects horizontal column 
spacing.

--
stage:  -> test needed
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: Pylint false positives

2018-08-18 Thread Marko Rauhamaa
Steven D'Aprano :
>> In a word, steer clear of metaprogramming.
>
> [...]
> (2) if you mean what you say, that means no decorators,

Correct. I don't find decorators all that useful or tasteful.

> no closures,

Closures I consider ordinary programming. Nothing meta there.

> no introspection ("reflection" in Java terms),

Introspection is suspect in general.

> no metaclasses (other than type),

Correct.

> no use of descriptors (other than the built-in ones),

Haven't used (or at least defined) them.

> no template-based programming,

Please, no.

> no source-code generators.

Lisp-style macros (or scheme syntax rules) are rather a clean way to do
that, but even that mechanism should be used very sparingly and
tastefully.

> No namedtuples, Enums, or data-classes.

They don't seem all that meta to me, but coincidentally I never found
uses for them in my Python code.


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


[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread Eric V. Smith

Eric V. Smith  added the comment:

Thanks, Andrés!

--
assignee: docs@python -> eric.smith
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



Re: Pylint false positives

2018-08-18 Thread Steven D'Aprano
On Sat, 18 Aug 2018 00:33:26 +0300, Marko Rauhamaa wrote:

> Chris Angelico :
>> Programming is heavily about avoiding duplicated work.
> 
> That is one aspect, but overcondensing and overabstracting programming
> logic usually makes code less obvious to its maintainer. 

That may very well be true, but we're not talking about those evils here. 
We're talking about a simple factory technique for creating a number of 
identical objects in a loop.


[...]
> I would guess such techniques could come in handy in some framework
> development but virtually never in ordinary application development. In
> a word, steer clear of metaprogramming.

Depending on your definition of metaprogramming, either:

(1) this either isn't metaprogramming at all, merely programming and no 
more scary than populating a dict at runtime; or


(2) if you mean what you say, that means no decorators, no closures, no 
introspection ("reflection" in Java terms), no metaclasses (other than 
type), no use of descriptors (other than the built-in ones), no template-
based programming, no source-code generators. No namedtuples, Enums, or 
data-classes.


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

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


[issue34415] Typo in logging.Formatter docstring

2018-08-18 Thread Vinay Sajip


Change by Vinay Sajip :


--
keywords: +patch, patch
pull_requests: +8288, 8289
stage:  -> patch review

___
Python tracker 

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



[issue34415] Typo in logging.Formatter docstring

2018-08-18 Thread Vinay Sajip


Change by Vinay Sajip :


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

___
Python tracker 

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



[issue34403] test_utf8_mode.test_cmd_line() fails on HP-UX due to false assumptions

2018-08-18 Thread Michael Osipov


Michael Osipov <1983-01...@gmx.net> added the comment:

Thanks, I'll do that. Hopefully I can provide a patch for. Though, I am 
convinced that I have to write a custom codec for roman8 to make all at stuff 
work flawlessly.

--

___
Python tracker 

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



[issue34402] strftime fails on HP-UX

2018-08-18 Thread Michael Osipov


Michael Osipov <1983-01...@gmx.net> added the comment:

Thanks changed appropriately. I here also have a PR idea I will try on Monday. 
It won't be idiotproof, but someone will likely comment on it and provide more 
input.

I am willing to provide even more patches, but am currently stuck with 
https://github.com/python/cpython/pull/8786 and juggle with "git stash" to make 
Python actually compile on HP-UX. This is cumbersome.

--
title: [SOLUTION] strftime fails on HP-UX -> strftime fails on HP-UX
type: crash -> behavior

___
Python tracker 

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



[issue34401] Make test_gdb work on HP-UX

2018-08-18 Thread Michael Osipov


Michael Osipov <1983-01...@gmx.net> added the comment:

My bad, I initially had attached a patch as you can see, but will turn that 
into a PR on GitHub on Monday. That's why I had that label, but removed the 
patch.

It doesn't crash, it is rather a behavior/regex issue in the test.

Thanks for pointing out. Will get to you with a solution on Monday.

--
title: [SOLUTION] Make test_gdb work on HP-UX -> Make test_gdb work on HP-UX
type: crash -> behavior

___
Python tracker 

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



[issue34382] test_os.test_mode fails when directory base directory has g+s set

2018-08-18 Thread Michael Felt

Michael Felt  added the comment:

Likewise, I have no idea who should review, or whether python2 should be 
included or not. 

The issue is not a bug in python, rather a shortcoming in the test suite. 

In short, since I do my builds in an environment where the mode includes SGID  
on the directory i see this “false” fail. 

Sent from my iPhone

> On 17 Aug 2018, at 23:19, Terry J. Reedy  wrote:
> 
> 
> Terry J. Reedy  added the comment:
> 
> 'Backport' might or might not mean 2.7. You should be able to explicitly 
> select versions in the box above.  I have no idea who should review this.
> 
> --
> nosy: +terry.reedy
> 
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread Eric V. Smith


Eric V. Smith  added the comment:


New changeset 0fd6f832a9c30404bf595a4af36e171d11fab024 by Eric V. Smith (Miss 
Islington (bot)) in branch '3.7':
bpo-34432: doc Mention complex and decimal.Decimal on str.format note about 
locales (GH-8808) (GH-8809)
https://github.com/python/cpython/commit/0fd6f832a9c30404bf595a4af36e171d11fab024


--

___
Python tracker 

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



[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread Eric V. Smith


Eric V. Smith  added the comment:


New changeset fbd0a14cc941e340df0979d94ac55191dd31ad00 by Eric V. Smith (Miss 
Islington (bot)) in branch '3.6':
bpo-34432: doc Mention complex and decimal.Decimal on str.format not about 
locales (GH-8808) (GH-8810)
https://github.com/python/cpython/commit/fbd0a14cc941e340df0979d94ac55191dd31ad00


--

___
Python tracker 

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



[issue34431] Docs does not eval allows code object as argument

2018-08-18 Thread Jonathan Fine


Jonathan Fine  added the comment:

OK. I'll do as you say. I've just signed the CLA.

--

___
Python tracker 

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



[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread Andrés Delfino

Change by Andrés Delfino :


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



[issue34431] Docs does not eval allows code object as argument

2018-08-18 Thread Berker Peksag


Berker Peksag  added the comment:

Ok, I think it would be a good idea to mention that the function accepts a code 
object in the first sentence. I'd be happy to review such PR. The eval() 
documentation is located at 
https://github.com/python/cpython/blob/master/Doc/library/functions.rst

See https://devguide.python.org/ for more details about the contribution 
process.

Note that you need to sign the CLA in order to contribute to Python: 
https://www.python.org/psf/contrib/contrib-form/

#22057 and #25810 are out of scope for this issue, so let's not discuss them 
here.

--
resolution: not a bug -> 
stage:  -> needs patch

___
Python tracker 

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



[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8287

___
Python tracker 

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



[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread miss-islington


Change by miss-islington :


--
pull_requests: +8286

___
Python tracker 

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



[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread Eric V. Smith

Eric V. Smith  added the comment:


New changeset 93b5655c040a33f9ba4cdbd303afc8398c8413c7 by Eric V. Smith (Andrés 
Delfino) in branch 'master':
bpo-34432: doc Mention complex and decimal.Decimal on str.format not about 
locales (GH-8808)
https://github.com/python/cpython/commit/93b5655c040a33f9ba4cdbd303afc8398c8413c7


--
nosy: +eric.smith

___
Python tracker 

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



[issue34431] Docs does not eval allows code object as argument

2018-08-18 Thread Jonathan Fine


Jonathan Fine  added the comment:

Summary: There's my problem, and others. I'm willing to provide a patch, if 
supported.

There's a gotcha here. I fell into it. The docs for eval state
===
eval(expression, globals=None, locals=None)
The arguments are a string and optional globals and locals.
===
I read this and concluded, fairly I think, that I'm not allowed to pass in a 
code object [1]. So I didn't read any further. I'd already got the answer to my 
question.

But I knew that exec would take a code object, so I had doubt, and did my 
little experiment.

I'd prefer something more like exec, which says
===
This function supports dynamic execution of Python code. object must be either 
a string or a code object.
===

There are other problems, such as not agreeing with the help(eval) etc messages 
(and the still open #22057, #25810):
===
eval(source, globals=None, locals=None, /)
Evaluate the given source in the context of globals and locals.

The source may be a string representing a Python expression
or a code object as returned by compile().
The globals must be a dictionary and locals can be any mapping,
defaulting to the current globals and locals.
If only globals is given, locals defaults to it.
===
exec(source, globals=None, locals=None, /)
Execute the given source in the context of globals and locals.

The source may be a string representing one or more Python statements
or a code object as returned by compile().
The globals must be a dictionary and locals can be any mapping,
defaulting to the current globals and locals.
If only globals is given, locals defaults to it.
===

Finally, I'm willing to provide a patch, if supported. (I've not contributed to 
Python before.)

[1] I'd just read the docs for exec, which is up-front about 'string or code'.

--
status: pending -> open

___
Python tracker 

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



[issue34425] :s formatting broken for objects without __format__

2018-08-18 Thread Eric V. Smith


Eric V. Smith  added the comment:

I agree this is the desired behavior, and not a bug.

Because you are not specifying a __format__ in your class, object.__format__ is 
being called. By design, it does not understand any formatting specifiers, 
instead reserving them for your class to implement. "!s" is the correct way to 
convert your type to a string. Either that, or add a __format__ that 
understands "s".

Note that not all types understand "s", for example, datetime.

--
assignee:  -> eric.smith
nosy: +eric.smith
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread Andrés Delfino

Change by Andrés Delfino :


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

___
Python tracker 

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



[issue34432] doc Mention complex and decimal.Decimal on str.format note about locales

2018-08-18 Thread Andrés Delfino

New submission from Andrés Delfino :

On str.format method, the note about how locales are dealt with reads:

"When formatting a number (int, float, float and subclasses)..."

PR removes the second float, and mentions complex and decimal.Decimal.

The bug which introduced this note is: #31900

--
assignee: docs@python
components: Documentation
messages: 323718
nosy: adelfino, docs@python
priority: normal
severity: normal
status: open
title: doc Mention complex and decimal.Decimal on str.format note about locales
type: enhancement
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



Re: defaultdict and datetime

2018-08-18 Thread MRAB

On 2018-08-18 16:43, Jason Friedman wrote:

$ python3
Python 3.6.1 (default, Apr  8 2017, 09:56:20)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.

import collections, datetime
x = collections.defaultdict(int)
x['something']

0

x = collections.defaultdict(datetime.datetime)
x['something']

Traceback (most recent call last):
   File "", line 1, in 
TypeError: Required argument 'year' (pos 1) not found

I would like to have a dictionary where the default value is a
datetime.datetime object, preferably something small like January 1, year 1.


For the value you can use datetime.datetime.min.

The argument to defaultdict must be a function that takes no arguments. 
You can use lambda for that:


x = collections.defaultdict(lambda: datetime.datetime.min)
--
https://mail.python.org/mailman/listinfo/python-list


[issue34431] Docs does not eval allows code object as argument

2018-08-18 Thread Berker Peksag


Berker Peksag  added the comment:

Thank you for your report.

Quoting from https://docs.python.org/3.6/library/functions.html#eval

This function can also be used to execute arbitrary code objects
(such as those created by compile()). In this case pass a code
object instead of a string.

So, your example is already documented as a legal way of using the eval() 
function.

I don't see anything wrong here.

--
nosy: +berker.peksag
resolution:  -> not a bug
status: open -> pending
type:  -> behavior
versions:  -Python 3.4, Python 3.5

___
Python tracker 

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



[issue34431] Docs does not eval allows code object as argument

2018-08-18 Thread Jonathan Fine


New submission from Jonathan Fine :

See https://docs.python.org/3.6/library/functions.html#eval
This says the following won't happen. But it does.

Python 3.6.2 (default, Jul 29 2017, 00:00:00) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> def fn(): print(3); return 4
... 
>>> eval(fn.__code__)
3
4

Compare with https://docs.python.org/3.6/library/functions.html#exec

Search for eval in title of open issues bring up related

#22057 (The doc say all globals are copied on eval(), but only __builtins__ is 
copied)
#25810 (Python 3 documentation for eval is incorrect)

--
assignee: docs@python
components: Documentation
messages: 323716
nosy: docs@python, jfine2358
priority: normal
severity: normal
status: open
title: Docs does not eval allows code object as argument
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



defaultdict and datetime

2018-08-18 Thread Jason Friedman
$ python3
Python 3.6.1 (default, Apr  8 2017, 09:56:20)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import collections, datetime
>>> x = collections.defaultdict(int)
>>> x['something']
0
>>> x = collections.defaultdict(datetime.datetime)
>>> x['something']
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Required argument 'year' (pos 1) not found

I would like to have a dictionary where the default value is a
datetime.datetime object, preferably something small like January 1, year 1.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue34430] Symmetrical chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Change by Alfred Sawaya :


--
title: Double chaining futures in asyncio.future.wrap_future -> Symmetrical 
chaining futures in asyncio.future.wrap_future

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Change by Alfred Sawaya :


--
versions:  -Python 3.6, Python 3.7

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Change by Alfred Sawaya :


--
pull_requests:  -8283

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Alfred Sawaya  added the comment:

The proposed solution (PR) has passed all tests.

--

___
Python tracker 

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



[issue34421] Cannot install package with unicode module names on Windows

2018-08-18 Thread Julien Malard

Julien Malard  added the comment:

Hello,

Yes, it does seem odd that that code does not work. On my Windows machine 
(WIndows 7, 64 bits, running 32-bit Python) I checked and it seems that the 
code in the if block immediately preceding my PR does not run at all, whereby 
the error.

For a reproducible example, my Taqdir package, mostly consisting of unicode 
packages and modules, runs into this issue (and installs successfully after my 
proposed fix here combined with a separate PR in pip). Perhaps the most easily 
accessible example would be the Appveyor build 
(https://ci.appveyor.com/project/julienmalard/Tinamit) for my TInamit project, 
which has Taqdir as a dependency.

Thanks!

-Julien Malard


દ્વારા: Serhiy Storchaka 
મોકલ્યું: 18 ઑગસ્ટ 2018 06:32
પ્રતિ: Julien Malard
વિષય: [issue34421] Cannot install package with unicode module names on Windows

New submission from Serhiy Storchaka :

Please provide more details. How to reproduce your issue? What you got, and 
what you expect to get?

Seems the code just before lines modified by your PR are purposed to solve this 
issue. Why it doesn't work?

--
nosy: +serhiy.storchaka

___
Python tracker 

___

--

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Change by Alfred Sawaya :


--
pull_requests: +8284

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Change by Alfred Sawaya :


--
pull_requests: +8283

___
Python tracker 

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



[issue34217] windows: cross compilation fails due to headers with uppercase

2018-08-18 Thread Steve Dower


Steve Dower  added the comment:

As someone who has written MSDN samples, I'll spoil the secret and let you know 
that there's no consistency there, so you can find examples to prove either 
direction ;)

I wasn't expecting expertise or research. I was only expecting a description of 
the change that clearly specifies who benefits and who loses, and leaves a 
chance for the affected experts to confirm impact before being merged. There 
can be a surprising amount of subtlety around cross-platform issues, which is 
why we have designated people who are responsible for tracking them.

--

___
Python tracker 

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



[issue34427] calling MutableSequence.extend on self produces infinite loop

2018-08-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

deque and bytearray make an in-memory copy of self if extended with self. deque 
creates a temporary list, bytearray creates a temporary bytearray. list just 
iterates itself as a linear array of known size and avoids infinite loop. It 
could be possible to avoid creaing a temporary copy in case of deque and 
bytearray too, but I don't think this special case is worth an additional code.

But a MutableSequence can represents a sequence that doesn't fit in memory. It 
can provide an interface to a linear on-disk store. In this case creating an 
on-memory copy is not possible.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue34427] calling MutableSequence.extend on self produces infinite loop

2018-08-18 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

It would be reasonable to add special handling for this case to match what is 
done in the concrete sequences like list, deque, bytes, ...

--
assignee:  -> rhettinger

___
Python tracker 

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



[issue34365] datetime's documentation refers to "comparison [...] falling back to the default scheme of comparing object addresses"

2018-08-18 Thread Kevin Norris


Kevin Norris  added the comment:

There is none.  It raises a TypeError.  See 
https://docs.python.org/3/reference/expressions.html#value-comparisons

--

___
Python tracker 

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



[issue31370] Remove support for threads-less builds

2018-08-18 Thread Zackery Spytz


Change by Zackery Spytz :


--
pull_requests: +8282

___
Python tracker 

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



[issue34428] tokenize

2018-08-18 Thread Luke Kenneth Casson Leighton


Luke Kenneth Casson Leighton  added the comment:

ahh darn-it, autopep8 is passing in tokens line-by-line,
to be parsed one at a time oh and of course it's losing
state information that tokenizer critically relies on.

i *think* that's what's going on so it's highly unlikely
to be a python tokenize bug... can we wait to see what the
autopep8 developer says?

--

___
Python tracker 

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



[issue34428] tokenize

2018-08-18 Thread Luke Kenneth Casson Leighton


Luke Kenneth Casson Leighton  added the comment:

wtf??? neither can i

import io
import tokenize

text = r'''\
(
r"\(")

(
"\(")
'''

string_io = io.StringIO(text)
tokens = list(
tokenize.generate_tokens(string_io.readline)
)

print (tokens)

works perfectly.

ok a i bet you it's something to do with how
string_io.readline works, or something to do with
the format of the text.  give me a sec to triage it.

--

___
Python tracker 

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



[issue34428] tokenize

2018-08-18 Thread Luke Kenneth Casson Leighton


Luke Kenneth Casson Leighton  added the comment:

regular expressions are not something i am familiar or comfortable
with (never have been: the patterns are too dense).  however REMOVING
"Bracket" from the regular expression(s) for PseudoToken "fixes"
the problem.

some debug print statements dropped in at around line 640 of
tokenize.py show that the match on the "working" code
with r"\(") as input gives a start/end/spos/epos that is DIFFERENT
from when the same code is given just "\("

line 'r"\\(")\n'
pos 0 7 r <_sre.SRE_Match object; span=(0, 5), match='r"\\("'>
pseudo start/end 0 5 (2, 0) (2, 5)

vs

line '"\\(")\n'
pos 0 6 " <_sre.SRE_Match object; span=(0, 4), match='"\\("'>
pseudo start/end 0 4 (5, 0) (5, 4)

there *may* be a way to "fix" this by taking out the pattern
matching on Bracket and prioritising everything else.


while pos < max:
pseudomatch = _compile(PseudoToken).match(line, pos)
print ("pos", pos, max, line[pos], pseudomatch)
if pseudomatch:# scan for tokens
start, end = pseudomatch.span(1)
spos, epos, pos = (lnum, start), (lnum, end), end
print ("pseudo start/end", start, end, spos, epos)
if start == end:
continue

 
Bracket = '[][(){}]'
Special = group(r'\r?\n', r'\.\.\.', r'[:;.,@]')
# REMOVE Bracket
Funny = group(Operator, Special)

PlainToken = group(Number, Funny, String, Name)
Token = Ignore + PlainToken

# First (or only) line of ' or " string.
ContStr = group(StringPrefix + r"'[^\n'\\]*(?:\\.[^\n'\\]*)*" +
group("'", r'\\\r?\n'),
StringPrefix + r'"[^\n"\\]*(?:\\.[^\n"\\]*)*' +
group('"', r'\\\r?\n'))
PseudoExtras = group(r'\\\r?\n|\Z', Comment, Triple)
PseudoToken = Whitespace + group(PseudoExtras, Number, Funny, ContStr, Name)

--
nosy:  -serhiy.storchaka

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Alfred Sawaya  added the comment:

Actually the PR does not pass some tests, I will work on this. If the new 
behaviours are accepted, I will implement them soon.

--

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Change by Alfred Sawaya :


--
pull_requests:  -8281

___
Python tracker 

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



[issue34428] tokenize

2018-08-18 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I can't reproduce.

>>> import tokenize
>>> list(tokenize.generate_tokens(iter(['(\n', r'"\(")']).__next__))
[TokenInfo(type=53 (OP), string='(', start=(1, 0), end=(1, 1), line='(\n'), 
TokenInfo(type=56 (NL), string='\n', start=(1, 1), end=(1, 2), line='(\n'), 
TokenInfo(type=3 (STRING), string='"\\("', start=(2, 0), end=(2, 4), 
line='"\\(")'), TokenInfo(type=53 (OP), string=')', start=(2, 4), end=(2, 5), 
line='"\\(")'), TokenInfo(type=4 (NEWLINE), string='', start=(2, 5), end=(2, 
6), line=''), TokenInfo(type=0 (ENDMARKER), string='', start=(3, 0), end=(3, 
0), line='')]

Could you please provide a minimal script that reproduces your issue?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Change by Alfred Sawaya :


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

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


Change by Alfred Sawaya :


--
pull_requests:  -8280

___
Python tracker 

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



[issue34428] tokenize

2018-08-18 Thread Luke Kenneth Casson Leighton


Luke Kenneth Casson Leighton  added the comment:

python2.7 and 3.5 also has exact same issue.

--
versions: +Python 2.7, Python 3.5

___
Python tracker 

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



[issue34430] Double chaining futures in asyncio.future.wrap_future

2018-08-18 Thread Alfred Sawaya


New submission from Alfred Sawaya :

asyncio.future.wrap_future is used to wrap a concurrent.future.Future in a 
asyncio.future.Future. 

The actual implementation as the following behaviours : 

 1) When the concurrent.future.Future gets a result, the asyncio.future.Future 
gets the same result,
 2) When the asyncio.future.Future is cancelled, the concurrent.future.Future 
is cancelled

I wonder why the futures synchronisation is not symmetrical ?
I propose to add the following behaviours : 

 3) When the asyncio.future.Future gets a result, the concurrent.future.Future 
gets the same result,
 4) When the concurrent.future.Future is cancelled, the asyncio.future.Future 
is cancelled

I have also posted a request pull that implements the proposed behaviours, in 
case of acceptation.

If there is good reasons to not implement the proposed behaviours, I would be 
glad to know.

Thank you !

--
components: asyncio
messages: 323703
nosy: asvetlov, huji, yselivanov
priority: normal
pull_requests: 8280
severity: normal
status: open
title: Double chaining futures in asyncio.future.wrap_future
type: enhancement
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue34429] On Windows tempfile.TemporaryFile behaves like NamedTemporaryFile

2018-08-18 Thread dwich


New submission from dwich :

On Windows tempfile.TemporaryFile() accepts delete attribute. On Linux 
TemporaryFile() raises TypeError if delete attribute is used.

In tempfile.py source is the code below which means that on Windows 
TemporaryFile behaves like NamedTemporaryFile. I suppose the code should not be 
changed but the behaviour should be mentioned in documentation.

if _os.name != 'posix' or _os.sys.platform == 'cygwin':
# On non-POSIX and Cygwin systems, assume that we cannot unlink a file
# while it is open.
TemporaryFile = NamedTemporaryFile

Steps to reproduce:
>>> import tempfile
>>> tf = tempfile.TemporaryFile(delete=False)

On Linux Python throws TypeError:

Traceback (most recent call last):
  File "", line 1, in 
TypeError: TemporaryFile() got an unexpected keyword argument 'delete'

On Windows Python does not throw TypeError because on Windows TemporaryFile is 
in fact NamedTemporaryFile which accepts delete attribute.

Tested on all these versions: 3.7.0 64 bit, 3.6.5 32 bit, 3.5.4 32 bit, 3.4.4 
32 bit, 2.7.15 32 bit 


Proposed text to tempfile.TemporaryFile documentation:

On non POSIX or Cygwin platforms TemporaryFile behaves exacly like 
NamedTemporaryFile including the fact that TemporaryFile accepts delete 
attribute and does not raise
TypeError: TemporaryFile() got an unexpected keyword argument 'delete'.

--
assignee: docs@python
components: Documentation
messages: 323702
nosy: docs@python, dwich
priority: normal
severity: normal
status: open
title: On Windows tempfile.TemporaryFile behaves like NamedTemporaryFile
versions: Python 2.7, 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



[issue34217] windows: cross compilation fails due to headers with uppercase

2018-08-18 Thread Erik Janssens


Erik Janssens  added the comment:

I'll try to be more precise :

- I did an (imperfect) search : before these changes 98% of the windows headers 
were included in the .c files in lowercase

- These changes would bring it to 100%

- The advantage of these changes are consistency and the ability to cross 
compile those .c files on linux for a windows target, using the mingw-w64 sdk, 
where the sdk is on a case sensitive filesystem, as is the default when 
installing this sdk in most linux distributions.

- I did not consider, nor did I test other toolchains than 
mingw-w64/mingw-w64-sdk on linux and msvc/windows-sdk on windows.

I'm not enough of an expert on the different tools to come up with a 
comprehensive solution for this issue, but am willing to validate such solution 
for the use case of cross compiling on linux.

--

___
Python tracker 

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



[issue34428] tokenize

2018-08-18 Thread Luke Kenneth Casson Leighton


Luke Kenneth Casson Leighton  added the comment:

these two line also pass (do not throw an exception):

co = re.compile(
r"\(")

the code that fails may be further reduced to the following:

(
"\(")

--

___
Python tracker 

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



[issue34421] Cannot install package with unicode module names on Windows

2018-08-18 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Please provide more details. How to reproduce your issue? What you got, and 
what you expect to get?

Seems the code just before lines modified by your PR are purposed to solve this 
issue. Why it doesn't work?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue34428] tokenize

2018-08-18 Thread Luke Kenneth Casson Leighton


New submission from Luke Kenneth Casson Leighton :

https://github.com/hhatto/autopep8/issues/414

the following two lines of code are not parseable by tokenize.py:

co = re.compile(
"\(")

the combination of:
* being split on two lines
* having a backslash inside quotes
* having a bracket inside quotes

is an edge-case that _tokenize cannot cope with.

--
components: Library (Lib)
messages: 323698
nosy: lkcl
priority: normal
severity: normal
status: open
title: tokenize
type: crash
versions: Python 3.6, Python 3.7

___
Python tracker 

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



[issue34427] calling MutableSequence.extend on self produces infinite loop

2018-08-18 Thread Naris R


Change by Naris R :


--
nosy: +rhettinger, stutzbach

___
Python tracker 

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



[issue34427] calling MutableSequence.extend on self produces infinite loop

2018-08-18 Thread Naris R


Naris R  added the comment:

I forgot to copy over __len__ in the example

--

___
Python tracker 

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



[issue34427] calling MutableSequence.extend on self produces infinite loop

2018-08-18 Thread Naris R


New submission from Naris R :

Example:

```
from typing import MutableSequence, TypeVar

CliffordGate = TypeVar('CliffordGate')

class QCircuit(MutableSequence[CliffordGate]):
def __init__(self, gates):
self.gates = list(gates)

def __repr__(self):
return f'{self.__class__.__name__}({self.gates})'
   
def __getitem__(self, key):
return self.gates[key]

def __setitem__(self, key, item):
self.gates[key] = item

def __delitem__(self, key):
del self.gates[key]

def insert(self, key, item):
self.gates.insert(key, item)

a = QCircuit(['H0', 'S2'])
a += a
```

--
components: Library (Lib)
messages: 323696
nosy: Naris R
priority: normal
severity: normal
status: open
title: calling MutableSequence.extend on self produces infinite loop
type: 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



[issue34365] datetime's documentation refers to "comparison [...] falling back to the default scheme of comparing object addresses"

2018-08-18 Thread Danish Prakash


Danish Prakash  added the comment:

> But in 3.x, comparison no longer falls back to comparing object addresses.

What is the default fallback in 3.x?

--
nosy: +prakashdanish

___
Python tracker 

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



[issue1016626] distutils support for swig is under par

2018-08-18 Thread Ben McGinnes


Change by Ben McGinnes :


--
versions: +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



[issue34415] Typo in logging.Formatter docstring

2018-08-18 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

... the style-dependent default value, "%(message)s", "{message}", or 
"${message}", is used.

--

___
Python tracker 

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



[issue12568] Add functions to get the width in columns of a character

2018-08-18 Thread Bian Jiaping


Change by Bian Jiaping :


--
nosy: +bianjp

___
Python tracker 

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



[issue30717] Add unicode grapheme cluster break algorithm

2018-08-18 Thread Bian Jiaping


Change by Bian Jiaping :


--
nosy: +bianjp

___
Python tracker 

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