[issue26149] Suggest PyCharm Community as an editor for Unix platforms

2016-10-03 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Thanks for the feedback, Berker.
I updated the patch as suggested.

--
Added file: http://bugs.python.org/file44949/issue26149.patch

___
Python tracker 

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




[issue28288] Expose environment variable for Py_Py3kWarningFlag

2016-10-03 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the new patch.

> I've uploaded the new patchset here.

We don't directly upload patches to Rietveld so you did the right thing :) See 
https://docs.python.org/devguide/patch.html for details.

Can you also add a note about this new variable to Doc/howto/pyporting.rst?

--

___
Python tracker 

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



[issue28318] Python unittest.mock.mock_calls stores references to arguments instead of their values

2016-10-03 Thread Vedran Čačić

Vedran Čačić added the comment:

> # passes, even though we didn't make the exact same call twice!

Weird. It looks like a matter of perspective, but to me it surely _does_ seem 
like you _did_ make the exact same call twice.

> test_function(arg)
> test_function(arg)

Neither test_function nor arg were rebound in the meantime. (If there's a 
"bug", it's a subtle thing that += seems like rebinding, and in fact it does 
rebind immutable objects. But that's off topic here.)

[*Also, it could be argued that assert_has_calls should compare the arguments 
with `is` instead of `==`, but that would probably break too many things.]

But let's try to be constructive. IIRC, unittest was modelled after Java's 
analogous library. Can someone check how Java solves this? I'm pretty sure it 
has the same "problem" (when arguments are objects), but maybe it keeps the 
reference semantics totally as conjectured in the previous paragraph.

--
nosy: +veky

___
Python tracker 

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



Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Gregory Ewing

On Mon, 3 Oct 2016 10:57:27 -0700 (PDT), sohcahto...@gmail.com declaimed
the following:

>

My car is similar, but the R is actually to the left of 1.  It looks like this:

R 1 3 5
+-+-+-+
2 4 6


Mine is actually like that too, but it feels like you're
doing the same thing in both cases -- push left as far
as it will go and then forward.

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


Re: PyQt5, OpenGL, where to start, minimal example code?

2016-10-03 Thread John Ladasky
On Monday, October 3, 2016 at 1:30:29 AM UTC-7, Phil Thompson wrote:
> On 3 Oct 2016, at 4:29 am, John Ladasky  wrote:

> > And as you can see: trying to call versionFunctions() is exactly where my 
> > program failed.
> 
> Try passing a QOpenGLVersionProfile object to versionFunctions() that has a 
> version set to one supported by PyQt.

Hi Phil,

I'm trying to follow your advice.  It's strange, "from PyQt5.QtGui import 
QOpenGLVersionProfile" works fine, and I can make an object of that type.

However: http://pyqt.sourceforge.net/Docs/PyQt5/ DOES NOT DOCUMENT 
QOpenGLVersionProfile.  I did find Qt documentation, at 
http://doc.qt.io/qt-5/qopenglversionprofile.html.  I will investigate this 
issue further.  Sometimes it isn't obvious how the C++ constructors are wrapped 
in Python.

If I ever understand a GUI like PyQt5 well enough, I'd like to contribute to 
its documentation.  Sigh.

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


Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Michael Torrie
On 10/03/2016 08:21 PM, Steve D'Aprano wrote:
> On Tue, 4 Oct 2016 05:48 am, Michael Torrie wrote:
> 
>> There is that old, but false, saying that the only intuitive interface
>> is the nipple.  Turns out everything, even that, is learned
> 
> Citation required.

Sure, just ask a nursing woman.

> Of course many things are intuitive/instinctive, e.g. breathing, but as far
> as *interfaces* go, I'd like to see the research that proves that babies
> don't intuitively know how to suckle from a nipple.

Research? Can't you just ask women about it?  I've heard quite a few
women (with experience) comment on the learned nature of babies nursing
over the years whenever this statement would come up in such company.
Which it will when you're in with a large group of married computer nerds.

Sucking seems to be instinctive but the actual interface is learned
(albeit very quickly) by experience.  Babies don't just see a nipple and
know what it's for. If your children ever did, they are remarkable
indeed.  Anyway, it's certainly not "intuitive" if intuitive is defined
as understanding with only basic perception of an object.  Similarly an
unmarked, red button you push to give you food is not intuitive.  You
can't see the button and know what it does without experience, or
someone telling you.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue26149] Suggest PyCharm Community as an editor for Unix platforms

2016-10-03 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

ping :)

--

___
Python tracker 

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



Re: Assignment versus binding [was Re: unintuitive for-loop behavior]

2016-10-03 Thread Rustom Mody
On Tuesday, October 4, 2016 at 8:11:41 AM UTC+5:30, Steve D'Aprano wrote:
> On Mon, 3 Oct 2016 04:15 pm, Jussi Piitulainen wrote:
> 
> > Steve D'Aprano writes:
> >> Why shouldn't people say that binding and assignment are the same
> >> thing in Python? What's the difference?
> > 
> > Outside Python, (lambda x : f(x)) is said to "bind" x. It's different
> > from assigning a new value to x. It's similar to how quantifiers in
> > logic are said to bind their variables, so that variables bound to
> > different quantifiers are different variables.
> 
> o_O
> 
> Me: "How is binding different from assignment?"
> 
> You: "This is an example of binding: lambda x: f(x). Its different from
> assigning to x. Clear now?"
> 
> 
> What's "outside python"? Can you give some examples? Presumably you don't
> actually mean "every single programming language apart from Python", even
> if that's what it sounds like.
> 
> Anyway, I've done my own research, and what I've found is:
> 
> - Some people consider assignment and binding to be synonyms. This is
> especially common in OOP languages (like Python), and procedural languages.

Here’s C++
http://www.informit.com/articles/article.aspx?p=376876
roughly using initialization where Jussi/Greg/myself/etc are using binding



> 
> - Some people consider them to be different. This is especially common in
> functional languages with an academic emphasis.
> 
> For those who consider them different, the distinction is usually along
> these lines:
> 
> - Assignment associates a mutable label to a value. So if I say "x = 1",
> that sets up a labelled box and puts 1 inside that box. Then if I say "x =
> 2", the box is updated to contain 2 instead of 1.
> 
> - Binding is more like setting up a label or identifier for a constant. For
> example, in a legal contract, you might say words to the effect of:
> 
>John and Jane Smith, of 123 Evergreen Terrace, Metropolis ("the Client")
> 
> and then everywhere the contract refers to "the Client", you are supposed to
> mentally substitute "John and Jane Smith, of ...". Its a fixed label for a
> fixed value. Even if the value is mutable (John and Jane have a baby, and
> the baby is now automatically covered by the contract, the value cannot be
> replaced with a new value (you can't swap out John and Jane and replace
> them with their neighbours Fred and Ethel, you have to cancel the contract
> and write a new one).
> 
> So for these languages, bindings relate to a *fixed* association between a
> label and value. Whether the *value* itself is mutable or immutable, the
> association is fixed.

Are you suggesting that python can be understood without this distinction?
Consider the ‘mutable default gotcha’ in which the mutable is assigned but not 
mutated

tl;dr 
Many concepts are needed to understand programming languages
Some of them may be reified into the language; all cannot be.
“Not reified into the language” ≠ “Not a necessary concept for the language”
If you have variables+scopes you need (the concept of) binding
As understood by language-theorists, eg:
http://homepage.cs.uiowa.edu/~slonnegr/plf/Book/Chapter9.pdf
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28348] Doc typo in asyncio.Task

2016-10-03 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

fixed the typo as reported.

--
keywords: +patch
Added file: http://bugs.python.org/file44948/issue28348.patch

___
Python tracker 

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



[issue19398] test_trace fails with -S

2016-10-03 Thread Tim Smith

Changes by Tim Smith :


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



Re: working with ctypes and complex data structures

2016-10-03 Thread eryk sun
On Mon, Oct 3, 2016 at 9:27 PM, Michael Felt  wrote:
>
> int perfstat_subsystem_total(
>perfstat_id_t *name,
>perfstat_subsystem_total_t *userbuff,
>int sizeof_struct,
>int desired_number);
> ...
>+79  class cpu_total:
>+80  def __init__(self):
>+81  __perfstat__ = CDLL("libperfstat.a(shr_64.o)")

Move loading the library and defining function prototypes to either
the module or class body. Also, don't use dunder names. The convention
for a private attribute is a single underscore. For type safety,
define each function's argtypes (and restype where required, the
default is c_int). For a more Pythonic interface, define a ctypes
errcheck function that encapsulates raising an appropriate exception
when a C call fails. For example:

import ctypes

# If the following types are used generally, define them at
# the module level, else define them in the class namespace
# that uses them.

perfstat = ctypes.CDLL("libperfstat.a(shr_64.o)")

class perfstat_id_t(ctypes.Structure):
pass

IDENTIFIER_LENGTH = 64

class time64_t(ctypes._SimpleCData):
_type_ = ctypes.c_int64._type_

time_t = time64_t

class perfstat_cpu_total_t(ctypes.Structure):
_fields_ = (("ncpus",   ctypes.c_int),
("ncpus_cfg",   ctypes.c_int),
("description", ctypes.c_char * IDENTIFIER_LENGTH),
("buffer1", ctypes.c_ulonglong * 15),
("lbolt",   time_t),
("loadavg", ctypes.c_ulonglong * 3),
("buffer2", ctypes.c_ulonglong * 29),
("ncpus_high",  ctypes.c_int),
("puser",   ctypes.c_ulonglong),
("psys",ctypes.c_ulonglong),
("pidle",   ctypes.c_ulonglong),
("pwait",   ctypes.c_ulonglong),
("buffer3", ctypes.c_ulonglong * 12))

