[issue37760] Refactor makeunicodedata.py: dedupe parsing, use dataclass

2019-08-20 Thread Greg Price


Greg Price  added the comment:

(A bit easy to miss in the way this thread gets displayed, so to highlight in a 
comment: GH-15265 is up, following the 5 other patches which have now all been 
merged.  That's the one that replaces the length-18 tuples with a dataclass.)

--

___
Python tracker 

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



Re: python requests get from API and post to another API and remote u'

2019-08-20 Thread Pankaj Jangid
Noah  writes:

> I place a get request and the response from the API is "{'id': 32,
> 'description': u'Firewall Outside', 'address': u'10.10.10.230/30'}"
>
> I then take that information and attempt post it to the other API.
> The data is not accepted and the result is an HTTP 400 code.
>
> I tried posting with postman and still rejected.
>
> I can post to the second API if I change the data to look like this:
> {"id": 32, "description": "Firewall Outside", "address":
> "10.10.10.230/30"}

This could be python version issue at your end. But I am thinking why
this is getting rejected by Postman as well. Try with vREST.

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


Re: Enumerate - int object not subscriptable

2019-08-20 Thread Sayth Renshaw
On Wednesday, 21 August 2019 03:16:01 UTC+10, Ian  wrote:
> Or use the "pairwise" recipe from the itertools docs:
> 
> from itertools import tee
> 
> def pairwise(iterable):
> "s -> (s0,s1), (s1,s2), (s2, s3), ..."
> a, b = tee(iterable)
> next(b, None)
> return zip(a, b)
> 
> for num1, num2 in pairwise(a):
> print(num1, num2)
> 

> > Stanley C. Kitching
> > Human Being
> > Phoenix, Arizona
> >
> > --

This definitely ended up being the ticket.

def pairwise(iterable): 
"s -> (s0,s1), (s1,s2), (s2, s3), ..." 
a, b = tee(iterable) 
next(b, None) 
return zip(a, b) 


def output_data(s):
serie = fibo(input_length)
x = []
y = []

for num1, num2 in pairwise(serie): 
y.append( num2 / num1) 

for item in y:
x.append(y.index(item))

draw_graph(x, y)


Kept trying with the enumerate style
for i, num in enumerate(serie):
while i < len(serie)-1:
x.append(int(serie[i + 1])/ int(serie[i]))
i += 1

but just couldn't quite get it to work. Itertools definitely made it easier.

for i, num in enumerate(serie):
while i < len(serie)-1:
x.append(int(serie[i + 1])/ int(serie[i]))
i += 1
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread miss-islington


miss-islington  added the comment:


New changeset 198a0d622a696a4c234aa7866d6c15e38839cc76 by Miss Islington (bot) 
in branch '2.7':
bpo-35518: Skip test that relies on a deceased network service. (GH-15349)
https://github.com/python/cpython/commit/198a0d622a696a4c234aa7866d6c15e38839cc76


--

___
Python tracker 

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