def _perfstat_errcheck(result, func, args):
if result == -1:
# get error info and
raise SomeException()
return args

class CPUTotal(object):
# These may be defined here or just referenced here.
_perfstat = perfstat
_perfstat_id_t = perfstat_id_t
_perfstat_cpu_total_t = perfstat_cpu_total_t

_cpu_total = _perfstat.perfstat_cpu_total
_cpu_total.errcheck = _perfstat_errcheck
_cpu_total.argtypes = (
ctypes.POINTER(_perfstat_id_t),
ctypes.POINTER(_perfstat_cpu_total_t),
ctypes.c_int, ctypes.c_int)

def __init__(self):
self._tcpu = self._perfstat_cpu_total_t()
self._cpu_total(None,
ctypes.byref(self._tcpu),
ctypes.sizeof(self._tcpu), 1)
-- 
https://mail.python.org/mailman/listinfo/python-list


Assignment versus binding [was Re: unintuitive for-loop behavior]

2016-10-03 Thread Steve D'Aprano
On Mon, 3 Oct 2016 04:15 pm, Jussi Piitulainen wrote:

> Steve D'Aprano writes:
>> Why shouldn't people say that binding and assignment are the same
>> thing in Python? What's the difference?
> 
> Outside Python, (lambda x : f(x)) is said to "bind" x. It's different
> from assigning a new value to x. It's similar to how quantifiers in
> logic are said to bind their variables, so that variables bound to
> different quantifiers are different variables.

o_O

Me: "How is binding different from assignment?"

You: "This is an example of binding: lambda x: f(x). Its different from
assigning to x. Clear now?"


What's "outside python"? Can you give some examples? Presumably you don't
actually mean "every single programming language apart from Python", even
if that's what it sounds like.

Anyway, I've done my own research, and what I've found is:

- Some people consider assignment and binding to be synonyms. This is
especially common in OOP languages (like Python), and procedural languages.

- Some people consider them to be different. This is especially common in
functional languages with an academic emphasis.

For those who consider them different, the distinction is usually along
these lines:

- Assignment associates a mutable label to a value. So if I say "x = 1",
that sets up a labelled box and puts 1 inside that box. Then if I say "x =
2", the box is updated to contain 2 instead of 1.

- Binding is more like setting up a label or identifier for a constant. For
example, in a legal contract, you might say words to the effect of:

   John and Jane Smith, of 123 Evergreen Terrace, Metropolis ("the Client")

and then everywhere the contract refers to "the Client", you are supposed to
mentally substitute "John and Jane Smith, of ...". Its a fixed label for a
fixed value. Even if the value is mutable (John and Jane have a baby, and
the baby is now automatically covered by the contract, the value cannot be
replaced with a new value (you can't swap out John and Jane and replace
them with their neighbours Fred and Ethel, you have to cancel the contract
and write a new one).

So for these languages, bindings relate to a *fixed* association between a
label and value. Whether the *value* itself is mutable or immutable, the
association is fixed.



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

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


[issue28352] winfo_pathname(..) | window id "xyz" doesn't exist in this application. | Python 3.4.4

2016-10-03 Thread Zachary Ware

Zachary Ware added the comment:

Can you provide a minimal example to reproduce the issue with Python 3.5.2 or 
3.6b1 (3.4 is no longer receiving bug fixes)?  Also, what OS are you on, and if 
not Windows, what version of Tcl/Tk are you using?

--
nosy: +zach.ware

___
Python tracker 

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



Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Steve D'Aprano
On Tue, 4 Oct 2016 05:48 am, Michael Torrie wrote:

> There is that old, but false, saying that the only intuitive interface
> is the nipple.  Turns out everything, even that, is learned

Citation required.

Of course many things are intuitive/instinctive, e.g. breathing, but as far
as *interfaces* go, I'd like to see the research that proves that babies
don't intuitively know how to suckle from a nipple.



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

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


[issue28352] winfo_pathname(..) | window id "xyz" doesn't exist in this application. | Python 3.4.4

2016-10-03 Thread Tyler Sweeden

New submission from Tyler Sweeden:

This issue presents itself in 3.4.4.. Reverted back to 3.4.1 and the issue was 
gone.

--
components: Tkinter
messages: 278004
nosy: Tyler Sweeden
priority: normal
severity: normal
status: open
title: winfo_pathname(..) | window id "xyz" doesn't exist in this application. 
| Python 3.4.4
versions: Python 3.4

___
Python tracker 

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



[issue24712] Docs page's sidebar vibrates on mouse wheel scroll on Chrome.

2016-10-03 Thread karl

karl added the comment:

@ezio.melotti 
What is the next step for getting the patch accepted.

--
nosy: +karlcow

___
Python tracker 

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



[issue28338] test_pdb doctests have been removed from its test suite

2016-10-03 Thread Łukasz Langa

Łukasz Langa added the comment:

Uh oh. Sorry for the mess! If this is any consolation, that was in the heat of 
the sprint. Thank you for cleaning it up.

--

___
Python tracker 

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



[issue26240] Docstring of the subprocess module should be cleaned up

2016-10-03 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
nosy: +Mariatta

___
Python tracker 

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



Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Gregory Ewing

BartC wrote:

On 03/10/2016 12:53, Marko Rauhamaa wrote:


Well, it could be worse. This layout is pretty traditional:

1  3  5
|  |  |
+--+--+
|  |  |
2  4  R


Yes, you get a funny grinding sound when attempting to change from 5th 
to '6th' at 70mph/110kph. Fortunately it doesn't actually go into reverse.


Yes, my previous car had that layout. I never actually
tried to go from 5 to R at speed, so I don't know
what it would have sounded like, but I know from the
service manual that it had a mechanism to prevent it
from happening.

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


Re: Create a map for data to flow through

2016-10-03 Thread Gregory Ewing

Sayth Renshaw wrote:

Is there a standard library feature that allows you to define a declarative
map or statement that defines the data and its objects to be parsed and
output format?


Not really.


Just wondering as for loops are good but when i end up 3-4 for loops deep and
want multiple matches at each level i am finding it harder to manage.


When your loops get more than about one or two levels deep,
think about separaring each level into its own function.
That will allow you to think about just one part of the
problem at a time, and help you to not get confused.

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


[issue28342] OSX 10.12 crash in urllib.request getproxies_macosx_sysconf and proxy_bypass_macosx_sysconf

2016-10-03 Thread Alexander Mohr

Alexander Mohr added the comment:

I'm sure it would work, I just wanted a solution that didn't changes to our 
build infrastructure. btw if we're marking this as a duplicate of the other 
bug, can we update the other bug to say it affects python3.x as well?  Thanks!

--
status: pending -> open

___
Python tracker 

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



Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt



On 02-Oct-16 19:50, Michael Felt wrote:

class perfstat_cpu_total_t(Structure):
"""
typedef struct { /* global cpu information */
int ncpus;/* number of active logical 
processors */

int ncpus_cfg; /* number of configured processors */
char description[IDENTIFIER_LENGTH]; /* processor description 
(type/official name) */
u_longlong_t buffer1[15];   /*  several variables being 
skipped for now */
time_t lbolt;  /* number of ticks since last 
reboot */
u_longlong_t loadavg[3];  /* (1<

[issue28130] Document that time.tzset updates time module globals

2016-10-03 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


--
nosy: +Mariatta

___
Python tracker 

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



[issue11698] Improve repr for structseq objects to show named, but unindexed fields

2016-10-03 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue28288] Expose environment variable for Py_Py3kWarningFlag

2016-10-03 Thread Roy Williams

Roy Williams added the comment:

Thanks for the feedback Berker.  I addressed your feedback, but unfortunately I 
get a 500 from Rietveld when I try to attach a new patchset.  I've uploaded the 
new patchset here.

--

___
Python tracker 

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



[issue28288] Expose environment variable for Py_Py3kWarningFlag

2016-10-03 Thread Roy Williams

Changes by Roy Williams :


Added file: http://bugs.python.org/file44947/pythonenable3kwarningsflag.patch

___
Python tracker 

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



[issue28111] geometric_mean can raise OverflowError for large input length

2016-10-03 Thread Mark Dickinson

Mark Dickinson added the comment:

Whoops; that patch was incomplete (it was missing the change to the 
geometric_mean function itself). Here's an updated patch.

--
Added file: http://bugs.python.org/file44946/geometric_mean_long_input_v2.py

___
Python tracker 

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



[issue28259] Ctypes bug windows

2016-10-03 Thread Eryk Sun

Eryk Sun added the comment:

If you want a resolution to this issue, then you need to provide a minimal 
example that reproduces the problem. It would also be helpful if you could 
provide a download link for the library that you're wrapping. If not, at least 
upload a dump file, preferably from 3.5 since 3.4 is no longer actively 
maintained.

--
versions:  -Python 3.5

___
Python tracker 

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



[issue28351] statistics.geometric_mean can enter infinite loop for Decimal inputs

2016-10-03 Thread Mark Dickinson

Changes by Mark Dickinson :


--
title: statistics.geometric_mean enters infinite loop for Decimal inputs -> 
statistics.geometric_mean can enter infinite loop for Decimal inputs

___
Python tracker 

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



[issue28350] Interning string constants with null character

2016-10-03 Thread STINNER Victor

STINNER Victor added the comment:

all_name_chars.patch LGTM.

--
nosy: +haypo

___
Python tracker 

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



[issue28328] statistics.geometric_mean has no tests. Defer to 3.7?

2016-10-03 Thread Mark Dickinson

Mark Dickinson added the comment:

One more geometric_mean issue (the current code can enter an infinite loop for 
Decimal inputs): #28351.

Steve, I really think we should postpone to 3.7. I'm very happy to help out 
with all the necessary fixes, tests and review, but I'm not going to have time 
for that before 3.6b2. If we defer, that takes the pressure off a bit and lets 
us get a good solid implementation in for 3.7.

--

___
Python tracker 

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



[issue28351] statistics.geometric_mean enters infinite loop for Decimal inputs

2016-10-03 Thread Mark Dickinson

New submission from Mark Dickinson:

On my machine, the following code enters an infinite loop:

Python 3.7.0a0 (default:14c52bb996be, Oct  3 2016, 20:20:58) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from statistics import geometric_mean
>>> from decimal import Decimal
>>> x = [0.5636536271446626, 0.7185039116960741, 0.5265438727361142]
>>> geometric_mean(map(Decimal, x))

The nth_root implementation for Decimals does a repeated Newton iteration until 
convergence, with convergence being defined as the current iteration value 
being exactly equal to the last one. It's very easy for the iteration to end up 
alternating between two (or more) nearby values, and that's what happens above. 
This isn't a rare corner case: if you generate triples of random floats, 
convert to Decimal and apply geometric mean, you'll hit something like the 
above within just a few trials.

I don't think there's any need for an iteration here: I'd suggest simply 
computing the nth root directly after increasing the Decimal context precision 
by a suitable amount. If we do use Newton iteration, it should likely restrict 
itself to doing a single polishing step, as in the issue #28111 fix and #27181 
discussion.

--
messages: 277995
nosy: mark.dickinson
priority: normal
severity: normal
status: open
title: statistics.geometric_mean enters infinite loop for Decimal inputs
type: behavior
versions: Python 3.6, Python 3.7

___
Python tracker 

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



[issue28350] Interning string constants with null character

2016-10-03 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Currently string constants are interned if they consist of ASCII word 
characters ([0-9A-Za-z_]). But strings are tested only to the first null 
character. This is not problem for names, since they can't include null 
characters, but string constants that contains ASCII non-word characters after 
the null character passes this test.

Proposed simple patch fixes the testing function all_name_chars().

Other question: shouldn't PyUnicode_IsIdentifier() be used in 3.x?

--
components: Interpreter Core
files: all_name_chars.patch
keywords: patch
messages: 277994
nosy: benjamin.peterson, brett.cannon, georg.brandl, ncoghlan, rhettinger, 
serhiy.storchaka, yselivanov
priority: normal
severity: normal
stage: patch review
status: open
title: Interning string constants with null character
type: behavior
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file44945/all_name_chars.patch

___
Python tracker 

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



[issue28111] geometric_mean can raise OverflowError for large input length

2016-10-03 Thread Mark Dickinson

Mark Dickinson added the comment:

And here's the actual patch. :-)

--
Added file: http://bugs.python.org/file44944/geometric_mean_long_input.py

___
Python tracker 

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



[issue28111] geometric_mean can raise OverflowError for large input length

2016-10-03 Thread Mark Dickinson

Changes by Mark Dickinson :


--
versions: +Python 3.7

___
Python tracker 

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



[issue28111] geometric_mean can raise OverflowError for large input length

2016-10-03 Thread Mark Dickinson

Mark Dickinson added the comment:

The attached patch provides a fix, and is based partly on Tim Peters' 
suggestions and code from the issue 27761 discussion. It needs tests. For 
convenience, it includes the fix for #28327, since it needs the `_frexp_gen` 
function added there.

--

___
Python tracker 

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



[issue28335] Exception reporting in `logging.config`

2016-10-03 Thread Ram Rachum

Ram Rachum added the comment:

Thanks for the quick fix Vinay!

--

___
Python tracker 

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



[issue28259] Ctypes bug windows

2016-10-03 Thread Aristotel

Aristotel added the comment:

CDLL. I didn't test it on Python 3.5.2, 3.3 - 3.4 only. And btw my OS is 
windows 7. Lib is also used by some apps (not Python apps) and there this 
function works well.

--

___
Python tracker 

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



[issue28335] Exception reporting in `logging.config`

2016-10-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8c005be54305 by Vinay Sajip in branch 'default':
Issue #28335: made minor improvement to implementation.
https://hg.python.org/cpython/rev/8c005be54305

--

___
Python tracker 

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



Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Michael Torrie
On 10/03/2016 11:57 AM, sohcahto...@gmail.com wrote:
> Surprisingly, despite driving that previous car for 13 years, the switch was 
> incredibly easy.  I've never accidentally gone to sixth gear instead of 
> reverse, or forgotten to shift into sixth on the highway.  Also, accidentally 
> going into first when I want to reverse has never happened.  I was actually 
> pretty surprised.  I thought I'd mess it up constantly for the first couple 
> months.

I drive a lot of trucks with different patterns.  One is the traditional
one with reverse to the right and back.  Several use left and up for
reverse (first or low is left and down). Never had bothered me and I
rarely select reverse when I want forward or vice versa.  In fact all it
takes to determine which pattern I have without looking is to see which
side of the H has the spring-back on it.

What would throw me off would be left-side driving where the pattern is
the same but the stick is on the left hand side of me and the pattern
works its way towards me instead of away.

There is that old, but false, saying that the only intuitive interface
is the nipple.  Turns out everything, even that, is learned, and humans
are pretty adaptable, even to non-obvious and non-intuitive things such
as how python's loops work, lambdas, comprehensions, etc.  Anyone ever
driven a 5 and 4 transmission? :)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue2897] Deprecate structmember.h

2016-10-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Changed the title to reflect the way forward and added affected versions to 
remember to update the documentation.  See #28349 and #24065 for details.

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python
title: include structmember.h in Python.h -> Deprecate structmember.h
versions: +Python 2.7, Python 3.5, Python 3.6

___
Python tracker 

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



[issue28335] Exception reporting in `logging.config`

2016-10-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 69bf09bf4952 by Vinay Sajip in branch 'default':
Closes #28335: used 'raise from' in logging configuration code.
https://hg.python.org/cpython/rev/69bf09bf4952

--
nosy: +python-dev
resolution:  -> fixed
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread Michael Torrie
On 10/03/2016 03:10 AM, Gregory Ewing wrote:
> Rustom Mody wrote:
>> My new car goes in reverse when I put it in first gear but only on full-moon 
>> nights with the tank on reserve when the left light is blinking
> 
> OT aside: When I went to take my current car (a manual)
> for a test drive, I had to stop and ask the dealer how
> to put it into reverse.
> 
> Turns out the only difference between first and reverse
> on that model is whether you lift up a little ring on the
> shaft of the gear lever prior to engagement.
> 
> Who came up with *that* brilliant piece of user interface
> design I don't know. It seems specifically designed to
> encourage velocity sign errors when starting off...

Yeah I'm not sure what's up with car engineers these days. The Chrysler
transmission shifter that springs back to the center position is another
one of those brain-dead things.  There's no way to know if you've made
it all the way into park without looking at the dash.  Click it up and
hold it to hit neutral, then reverse, then park.  Then it springs back
to center position.  This contributed to the death of that Star Trek
movie actor.  He thought it was in park but it wasn't, and it rolled
over him.


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


[issue2897] include structmember.h in Python.h

2016-10-03 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
dependencies: +Issues with PyMemberDef flags, Outdated *_RESTRICTED flags in 
structmember.h

___
Python tracker 

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



[issue2897] include structmember.h in Python.h

2016-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

And please don't miss to fix the documentation in 2.7 and 3.5-3.6.

--

___
Python tracker 

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



[issue2897] include structmember.h in Python.h

2016-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

PY_T_PY_SSIZE_T is not much readable than PY_T_PYSSIZET. I think it can be just 
PY_T_SSIZE.

--

___
Python tracker 

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



[issue24065] Outdated *_RESTRICTED flags in structmember.h

2016-10-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

See #2897 for a plan to deperecate Include/structmember.h.

--
nosy: +belopolsky
resolution:  -> duplicate
status: open -> closed
superseder:  -> include structmember.h in Python.h

___
Python tracker 

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



[issue28349] Issues with PyMemberDef flags

2016-10-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

There is also #24065 ("Outdated *_RESTRICTED flags in structmember.h") which I 
think should be folded into #2897.

--

___
Python tracker 

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



[issue28349] Issues with PyMemberDef flags

2016-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ah this is a duplicate of issue24065!

--
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder: include structmember.h in Python.h -> Outdated *_RESTRICTED flags 
in structmember.h

___
Python tracker 

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



[issue2897] include structmember.h in Python.h

2016-10-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

As explained in #24065, READ_RESTRICTED, PY_WRITE_RESTRICTED and RESTRICTED 
flags were used for "restricted mode" in Python 2. I don't think we would want 
to preserve these as we move the rest to object.h.

--

___
Python tracker 

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



[issue28349] Issues with PyMemberDef flags

2016-10-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

Serhiy, while I see that you've raised some additional issues here, let's keep 
the discussion related to Include/structmember.h in one place.  I would not 
mind adding additional affected versions there.

--
nosy: +belopolsky

___
Python tracker 

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



[issue28335] Exception reporting in `logging.config`

2016-10-03 Thread Vinay Sajip

Vinay Sajip added the comment:

Patch as posted will not work (contains a syntax error), and was thus never 
tested. Never mind, I will address this soon.

--
assignee:  -> vinay.sajip

___
Python tracker 

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



[issue28349] Issues with PyMemberDef flags

2016-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

We still should correct the documentation in 2.7 and 3.x.

--
resolution: duplicate -> 
stage: resolved -> needs patch
status: closed -> open

___
Python tracker 

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



[issue2897] include structmember.h in Python.h

2016-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Please don't forget to use "hg copy" for creating object.h from structmember.h. 
This preserves the history.

structmember.h should be implemented using object.h. Include object.h and add 
aliases.

Only READONLY flag is used in 3.x (issue28349). Other flags can be removed.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue28349] Issues with PyMemberDef flags

2016-10-03 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> include structmember.h in Python.h

___
Python tracker 

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



[issue28318] Python unittest.mock.mock_calls stores references to arguments instead of their values

2016-10-03 Thread Guillaume Chorn

Guillaume Chorn added the comment:

If it's true that our ability to accurately deep-copy mutable args makes fixing 
this behavior impossible, we should at the very least update the official 
unittest.mock documentation to warn users that testing for mock calls with 
mutable arguments is not reliable; i.e. make it clear that we're storing a 
reference to the arguments and not just the values. If it's not a bug, it's 
certainly a limitation that deserves as much mention as possible.

--

___
Python tracker 

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



[issue2897] include structmember.h in Python.h

2016-10-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I would also like this opportunity to rename T_PYSSIZET to something more 
readable: maybe PY_T_PY_SSIZE_T or PY_T_SSIZE_T.

--

___
Python tracker 

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



[issue28349] Issues with PyMemberDef flags

2016-10-03 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The latter issue is a duplicate of issue2897.

--

___
Python tracker 

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



[issue28349] Issues with PyMemberDef flags

2016-10-03 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

As documented in Doc/extending/newtypes.rst, the flags field of PyMemberDef 
must be bitwise-or-ed combination of flag constants READONLY, READ_RESTRICTED, 
WRITE_RESTRICTED and RESTRICTED. There are problems with this:

1. Actually WRITE_RESTRICTED was renamed to PY_WRITE_RESTRICTED in 2.6 
(a8dd8874ff2d). I didn't find mention of this backward incompatible change in 
Misc/NEWS and whatsnew files.

2. Since the support of restricted mode was removed in 3.x, only READONLY flag 
has effect. Other flags are still documented and used in CPython sources. I 
think we should get rid of using these flags and undocument them or document as 
outdated.

3. As noted by Skip Montanaro on the Python-Dev mailing list, these flags (as 
well as T_* type tags in Include/structmember.h) should have the PY_ prefix.

--
assignee: docs@python
components: Documentation
messages: 277972
nosy: christian.heimes, docs@python, serhiy.storchaka, skip.montanaro
priority: normal
severity: normal
status: open
title: Issues with PyMemberDef flags
versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



Re: working with ctypes and complex data structures

2016-10-03 Thread Michael Felt



On 03-Oct-16 16:35, Michael Felt wrote:

I'd alias the type instead of defining a struct, e.g. `time_t =
c_long`. This preserves automatic conversion of the simple type.
The reason for the not using alias is because a) I was trying to be 
more inline with the text of the include file.
I will have to check the sizeof c_long (i.e., sizeof(long) in both 32 
and 64-bit modes

Also, sys.maxsize is based on the platform's size_t type. That's
generally the same size as a pointer, but C doesn't require this.
Instead use sizeof(c_void_p), which will be 8 on a 64-bit platform and
4 on a 32-bit platform. 


I had checked this before - I shall have to try a 32-bit python to see 
what _ctypes is doing with c_long on AIX - is it 4, or is it 8.
michael@x071:[/data/prj/python/cloud-init/aix-cloud-init-0.7.8.1/new]cat 
xxx.c

#include 
time_t
lbolt()
{
perfstat_cpu_total_t cpu_totals;
void *p1, *p2;

printf("int_size:%d\n", sizeof(int));
printf("long_size:%d\n", sizeof(long));
printf("timet_size:%d\n", sizeof(time_t));
printf("void_ptr_size:%d\n", sizeof(void *));
printf("lbolt_size:%d\n", sizeof(cpu_totals.lbolt));

p1 = _totals;
p2 = _totals.lbolt;
printf("lbolt offset:%d\n", p2 - p1);
}

main()
{
lbolt();
}

michael@x071:[/data/prj/python/cloud-init/aix-cloud-init-0.7.8.1/new]cc 
-q32 >

int_size:4
long_size:4
timet_size:4
void_ptr_size:4
lbolt_size:4
lbolt offset:192
michael@x071:[/data/prj/python/cloud-init/aix-cloud-init-0.7.8.1/new]cc 
-q64 >

int_size:4
long_size:8
timet_size:8
void_ptr_size:8
lbolt_size:8
lbolt offset:192


I think 4 and 8 because of problems I have with this block when not in 
the right "mode", i.e. SIZEOF_LONG changes


#if LONG_BIT != 8 * SIZEOF_LONG
/* 04-Oct-2000 LONG_BIT is apparently (mis)defined as 64 on some recent
 * 32-bit platforms using gcc.  We try to catch that here at compile-time
 * rather than waiting for integer multiplication to trigger bogus
 * overflows.
 */
#error "LONG_BIT definition appears wrong for platform (bad gcc/glibc 
config?)."

#endif

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


Re: python (scipy) TypeError

2016-10-03 Thread chrischris201444
Τη Δευτέρα, 3 Οκτωβρίου 2016 - 7:17:03 μ.μ. UTC+3, ο χρήστης 
chrischr...@gmail.com έγραψε:
> hello
> 
> 
> i try to follow some tutorial but i have that error :
> 
> Traceback (most recent call last):
>   File "C:\Python27\test\test\earth.py", line 42, in 
> slope_array = np.ones_like(data_array) * nodataval
> TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'
> 
> 
> first i define that lines of code :
> 
> data_array = raster2array(filename)
> nodataval = getNoDataValue(filename)
> 
> and the line with error :
> 
> slope_array = np.ones_like(data_array) * nodataval
> 
> how can i fix this error ?i change type field ?
> 
> on the four prints:
> 
> print(resolution)
> print(nodataval)
> print(type(data_array))
> print(data_array.shape)
> 
> i take that exports :
> 
> {'east-west': 0.0002778, 'north-south': 0.0002778}
> None
> 
> (3601, 3601)
> 
> the full code :
> 
> 
> from __future__ import division
> from osgeo import gdal
> from matplotlib.colors import ListedColormap
> from matplotlib import colors
> import sys
> import numpy as np
> import matplotlib
> import matplotlib.pyplot as plt
> import math
> 
> filename = 'dem.tif'
> 
> def getResolution(rasterfn):
> raster = gdal.Open(rasterfn)
> geotransform = raster.GetGeoTransform()
> res = {"east-west": abs(geotransform[1]), 
>"north-south": abs(geotransform[5])}
> return res
> 
> def raster2array(rasterfn):
> raster = gdal.Open(rasterfn)
> band = raster.GetRasterBand(1)
> return band.ReadAsArray()
> 
> def getNoDataValue(rasterfn):
> raster = gdal.Open(rasterfn)
> band = raster.GetRasterBand(1)
> return band.GetNoDataValue()
> 
> data_array = raster2array(filename)
> nodataval = getNoDataValue(filename)
> resolution = getResolution(filename)
> print(resolution)
> print(nodataval)
> 
> print(type(data_array))
> print(data_array.shape)
> 
> num_rows = data_array.shape[0]
> num_cols = data_array.shape[1]
> 
> slope_array = np.ones_like(data_array) * nodataval
> aspect_array = np.ones_like(data_array) * nodataval
> 
> for i in range(1, num_rows - 1):
> for j in range(1, num_cols - 1):
> a = data_array[i - 1][j - 1]
> b = data_array[i - 1][j]
> c = data_array[i - 1][j + 1]
> d = data_array[i][j - 1]
> e = data_array[i][j]
> f = data_array[i][j + 1]
> g = data_array[i + 1][j - 1]
> h = data_array[i + 1][j]
> q = data_array[i + 1][j + 1]
> 
> vals = [a, b, c, d, e, f, g, h, q]
> 
> if nodataval in vals:
> all_present = False
> else:
> all_present = True
> 
> if all_present == True:
> dz_dx = (c + (2 * f) + q - a - (2 * d) - g) / (8 * 
> resolution['east-west'])
> dz_dy = (g + (2 * h) + q - a - (2 * b) - c) / (8 * 
> resolution['north-south'])
> dz_dx_sq = math.pow(dz_dx, 2)
> dz_dy_sq = math.pow(dz_dy, 2)
> 
> rise_run = math.sqrt(dz_dx_sq + dz_dy_sq)
> slope_array[i][j] = math.atan(rise_run) * 57.29578
> 
> aspect = math.atan2(dz_dy, (-1 * dz_dx)) * 57.29578
> if aspect < 0:
> aspect_array[i][j] = 90 - aspect
> elif aspect > 90:
> aspect_array[i][j] = 360 - aspect + 90
> else:
> aspect_array[i][j] = 90 - aspect
> 
> hist, bins = np.histogram(slope_array, bins=100, range=(0, 
> np.amax(slope_array)))
> width = 0.7 * (bins[1] - bins[0])
> center = (bins[:-1] + bins[1:]) / 2
> plt.bar(center, hist, align='center', width=width)
> plt.xlabel('Slope (degrees)')
> plt.ylabel('Frequency')
> plt.show()
> 
> color_map = ListedColormap(['white', 'darkgreen', 'green', 'limegreen', 
> 'lime', 
> 'greenyellow', 'yellow', 'gold', 
> 'orange', 'orangered', 'red'])
> 
> # range begins at negative value so that missing values are white
> color_bounds = list(range(-3, math.ceil(np.amax(slope_array)), 1))
> color_norm = colors.BoundaryNorm(color_bounds, color_map.N)
> 
> #Create the plot and colorbar
> img = plt.imshow(slope_array, cmap = color_map, norm = color_norm)
> cbar = plt.colorbar(img, cmap = color_map, norm = color_norm,
>boundaries = color_bounds, ticks = color_bounds)
> 
> #Show the visualization
> plt.axis('off')
> plt.title("Slope (degrees)")
> plt.show()
> plt.close()

yes you are corrent now i dont have error,i have coloring from -3 to 50 with 
step 1.. the -3 number is the -3 from my range ?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue2897] include structmember.h in Python.h

2016-10-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I am attaching a patch that implements steps 1 and 2 of Martin's plan.  There 
are over 50 files that include structmember.h. I am not sure it is worth the 
trouble to update all those files before structmember.h is actually removed.  
If we agree that this is the right way forward, I'll make the necessary changes 
to the docs.

--
keywords: +patch
Added file: http://bugs.python.org/file44943/issue2897.diff

___
Python tracker 

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



[issue11702] dir on return value of msilib.OpenDatabase() crashes python

2016-10-03 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread sohcahtoa82
On Monday, October 3, 2016 at 2:11:12 AM UTC-7, Gregory Ewing wrote:
> Rustom Mody wrote:
> > My new car goes in reverse when I put it in first gear but only on 
> > full-moon 
> > nights with the tank on reserve when the left light is blinking
> 
> OT aside: When I went to take my current car (a manual)
> for a test drive, I had to stop and ask the dealer how
> to put it into reverse.
> 
> Turns out the only difference between first and reverse
> on that model is whether you lift up a little ring on the
> shaft of the gear lever prior to engagement.
> 
> Who came up with *that* brilliant piece of user interface
> design I don't know. It seems specifically designed to
> encourage velocity sign errors when starting off...
> 
> -- 
> Greg

My car is similar, but the R is actually to the left of 1.  It looks like this:

R 1 3 5
+-+-+-+
  2 4 6

However, you can't get to R unless you lift the ring around the stick upwards.  
once you go to the far left, the ring stays up until you slide it out of the 
far left notch.  My previous car was the traditional:

1 3 5
+-+-+
2 4 R

Surprisingly, despite driving that previous car for 13 years, the switch was 
incredibly easy.  I've never accidentally gone to sixth gear instead of 
reverse, or forgotten to shift into sixth on the highway.  Also, accidentally 
going into first when I want to reverse has never happened.  I was actually 
pretty surprised.  I thought I'd mess it up constantly for the first couple 
months.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28342] OSX 10.12 crash in urllib.request getproxies_macosx_sysconf and proxy_bypass_macosx_sysconf

2016-10-03 Thread Ned Deily

Ned Deily added the comment:

Glad you have it working.  Did you try the suggested workaround of setting 
environment variable "no_proxy" to "*"?  I believe that should have had the 
same net effect as the monkey patching.

--
status: open -> pending

___
Python tracker 

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



Re: python (scipy) TypeError

2016-10-03 Thread MRAB

On 2016-10-03 17:48, chrischris201...@gmail.com wrote:

Τη Δευτέρα, 3 Οκτωβρίου 2016 - 7:17:03 μ.μ. UTC+3, ο χρήστης 
chrischr...@gmail.com έγραψε:

hello


i try to follow some tutorial but i have that error :

Traceback (most recent call last):
  File "C:\Python27\test\test\earth.py", line 42, in 
slope_array = np.ones_like(data_array) * nodataval
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'


[snip]


#Show the visualization
plt.axis('off')
plt.title("Slope (degrees)")
plt.show()
plt.close()

yes you are correct i solution this error but now i have another error in the 
line :color_bounds = list(range(-3, math.ceil(np.amax(slope_array)), 1))

error massage :
Traceback (most recent call last):
  File "C:\Python27\test\test\earth.py", line 95, in 
color_bounds = list(range(-3, math.ceil(np.amax(slope_array)), 1))
TypeError: range() integer end argument expected, got float.


any idea ?


Look at the help for math.ceil:

>>> help(math.ceil)
Help on built-in function ceil in module math:

"""
ceil(...)
ceil(x)

Return the ceiling of x as a float.
This is the smallest integral value >= x.
"""

It returns an integer value, but as a _float_.

'range' expects an int, not a float, so you'll need to convert the float 
to an int:


color_bounds = list(range(-3, int(math.ceil(np.amax(slope_array))), 1))


Did you copy the code straight from the tutorial?

You're using Python 2.7, but for which version of Python was the 
tutorial written? Python 2 or Python 3?


If it was written for Python 3 and you're using Python 2, that might 
explain why the code isn't working for you. (In Python 2, math.ceil 
returns a float, whereas in Python 3 it returns an int.)


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


[issue20491] textwrap: Non-breaking space not honored

2016-10-03 Thread Johannes Bauer

Johannes Bauer added the comment:

Hey there,

wanted to follow up on the state of this... is there a reason why this has not 
made it into vanilla yet? If so, I'd like to try to help out clear impediments 
if I can.

This issue is *really*, really, really annoying me. I've posted about a year 
ago on python-list (http://code.activestate.com/lists/python-list/685604/) and 
was referred to this bug and thought I'd wait it out. But now the last change 
was 2 years ago and no relief in sight.

So if nothing else, please take it as a gentle reassurance that this bug is 
really affecting real-world scenarios and annoying as hell. Especially since 
the semantic of a non-breaking space is pretty much exactly to *not* break on 
text wrapping.

If there's anything I can contribute to get things going again, by all means 
please let me know. All hands on deck!

Cheers,
Johannes

--
nosy: +joebauer

___
Python tracker 

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



Re: Copying a compiled Python from one system to another

2016-10-03 Thread Paul Rubin
Steve D'Aprano  writes:
> The dependencies needed to build 4.8 aren't available for my system. And
> there's no supported upgrade path.

If you're system runs 4.4 it should be able to build 4.8 I'd hope.  I
have Debian 7 which comes with 4.7, and I was able to download and build
6.1 with any significant trouble.  I had to change the library path to
build stuff with 6.1 and a locally installed library.  What system are
you running?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue2897] include structmember.h in Python.h

2016-10-03 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
nosy: +skip.montanaro
versions: +Python 3.7 -Python 3.4

___
Python tracker 

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



[issue28342] OSX 10.12 crash in urllib.request getproxies_macosx_sysconf and proxy_bypass_macosx_sysconf

2016-10-03 Thread Alexander Mohr

Alexander Mohr added the comment:

ya I did a monkey patch which resolved it.

if sys.platform == 'darwin':
import botocore.vendored.requests.utils, urllib.request
botocore.vendored.requests.utils.proxy_bypass = 
urllib.request.proxy_bypass_environment
botocore.vendored.requests.utils.getproxies = 
urllib.request.getproxies_environment

urllib.request.proxy_bypass = urllib.request.proxy_bypass_environment
urllib.request.getproxies = urllib.request.getproxies_environment

--
status: pending -> open

___
Python tracker 

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



[issue28128] Improve the warning message for invalid escape sequences

2016-10-03 Thread Nick Coghlan

Nick Coghlan added the comment:

Eric's basic approach sounds fine to me, as it gets the traceback in the right 
place (i.e. blaming the code being compiled, not the code doing the import).

For beta 2, how about we just go with a plain SyntaxWarning? Since users 
running pre-compiled modules won't see it regardless, so it will be effectively 
silenced by default for end users of pre-built Python applications.

--

___
Python tracker 

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



Re: print to previous line in console

2016-10-03 Thread Adam M
On Monday, October 3, 2016 at 12:46:41 PM UTC-4, Skip Montanaro wrote:
> On Mon, Oct 3, 2016 at 10:23 AM, udhay prakash pethakamsetty
> > Hi skip,
> >
> > I am unable to even install that curses package
> >
> >
> > C:\>pip install curses
> > Collecting curses
> >   Could not find a version that satisfies the requirement curses (from
> > versions: )
> > No matching distribution found for curses
> >
> >
> > I am using python 2.7.
> 
> You shouldn't have to install it. Unless your Python installation is
> defective in some regard, you should have it. That said, I don't do
> Windows, so perhaps curses isn't available there.
> 
> % python
> Python 2.7.2 (default, Nov 14 2012, 05:07:35)
> [GCC 4.4.6 [TWW]] on linux3
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import curses
> >>> curses.version
> '2.2'
> 
> Oh, and when asking for help, it's best to cc the mailing list, not
> just the person to whom you are responding. You get more timely -- and
> more complete -- help. In this case, I can't state authoritatively if
> curses is available on Windows. You also don't know that I didn't hit
> "send" on my original response then immediately head off to the North
> Woods for a week of hiking.
> 
> Skip

Because on Linux it is part of 2.7.x distribution. On Windows it is not.
You will need to download wheel from that place:
http://www.lfd.uci.edu/~gohlke/pythonlibs/
And install it using PIP.

Regards
Adam

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


[issue28128] Improve the warning message for invalid escape sequences

2016-10-03 Thread Brett Cannon

Changes by Brett Cannon :


--
nosy:  -brett.cannon

___
Python tracker 

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



Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread breamoreboy
On Monday, October 3, 2016 at 5:41:23 PM UTC+1, BartC wrote:
> On 03/10/2016 16:03, wrote:
> > On Monday, October 3, 2016 at 12:53:55 PM UTC+1, Marko Rauhamaa wrote:
> >> Gregory Ewing:
> >>
> >>> Turns out the only difference between first and reverse on that model
> >>> is whether you lift up a little ring on the shaft of the gear lever
> >>> prior to engagement.
> >>>
> >>> Who came up with *that* brilliant piece of user interface design I
> >>> don't know. It seems specifically designed to encourage velocity sign
> >>> errors when starting off...
> >>
> >> Well, it could be worse. This layout is pretty traditional:
> >>
> >> 1  3  5
> >> |  |  |
> >> +--+--+
> >> |  |  |
> >> 2  4  R
> 
> >
> > There was the shift on the steering column on the 2CV, but then there's 
> > also this.
> >
> > 
> > Traditional Italian military vehicle layout.
> >
> >  1  3  5
> >  |  |  |
> >  +--+--+
> >  |  |  |
> >  2  4  F
> >
> > 
> 
> I don't get it. Shouldn't it be:
> 
>R  R  R
>|  |  |
>+--+--+
>|  |  |
>R  R  R
> 
> ?
> 
> -- 
> Bartc
> 
> (It's OK, I'm Italian...)

A very poor design, what happens if the enemy attack from the rear? :)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28286] gzip guessing of mode is ambiguous

2016-10-03 Thread Jim Jewett

Changes by Jim Jewett :


--
title: gzip guessing of mode is ambiguilous -> gzip guessing of mode is 
ambiguous

___
Python tracker 

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



Re: python (scipy) TypeError

2016-10-03 Thread chrischris201444
Τη Δευτέρα, 3 Οκτωβρίου 2016 - 7:17:03 μ.μ. UTC+3, ο χρήστης 
chrischr...@gmail.com έγραψε:
> hello
> 
> 
> i try to follow some tutorial but i have that error :
> 
> Traceback (most recent call last):
>   File "C:\Python27\test\test\earth.py", line 42, in 
> slope_array = np.ones_like(data_array) * nodataval
> TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'
> 
> 
> first i define that lines of code :
> 
> data_array = raster2array(filename)
> nodataval = getNoDataValue(filename)
> 
> and the line with error :
> 
> slope_array = np.ones_like(data_array) * nodataval
> 
> how can i fix this error ?i change type field ?
> 
> on the four prints:
> 
> print(resolution)
> print(nodataval)
> print(type(data_array))
> print(data_array.shape)
> 
> i take that exports :
> 
> {'east-west': 0.0002778, 'north-south': 0.0002778}
> None
> 
> (3601, 3601)
> 
> the full code :
> 
> 
> from __future__ import division
> from osgeo import gdal
> from matplotlib.colors import ListedColormap
> from matplotlib import colors
> import sys
> import numpy as np
> import matplotlib
> import matplotlib.pyplot as plt
> import math
> 
> filename = 'dem.tif'
> 
> def getResolution(rasterfn):
> raster = gdal.Open(rasterfn)
> geotransform = raster.GetGeoTransform()
> res = {"east-west": abs(geotransform[1]), 
>"north-south": abs(geotransform[5])}
> return res
> 
> def raster2array(rasterfn):
> raster = gdal.Open(rasterfn)
> band = raster.GetRasterBand(1)
> return band.ReadAsArray()
> 
> def getNoDataValue(rasterfn):
> raster = gdal.Open(rasterfn)
> band = raster.GetRasterBand(1)
> return band.GetNoDataValue()
> 
> data_array = raster2array(filename)
> nodataval = getNoDataValue(filename)
> resolution = getResolution(filename)
> print(resolution)
> print(nodataval)
> 
> print(type(data_array))
> print(data_array.shape)
> 
> num_rows = data_array.shape[0]
> num_cols = data_array.shape[1]
> 
> slope_array = np.ones_like(data_array) * nodataval
> aspect_array = np.ones_like(data_array) * nodataval
> 
> for i in range(1, num_rows - 1):
> for j in range(1, num_cols - 1):
> a = data_array[i - 1][j - 1]
> b = data_array[i - 1][j]
> c = data_array[i - 1][j + 1]
> d = data_array[i][j - 1]
> e = data_array[i][j]
> f = data_array[i][j + 1]
> g = data_array[i + 1][j - 1]
> h = data_array[i + 1][j]
> q = data_array[i + 1][j + 1]
> 
> vals = [a, b, c, d, e, f, g, h, q]
> 
> if nodataval in vals:
> all_present = False
> else:
> all_present = True
> 
> if all_present == True:
> dz_dx = (c + (2 * f) + q - a - (2 * d) - g) / (8 * 
> resolution['east-west'])
> dz_dy = (g + (2 * h) + q - a - (2 * b) - c) / (8 * 
> resolution['north-south'])
> dz_dx_sq = math.pow(dz_dx, 2)
> dz_dy_sq = math.pow(dz_dy, 2)
> 
> rise_run = math.sqrt(dz_dx_sq + dz_dy_sq)
> slope_array[i][j] = math.atan(rise_run) * 57.29578
> 
> aspect = math.atan2(dz_dy, (-1 * dz_dx)) * 57.29578
> if aspect < 0:
> aspect_array[i][j] = 90 - aspect
> elif aspect > 90:
> aspect_array[i][j] = 360 - aspect + 90
> else:
> aspect_array[i][j] = 90 - aspect
> 
> hist, bins = np.histogram(slope_array, bins=100, range=(0, 
> np.amax(slope_array)))
> width = 0.7 * (bins[1] - bins[0])
> center = (bins[:-1] + bins[1:]) / 2
> plt.bar(center, hist, align='center', width=width)
> plt.xlabel('Slope (degrees)')
> plt.ylabel('Frequency')
> plt.show()
> 
> color_map = ListedColormap(['white', 'darkgreen', 'green', 'limegreen', 
> 'lime', 
> 'greenyellow', 'yellow', 'gold', 
> 'orange', 'orangered', 'red'])
> 
> # range begins at negative value so that missing values are white
> color_bounds = list(range(-3, math.ceil(np.amax(slope_array)), 1))
> color_norm = colors.BoundaryNorm(color_bounds, color_map.N)
> 
> #Create the plot and colorbar
> img = plt.imshow(slope_array, cmap = color_map, norm = color_norm)
> cbar = plt.colorbar(img, cmap = color_map, norm = color_norm,
>boundaries = color_bounds, ticks = color_bounds)
> 
> #Show the visualization
> plt.axis('off')
> plt.title("Slope (degrees)")
> plt.show()
> plt.close()
yes you are correct i solution this error but now i have another error in the 
line :color_bounds = list(range(-3, math.ceil(np.amax(slope_array)), 1))

error massage :
Traceback (most recent call last):
  File "C:\Python27\test\test\earth.py", line 95, in 
color_bounds = list(range(-3, math.ceil(np.amax(slope_array)), 1))
TypeError: range() integer end argument expected, got float.


any idea ?

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


Re: python (scipy) TypeError

2016-10-03 Thread MRAB

On 2016-10-03 17:14, chrischris201...@gmail.com wrote:

hello


i try to follow some tutorial but i have that error :

Traceback (most recent call last):
  File "C:\Python27\test\test\earth.py", line 42, in 
slope_array = np.ones_like(data_array) * nodataval
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'


The errors is saying that nodataval is None.



first i define that lines of code :

data_array = raster2array(filename)
nodataval = getNoDataValue(filename)

and the line with error :

slope_array = np.ones_like(data_array) * nodataval

how can i fix this error ?i change type field ?

on the four prints:


Look at what print(nodataval) shows. It says that nodataval is None.


print(resolution)
print(nodataval)
print(type(data_array))
print(data_array.shape)

i take that exports :

{'east-west': 0.0002778, 'north-south': 0.0002778}
None

(3601, 3601)

the full code :

Why is nodataval None? It's because getNoDataValue returned None, which 
means that band.GetNoDataValue() returned None.


You'll have to read the docs to see under what conditions it does that.



from __future__ import division
from osgeo import gdal
from matplotlib.colors import ListedColormap
from matplotlib import colors
import sys
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import math

filename = 'dem.tif'

def getResolution(rasterfn):
raster = gdal.Open(rasterfn)
geotransform = raster.GetGeoTransform()
res = {"east-west": abs(geotransform[1]),
   "north-south": abs(geotransform[5])}
return res

def raster2array(rasterfn):
raster = gdal.Open(rasterfn)
band = raster.GetRasterBand(1)
return band.ReadAsArray()

def getNoDataValue(rasterfn):
raster = gdal.Open(rasterfn)
band = raster.GetRasterBand(1)
return band.GetNoDataValue()

data_array = raster2array(filename)
nodataval = getNoDataValue(filename)
resolution = getResolution(filename)
print(resolution)
print(nodataval)

print(type(data_array))
print(data_array.shape)


[snip]

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


Re: print to previous line in console

2016-10-03 Thread Skip Montanaro
On Mon, Oct 3, 2016 at 10:23 AM, udhay prakash pethakamsetty
 wrote:
> Hi skip,
>
> I am unable to even install that curses package
>
>
> C:\>pip install curses
> Collecting curses
>   Could not find a version that satisfies the requirement curses (from
> versions: )
> No matching distribution found for curses
>
>
> I am using python 2.7.

You shouldn't have to install it. Unless your Python installation is
defective in some regard, you should have it. That said, I don't do
Windows, so perhaps curses isn't available there.

% python
Python 2.7.2 (default, Nov 14 2012, 05:07:35)
[GCC 4.4.6 [TWW]] on linux3
Type "help", "copyright", "credits" or "license" for more information.
>>> import curses
>>> curses.version
'2.2'

Oh, and when asking for help, it's best to cc the mailing list, not
just the person to whom you are responding. You get more timely -- and
more complete -- help. In this case, I can't state authoritatively if
curses is available on Windows. You also don't know that I didn't hit
"send" on my original response then immediately head off to the North
Woods for a week of hiking.

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


Re: Is that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread BartC

On 03/10/2016 16:03, breamore...@gmail.com wrote:

On Monday, October 3, 2016 at 12:53:55 PM UTC+1, Marko Rauhamaa wrote:

Gregory Ewing:


Turns out the only difference between first and reverse on that model
is whether you lift up a little ring on the shaft of the gear lever
prior to engagement.

Who came up with *that* brilliant piece of user interface design I
don't know. It seems specifically designed to encourage velocity sign
errors when starting off...


Well, it could be worse. This layout is pretty traditional:

1  3  5
|  |  |
+--+--+
|  |  |
2  4  R




There was the shift on the steering column on the 2CV, but then there's also 
this.


Traditional Italian military vehicle layout.

 1  3  5
 |  |  |
 +--+--+
 |  |  |
 2  4  F




I don't get it. Shouldn't it be:

  R  R  R
  |  |  |
  +--+--+
  |  |  |
  R  R  R

?

--
Bartc

(It's OK, I'm Italian...)
--
https://mail.python.org/mailman/listinfo/python-list


Re: python (scipy) TypeError

2016-10-03 Thread Peter Pearson
On Mon, 3 Oct 2016 09:14:23 -0700 (PDT), chrischris201...@gmail.com wrote:
[snip]
>
> i try to follow some tutorial but i have that error :
>
> Traceback (most recent call last):
>   File "C:\Python27\test\test\earth.py", line 42, in 
> slope_array = np.ones_like(data_array) * nodataval
> TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'
>
>
> first i define that lines of code :
>
> data_array = raster2array(filename)
> nodataval = getNoDataValue(filename)
>
> and the line with error :
>
> slope_array = np.ones_like(data_array) * nodataval
>
> how can i fix this error ?i change type field ?
>
> on the four prints:
>
> print(resolution)
> print(nodataval)
> print(type(data_array))
> print(data_array.shape)
>
> i take that exports :
>
> {'east-west': 0.0002778, 'north-south': 0.0002778}
> None
>
> (3601, 3601)

The TypeError error message is telling you that in the line

 slope_array = np.ones_like(data_array) * nodataval

you're attempting to multiply something of type "int" by something 
of type "NoneType".  And look, when you printed nodataval, you got "None".

So, the real question is why getNoDataValue is returning None.  To
answer that question, I would have to know something about the osgeo
package and your input file dem.tif, but unfortunately I don't.

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


[issue28348] Doc typo in asyncio.Task

2016-10-03 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Thanks for the report. 
Seems like easy fix :)
I'll work on a patch for this today.

--
nosy: +Mariatta

___
Python tracker 

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



[issue6280] calendar.timegm() belongs in time module, next to time.gmtime()

2016-10-03 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

I would like to revisit this for 3.7.

--
keywords:  -needs review, patch
priority: low -> normal
resolution: rejected -> 
stage: commit review -> needs patch
status: closed -> open
versions: +Python 3.7 -Python 3.2

___
Python tracker 

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



[issue28218] Windows docs have wrong versionadded description

2016-10-03 Thread Steve Dower

Changes by Steve Dower :


--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue11698] Improve repr for structseq objects to show named, but unindexed fields

2016-10-03 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
stage:  -> patch review
versions: +Python 3.7 -Python 3.4

___
Python tracker 

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



[issue5907] repr of time.struct_time type does not eval

2016-10-03 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
priority: low -> normal
versions: +Python 3.7 -Python 3.3

___
Python tracker 

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



[issue1820] Enhance Object/structseq.c to match namedtuple and tuple api

2016-10-03 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
stage: needs patch -> patch review
versions: +Python 3.7 -Python 3.5

___
Python tracker 

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



python (scipy) TypeError

2016-10-03 Thread chrischris201444
hello


i try to follow some tutorial but i have that error :

Traceback (most recent call last):
  File "C:\Python27\test\test\earth.py", line 42, in 
slope_array = np.ones_like(data_array) * nodataval
TypeError: unsupported operand type(s) for *: 'int' and 'NoneType'


first i define that lines of code :

data_array = raster2array(filename)
nodataval = getNoDataValue(filename)

and the line with error :

slope_array = np.ones_like(data_array) * nodataval

how can i fix this error ?i change type field ?

on the four prints:

print(resolution)
print(nodataval)
print(type(data_array))
print(data_array.shape)

i take that exports :

{'east-west': 0.0002778, 'north-south': 0.0002778}
None

(3601, 3601)

the full code :


from __future__ import division
from osgeo import gdal
from matplotlib.colors import ListedColormap
from matplotlib import colors
import sys
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
import math

filename = 'dem.tif'

def getResolution(rasterfn):
raster = gdal.Open(rasterfn)
geotransform = raster.GetGeoTransform()
res = {"east-west": abs(geotransform[1]), 
   "north-south": abs(geotransform[5])}
return res

def raster2array(rasterfn):
raster = gdal.Open(rasterfn)
band = raster.GetRasterBand(1)
return band.ReadAsArray()

def getNoDataValue(rasterfn):
raster = gdal.Open(rasterfn)
band = raster.GetRasterBand(1)
return band.GetNoDataValue()

data_array = raster2array(filename)
nodataval = getNoDataValue(filename)
resolution = getResolution(filename)
print(resolution)
print(nodataval)

print(type(data_array))
print(data_array.shape)

num_rows = data_array.shape[0]
num_cols = data_array.shape[1]

slope_array = np.ones_like(data_array) * nodataval
aspect_array = np.ones_like(data_array) * nodataval

for i in range(1, num_rows - 1):
for j in range(1, num_cols - 1):
a = data_array[i - 1][j - 1]
b = data_array[i - 1][j]
c = data_array[i - 1][j + 1]
d = data_array[i][j - 1]
e = data_array[i][j]
f = data_array[i][j + 1]
g = data_array[i + 1][j - 1]
h = data_array[i + 1][j]
q = data_array[i + 1][j + 1]

vals = [a, b, c, d, e, f, g, h, q]

if nodataval in vals:
all_present = False
else:
all_present = True

if all_present == True:
dz_dx = (c + (2 * f) + q - a - (2 * d) - g) / (8 * 
resolution['east-west'])
dz_dy = (g + (2 * h) + q - a - (2 * b) - c) / (8 * 
resolution['north-south'])
dz_dx_sq = math.pow(dz_dx, 2)
dz_dy_sq = math.pow(dz_dy, 2)

rise_run = math.sqrt(dz_dx_sq + dz_dy_sq)
slope_array[i][j] = math.atan(rise_run) * 57.29578

aspect = math.atan2(dz_dy, (-1 * dz_dx)) * 57.29578
if aspect < 0:
aspect_array[i][j] = 90 - aspect
elif aspect > 90:
aspect_array[i][j] = 360 - aspect + 90
else:
aspect_array[i][j] = 90 - aspect

hist, bins = np.histogram(slope_array, bins=100, range=(0, 
np.amax(slope_array)))
width = 0.7 * (bins[1] - bins[0])
center = (bins[:-1] + bins[1:]) / 2
plt.bar(center, hist, align='center', width=width)
plt.xlabel('Slope (degrees)')
plt.ylabel('Frequency')
plt.show()

color_map = ListedColormap(['white', 'darkgreen', 'green', 'limegreen', 'lime', 
'greenyellow', 'yellow', 'gold', 
'orange', 'orangered', 'red'])

# range begins at negative value so that missing values are white
color_bounds = list(range(-3, math.ceil(np.amax(slope_array)), 1))
color_norm = colors.BoundaryNorm(color_bounds, color_map.N)

#Create the plot and colorbar
img = plt.imshow(slope_array, cmap = color_map, norm = color_norm)
cbar = plt.colorbar(img, cmap = color_map, norm = color_norm,
   boundaries = color_bounds, ticks = color_bounds)

#Show the visualization
plt.axis('off')
plt.title("Slope (degrees)")
plt.show()
plt.close()
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28218] Windows docs have wrong versionadded description

2016-10-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset de79cc895203 by Steve Dower in branch '3.6':
Issue #28218: Fixes versionadded description in using/windows.rst
https://hg.python.org/cpython/rev/de79cc895203

--
nosy: +python-dev

___
Python tracker 

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



[issue28217] Add interactive console tests

2016-10-03 Thread Steve Dower

Changes by Steve Dower :


--
resolution:  -> fixed
stage: test needed -> 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



[issue28217] Add interactive console tests

2016-10-03 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 363888141f41 by Steve Dower in branch '3.6':
Issue #28217: Adds _testconsole module to test console input. Fixes some issues 
found by the tests.
https://hg.python.org/cpython/rev/363888141f41

New changeset 3ec6a610e93e by Steve Dower in branch 'default':
Issue #28217: Adds _testconsole module to test console input.
https://hg.python.org/cpython/rev/3ec6a610e93e

--
nosy: +python-dev

___
Python tracker 

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



[issue28251] Help manuals do not appear in Windows search

2016-10-03 Thread Steve Dower

Changes by Steve Dower :


--
resolution:  -> fixed
stage: commit 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



[issue28348] Doc typo in asyncio.Task

2016-10-03 Thread Poren Chiang

New submission from Poren Chiang:

Version: Latest (v3.5.2)
Affected module: asyncio (section 18.5)

Problem:
Under section 18.5.3.5. "Task", The word "completion" is misspelled 
"completition".

> A task is responsible for executing a coroutine object in an event loop. If 
> the wrapped coroutine yields from a future, the task suspends the execution 
> of the wrapped coroutine and waits for the **completition** of the future. 
> When the future is done, the execution of the wrapped coroutine restarts with 
> the result or the exception of the future.

Possible fixes:

Replace "completition" with "completion".

Reference:

[1] https://docs.python.org/3/library/asyncio-task.html#task

--
assignee: docs@python
components: Documentation
messages: 277962
nosy: RSChiang, docs@python
priority: normal
severity: normal
status: open
title: Doc typo in asyncio.Task
versions: Python 3.5

___
Python tracker 

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



Re: working with ctypes and complex data structures

2016-10-03 Thread eryk sun
On Mon, Oct 3, 2016 at 2:35 PM, Michael Felt  wrote:
> On 02-Oct-16 23:44, eryk sun wrote:
>>   On Sun, Oct 2, 2016 at 5:50 PM, Michael Felt 
>> wrote:
>>
>>> b) what I am not understanding - as the basic documentation shows
>>> FOO.value as the way to set/get the value of a _field_
>>
>> You may be surprised when accessing simple-type fields such as c_int
>> and c_char_p. These simple types have getter and setter functions that
>> get called automatically whenever the type is used as a function
>> result, array index, or struct field. For example:
>
> OK - so lucky me - it "does not work" like earlier examples because I am
> referencing, generally, c_ulonglong - and these do not have a automatic
> getter/setter function? If not, how do I go about making one (preferably
> without needing to right a "method" for each and every _field_ in a class.

No, c_ulonglong is a simple (fundamental) type, which behaves just
like other simple types such as c_int or c_char_p.

On platform's with a 64-bit long, c_ulonglong is an alias for c_ulong
(i.e. type "L"). On the other hand, on 64-bit Windows, c_ulonglong is
an unsigned quad word (i.e. type "Q").

All simple types subclass ctypes._SimpleCData and define a `_type_`
code such as "c" for c_char. On 64-bit Linux the simple types are
defined as follows:

?: c_bool
c: c_char
z: c_char_p
u: c_wchar
Z: c_wchar_p
P: c_void_p

b: c_int8, c_byte
B: c_uint8, c_ubyte
h: c_int16, c_short
H: c_uint16, c_ushort
i: c_int32, c_int
I: c_uint32, c_uint
l: c_int64, c_long, c_longlong, c_ssize_t
L: c_uint64, c_ulong, c_ulonglong, c_size_t

f: c_float
d: c_double
g: c_longdouble

For convenience, simple types are automatically converted when
accessed as a function result, struct field, or array index. As I
mentioned previously, the only way around this behavior is to use a
subclass. A subclass doesn't get automatically converted because it
might define custom methods and attributes that need to be preserved.

>> I'd alias the type instead of defining a struct, e.g. `time_t =
>> c_long`. This preserves automatic conversion of the simple type.
>
> The reason for the not using alias is because a) I was trying to be more
> inline with the text of the include file. I will have to check the sizeof
> c_long (i.e., sizeof(long) in both 32 and 64-bit modes

I don't follow. Currently you wrap a c_int or c_long in a struct when
you could just use those types directly. You have to check the pointer
size, but then it's up to you what assumptions to make about the
target platform's integer sizes. Currently on a 64-bit system you're
assuming a Unix-style LP64 data model [1], in which a long is 64-bit.
That should be fine if you're writing Unix-specific code that doesn't
care about LLP64 Windows systems.

Wrapping the type in a struct provides more type safety, but if I
wanted that I'd create my own simple subclass. For example, assuming
time_t should be a signed integer that's the same size as a pointer:

class time_t(ctypes._SimpleCData):
if ctypes.sizeof(ctypes.c_void_p) == ctypes.sizeof(ctypes.c_longlong):
_type_ = ctypes.c_longlong._type_
elif ctypes.sizeof(ctypes.c_void_p) == ctypes.sizeof(ctypes.c_long):
_type_ = ctypes.c_long._type_
elif ctypes.sizeof(ctypes.c_void_p) == ctypes.sizeof(ctypes.c_int):
_type_ = ctypes.c_int._type_
# else raise AttributeError for missing _type_

[1]: https://en.wikipedia.org/wiki/64-bit_computing#64-bit_data_models
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28339] "TypeError: Parameterized generics cannot be used with class or instance checks" in test_functools after importing typing module

2016-10-03 Thread Guido van Rossum

Guido van Rossum added the comment:

I have merged the upstream fix (and some other things) into 3.5, 3.6, 3.7.

changeset:   104262:7f0d27180b6d
tag: tip
parent:  104259:36b052adf5a7
parent:  104261:0e0189b47291
user:Guido van Rossum 
date:Mon Oct 03 08:42:17 2016 -0700
summary: More updates from upstream typing.py (3.6->3.7)

changeset:   104261:0e0189b47291
branch:  3.6
parent:  104258:0d948a46c59a
parent:  104260:b24d0f274623
user:Guido van Rossum 
date:Mon Oct 03 08:41:37 2016 -0700
summary: More updates from upstream typing.py (3.5->3.6)

changeset:   104260:b24d0f274623
branch:  3.5
parent:  104255:ac838bf5499d
user:Guido van Rossum 
date:Mon Oct 03 08:40:50 2016 -0700
summary: More updates from upstream typing.py

--

___
Python tracker 

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



[issue21124] _struct module compilation error under Cygwin 1.7.17 on Python 3.4

2016-10-03 Thread Masayuki Yamamoto

Masayuki Yamamoto added the comment:

unpack_iterator type has not been registered into _struct module. And all users 
get only unpack_iterator object from function returning iterator. The object 
iterating doesn't need reference to type. Therefore, I think issue finish by 
PyType_Ready fix because this segfault doesn't have big impact.

However, I think if possible, it is preferable that extension module having 
un-initialize type objects gets a compile error at build time. And impossible 
case for compile error is better that wrong extension module always fails 
import.

--

___
Python tracker 

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



[issue28329] Add support for customizing scheduler's timefunc and delayfunc using subclassing

2016-10-03 Thread Raymond Hettinger

New submission from Raymond Hettinger:

Why do you need a second way to do it?  Is there any use case not handled by 
the current API?

--
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 that forwards first or backwards first? (Re: unintuitive for-loop behavior)

2016-10-03 Thread breamoreboy
On Monday, October 3, 2016 at 12:53:55 PM UTC+1, Marko Rauhamaa wrote:
> Gregory Ewing:
> 
> > Turns out the only difference between first and reverse on that model
> > is whether you lift up a little ring on the shaft of the gear lever
> > prior to engagement.
> >
> > Who came up with *that* brilliant piece of user interface design I
> > don't know. It seems specifically designed to encourage velocity sign
> > errors when starting off...
> 
> Well, it could be worse. This layout is pretty traditional:
> 
> 1  3  5
> |  |  |
> +--+--+
> |  |  |
> 2  4  R
> 
> 
> Marko

There was the shift on the steering column on the 2CV, but then there's also 
this.


Traditional Italian military vehicle layout.

 1  3  5
 |  |  |
 +--+--+
 |  |  |
 2  4  F



Kindest regards.

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


Re: print to previous line in console

2016-10-03 Thread Skip Montanaro
> When we are printing to the console, is there a way to display to the 
> previous line in the console.

Check out the curses module:

https://docs.python.org/3.6/library/curses.html

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


print to previous line in console

2016-10-03 Thread udhay prakash pethakamsetty

Hi, 

\t is for tab(forward) space; and 
\r is for carriage return (back space)

When we are printing to the console, is there a way to display to the previous 
line in the console. 

We can achive that easily in file operations, But I want a solution in 
displaying on Console. 

regards

Udhay Prakash Pethakamsetty
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Copying a compiled Python from one system to another

2016-10-03 Thread Chris Angelico
On Tue, Oct 4, 2016 at 1:06 AM, Steve D'Aprano
 wrote:
> On Sun, 2 Oct 2016 04:45 pm, Paul Rubin wrote:
>
>> Steve D'Aprano  writes:
>>> Yes, this. You need gcc 4.8 or better to build CPython 3.6, and the most
>>> recent any of my systems support is 4.4.
>>
>> Building gcc takes a while but it's reasonably simple.  Just start it
>> going and read a book for a while.
>
> The dependencies needed to build 4.8 aren't available for my system. And
> there's no supported upgrade path.

At this point, I think you're at "try it and let us know". There's not
a lot more that can be predicted.

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


  1   2   >