[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread miss-islington


miss-islington  added the comment:


New changeset b9d88e771238b5098842cad8a6ad624621f3f62e by Miss Islington (bot) 
in branch '3.7':
bpo-35518: Skip test that relies on a deceased network service. (GH-15349)
https://github.com/python/cpython/commit/b9d88e771238b5098842cad8a6ad624621f3f62e


--

___
Python tracker 

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



[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread miss-islington


miss-islington  added the comment:


New changeset 44f2c096804e8e3adc09400a59ef9c9ae843f339 by Miss Islington (bot) 
in branch '3.8':
bpo-35518: Skip test that relies on a deceased network service. (GH-15349)
https://github.com/python/cpython/commit/44f2c096804e8e3adc09400a59ef9c9ae843f339


--
nosy: +miss-islington

___
Python tracker 

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



[issue31461] IDLE: Enhance module browser

2019-08-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

#37902 Add mousewheel scrolling.

--
dependencies: +Add scrolling for IDLE browsers

___
Python tracker 

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



[issue37902] Add scrolling for IDLE browsers

2019-08-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

#31461 is the index issue for class browser.  Mousewheel scrolling was listed 
without an issue.  Now there is, and this has been added as a dependency.

--

___
Python tracker 

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



[issue37902] Add scrolling for IDLE browsers

2019-08-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I agree.  We added mousewheel scrolling to editor just over a year ago and 
later added it to text views.  But for the browsers, I want to factor out the 
common code.  It is a bit tricky since the 3 major systems each send different 
events for the same action, and macOS has the opposite convention for how the 
text moves when pushing the wheel up.

--
stage:  -> needs patch

___
Python tracker 

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



[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15065
pull_request: https://github.com/python/cpython/pull/15351

___
Python tracker 

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



[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15066
pull_request: https://github.com/python/cpython/pull/15352

___
Python tracker 

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



[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15064
pull_request: https://github.com/python/cpython/pull/15350

___
Python tracker 

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



[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread Benjamin Peterson


Benjamin Peterson  added the comment:


New changeset 5b95a1507e349da5adae6d2ab57deac3bdd12f15 by Benjamin Peterson 
(Greg Price) in branch 'master':
bpo-35518: Skip test that relies on a deceased network service. (GH-15349)
https://github.com/python/cpython/commit/5b95a1507e349da5adae6d2ab57deac3bdd12f15


--

___
Python tracker 

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



[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread Greg Price


Greg Price  added the comment:

I ran across this test when looking at especially slow files in the test suite: 
it turns out that not only is this service currently down, but the 
snakebite.net domain still exists, and as a result the test can end up waiting 
20-30s before learning that the hosts can't be found and the test gets skipped.

I agree with Benjamin's and Victor's comments -- the best solution would be to 
recreate the test, ideally as something that anyone (anyone with Docker 
installed, perhaps?) can just run locally.

For now I've just sent GH-15349 as a one-line fix to skip the test, with a 
remark pointing at this issue. It's already getting skipped 100% of the time 
thanks to the handy `support.transient_internet` mechanism -- this just makes 
the skip (a) explicit in the source code, and (b) a lot faster. :-)

--
nosy: +Greg Price

___
Python tracker 

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



[issue35518] test_timeout uses blackhole.snakebite.net domain which doesn't exist anymore

2019-08-20 Thread Greg Price


Change by Greg Price :


--
keywords: +patch
pull_requests: +15063
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15349

___
Python tracker 

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



Re: Style suggestions/critiques

2019-08-20 Thread DL Neil

On 21/08/19 9:11 AM, Michael F. Stemper wrote:

I recently wrote a couple of modules (more to come) to help me
use the tikz package in TeX/LaTeX. Since it's all to do with
drawing, I have a lot of points in R^2. Being unimaginative, I
implemented them as ordered pairs (2-tuples) of floats. E.g.:
p1 = 3,4
p2 = 5,6

Naturally, lines are implemented as ordered pairs[1] of points:
line = p1,p2

This all seems reasonably simple and intuitive (to me). However,
in order to actually do some manipulation, I have stuff like:
# Unpack the lines
l1p1,l1p2 = line1
l1x1,l1y1 = l1p1
l1x2,l1y2 = l1p2
l2p1,l2p2 = line2
l2x1,l2y1 = l2p1
l2x2,l2y2 = l2p2
spattered all over. Although this is simple enough, I find it
aesthetically unappealing.


Agreed, but could more descriptive names be used?



Is there some better idiom that I should be using, or is this
really in accord with The Zen of Python?
[1] (I could have done sets, I suppose, but orientation might be
useful at some point.)


Assuming that the code does-stuff with/to lines, eg rotate the line 0.2 
radians about some nominated rotational-center; maybe construct a class, eg


class Line():
def __init__( self, starting_point, ending_point ):
self.starting_point = starting_point
self.ending_point = ending_point
def rotate( self, angle, center ):
...

The same could also be said for a Point class. However, if they are 
'only' Cartesian coordinates and no methods ever apply(???), then maybe 
named-tuples or a dict?

(thus able to refer to p1.x and p1.y (or p1[ "x" ], etc) )


Using examples from above:

p1 = Point( 3, 4 )  # p1 = 3,4
p2 = Point( 5, 6 )  # p2 = 5,6

line = Line( p1, p2 )   # line = p1,p2

and instead of:
> l1p1,l1p2 = line1

Do things now appear to be closer to self-documenting?


Also, we can now use:
p1.x#instead of l1p1, and
p1.y#instead of l1p2

In fact, chances-are you won't ever do this because any point/line 
manipulation would become a method (hidden-away) within the respective 
class...

--
Regards =dn
--
https://mail.python.org/mailman/listinfo/python-list


[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-20 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

Additional logging on failures is always welcome.  Might I suggest that, in 
this case, regrtest treats this action as a hard fail so as to not got lost in 
the other transient failures (test_asyncio).

By that I mean, either to not re-run, or to still be "failed" even after a 
successful re-run as this test_concurrent mishap is rare enough that I doubt it 
would happen twice in one build.

Now for a brain dump.

The process tree at this time:

python.exe (buildbot)
. cmd.exe (test step)
.. python_d.exe (regrtest main)
... typepref.exe (load)
... 
 typepref.exe (load for test_concurrent_futures)
 python_d.exe (multiprocessing pool)
 python_d.exe (multiprocessing pool)
 python_d.exe (multiprocessing pool)
 python_d.exe (multiprocessing pool)
 python_d.exe (multiprocessing pool)


1. To see how process termination played out, I killed the main regrtest 
process.  This did not let the buildbot complete, but just sit there without 
any output.  Also the typepref.exe process (and the failed multiprocessing pool 
processes) still lingered.

2. I then terminated the children* of the already terminated process.  No 
change to the buildbot.

 [*] Windows doesn't really have the concept of a process tree

3. I then terminated the final typepref.exe process.  The buildbot finally 
finished its test step.

Given that typepref.exe also prevents completion, I believe the problem is in 
how we are spawning subprocesses.  Maybe a process handle is being inherited by 
the spawned processes preventing it from fully terminating?

I mention the process handle as it was listed as an open handle in Process 
Explorer for the regrtest process even though it had been terminated prior.

--
nosy: +eryksun

___
Python tracker 

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



[issue29427] Option to skip padding for base64 urlsafe encoding/decoding

2019-08-20 Thread Franklin Yu


Change by Franklin Yu :


--
nosy: +Franklin Yu

___
Python tracker 

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



Re: absolute path to a file

2019-08-20 Thread Grant Edwards
On 2019-08-21, Richard Damon  wrote:

> I think gmane feed the newsgroup comp.lang.python which feeds
> python-list@python.org.

No, gmane is a gateway to python-list@python.org.

--
Grant



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


[issue37901] 21 tests fail when run on an IPv6-only host

2019-08-20 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +vstinner

___
Python tracker 

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



[issue37902] Add scrolling for IDLE browsers

2019-08-20 Thread George Zhang


New submission from George Zhang :

I've just started using IDLE's module/path browsers and they offer a lot! 
Putting aside the issue of them opening in separate windows, they have a small 
change that could be made to improve them.

Both browsers have scrollbars, but (for me at least) I cannot scroll using my 
mouse. I propose adding support for scrolling similar to the editor/shell 
windows.

--
assignee: terry.reedy
components: IDLE
messages: 350043
nosy: GeeVye, terry.reedy
priority: normal
severity: normal
status: open
title: Add scrolling for IDLE browsers
type: enhancement
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



Re: Style suggestions/critiques

2019-08-20 Thread Aldwin Pollefeyt
The Zen of Python is readability? Does this look neater?

x11, y11, x12, y12, x21, y21, x22, y22 = line1[0] + line1[1] + line2[0] +
line2[1]

Compared to tuples, lists are maybe more useful if you need to manipulate
the coordinates.

line1 = [ [1, 2], [3, 4] ]
line1[1][0] = 5
line1[0] = [2, 3]

or

_p1, _p2, _x, _y = 0, 1, 0, 1
line1 = [ [1, 2], [3, 4] ]
line1[_p2][_x] = 5
line1[_p1] = [2, 3]







On Wed, Aug 21, 2019 at 5:15 AM Michael F. Stemper <
michael.stem...@gmail.com> wrote:

> I recently wrote a couple of modules (more to come) to help me
> use the tikz package in TeX/LaTeX. Since it's all to do with
> drawing, I have a lot of points in R^2. Being unimaginative, I
> implemented them as ordered pairs (2-tuples) of floats. E.g.:
>
> p1 = 3,4
> p2 = 5,6
>
> Naturally, lines are implemented as ordered pairs[1] of points:
>
> line = p1,p2
>
> This all seems reasonably simple and intuitive (to me). However,
> in order to actually do some manipulation, I have stuff like:
>
> # Unpack the lines
> l1p1,l1p2 = line1
> l1x1,l1y1 = l1p1
> l1x2,l1y2 = l1p2
> l2p1,l2p2 = line2
> l2x1,l2y1 = l2p1
> l2x2,l2y2 = l2p2
>
> spattered all over. Although this is simple enough, I find it
> aesthetically unappealing.
>
> Is there some better idiom that I should be using, or is this
> really in accord with The Zen of Python?
>
> [1] (I could have done sets, I suppose, but orientation might be
> useful at some point.)
>
> --
> Michael F. Stemper
> The FAQ for rec.arts.sf.written is at:
> http://leepers.us/evelyn/faqs/sf-written
> Please read it before posting.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which editor is suited for view a python package's source?

2019-08-20 Thread Kyle Stanley
> Then, I can only download the older version 2016.2.3 for my old 32 bit
system:-(

You could always use VSCode with the Python extension instead:
https://code.visualstudio.com/Download. There's support for 32bit Windows
as long as you're on 7, 8, or 10. I haven't used it myself though, I most
use the 64bit Linux version.

On Tue, Aug 20, 2019 at 9:30 PM  wrote:

> Nick Sarbicki於 2019年8月20日星期二 UTC+8下午1時33分32秒寫道:
> > Yes the community edition works fine.
> >
> > It seems to require a 64 bit version of Windows 7 or higher (I'm not sure
> > as I haven't used Windows in years).
> >
> > On Tue, 20 Aug 2019, 03:27 ,  wrote:
> >
> > > Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒寫道:
> > > > PyCharm takes you to the source code within the editor for any
> > > > variables/functions/classes/modules if you ctrl+click on what you
> want to
> > > > see. It allows you to browse the relevant bits of code quickly, as
> well
> > > as
> > > > let you change them in your local environment if need be.
> > > >
> > > > That way you don't have to download the source separately, you can
> just
> > > use
> > > > it as a normal dependency.
> > > >
> > > > But if you want to view the source of a project in isolation I
> imagine
> > > any
> > > > common editor will suffice. Personally I'll tend to look where the
> source
> > > > is hosted (GitHub, GitLab etc) instead of downloading it. But I can
> > > > understand why some may not trust this.
> > > >
> > > > On Mon, 19 Aug 2019, 10:17 ,  wrote:
> > > >
> > > > > I like to download one package's source and study it in an editor.
> It
> > > > > allows me to open the whole package as a project and let me jump
> from a
> > > > > reference in one file to its definition in another file back and
> > > forth. It
> > > > > will be even better if it can handle the import modules too. (Maybe
> > > this is
> > > > > too much:-)
> > > > >
> > > > > Can anyone recommend such a tool?
> > > > >
> > > > > --Jach
> > > > > --
> > > > > https://mail.python.org/mailman/listinfo/python-list
> > > > >
> > >
> > > There is a free community version of PyCharm. Will it support the
> > > cross-reference of viewing different files in different subdirectory?
> and
> > > what Windows versions it requires?
> > >
> > > --Jach
> > > --
> > > https://mail.python.org/mailman/listinfo/python-list
> > >
>
> Then, I can only download the older version 2016.2.3 for my old 32 bit
> system:-(
>
> --Jach
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: absolute path to a file

2019-08-20 Thread Richard Damon
On 8/20/19 5:56 PM, Cameron Simpson wrote:
>
> Hmm. I've been getting some of your posts directly to me as email with
> no obvious python-list@python.org to/cc header. Maybe some interaction
> with gmane? If you've been posting to the gmane newsgroup and CCing me
> privately that is likely fine, and I've misread the event (provided
> gmane backfeeds to the mailing list).

I think gmane feed the newsgroup comp.lang.python which feeds
python-list@python.org. Python-list probably then sees that you already
were getting a direct copy so omits sending you the duplicate.

-- 
Richard Damon

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


Re: Which editor is suited for view a python package's source?

2019-08-20 Thread jfong
Nick Sarbicki於 2019年8月20日星期二 UTC+8下午1時33分32秒寫道:
> Yes the community edition works fine.
> 
> It seems to require a 64 bit version of Windows 7 or higher (I'm not sure
> as I haven't used Windows in years).
> 
> On Tue, 20 Aug 2019, 03:27 ,  wrote:
> 
> > Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒寫道:
> > > PyCharm takes you to the source code within the editor for any
> > > variables/functions/classes/modules if you ctrl+click on what you want to
> > > see. It allows you to browse the relevant bits of code quickly, as well
> > as
> > > let you change them in your local environment if need be.
> > >
> > > That way you don't have to download the source separately, you can just
> > use
> > > it as a normal dependency.
> > >
> > > But if you want to view the source of a project in isolation I imagine
> > any
> > > common editor will suffice. Personally I'll tend to look where the source
> > > is hosted (GitHub, GitLab etc) instead of downloading it. But I can
> > > understand why some may not trust this.
> > >
> > > On Mon, 19 Aug 2019, 10:17 ,  wrote:
> > >
> > > > I like to download one package's source and study it in an editor. It
> > > > allows me to open the whole package as a project and let me jump from a
> > > > reference in one file to its definition in another file back and
> > forth. It
> > > > will be even better if it can handle the import modules too. (Maybe
> > this is
> > > > too much:-)
> > > >
> > > > Can anyone recommend such a tool?
> > > >
> > > > --Jach
> > > > --
> > > > https://mail.python.org/mailman/listinfo/python-list
> > > >
> >
> > There is a free community version of PyCharm. Will it support the
> > cross-reference of viewing different files in different subdirectory? and
> > what Windows versions it requires?
> >
> > --Jach
> > --
> > https://mail.python.org/mailman/listinfo/python-list
> >

Then, I can only download the older version 2016.2.3 for my old 32 bit 
system:-( 

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


[issue37890] Modernize several tests in test_importlib

2019-08-20 Thread Kyle Stanley


Kyle Stanley  added the comment:

> This might be a decent way to prevent the AttributeErrors, but still allows 
> for differentiation of actual None values

Another alternative solution might be to use hasattr() before getattr(), if it 
is not desirable for test_pkg_import.py to raise exceptions:

```
 self.assertTrue(hasattr(module, var), msg=f"{module} should have attribute 
{var}")
 self.assertEqual(getattr(module, var), 1)
```

That would follow more of a LBYL style, but I know that EAFP is more common 
within Python. The better alternative depends on the answer to my earlier 
question regarding exceptions being raised from the unit tests:

> Is there a particular preference in the context of Python's tests?

--

___
Python tracker 

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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters


Tim Peters  added the comment:

I don't have a problem with the trivial ring - I wasn't being that high-minded 
;-)  I was testing a different inverse algorithm, and in the absence of errors 
checked that

minv(a, m) * a % m == 1

for various a and m >= 0.  Of course that failed using pow(a, -1, m) instead 
when m=1.  Offhand, I couldn't imagine a plausible use case for finding an 
inverse mod 1 - and still can't ;-)  In abstract algebra, sure - but for 
concrete numerical computation?  Oh well.

In any case, testing

(minv(a, m) * a - 1) % m == 0

instead appears to work for all non-error cases.

--

___
Python tracker 

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



[issue37890] Modernize several tests in test_importlib

2019-08-20 Thread Kyle Stanley


Kyle Stanley  added the comment:

Ah okay, I wasn't sure what exactly would be involved with the "modernization" 
process, so those points were just rough ideas more than anything. I haven't 
started working on anything yet since I figured it'd be worthwhile to wait for 
approval first.

> 1) __import__() can be used for purpose. I would not change this.

Okay, I'll keep that part as is then. This idea was primarily based on 
importlib's documentation:

"Programmatic importing of modules should use import_module() instead of 
[importlib.__import__()]" 

But that probably applies more to users of importlib, rather than the internal 
tests for it. That would make sense.

3) How would you distinguish the case when the module have an attribute with 
the value is None and when it does not have the attribute at all? This 
information would lost with your change.

Good point. This might be a decent way to prevent the AttributeErrors, but 
still allows for differentiation of actual None values:

```
try:
self.assertEqual(getattr(module, var), 1)
except AttributeError:
self.fail(f"{module} should have attribute {var}")
```

Personally I think it makes a bit more sense to use self.fail() with a helpful 
message rather than raising errors within the tests. There's a comment on line 
56, "# self.fail() ?", which gave me this idea. Is there a particular 
preference in the context of Python's tests?

Also, do either of you (or anyone else) have any ideas for other modernization 
improvements that could be made to either test_pkg_import.py or to the other 
two? In the meantime, I can start working on ideas (2) and (4) if those ones 
would be appropriate. (2) should be fairly straightforward, but (4) will 
probably be a bit more subjective.

--

___
Python tracker 

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



[issue34690] Store startup modules as C structures for 20%+ startup speed improvement

2019-08-20 Thread Barry A. Warsaw


Change by Barry A. Warsaw :


--
nosy: +barry

___
Python tracker 

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



[issue37901] 21 tests fail when run on an IPv6-only host

2019-08-20 Thread Gregory P. Smith


New submission from Gregory P. Smith :

21 tests failed:
test_asynchat test_asyncore test_docxmlrpc test_eintr test_epoll
test_ftplib test_httplib test_imaplib
test_multiprocessing_forkserver test_multiprocessing_spawn
test_nntplib test_os test_poplib test_robotparser test_smtplib
test_socket test_ssl test_support test_telnetlib
test_urllib2_localnet test_wsgiref

This is a rollup tracking issue.  I've got an IPv6-only future buildbot host 
with which to run an diagnose these for fixes.  Of note there is no IPv4 
localhost.

If there are larger problems I may spawn child bugs for specific issues off of 
this one.  (I already filed separate issues about 5 other tests that hang 
rather than fail)

--
assignee: gregory.p.smith
components: Tests
messages: 350039
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: 21 tests fail when run on an IPv6-only host
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



Re: absolute path to a file

2019-08-20 Thread Cameron Simpson

On 20Aug2019 21:06, Paul St George  wrote:

On 20/08/2019 11:43, Cameron Simpson wrote:

Please remember to CC the list.
Instead of 'Post a followup to this newsgroup' or 'To: 
python-list@python.org'?


Hmm. I've been getting some of your posts directly to me as email with 
no obvious python-list@python.org to/cc header. Maybe some interaction 
with gmane? If you've been posting to the gmane newsgroup and CCing me 
privately that is likely fine, and I've misread the event (provided 
gmane backfeeds to the mailing list).


[...]

We used
blend_file = '/Users/Lion/Desktop/test8/tifftest8.blend'
So, if I read you correctly, this is an absolute path.

When we used unblenderise on it, out popped a path that was partly but 
not wholly relative. The latter half of the path is relative to the 
absolute first half (/Users/Lion/Desktop/test8/).


/Users/Lion/Desktop/test8/../images/image02.tif

It starts with a slash but cannot be pasted into "Go to...". But maybe 
that is an absolute path in UNIX?


Yes. It starts with a slash.

If you hand this to abspath it would fold out the "test8/.." part and 
give you a more direct absolute path.


And realpath would traverse the path looking for symlinks etc and fold 
out the same pair as a side effect of traversing the path.


But realpath is symlink aware. If test8 were a symlink to some remote 
part of the filesystem so that the TIF image were also elswhere, you'd 
get a direct path to that remote location.


For example, on our home server my ~/media directory is actually a 
symlink to an area on our 8TB RAID-1 volume:


   [~]borg*> pwd
   /home/cameron
   [~]borg*> ls -ld media
   lrwxrwxrwx 1 cameron cameron 9 Nov  2  2017 media -> 8TB/media

In fact "8TB" is also a symlink. So let's look:

   [~]borg*> python3
   Python 3.7.1 (default, Nov 14 2018, 10:38:43)
   [GCC 5.4.0 20160609] on linux
   Type "help", "copyright", "credits" or "license" for more information.
   >>> from os.path import abspath, realpath
   >>> abspath('media')
   '/home/cameron/media'
   >>> realpath('media')
   '/app8tb/cameron/media'

Both are valid absolute paths to the media directory.

Realpath has follwed the symlinks and given a direct route from '/' 
which does not go through any symlinks. Abspath has not bothered with 
such effort.


Cheers,
Cameron Simpson  (formerly c...@zip.com.au)
--
https://mail.python.org/mailman/listinfo/python-list


pytest 5.1.1 has been released!

2019-08-20 Thread Anthony Sottile
pytest 5.1.1 has just been released to PyPI.

This is a bug-fix release, being a drop-in replacement. To upgrade::

  pip install --upgrade pytest

The full changelog is available at
https://docs.pytest.org/en/latest/changelog.html.

Thanks to all who contributed to this release, among them:

* Anthony Sottile
* Bruno Oliveira
* Daniel Hahler
* Florian Bruhin
* Hugo van Kemenade
* Ran Benita
* Ronny Pfannschmidt


Happy testing,
The pytest Development Team
--
Python-announce-list mailing list -- python-announce-list@python.org
To unsubscribe send an email to python-announce-list-le...@python.org
https://mail.python.org/mailman3/lists/python-announce-list.python.org/

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Style suggestions/critiques

2019-08-20 Thread Michael F. Stemper
I recently wrote a couple of modules (more to come) to help me
use the tikz package in TeX/LaTeX. Since it's all to do with
drawing, I have a lot of points in R^2. Being unimaginative, I
implemented them as ordered pairs (2-tuples) of floats. E.g.:

p1 = 3,4
p2 = 5,6

Naturally, lines are implemented as ordered pairs[1] of points:

line = p1,p2

This all seems reasonably simple and intuitive (to me). However,
in order to actually do some manipulation, I have stuff like:

# Unpack the lines
l1p1,l1p2 = line1
l1x1,l1y1 = l1p1
l1x2,l1y2 = l1p2
l2p1,l2p2 = line2
l2x1,l2y1 = l2p1
l2x2,l2y2 = l2p2

spattered all over. Although this is simple enough, I find it
aesthetically unappealing.

Is there some better idiom that I should be using, or is this
really in accord with The Zen of Python?

[1] (I could have done sets, I suppose, but orientation might be
useful at some point.)

-- 
Michael F. Stemper
The FAQ for rec.arts.sf.written is at:
http://leepers.us/evelyn/faqs/sf-written
Please read it before posting.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37900] [urllib] proxy_bypass_registry doesn't handle invalid proxy override values

2019-08-20 Thread Kevin Wojniak


New submission from Kevin Wojniak :

proxy_bypass_registry() will split the ProxyOverride registry key by semicolon. 
Then for each value it uses that value as a regular expression pattern with 
match(). However, if this value is not a valid regular expression, then match() 
will throw an exception that goes uncaught. This then breaks the loop and 
prevents the function from working correctly on other valid input.

It's easy to reproduce:

1. Set this registry key to 1 
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet 
Settings\ProxyEnable
2. Set HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet 
Settings\ProxyOverride to this value (create as a string if necessary):
[]-78;
3. Call urllib.proxy_bypass()

My suggestion for a fix would be to catch exceptions from match() in the loop 
and continue the loop on error.

--
components: Windows
messages: 350038
nosy: kwojniak_box, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: [urllib] proxy_bypass_registry doesn't handle invalid proxy override 
values
type: crash
versions: Python 2.7, Python 3.7

___
Python tracker 

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



[issue37891] Exceptions tutorial page does not mention raise from

2019-08-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Please give Niel a chance to submit wording, even a post here on the tracker 
will be fine.  We usually defer to the person who actually encountered the 
issue.  

If after a week or so, there is no response, you can pick this up.  Try to be 
minimal with it and avoid the temptation to go gonzo.  The "from" part of 
exception semantics is one of its most minor and easily ignored features.  
Accordingly, it should get minimal space in the tutorial and probably doesn't 
even warrant an example if a simple, clear sentence will suffice.

--

___
Python tracker 

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



Re: absolute path to a file

2019-08-20 Thread Paul St George

On 20/08/2019 11:43, Cameron Simpson wrote:

Please remember to CC the list.
Instead of 'Post a followup to this newsgroup' or 'To: 
python-list@python.org'?




On 19Aug2019 22:06, Paul St George  wrote:

On 19/08/2019 14:16, Cameron Simpson wrote:

[...]
There's a remark on that web page I mentioned that suggests that the 
leading '//' indicates the filename is relative to the Blender model, 
so the context directory for the '//' is likely 
/Users/Lion/Desktop/test8.


Yes. That makes sense. The reason I was testing with two images, one 
at /Users/Lion/Desktop/test8/image01.tif and the other at 
/Users/Lion/Desktop/images/image02.tif is that I cannot rely on images 
being in the same folder as the Blender file.


So, let's assume the context directory is /Users/Lion/Desktop/test8
and see how we get on below.

[...]
realpath needs a UNIX path. Your //image01.tif isn't a UNIX path, it 
is a special Blender path. First you need to convert it. By replacing 
'//' with the blend file's directory. Then you can call realpath. If 
you still need to.


Understood. Now. Thanks!


[...snip...]


Did you just [...snip...] yourself?


Yes. It keeps the surrounding context manageable. In this way you know 
to which text I am referring, without having to wade through paragraphs 
to guess what may be relevant.



   from os.path import dirname

   # Get this from somewhere just hardwiring it for the example.
   # Maybe from your 'n' object below?
   blend_file = '/Users/Lion/Desktop/test8/tifftest8.blend'

Is this setting a relative path?


   blender_image_file = n.image.filename

   unix_image_file = unblenderise(blender_image_file, 
dirname(blend_file))


Now you have a UNIX path. If blend_file is an absolute path, 
unix_image_path will also be an absolute path. But if blend_file is a 
relative path (eg you opened up "tifftest8.blend") unix_image_path 
will be a relative path.


Does unix_image_path = unix_image_file?


Yeah, sorry,  my mistake.


Two possibilities here.
blend_file (and so unix_image_file) is an absolute path OR blend_file 
(and so unix_image_file) is a relative path.


I just want to check my understanding. If I supply the path to 
blend_file then it is absolute, and if I ask Python to generate the 
path to blend_file from within Blender it is relative. Have I got it?


Not quite. What seems to be the situation is:

You've got some object from Blender called "n.image", which has a 
".file" attribute which is a Blender reference to the image file of the 
form "//image01.tif".


I presume that Blender has enough state inside "n" or "n.image" to 
locate this in the real filesystem; maybe it has some link to the 
Blender model of your blend file, and thus knows the path to the blend 
file and since //image01.tif is a reference relative to the blend file, 
it can construct the UNIX path to the file.


You want to know the UNIX pathname to the image file (maybe you want to 
pass it to some unrelated application to view the file or something).


Exactly. I am using Python to log a series of experiments. If I have a 
record of the settings and the assets used, I can better learn from what 
works and so repeat the successes and avoid the failures.


So you need to do what Blender would do if it needs a UNIX path (eg to 
open the file).


The formula for that is dirname(path_to_blendfile) with n.image.file[2:] 
appended to it. So that's what we do with unblenderise(): if the 
filename is a "Blender relative name", rip off the "//" and prepend the 
blend file directory path. That gets you a UNIX path which you can hand 
to any function expecting a normal operating system pathname.


Whether that is an absolute path or a relative path is entirely "does 
the resulting path start with a '/'"?


We used
blend_file = '/Users/Lion/Desktop/test8/tifftest8.blend'
So, if I read you correctly, this is an absolute path.

When we used unblenderise on it, out popped a path that was partly but 
not wholly relative. The latter half of the path is relative to the 
absolute first half (/Users/Lion/Desktop/test8/).


/Users/Lion/Desktop/test8/../images/image02.tif

It starts with a slash but cannot be pasted into "Go to...". But maybe 
that is an absolute path in UNIX?




An absolute path starts with a slash and is relative to the root of the 
filesystem. You can use such a path regardless of what your current 
working directory is, because it doesn't use the working directory.




A relative path doesn't start with a slash and is relative to the 
current working directory. It only works if you're in the right working 
directory.


_Because_ a relative path depends on the _your_ working directory, 
usually we pass around absolute paths if we need to tell something else 
about a file, because that will work regardless if what _their_ working 
directory may be.


So, you may well want to turn a relative path into an absolute path...

If I decided not to supply the path and so ended up with a relative 
UNIX path, I could now use 

[issue37891] Exceptions tutorial page does not mention raise from

2019-08-20 Thread Srinivas Nyayapati


Srinivas Nyayapati  added the comment:

In case Niels Albers is not interested, can I submit a PR?
I noticed the linked raise reference documentation from the tutorial having 
details on exception chaining 
(https://docs.python.org/3.7/reference/simple_stmts.html#raise). Does it make 
sense to mention exception chaining in the tutorial and say "read details in 
the reference docs"? Or as you mentioned.. just write a short paragraph on 
exception chaining and give an example in the tutorial?

--
nosy: +shireenrao

___
Python tracker 

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



[issue37899] test_xmlrpc hangs on an IPv6-only host

2019-08-20 Thread Gregory P. Smith


New submission from Gregory P. Smith :

test_404 (test.test_xmlrpc.SimpleServerTestCase) ... Exception in thread 
Thread-1:
Traceback (most recent call last):
  File "/home/greg/oss/cpython/Lib/threading.py", line 938, in _bootstrap_inner
self.run()
  File "/home/greg/oss/cpython/Lib/threading.py", line 876, in run
self._target(*self._args, **self._kwargs)
  File "/home/greg/oss/cpython/Lib/test/test_xmlrpc.py", line 619, in 
http_server
serv.server_bind()
  File "/home/greg/oss/cpython/Lib/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 99] Cannot assign requested address

I'm preparing an IPv6-only buildbot.  There is no IPv4 localhost.

--
assignee: gregory.p.smith
components: Tests
messages: 350035
nosy: gregory.p.smith
priority: normal
severity: normal
status: open
title: test_xmlrpc hangs on an IPv6-only host
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue37898] test_httpservers hangs on an IPv6-only host

2019-08-20 Thread Gregory P. Smith


New submission from Gregory P. Smith :

test_err (test.test_httpservers.RequestHandlerLoggingTestCase) ... Exception in 
thread Thread-1:
Traceback (most recent call last):
  File "/home/greg/oss/cpython/Lib/threading.py", line 938, in _bootstrap_inner
self.run()
  File "/home/greg/oss/cpython/Lib/test/test_httpservers.py", line 50, in run
self.server = HTTPServer(('localhost', 0), self.request_handler)
  File "/home/greg/oss/cpython/Lib/socketserver.py", line 452, in __init__
self.server_bind()
  File "/home/greg/oss/cpython/Lib/http/server.py", line 137, in server_bind
socketserver.TCPServer.server_bind(self)
  File "/home/greg/oss/cpython/Lib/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 99] Cannot assign requested address

I'm preparing an IPv6-only buildbot.  There is no IPv4 localhost.

--
assignee: gregory.p.smith
components: Tests
messages: 350034
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: test_httpservers hangs on an IPv6-only host
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue37897] test_asyncio hangs on an IPv6-only host

2019-08-20 Thread Gregory P. Smith


New submission from Gregory P. Smith :

test_drain_raises (test.test_asyncio.test_streams.StreamTests) ... Exception in 
thread Thread-20:
Traceback (most recent call last):
  File "/home/greg/oss/cpython/Lib/threading.py", line 938, in _bootstrap_inner
self.run()
  File "/home/greg/oss/cpython/Lib/threading.py", line 876, in run
self._target(*self._args, **self._kwargs)
  File "/home/greg/oss/cpython/Lib/test/test_asyncio/test_streams.py", line 
951, in server
with socket.create_server(('localhost', 0)) as sock:
  File "/home/greg/oss/cpython/Lib/socket.py", line 804, in create_server
raise error(err.errno, msg) from None
OSError: [Errno 99] Cannot assign requested address (while attempting to bind 
on address ('localhost', 0))

I'm preparing an IPv6-only buildbot.  (there is no IPv4 localhost)

--
assignee: gregory.p.smith
components: Tests
messages: 350033
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: test_asyncio hangs on an IPv6-only host
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue37896] test_multiprocessing_fork hangs on an IPv6-only host

2019-08-20 Thread Gregory P. Smith


New submission from Gregory P. Smith :

It winds up stuck on a leftover process:

test_import (test.test_multiprocessing_fork._TestImportStar) ... ok
Warning -- Dangling processes: {}

Which is likely related to one of the other numerous failure ERRORs further up 
in the log.

I'm preparing an IPv6-only buildbot

--
assignee: gregory.p.smith
components: Tests
messages: 350032
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: test_multiprocessing_fork hangs on an IPv6-only host
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue37895] test_logging hangs on an IPv6-only host

2019-08-20 Thread Gregory P. Smith


New submission from Gregory P. Smith :

test_logging hangs when run on an IPv6-only host.  (127.0.0.1 isn't even 
available)

test_listen_config_10_ok (test.test_logging.ConfigDictTest) ... Exception in 
thread Thread-3:
Traceback (most recent call last):
  File "/home/greg/oss/cpython/Lib/threading.py", line 938, in _bootstrap_inner
self.run()
  File "/home/greg/oss/cpython/Lib/logging/config.py", line 918, in run
server = self.rcvr(port=self.port, handler=self.hdlr,
  File "/home/greg/oss/cpython/Lib/logging/config.py", line 885, in __init__
ThreadingTCPServer.__init__(self, (host, port), handler)
  File "/home/greg/oss/cpython/Lib/socketserver.py", line 452, in __init__
self.server_bind()
  File "/home/greg/oss/cpython/Lib/socketserver.py", line 466, in server_bind
self.socket.bind(self.server_address)
OSError: [Errno 99] Cannot assign requested address

possibly more, but it's hung here.

I'm preparing an IPv6-only buildbot.

--
assignee: gregory.p.smith
components: Tests
messages: 350031
nosy: gregory.p.smith
priority: normal
severity: normal
stage: needs patch
status: open
title: test_logging hangs on an IPv6-only host
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

> I guess I'm just not used to 0 being a multiplicative identity.

Yes, there's a whole generation of mathematicians who believe (wrongly) that "0 
!= 1" is one of the ring axioms. But it turns out that excluding the zero ring 
from the category of (commutative, unital) rings isn't helpful, and causes all 
sorts of otherwise universal constructs (quotients, localizations, categorical 
limits in general) to have only conditional existence. So nowadays most (but 
not all) people accept that the zero ring has the same right to exist as any 
other commutative ring.

Integral domains are another matter, of course: there you really _do_ want to 
insist that 1 != 0, though what you're really insisting is that any finite 
product of nonzero elements should be nonzero, and 1 != 0 is just the special 
case of that rule for the empty product, while x*y !=0 for x != 0 and y != 0 is 
the special case for two arguments.

--

___
Python tracker 

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



[issue37890] Modernize several tests in test_importlib

2019-08-20 Thread Brett Cannon


Brett Cannon  added the comment:

What Serhiy said. :) There's code to be able to easily test both 
builtins.__import__ and importlib.__import__ in tests so that there's no drift 
between the two implementations.

--

___
Python tracker 

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



Re: Xlabel and ylabel are not shown

2019-08-20 Thread David Lowry-Duda
There are two main ways of creating a plot in matplotlib: the pyplot 
MATLAB-style system and an object-oriented system. Although many 
tutorials online use the MATLAB interface, it is usually a good idea to 
use the object-oriented system.

I mention this here because after one calls `plt.plot()`, it can 
be a bit nonintuitive how to alter the plot through the MATLAB-style 
interface. I think this might be happening here.

If you provide a complete minimally-running-code sample, I'd be happy to 
go through it in a bit more detail.

- David Lowry-Duda
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue30458] [security][CVE-2019-9740][CVE-2019-9947] HTTP Header Injection (follow-up of CVE-2016-5699)

2019-08-20 Thread Gregory P. Smith


Gregory P. Smith  added the comment:

I'm not a fan of CVE numbers in general, people have been creating too many of 
those.  But that also means I just don't care if someone does.  Having a CVE 
entry is not a way to claim something is important.

This issue is still open and can be used to track dealing with the host.

--
assignee: larry -> 
keywords: +security_issue
stage: patch review -> needs patch

___
Python tracker 

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



[issue32793] smtplib: duplicated debug message

2019-08-20 Thread miss-islington


miss-islington  added the comment:


New changeset 46a7564578f208df1e0c54fc0520d3b7ca32c981 by Miss Islington (bot) 
(Zackery Spytz) in branch 'master':
bpo-32793: Fix a duplicate debug message in smtplib (GH-15341)
https://github.com/python/cpython/commit/46a7564578f208df1e0c54fc0520d3b7ca32c981


--
nosy: +miss-islington

___
Python tracker 

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



[issue32793] smtplib: duplicated debug message

2019-08-20 Thread Abhilash Raj


Abhilash Raj  added the comment:

Removing 2.7 which only accepts security patches.

--
nosy: +maxking
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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters


Tim Peters  added the comment:

Mark, to save you the hassle, I'm closing this myself now.  Thanks for the 
feedback!

--
assignee:  -> tim.peters
resolution:  -> not a bug
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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters


Tim Peters  added the comment:

Yup, you have a point there! :-)  I guess I'm just not used to 0 being a 
multiplicative identity.

Don't know what other systems do.  Playing with Maxima, modulo 1 it seems to 
think 0 is the inverse of everything _except_ for 0.  `inv_mod(0, 1)` returns 
`false`.  Modulo -1, everything I tried returned `false`.

Which makes less sense to me.

Fine by me if you want to close this as "not a bug".

--

___
Python tracker 

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



[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:

I wrote PR 15345 to enhance regrtest timeout: more logs, more timeouts.

--

___
Python tracker 

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



[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15062
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/15345

___
Python tracker 

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



Re: Enumerate - int object not subscriptable

2019-08-20 Thread Ian Kelly
Or use the "pairwise" recipe from the itertools docs:

from itertools import tee

def pairwise(iterable):
"s -> (s0,s1), (s1,s2), (s2, s3), ..."
a, b = tee(iterable)
next(b, None)
return zip(a, b)

for num1, num2 in pairwise(a):
print(num1, num2)

On Tue, Aug 20, 2019 at 7:42 AM Cousin Stanley 
wrote:

> Sayth Renshaw wrote:
>
> > I want to do basic math with a list.
> >
> > a = [1, 2, 3, 4, 5, 6, 7, 8]
> >
> > for idx, num in enumerate(a):
> > print(idx, num)
> >
> > This works, but say I want to print the item value
> > at the next index as well as the current.
> >
> > for idx, num in enumerate(a):
> >
> > print(num[idx + 1], num)
> > 
>
>
> #!/usr/bin/env python3
>
> # sum each adjacent pair of elements in a list
>
> ls = list( range( 10 , 1 , -1 ) )
>
> print('\n  ' , ls , '\n' )
>
> for enum , n in enumerate( range( len( ls ) - 1 ) ) :
>
> i_left , i_rite = ls[ n : n + 2 ]
>
> i_tot = i_left  +  i_rite
>
> print( '  {:2d} :  {:2d}  +  {:2d} = {:4d} '.format( enum , i_left ,
> i_rite , i_tot ) )
>
>
> --
> Stanley C. Kitching
> Human Being
> Phoenix, Arizona
>
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

> Z/1Z is a perfectly-well-defined ring.

More to the point, it's a perfectly well-defined ring in which every element is 
invertible. That's why the Euler phi function has phi(1) = 1 (rather than 
phi(1) = 0), for example.

--

___
Python tracker 

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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

> While I doubt this, he may even argue that it's working correctly already ;-)

Yes, I'd argue exactly that. There's nothing ill-defined about working modulo 
+/-1. Z/1Z is a perfectly-well-defined ring. What's the motivation for this 
change?

--

___
Python tracker 

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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Batuhan


Change by Batuhan :


--
keywords: +patch
pull_requests: +15061
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/15344

___
Python tracker 

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



[issue37894] [win] shutil.which can not find the path if 'cmd' include directory path and not include extension name

2019-08-20 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware

___
Python tracker 

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



[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:

(I reopen the issue.)

"There are no child processes of the main test process.  There are 5
orphaned processes from multiprocessing.  Their parent process is gone
(assuming the parent_pid argument is correct)."

Oh wow, that's really strange. I would expect that regrtest main process has 
one worker process: "test_concurrent_futures".

https://buildbot.python.org/all/#/builders/130/builds/1050

C:\buildbot.python.org\3.7.kloth-win64\build>"C:\buildbot.python.org\3.7.kloth-win64\build\PCbuild\amd64\python_d.exe"
  -u -Wd -E -bb -m test  -uall -rwW --slowest --timeout 1200 --fail-env-changed 
-j1 -j2 -j4 --timeout 900 
== CPython 3.7.4+ (heads/3.7:02c1457, Aug 20 2019, 00:03:57) [MSC v.1900 64 bit 
(AMD64)]
== Windows-7-6.1.7601-SP1 little-endian
== cwd: C:\buildbot.python.org\3.7.kloth-win64\build\build\test_python_5524
== CPU count: 4
== encodings: locale=cp1252, FS=utf-8
Using random seed 1058030
Run tests in parallel using 4 child processes
0:00:01 load avg: 0.00 [  1/416] test_call passed
0:00:02 load avg: 0.00 [  2/416] test_genexps passed
...
0:12:46 load avg: 2.30 [412/416] test_threaded_import passed -- running: 
test_concurrent_futures (8 min 42 sec)
0:12:47 load avg: 2.30 [413/416] test_email passed -- running: 
test_concurrent_futures (8 min 43 sec)
0:12:50 load avg: 2.19 [414/416] test_bytes passed -- running: 
test_concurrent_futures (8 min 46 sec)
0:12:55 load avg: 2.02 [415/416] test_timeout passed -- running: 
test_concurrent_futures (8 min 52 sec)
running: test_concurrent_futures (9 min 22 sec)
running: test_concurrent_futures (9 min 52 sec)
running: test_concurrent_futures (10 min 22 sec)
...
running: test_concurrent_futures (9 hour 51 min)
running: test_concurrent_futures (9 hour 51 min)
running: test_concurrent_futures (9 hour 52 min)
running: test_concurrent_futures (9 hour 52 min)
running: test_concurrent_futures (9 hour 53 min)

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

___
Python tracker 

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



[issue37894] [win] shutil.which can not find the path if 'cmd' include directory path and not include extension name

2019-08-20 Thread Wator Sead


New submission from Wator Sead :

The current code is:
...
if os.path.dirname(cmd):
if _access_check(cmd, mode):
return cmd
return None
...

In Windows, if 'cmd' include directory path and not include extension name, it 
return 'None'.
e.g. a file's path is 'd:\dir\app.exe', call shutil.which with 
'cmd=="d:\dir\app"'.

How about this patch:
...
if os.path.dirname(cmd):
path, cmd = os.path.split(cmd)
...

--
components: Library (Lib)
messages: 350019
nosy: seahoh
priority: normal
severity: normal
status: open
title: [win] shutil.which can not find the path if 'cmd' include directory path 
and not include extension name
type: behavior
versions: 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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters


Tim Peters  added the comment:

@Batuhan, fine by me if you want to take this on!  It should be relatively 
easy.  But Mark wrote the code, so it's really up to him.  While I doubt this, 
he may even argue that it's working correctly already ;-)

--

___
Python tracker 

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



[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-20 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

> Can you check the process hierarchy? I would like to know how many worker 
> processes are still running under the main regrtest process. I expect to see 
> exactly one. I don't know how to investigate more on such issue on Windows.

There are no child processes of the main test process.  There are 5
orphaned processes from multiprocessing.  Their parent process is gone
(assuming the parent_pid argument is correct).  There is also an
orphaned typeperf.exe process, probably also from the killed process.

--
nosy: +jeremy.kloth

___
Python tracker 

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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Batuhan


Batuhan  added the comment:

Can i work on this?

--
nosy: +BTaskaya

___
Python tracker 

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



[issue37893] pow() should disallow inverse when modulus is +-1

2019-08-20 Thread Tim Peters


New submission from Tim Peters :

For example, these should all raise ValueError instead:

>>> pow(2, -1, 1)
0
>>> pow(1, -1, 1)
0
>>> pow(0, -1, 1)
0
>>> pow(2, -1, -1)
0
>>> pow(1, -1, -1)
0
>>> pow(0, -1, -1)
0

--
components: Library (Lib)
messages: 350015
nosy: mark.dickinson, tim.peters
priority: normal
severity: normal
stage: needs patch
status: open
title: pow() should disallow inverse when modulus is +-1
type: behavior
versions: Python 3.8, Python 3.9

___
Python tracker 

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



[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:

> I can leave it "stuck" if there is some diagnostics that would be beneficial.

Can you check the process hierarchy? I would like to know how many worker 
processes are still running under the main regrtest process. I expect to see 
exactly one. I don't know how to investigate more on such issue on Windows.

--

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-20 Thread Steve Dower


Steve Dower  added the comment:

The latest PR also fixes issue1311 and issue20541 properly 
(os.path.exists("NUL") now returns True).

--

___
Python tracker 

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



[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:

I just tested the 3.7 branch manually: regrtest works as expected.

I'm using this local changes:

diff --git a/Lib/test/libregrtest/runtest.py b/Lib/test/libregrtest/runtest.py
index e7dce180cb..7d996d6918 100644
--- a/Lib/test/libregrtest/runtest.py
+++ b/Lib/test/libregrtest/runtest.py
@@ -119,7 +119,7 @@ def _runtest(ns, test_name):
 
 use_timeout = (ns.timeout is not None)
 if use_timeout:
-faulthandler.dump_traceback_later(ns.timeout, exit=True)
+pass #faulthandler.dump_traceback_later(ns.timeout, exit=True)
 
 start_time = time.perf_counter()
 try:
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 8032da0530..e21399c840 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -89,6 +89,7 @@ class FileTests(unittest.TestCase):
 tearDown = setUp
 
 def test_access(self):
+import time; time.sleep(3600)
 f = os.open(support.TESTFN, os.O_CREAT|os.O_RDWR)
 os.close(f)
 self.assertTrue(os.access(support.TESTFN, os.W_OK))


Then I ran:

vstinner@apu$ ./python -m test -j2 test_os -m test_access --timeout=3
Run tests in parallel using 2 child processes
0:00:04 load avg: 0.59 [1/1/1] test_os timed out (4 sec 512 ms)

== Tests result: FAILURE ==

1 test failed:
test_os

Total duration: 4 sec 545 ms
Tests result: FAILURE

As you can see, test_os is killed after 4.5 seconds, as expected (it uses 
timeout x 1.5, since faulthandler is supposed to be first watchdog with timeout 
seconds).

--

Maybe something is wrong with test_concurrent_futures on Windows. Maybe 
subprocess.Popen.kill() is unable to kill the process immediately for an 
unknown reason?

Or maybe subprocess.Popen.communicate(timeout=self.timeout) didn't fail with 
TimeoutExpired?

Sadly, libregrtest is quite when it kills a worker process because of timeout, 
since the following output should be enough to understand what happened. But 
here the worker was not killed, or failed to be killed, or something else...

--

___
Python tracker 

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



[issue37754] Persistence of Shared Memory Segment after process exits

2019-08-20 Thread Eryk Sun


Eryk Sun  added the comment:

> PS: I personally believe from my experience that shared memory 
> segments should outlive the process, unless specified otherwise. 
> Also, a argument persist=True, can be added which can ensure 
> that the shared_memory segment outlives the process, and can be 
> used by processes which are spawned later.

In terms of providing "consistent behavior across platforms that can be 
reasonably supported", the behavior suggested above could not reasonably be 
supported in Windows. 

The Section (shared memory) object itself is not a file. It gets created in the 
object namespace, either globally in "\BaseNamedObjects" or in an interactive 
session's "\Sessions\\BaseNamedObjects". 

By default, kernel objects are temporary. Creating permanent named objects 
requires SeCreatePermanentPrivilege, which by default is only granted to SYSTEM 
(sort of like root in Unix). For an object to be accessible across sessions and 
outlive an interactive session, it needs to be global. Creating global Section 
objects requires SeCreateGlobalPrivilege, which by default is only granted to 
administrators and service accounts.

Also, the Windows API has no capability to create permanent objects, so this 
would require the NT API functions NtMakePermanentObject (undocumented, added 
in NT 5.1) and NtMakeTemporaryObject.

--
nosy: +eryksun

___
Python tracker 

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



[issue37891] Exceptions tutorial page does not mention raise from

2019-08-20 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Thanks for spotting this omission.  Would you like to submit a PR with a short 
paragraph on exception chaining and "raise from"?

--
nosy: +rhettinger

___
Python tracker 

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



Re: Is it able to connect remote win system from Linux using python

2019-08-20 Thread Iranna Mathapati
Hi Chris,

Want to run a command line on the remote windows machine [on powershell
command line] from linux device

I want to check what are the drivers are installed on the remote window
machine from a Linux machine using python.

Thanks,

On Tue, Aug 20, 2019 at 5:05 PM Chris Green  wrote:

> Iranna Mathapati  wrote:
> > Hi Team,
> >
> > can you please let me know , is there any module to  connect the remote
> > Windows system from Linux using python module?
> >
> We need more information, what sort of 'connect' to a remote Windows
> system do you want?  I.e.:-
>
> Do you want to run a Windows desktop remotely?
>
> Do you want to send messages to the Windows machine?
>
> Do you want to exchange files with the Windows machine?
>
> Do you want to run a command line on the Windows machine?
>
> ... or something else?
>
> --
> Chris Green
> ·
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37531] Fix regrtest timeout for subprocesses: regrtest -jN --timeout=SECONDS

2019-08-20 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

It seems that an issue still exists.

https://buildbot.python.org/all/#/builders/130/builds/1050

has been running for nearly 9 hours at this point.  I can leave it "stuck" if 
there is some diagnostics that would be beneficial.  But I would prefer not to 
have this impeding other testing for too long.

--

___
Python tracker 

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



[issue15913] Add PyBuffer_SizeFromFormat() C helper for struct.calcsize()

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:

Joannah Nanjekye implemented the function, thanks.

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



[issue15913] Add PyBuffer_SizeFromFormat() C helper for struct.calcsize()

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 9e66aba99925eebacfe137d9deb0ef1fdbc2d5db by Victor Stinner 
(Joannah Nanjekye) in branch 'master':
bpo-15913: Implement PyBuffer_SizeFromFormat() (GH-13873)
https://github.com/python/cpython/commit/9e66aba99925eebacfe137d9deb0ef1fdbc2d5db


--
nosy: +vstinner

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:

Thanks Joannah for the bug report. I fixed the warning on 3.7, 3.8 and master 
branches.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
versions: +Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset c9a484a1e76384680b90454018389465760dbeae by Victor Stinner in 
branch '3.7':
bpo-37732: Fix GCC warning in _PyObject_Malloc() (GH-15333) (GH-15342) 
(GH-15343)
https://github.com/python/cpython/commit/c9a484a1e76384680b90454018389465760dbeae


--

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-20 Thread Mark Dickinson


Mark Dickinson  added the comment:

> This issue if for optimization only. It does not expand the math module API.

I think it does, though. The PR adds something to the math module that's 
tested, that needs to be maintained for other modules to work, and that's 
imported for use in another module; that smells like an element of the API to 
me, even with the leading underscore in the name. Other Python implementations 
would also need to implement math._as_integer_ratio for the pure Python 
fractions code to continue working. If we're going to expand the math module 
API to include such a function (and I don't think we should), we should do it 
properly: remove the leading underscore, and add documentation. But as you say, 
that's a separate issue.

I'm with Raymond here; I don't think this change is desirable for the math 
module, either with or without the leading underscore in the name.

--

___
Python tracker 

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



Re: Enumerate - int object not subscriptable

2019-08-20 Thread Cousin Stanley
Sayth Renshaw wrote:

> I want to do basic math with a list.
> 
> a = [1, 2, 3, 4, 5, 6, 7, 8]
> 
> for idx, num in enumerate(a):
> print(idx, num)
> 
> This works, but say I want to print the item value 
> at the next index as well as the current.
> 
> for idx, num in enumerate(a):
>
> print(num[idx + 1], num)
> 


#!/usr/bin/env python3

# sum each adjacent pair of elements in a list

ls = list( range( 10 , 1 , -1 ) ) 

print('\n  ' , ls , '\n' )

for enum , n in enumerate( range( len( ls ) - 1 ) ) :

i_left , i_rite = ls[ n : n + 2 ]

i_tot = i_left  +  i_rite

print( '  {:2d} :  {:2d}  +  {:2d} = {:4d} '.format( enum , i_left , i_rite 
, i_tot ) )


-- 
Stanley C. Kitching
Human Being
Phoenix, Arizona

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


[issue30458] [security][CVE-2019-9740][CVE-2019-9947] HTTP Header Injection (follow-up of CVE-2016-5699)

2019-08-20 Thread Riccardo Schirone


Riccardo Schirone  added the comment:

Will the flaw outlined in https://bugs.python.org/issue30458#msg347282 be fixed 
in python itself? If so, I think a CVE for python should be requested to MITRE 
(I can request one, in that case).

Moreover, does it make sense to create a new bug to track the new issue? This 
bug already references 3 CVEs and it would probably just create more confusion 
to reference a 4th. What do you think?

--

___
Python tracker 

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



Re: Enumerate - int object not subscriptable

2019-08-20 Thread BlindAnagram
On 20/08/2019 13:00, Sayth Renshaw wrote:
> Hi
> 
> I want to do basic math with a list.
> 
> 
> for idx, num in enumerate(a): 
> print(idx, num)
> 
> This works, but say I want to print the item value at the next index as well 
> as the current.
> 
> for idx, num in enumerate(a): 
> print(num[idx + 1], num)

a = [1, 2, 3, 4, 5, 6, 7, 8]
for idx, num in enumerate(a):
print(a[idx + 1], num)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Enumerate - int object not subscriptable

2019-08-20 Thread Frank Millman

On 2019-08-20 2:00 PM, Sayth Renshaw wrote:

Hi

I want to do basic math with a list.

a = [1, 2, 3, 4, 5, 6, 7, 8]

for idx, num in enumerate(a):
 print(idx, num)

This works, but say I want to print the item value at the next index as well as 
the current.

for idx, num in enumerate(a):
 print(num[idx + 1], num)

I am expecting 2, 1.

But am receiving

TypeError: 'int' object is not subscriptable

Why?



I think you want a[idx+1], not num[idx+1].

Bear in mind that you will get IndexError for the last item in the list.

Frank Millman

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


[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15060
pull_request: https://github.com/python/cpython/pull/15343

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 30e5aff5fb0e3841107ddd4539a1f5b8521c80fb by Victor Stinner in 
branch '3.8':
bpo-37732: Fix GCC warning in _PyObject_Malloc() (GH-15333) (GH-15342)
https://github.com/python/cpython/commit/30e5aff5fb0e3841107ddd4539a1f5b8521c80fb


--

___
Python tracker 

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



[issue37754] Persistence of Shared Memory Segment after process exits

2019-08-20 Thread Vinay Sharma


Change by Vinay Sharma :


--
type: enhancement -> behavior

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-20 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15059
pull_request: https://github.com/python/cpython/pull/15342

___
Python tracker 

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



Enumerate - int object not subscriptable

2019-08-20 Thread Sayth Renshaw
Hi

I want to do basic math with a list.

a = [1, 2, 3, 4, 5, 6, 7, 8]

for idx, num in enumerate(a): 
print(idx, num)

This works, but say I want to print the item value at the next index as well as 
the current.

for idx, num in enumerate(a): 
print(num[idx + 1], num)

I am expecting 2, 1.

But am receiving 

TypeError: 'int' object is not subscriptable

Why?

Cheers

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


[issue7676] IDLE shell shouldn't use TABs

2019-08-20 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I think that using tabs for Shell indents is IDLE's current worst design wart.  
But I agree with KBK (#1196946) that merely replacing tabs with spaces does not 
really solve the problem, which is the jagged physical margin consequent on 
physically indenting only the first line with a prompt. 

#37892 proposes to stop using tabs by implementing updated versions of the 
alternate fixes, 3 and 1, mentioned in msg151418 below. The alternate proposal 
will fix some other issues as well.

--
resolution:  -> rejected
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



[issue37892] IDLE Shell: isolate user code input

2019-08-20 Thread Terry J. Reedy


New submission from Terry J. Reedy :

The main operational difference between the standard Python REPL and IDLE's 
Shell is that the latter operates with complete Python statements rather than 
physical lines.  Shell keeps the '>>>' prompt, but with the expanded meaning of 
"Enter a complete Python statement" rather than just "Enter the first line of a 
Python statement".  It omits the consequently superfluous continuation prompts, 
which would mostly be a nuisance if left.

Currently, the prompt precedes and indents the first line of code.  This causes 
multiple problems.  Internally, first lines have to be treated differently from 
the rest.  This has lead to bugs, mostly but not all fixed.  Externally, 
indentation depends on the prompt and does not look right or work right, 
compared to the same code in a proper editor.  And it lead to the use of Tab 
for indents.

The use of Tab for Shell indents was recognized as a problem by 2005.  #1196946 
proposed using the same space indents as in the editor, resulting, for 
instance, in
>>> if a:
if b:
print(a+b)
KBK rejected this with "Doesn't really solve the problem."

In 2010, #7676 suggested 4 space indents again and added 2 variations:  8 space 
indents, and 8 followed by 4, etc. OP Cherniavsky Beni noted that Tab indents 
are "inconsistent with PEP 8; what's worse, it's makes copy-paste code between 
the shell and editor windows confusing and dangerous!"  Raymond Hettinger later 
added that tabs are a "major PITA" and "a continual source of frustration for 
students".

Starting with msg151418 in 1212, my response was much the same as KBK's.  To 
me, the underlying problem is having the prompt physically indent the first 
physical line relative to the following lines.  I consider this IDLE's single 
biggest design wart.  I proposed then 3 possible solutions to avoid the first 
line non-significant indent.  They are, with current comments, ...

1. Prompt on a line by itself (vertical separation).

This is easy, and allows for an expanded active prompt, such as
  >>> Enter a complete Python statement on the lines below.
This says exactly what the user should do and should help avoid confusion with 
a command-line prompt.  ("I entered 'cd path' and got 'SyntaxError'".)

Once a statement is entered, the instruction is obsolete. Only '>>>' is needed, 
to identify input from output. I think putting '>>>' above past input works 
less well than for current input.  I will come back to this proposal below, 
after 3.

2. No input prompt; instead mark output (with #, for instance).

Possible, but confronting beginners with no prompt would likely leave them 
wondering what to do.  But this is a possible savefile format, one that could 
be run or edited.  (A savefile with only the code would do the same.)

3. Prompt in a margin, as with line numbers (horizontal separation).

In 1214, I realized that the 'margin' should be implemented as a separate 
sidebar widget, which was initially being developed for editor line numbers.  
We now have that, and a shell sidebar should be fairly easy.  I will open a 
separate issue with a fairly specific design.  Basically, the first lines of 
input, stderr output, and stdout output would be flagged with, for instance, 
'>>>', 'err', and 'out'.  This should be done before the additional proposal 
below. 


IDLE's Shell should isolate user input not only from prompts.  Debug on/off 
messages, warnings, and delayed program output can also interfere.  I think 
that IDLE's Shell should consist of an input and output history area with 
sidebar, fixed prompt and separator line such as in 1. above, and active input 
area.

The history area, as now, would be read-only except when responding to input() 
in the running code.  The change is that it would receive all messages from 
IDLE and asynchronous program output.  The input area would be a specialized 
editor area.  When input code is run, it would be copied above the separator 
prompt with '>>>' added to the sidebar, opposite the first line.

I believe that the easiest implementation would be to use a label for the fixed 
prompt line and a specialized editor that runs statements as entered.  The 
editing and smart indents would be the same as in a regular editor.  Once this 
is done, we could discuss refinements such as allowing pasting of multiple 
statements.

--
assignee: terry.reedy
components: IDLE
messages: 35
nosy: cheryl.sabella, rhettinger, taleinat, terry.reedy
priority: normal
severity: normal
stage: needs patch
status: open
title: IDLE Shell: isolate user code input
type: behavior
versions: Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



Re: Is it able to connect remote win system from Linux using python

2019-08-20 Thread Chris Green
Iranna Mathapati  wrote:
> Hi Team,
> 
> can you please let me know , is there any module to  connect the remote
> Windows system from Linux using python module?
> 
We need more information, what sort of 'connect' to a remote Windows
system do you want?  I.e.:-

Do you want to run a Windows desktop remotely?

Do you want to send messages to the Windows machine?

Do you want to exchange files with the Windows machine?

Do you want to run a command line on the Windows machine?

... or something else?

-- 
Chris Green
·
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue37887] some leak in the compiler_assert function

2019-08-20 Thread hai shi


hai shi  added the comment:

Ok, got it.

--

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-20 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 18f8dcfa10d8a858b152d12a9ad8fa83b7e967f0 by Victor Stinner in 
branch 'master':
bpo-37732: Fix GCC warning in _PyObject_Malloc() (GH-15333)
https://github.com/python/cpython/commit/18f8dcfa10d8a858b152d12a9ad8fa83b7e967f0


--

___
Python tracker 

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



[issue32793] smtplib: duplicated debug message

2019-08-20 Thread Zackery Spytz


Change by Zackery Spytz :


--
nosy: +ZackerySpytz
type:  -> behavior
versions: +Python 3.9 -Python 3.6

___
Python tracker 

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



[issue32793] smtplib: duplicated debug message

2019-08-20 Thread Zackery Spytz


Change by Zackery Spytz :


--
pull_requests: +15058
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15341

___
Python tracker 

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



Re: How to login remote windos device using python

2019-08-20 Thread Iranna Mathapati
Thanks Kyle

Its working fine

On Tue, Aug 20, 2019 at 2:45 PM Iranna Mathapati 
wrote:

> Hi Kyle,
>
> I have tried with as per above attached links and it leads following error:
> NOTE: Its able to connect  local
>
> Failed to connect remote windows
> >>> import wmi
> >>> c = wmi.WMI("XX.XX.XX.XX", user=r"XXX\XXX", password="")
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "C:\Python27\lib\site-packages\wmi.py", line 1290, in connect
> handle_com_error ()
>   File "C:\Python27\lib\site-packages\wmi.py", line 241, in
> handle_com_error
> raise klass (com_error=err)
> wmi.x_wmi:  occurred.', (0, u'SWbemLocator', u'The RPC server is unavailable. ', None,
> 0, -2147023174), None)>
>
> On Tue, Aug 20, 2019 at 7:03 AM Kyle Stanley  wrote:
>
>> I would recommend checking out WMI: https://pypi.org/project/WMI/
>>
>> For remote connection as a named user (official WMI docs):
>> http://timgolden.me.uk/python/wmi/tutorial.html#connecting-to-a-remote-machine-as-a-named-user
>>
>> Also, another example (unofficial):
>> https://stackoverflow.com/questions/18961213/how-to-connect-to-a-remote-windows-machine-to-execute-commands-using-python.
>> This was done in Python2, but the example is still useful.
>>
>> On Mon, Aug 19, 2019 at 2:11 PM Iranna Mathapati 
>> wrote:
>>
>>> Hi Team,
>>>
>>> can you please let me know, How to login the remote Windows machine using
>>> python??
>>>
>>> Thanks
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>>
>>
-- 
https://mail.python.org/mailman/listinfo/python-list


Is it able to connect remote win system from Linux using python

2019-08-20 Thread Iranna Mathapati
Hi Team,

can you please let me know , is there any module to  connect the remote
Windows system from Linux using python module?


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


[issue32545] Unable to install Python 3.7.0a4 on Windows 10 - Error 0x80070643: Failed to install MSI package.

2019-08-20 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
Removed message: https://bugs.python.org/msg349997

___
Python tracker 

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



[issue32545] Unable to install Python 3.7.0a4 on Windows 10 - Error 0x80070643: Failed to install MSI package.

2019-08-20 Thread Printer Setup


Printer Setup  added the comment:

Fix Canon Printer Offline Windows 10 issues by following simple steps. Feel 
free to reach techies at Canon Support to resolve Canon Printer Offline issues. 
For more info: https://printeroffline.co/canon-printer/

--
nosy: +Printer Setup

___
Python tracker 

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



Re: Which editor is suited for view a python package's source?

2019-08-20 Thread Bev In TX
Sorry, I meant to trim the older portion :-(

Bev in TX

> On Aug 20, 2019, at 4:53 AM, Bev In TX  wrote:
> 
> Search for “Choose” (without the quote marks) on the following webpage to see 
> the differences between the community and commercial versions:
> https://www.jetbrains.com/pycharm/features/
> 
> From the following webpage, “Microsoft Windows 7 SP1 or later”
> https://www.jetbrains.com/help/pycharm/installation-guide.html?_ga=2.186403823.798151923.1566294266-889030968.1566294266
> 
> Bev
> 
>> 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Which editor is suited for view a python package's source?

2019-08-20 Thread Bev In TX
Search for “Choose” (without the quote marks) on the following webpage to see 
the differences between the community and commercial versions:
https://www.jetbrains.com/pycharm/features/

From the following webpage, “Microsoft Windows 7 SP1 or later”
https://www.jetbrains.com/help/pycharm/installation-guide.html?_ga=2.186403823.798151923.1566294266-889030968.1566294266

Bev

> On Aug 19, 2019, at 9:24 PM, jf...@ms4.hinet.net wrote:
> 
> Nick Sarbicki於 2019年8月19日星期一 UTC+8下午5時33分27秒寫道:
>> PyCharm takes you to the source code within the editor for any
>> variables/functions/classes/modules if you ctrl+click on what you want to
>> see. It allows you to browse the relevant bits of code quickly, as well as
>> let you change them in your local environment if need be.
>> 
>> That way you don't have to download the source separately, you can just use
>> it as a normal dependency.
>> 
>> But if you want to view the source of a project in isolation I imagine any
>> common editor will suffice. Personally I'll tend to look where the source
>> is hosted (GitHub, GitLab etc) instead of downloading it. But I can
>> understand why some may not trust this.
>> 
>>> On Mon, 19 Aug 2019, 10:17 ,  wrote:
>>> 
>>> I like to download one package's source and study it in an editor. It
>>> allows me to open the whole package as a project and let me jump from a
>>> reference in one file to its definition in another file back and forth. It
>>> will be even better if it can handle the import modules too. (Maybe this is
>>> too much:-)
>>> 
>>> Can anyone recommend such a tool?
>>> 
>>> --Jach
>>> --
>>> https://mail.python.org/mailman/listinfo/python-list
>>> 
> 
> There is a free community version of PyCharm. Will it support the 
> cross-reference of viewing different files in different subdirectory? and 
> what Windows versions it requires? 
> 
> --Jach
> -- 
> https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: absolute path to a file

2019-08-20 Thread Cameron Simpson

Please remember to CC the list.

On 19Aug2019 22:06, Paul St George  wrote:

On 19/08/2019 14:16, Cameron Simpson wrote:

[...]
There's a remark on that web page I mentioned that suggests that the 
leading '//' indicates the filename is relative to the Blender model, 
so the context directory for the '//' is likely 
/Users/Lion/Desktop/test8.


Yes. That makes sense. The reason I was testing with two images, one 
at /Users/Lion/Desktop/test8/image01.tif and the other at 
/Users/Lion/Desktop/images/image02.tif is that I cannot rely on images 
being in the same folder as the Blender file.


So, let's assume the context directory is /Users/Lion/Desktop/test8
and see how we get on below.

[...]
realpath needs a UNIX path. Your //image01.tif isn't a UNIX path, it 
is a special Blender path. First you need to convert it. By replacing 
'//' with the blend file's directory. Then you can call realpath. If 
you still need to.


Understood. Now. Thanks!


[...snip...]


Did you just [...snip...] yourself?


Yes. It keeps the surrounding context manageable. In this way you know 
to which text I am referring, without having to wade through paragraphs 
to guess what may be relevant.



   from os.path import dirname

   # Get this from somewhere just hardwiring it for the example.
   # Maybe from your 'n' object below?
   blend_file = '/Users/Lion/Desktop/test8/tifftest8.blend'

Is this setting a relative path?


   blender_image_file = n.image.filename

   unix_image_file = unblenderise(blender_image_file, dirname(blend_file))

Now you have a UNIX path. If blend_file is an absolute path, 
unix_image_path will also be an absolute path. But if blend_file is 
a relative path (eg you opened up "tifftest8.blend") unix_image_path 
will be a relative path.


Does unix_image_path = unix_image_file?


Yeah, sorry,  my mistake.


Two possibilities here.
blend_file (and so unix_image_file) is an absolute path OR blend_file 
(and so unix_image_file) is a relative path.


I just want to check my understanding. If I supply the path to 
blend_file then it is absolute, and if I ask Python to generate the 
path to blend_file from within Blender it is relative. Have I got it?


Not quite. What seems to be the situation is:

You've got some object from Blender called "n.image", which has a 
".file" attribute which is a Blender reference to the image file of the 
form "//image01.tif".


I presume that Blender has enough state inside "n" or "n.image" to 
locate this in the real filesystem; maybe it has some link to the 
Blender model of your blend file, and thus knows the path to the blend 
file and since //image01.tif is a reference relative to the blend file, 
it can construct the UNIX path to the file.


You want to know the UNIX pathname to the image file (maybe you want to 
pass it to some unrelated application to view the file or something).


So you need to do what Blender would do if it needs a UNIX path (eg to 
open the file).


The formula for that is dirname(path_to_blendfile) with n.image.file[2:] 
appended to it. So that's what we do with unblenderise(): if the 
filename is a "Blender relative name", rip off the "//" and prepend the 
blend file directory path. That gets you a UNIX path which you can hand 
to any function expecting a normal operating system pathname.


Whether that is an absolute path or a relative path is entirely "does 
the resulting path start with a '/'"?


An absolute path starts with a slash and is relative to the root of the 
filesystem. You can use such a path regardless of what your current 
working directory is, because it doesn't use the working directory.


A relative path doesn't start with a slash and is relative to the 
current working directory. It only works if you're in the right working 
directory.


_Because_ a relative path depends on the _your_ working directory, 
usually we pass around absolute paths if we need to tell something else 
about a file, because that will work regardless if what _their_ working 
directory may be.


So, you may well want to turn a relative path into an absolute path...

If I decided not to supply the path and so ended up with a relative 
UNIX path, I could now use realpath or abspath to find the absolute 
path. Have I still got it?


This is correct.

Abspath may even call realpath to do its work, unsure.

It works very well. So thank you! I tested it with a Blend file that 
had two images, one in the same folder as the Blend file and the other 
was in a folder on the Desktop called 'images'.


The initial results were:
Plane uses image01.tif saved at //image01.tif which is at 
/Users/Lion/Desktop/test8/image01.tif
Plane uses image02.tif saved at //../images/image02.tif which is at 
/Users/Lion/Desktop/test8/../images/image02.tif
BUT as you say, this was easily sorted by using os.path.realpath or 
os.path.abspath. Both worked equally well.


Yep. Abspath does some things in a purely lexical way: it resolves '.' 
and '..' components in the path even if they 

Re: python requests get from API and post to another API and remote u'

2019-08-20 Thread Chris Angelico
On Tue, Aug 20, 2019 at 6:59 PM Noah  wrote:
>
> Hi,
>
> I am trying to migrate information and data between two systems using
> their corresponding APIs. I am using python requests.
>
> I place a get request and the response from the API is "{'id': 32,
> 'description': u'Firewall Outside', 'address': u'10.10.10.230/30'}"
>
> I then take that information and attempt post it to the other API.  The
> data is not accepted and the result is an HTTP 400 code.
>
> I tried posting with postman and still rejected.
>
> I can post to the second API if I change the data to look like this:
> {"id": 32, "description": "Firewall Outside", "address": "10.10.10.230/30"}
>
> How can I remove all u' from the get data or from the data I am
> attempting to post?
>

Use Python 3. Your problems with Unicode will either disappear, or
become a lot clearer.

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


Re: How to login remote windos device using python

2019-08-20 Thread Iranna Mathapati
Hi Kyle,

I have tried with as per above attached links and it leads following error:
NOTE: Its able to connect  local

Failed to connect remote windows
>>> import wmi
>>> c = wmi.WMI("XX.XX.XX.XX", user=r"XXX\XXX", password="")
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python27\lib\site-packages\wmi.py", line 1290, in connect
handle_com_error ()
  File "C:\Python27\lib\site-packages\wmi.py", line 241, in handle_com_error
raise klass (com_error=err)
wmi.x_wmi: 

On Tue, Aug 20, 2019 at 7:03 AM Kyle Stanley  wrote:

> I would recommend checking out WMI: https://pypi.org/project/WMI/
>
> For remote connection as a named user (official WMI docs):
> http://timgolden.me.uk/python/wmi/tutorial.html#connecting-to-a-remote-machine-as-a-named-user
>
> Also, another example (unofficial):
> https://stackoverflow.com/questions/18961213/how-to-connect-to-a-remote-windows-machine-to-execute-commands-using-python.
> This was done in Python2, but the example is still useful.
>
> On Mon, Aug 19, 2019 at 2:11 PM Iranna Mathapati 
> wrote:
>
>> Hi Team,
>>
>> can you please let me know, How to login the remote Windows machine using
>> python??
>>
>> Thanks
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >