Re: http.server.BaseHTTPRequestHandler basic auth logout? Django authentication system for REST interface?

2014-06-07 Thread dieter
Dan Stromberg drsali...@gmail.com writes:

 I have some code for a web server.  Right now, it uses
 BaseHTTPRequestHandler with Basic Auth, but we want to be able to log
 out, and there doesn't appear to be a general way to log out of
 something using Basic Auth, short of turning to unportable JavaScript.

You can't: With Basic Auth, the login is handled by the browser
(and not the server). This implies, that you must tell the browser
to logout (and not the server). There is no standard way to
tell the browser to logout.

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


Elektra 0.8.6

2014-06-07 Thread Markus Raab
Hello Python List,

Elektra provides a universal and secure framework to store configuration 
parameters in a global, hierarchical key database. The core is a small 
library implemented in C. The plugin-based framework fulfills many 
configuration-related tasks to avoid any unnecessary code duplication across 
applications while it still allows the core to stay without any external 
dependency. Elektra abstracts from cross-platform-related issues with an 
consistent API, and allows applications to be aware of other applications' 
configurations, leveraging easy application integration.
http://www.libelektra.org

While the core is in C, both applications and soon plugins (not yet relased) 
can be written in python. The API is complete and fully functional but not 
yet stable. So if you have any suggestions, please let us know.

Additionally the latest release added:
- C++11 und lua bindings
- a plugin to read virtually every configuration file around
- logging to journald (next to syslog)
- many other improvements and bug fixes
- compiler support for icc (+in clang warnings were fixed)
- for more details see:
http://sourceforge.net/p/registry/mailman/message/32418614/

You can download the release at:
 http://www.markus-raab.org/ftp/elektra/releases/elektra-0.8.6.tar.gz
 md5sum: 4a59824e70a29295e9ef9ae7605d9299

Make sure to enable BUILD_SWIG and BUILD_SWIG_PYTHON.

Docu (C/C++) can be found here:
 http://doc.libelektra.org/api/0.8.6/html/

best regards,
Markus
-- 
https://mail.python.org/mailman/listinfo/python-list


Uniform Function Call Syntax (UFCS)

2014-06-07 Thread jongiddy
The language D has a feature called Uniform Function Call Syntax, which allows 
instance methods to be resolved using function calls.

In Python terms, the call:

x.len()

would first check if 'x' has a method 'len', and would then look for a function 
'len', passing 'x' as the first argument.

The big wins are:

- the ability to override functions with more optimal class-specific 
implementations. (Of course, len() is a bad example, since we already have a 
way to override it, but there are other functions that do not have a special 
method).

- the readability of a.b().c().d() vs c(a.b()).d()

Here's a few links discussing the feature in D:
- First, a fairly gentle this is cool post: 
http://www.kr41.net/2013/08/27/uniform_function_call_syntax_in_d.html
- Second, an article from the Walter Bright, the creator of D: 
http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394

Has this been discussed or proposed before? I found PEP's 443 and 3124, which 
provide a form of function overloading, but not reordering.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-07 Thread Christian Gollwitzer

Am 06.06.14 13:20, schrieb Alain Ketterlin:

Chris Angelico ros...@gmail.com writes:

It's impossible to accidentally call a base class's method when you
ought to have called the overriding method in the subclass, which is a
risk in C++ [2].


I don't how this can happen in C++, unless you actually have an instance
of the base class. Anyway, I didn't mention C++.


A special, but important case of this is inside the constructor. Until 
you exit the constructor, C++ treats the object as not fully 
constructed, and if you call a virtual method there, it calls the method 
of the base class.


http://www.parashift.com/c++-faq/calling-virtuals-from-ctors.html

The answer is, of course, to create a *separate* init function in 
addition to the constructor and to require the user of the class to call 
it after the constructor, or to hide the real constructor away and 
require the user to call a factory function instead.


I love C++.
(seriously, but not /that/ part)

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


Re: OT: This Swift thing

2014-06-07 Thread Alain Ketterlin
Sturla Molden sturla.mol...@gmail.com writes:

 Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:
 Sturla Molden sturla.mol...@gmail.com writes:
 
 Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:
 
 Many of these students suggest Python as the
 development language (they learned it and liked it), and the suggestion
 is (almost) always rejected, in favor of Java or C# or C/C++.
 
 And it was almost always the wrong decision...
 
 I think they know better than you and me.

 Now it's my turn to say oh, come on. Those who make these decisions have
 likely never written a line of code in their life.

This totally contradicst my experience. I've heard horror stories like
everybody else, but I just have been lucky enough to work with people
that very seriously evaluate their engineering decisions.

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


Re: OT: This Swift thing

2014-06-07 Thread Mark Lawrence

On 07/06/2014 09:20, Alain Ketterlin wrote:

Sturla Molden sturla.mol...@gmail.com writes:


Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:

Sturla Molden sturla.mol...@gmail.com writes:


Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:


Many of these students suggest Python as the
development language (they learned it and liked it), and the suggestion
is (almost) always rejected, in favor of Java or C# or C/C++.


And it was almost always the wrong decision...


I think they know better than you and me.


Now it's my turn to say oh, come on. Those who make these decisions have
likely never written a line of code in their life.


This totally contradicst my experience. I've heard horror stories like
everybody else, but I just have been lucky enough to work with people
that very seriously evaluate their engineering decisions.

-- Alain.



Clearly manpower isn't an issue.

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: http.server.BaseHTTPRequestHandler basic auth logout? Django authentication system for REST interface?

2014-06-07 Thread Chris Angelico
On Sat, Jun 7, 2014 at 4:23 PM, dieter die...@handshake.de wrote:
 Dan Stromberg drsali...@gmail.com writes:

 I have some code for a web server.  Right now, it uses
 BaseHTTPRequestHandler with Basic Auth, but we want to be able to log
 out, and there doesn't appear to be a general way to log out of
 something using Basic Auth, short of turning to unportable JavaScript.

 You can't: With Basic Auth, the login is handled by the browser
 (and not the server). This implies, that you must tell the browser
 to logout (and not the server). There is no standard way to
 tell the browser to logout.

That said, though, it's quite common for browsers to discard the auth
(thus effectively logging out) if given another 401 Unauthorized
response. So you can generally send that back and expect it to be a
logout page.

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


Re: OT: This Swift thing

2014-06-07 Thread Alain Ketterlin
Mark Lawrence breamore...@yahoo.co.uk writes:

 On 07/06/2014 09:20, Alain Ketterlin wrote:
 Sturla Molden sturla.mol...@gmail.com writes:

 Many of these students suggest Python as the
 development language (they learned it and liked it), and the suggestion
 is (almost) always rejected, in favor of Java or C# or C/C++.

 And it was almost always the wrong decision...

 I think they know better than you and me.

 Now it's my turn to say oh, come on. Those who make these decisions have
 likely never written a line of code in their life.

 This totally contradicst my experience. I've heard horror stories like
 everybody else, but I just have been lucky enough to work with people
 that very seriously evaluate their engineering decisions.

 Clearly manpower isn't an issue.

No. Cost is the issue (development, maintenance, operation,
liability...). Want an example? Here is one:

http://tech.slashdot.org/story/14/06/06/1443218/gm-names-and-fires-engineers-involved-in-faulty-ignition-switch

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


strange behaivor of nested function

2014-06-07 Thread 1989lzhh
here is code

def make():
def jit(sig):
def wrap(function):
sig=sig[0] # unbound local error, if change to sig='' would be just 
fine
return function 
return wrap
return jit
jit=make()
@jit('')
def f():
pass

It is strange that the interpreter complain about unbound local error. 
please give me some suggestion, thanks!
Ps: I am using python 2.7
  Liu Zhenhai


   

发自我的 iPhone
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: strange behaivor of nested function

2014-06-07 Thread Chris Angelico
On Sat, Jun 7, 2014 at 9:17 PM, 1989lzhh 1989l...@gmail.com wrote:
 def make():
 def jit(sig):
 def wrap(function):
 sig=sig[0] # unbound local error, if change to sig='' would be 
 just fine
 return function
 return wrap
 return jit
 jit=make()
 @jit('')
 def f():
 pass

 It is strange that the interpreter complain about unbound local error.
 please give me some suggestion, thanks!
 Ps: I am using python 2.7

It's quite simple. You're assigning to the name 'sig' inside the
function 'wrap', which means that - in the absence of a declaration -
'sig' is a local name. But before you assign anything to it, you first
try to reference it, by subscripting it (sig[0]). Python doesn't have
a rule about pulling something in from another scope at the same time
as making it local (some languages do, and it's rather handy, but it
can only work with variable declarations), so what you're attempting
to do there simply won't work.

But it seems a little odd anyway. Why do you take the first element of
sig every time the inner function is called? Surely you want to do
that just once?

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


Re: OT: This Swift thing

2014-06-07 Thread Roy Smith
In article 87zjhpm8q7@dpt-info.u-strasbg.fr,
 Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:

 Sturla Molden sturla.mol...@gmail.com writes:
 
  Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:
  Sturla Molden sturla.mol...@gmail.com writes:
  
  Alain Ketterlin al...@dpt-info.u-strasbg.fr wrote:
  
  Many of these students suggest Python as the
  development language (they learned it and liked it), and the suggestion
  is (almost) always rejected, in favor of Java or C# or C/C++.
  
  And it was almost always the wrong decision...
  
  I think they know better than you and me.
 
  Now it's my turn to say oh, come on. Those who make these decisions have
  likely never written a line of code in their life.
 
 This totally contradicst my experience. I've heard horror stories like
 everybody else, but I just have been lucky enough to work with people
 that very seriously evaluate their engineering decisions.

You are lucky indeed.  Trust me, in big companies, technical decisions 
are often made by people who are not using the technology.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: strange behaivor of nested function

2014-06-07 Thread Steven D'Aprano
On Sat, 07 Jun 2014 19:17:23 +0800, 1989lzhh wrote:

 here is code
 
 def make():
 def jit(sig):
 def wrap(function):
 sig=sig[0] # unbound local error

You are saying:

sig is a local variable. Assign sig to the value of sig[0].

But what is sig? You've said it is a local variable, and at this point it 
doesn't have a value yet.

Lua allows you to do this:

sig = sig[0]

will look up a global sig and assign it to the local sig first, but that 
can be confusing and Python doesn't do that.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-07 Thread Roy Smith
In article mailman.10852.1402154644.18130.python-l...@python.org,
 Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 On 07 Jun 2014 04:57:19 GMT, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info declaimed the following:
 
 
 Swift is intended as a new generation *systems language*. The old 
 generation of systems languages are things like C, Objective-C, C#, C++, 
 Java, Pascal, Algol, and so forth. The new generation are intended to 
 fulfil the same niches, but to have syntax and usability closer to that 
 of scripting languages. Languages like Go, Rust, Ceylon, and now Swift.
 
   Pascal as a systems language? We must have major differences what
 constitutes a systems language then...

The original MacOS was written in Pascal (both applications and kernel).  
Being able to touch memory locations or registers requires no more than 
a few short glue routines written in assembler.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-07 Thread Roy Smith
In article mailman.10851.1402154030.18130.python-l...@python.org,
 Dennis Lee Bieber wlfr...@ix.netcom.com wrote:

 On Sat, 07 Jun 2014 08:52:36 -0400, Roy Smith r...@panix.com declaimed the
 following:
 
 
 You are lucky indeed.  Trust me, in big companies, technical decisions 
 are often made by people who are not using the technology.
 
   Or influenced by someone familiar with some tech and having a big
 ego...
 
   Many years ago, in a company to remain nameless, I was in a department
 with ~130 programmers distributed among 3-4 main subsystems (batch analysis
 [aka, post-processing of the daily tapes], planning [generating the
 schedule for the next day], and real-time [operations using the schedule]).
 The real-time group was 15-30 people using Macro-11 (PDP-11s if that dates
 things). The rest of the department was pretty much all skilled VAX
 FORTRAN-77.
 
   The time came to port real-time from PDP-11 to a VAX system. A small
 study was performed to determine what language would be used. Very small
 study -- I think it was restricted to the 30 RT folks; I only learned of
 the result after a choice had been made.
 
   The candidates: VAX-11 Assembly, F77, C, Pascal.

What was wrong with just running the original pdp-11 binaries on the VAX 
in compatibility mode? :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Science in Islam

2014-06-07 Thread bv4bv4bv4
Science in Islam

We (God) shall show them Our signs in the Universe and within themselves, 
until it becomes clear to them that this is the Truth. Quran 41:53

The Quran, the book of Islam, is the final book of revelation from God to 
humanity and the last in the line of revelations given to the Prophets.

Although the Quran (revealed over 1400 years ago), is not primarily a book of 
science, it does contain scientific facts that have only been discovered 
recently through the advancement of technology and scientific knowledge. Islam 
encourages reflection and scientific research because understanding the nature 
of creation enables people to further appreciate their Creator and the extent 
of His power and wisdom.

The Quran was revealed at a time when Science was primitive; there were no 
telescopes, microscopes or anything close to today's technology. People 
believed that the sun orbited the earth and the sky was held up by pillars at 
the corners of a flat earth. Against this backdrop the Quran was revealed, 
containing many scientific facts on topics ranging from astronomy to biology, 
geology to zoology.

Some of the many scientific facts found in the Quran include:

Fact #1 - Origin of Life
And We (God) made every living thing from water. Will they not believe?
Quran 21:30
Water is pointed out as the origin of all life. All living things are made of 
cells and we now know that cells are mostly made of water. This was discovered 
only after the invention of the microscope. In the deserts of Arabia, it would 
be inconceivable to think that someone would have guessed that all life came 
from water.

Fact #2 - Human Embryonic Development
God speaks about the stages of man's embryonic development:

We (God) created man from an extract of clay. Then We made him as a drop in a 
place of settlement, firmly fixed. Then We made the drop into an alaqah [leech, 
suspended thing, and blood clot], then We made the alaqah into a mudghah 
[chewed substance]...
Quran, 23:12-14
The Arabic word alaqah has three meanings: a leech, a suspended thing and a 
blood clot. Mudghah means a chewed substance. Embryology scientists have 
observed that the usage of these terms in describing the formation of the 
embryo is accurate and in conformity with our current scientific understanding 
of the development process.

Little was known about the staging and classification of human embryos until 
the twentieth century, which means that the descriptions of the human embryo in 
the Quran cannot be based on scientific knowledge from the seventh century.

Fact #3 - Expansion of the Universe
At a time when the science of Astronomy was still primitive, the following 
verse in the Quran was revealed:
And the heaven We (God) constructed with strength, and indeed, We (God) are 
[its] expander.
Quran 51:47
One of the intended meanings of the above verse is that God is expanding the 
universe (i.e. heavens). Other meanings are that God provides for, and has 
power over, the universe - which are also true.

The fact that the universe is expanding (e.g. planets are moving further away 
from each other) was discovered in the last century. Physicist Stephen Hawking 
in his book 'A Brief History of Time' writes, The discovery that the universe 
is expanding was one of the great intellectual revolutions of the twentieth 
century.

The Quran alludes to the expansion of the universe even before the invention of 
the telescope!

Fact #4 - Iron Sent Down
Iron is not natural to earth, as it came to this planet from outer space. 
Scientists have found that billions of years ago, the earth was struck by 
meteorites which were carrying iron from distant stars which had exploded.

We sent down iron with its great inherent strength and its many benefits for 
humankind.
Quran 57:25
God uses the words 'sent down'. The fact that iron was sent down to earth from 
outer space is something which could not be known by the primitive science of 
the seventh century.

Fact #5 - Sky's Protection
The sky plays a crucial role in protecting the earth and its inhabitants from 
the lethal rays of the sun, as well as the freezing cold of space.

God asks us to consider the sky in the following verse:

We (God) made the sky a protective ceiling. And yet they are turning away from 
Our signs!
Quran 21:32
The Quran points to the sky's protection as a sign of God, protective 
properties which were discovered by scientific research conducted in the 
twentieth century.

Fact #6 - Mountains
God draws our attention to an important characteristic of mountains:

Did We not make the earth a resting place, and the mountains as stakes?
Quran 78:6-7
The Quran accurately describes the deep roots of mountains by using the word 
stakes. Mount Everest, for example, has an approximate height of 9km above 
ground, while its root is deeper than 125km!

The fact that mountains have deep 'stake'-like roots was not known until after 
the development of the theory of plate tectonics in the 

Re: OT: This Swift thing

2014-06-07 Thread Michael Torrie
On 06/07/2014 09:23 AM, Dennis Lee Bieber wrote:
 On 07 Jun 2014 04:57:19 GMT, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info declaimed the following:
 

 Swift is intended as a new generation *systems language*. The old 
 generation of systems languages are things like C, Objective-C, C#, C++, 
 Java, Pascal, Algol, and so forth. The new generation are intended to 
 fulfil the same niches, but to have syntax and usability closer to that 
 of scripting languages. Languages like Go, Rust, Ceylon, and now Swift.

   Pascal as a systems language? We must have major differences what
 constitutes a systems language then...
 
   Native Pascal had no features to support hitting the hardware or
 arbitrary memory addresses/registers. It was a candidate for an
 applications language (though even that always felt a stretch to me; as a
 teaching language for structured programming it was ideal, though). Try
 writing a serial port driver for a memory mapped I/O system using pure
 Pascal.

Technically C doesn't either, except via subroutines in libc, though C
does have pointers which would be used to access memory.  In the old MS
DOS days, C would embed assembly to call interrupts and set up interrupt
tables, etc.

As someone else mentioned recently, Pascal was used as the system
language on Mac computers for many years.
-- 
https://mail.python.org/mailman/listinfo/python-list


How to use imported function to get current globals

2014-06-07 Thread 1989lzhh
Here is the code
m1.py
def f():
print globals()

m2.py
from m1 import f
f()# how to get current module's globals?



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


Re: How to use imported function to get current globals

2014-06-07 Thread Ian Kelly
On Sat, Jun 7, 2014 at 11:40 AM, 1989lzhh 1989l...@gmail.com wrote:
 Here is the code
 m1.py
 def f():
 print globals()

 m2.py
 from m1 import f
 f()# how to get current module's globals?

Evaluate globals() in the current module and pass the resulting dict
in as a parameter:

# m1.py
def f(globals):
print globals

# m2.py
from m1 import f
f(globals())

There's a code smell here, though.  If your function really needs to
interact with globals from other modules, then those should probably
not be globals in the first place.  More likely they should be
attributes of objects that can be easily passed around.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regarding Python official website

2014-06-07 Thread Aseem Bansal
The Job board. It has been on hold for quite some time.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-07 Thread Roy Smith
In article mailman.10853.1402162690.18130.python-l...@python.org,
 Michael Torrie torr...@gmail.com wrote:

 Technically C doesn't [have features to support hitting the hardware] 
 either, except via subroutines in libc, though C does have pointers 
 which would be used to access memory.

Several language constructs in C are there specifically to diddle bits 
in hardware.  Bit fields were in the earliest implementations of the 
language to allow you to address individual bit control and status bits 
in memory-mapped device controllers.  The volatile keyword is there to 
deal with bits which change value on their own (as hardware status 
registers do).

And, why do you need a library routine to touch a memory location, when 
you can just dereference an integer? :-)
-- 
https://mail.python.org/mailman/listinfo/python-list


Token-based authentication (was http.server.BaseHTTPRequestHandler basic auth logout? Django authentication system for REST interface?)

2014-06-07 Thread Demian Brecht
On Jun 6, 2014 6:30 PM, Roy Smith r...@panix.com wrote:
 We would have to keep state on the server side about every extant valid
 token (but then again, we need to do that now, for each session).

If you didn't want to have to manage such state server side, you could opt
to use JWTs (http://datatracker.ietf.org/wg/jose/). A number of auth
providers (including Microsoft and Google) are moving to using these as
well.

Of course, /some/ server side state would have to be managed to deal with
invalidation or any other mutable data that doesn't belong in a token, but
it's generally minimal.

[Shameless plug] I've implemented a subset of the algorithms for both JWE
and JWSs as a part of https://pypi.python.org/pypi/jose.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-07 Thread Michael Torrie
On 06/07/2014 12:11 PM, Roy Smith wrote:
 Several language constructs in C are there specifically to diddle bits 
 in hardware.  Bit fields were in the earliest implementations of the 
 language to allow you to address individual bit control and status bits 
 in memory-mapped device controllers.  The volatile keyword is there to 
 deal with bits which change value on their own (as hardware status 
 registers do).
 
 And, why do you need a library routine to touch a memory location, when 
 you can just dereference an integer? :-)

Which of course, technically, Pascal has too.

But memory addressing is only half the story.  You still need interrupts
and ioctl access, both of which happen via assembly instructions that
libc exposes via a standard C subroutine interface.

Really any language can access hardware this way.  Whether it's
MicroPython on an embedded system, or BASIC on a pic.  The lines are
being blurred.

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


Re: OT: This Swift thing

2014-06-07 Thread Roy Smith
In article mailman.10857.1402167635.18130.python-l...@python.org,
 Michael Torrie torr...@gmail.com wrote:

 On 06/07/2014 12:11 PM, Roy Smith wrote:
  Several language constructs in C are there specifically to diddle bits 
  in hardware.  Bit fields were in the earliest implementations of the 
  language to allow you to address individual bit control and status bits 
  in memory-mapped device controllers.  The volatile keyword is there to 
  deal with bits which change value on their own (as hardware status 
  registers do).
  
  And, why do you need a library routine to touch a memory location, when 
  you can just dereference an integer? :-)
 
 Which of course, technically, Pascal has too.
 
 But memory addressing is only half the story.  You still need interrupts
 and ioctl access, both of which happen via assembly instructions that
 libc exposes via a standard C subroutine interface.

Well, on a machine where all I/O is memory mapped, it's really 3/4 of 
the story, but I get your point.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Regarding Python official website

2014-06-07 Thread Kushal Das
On Sat, Jun 7, 2014 at 1:12 AM, Aseem Bansal asmbans...@gmail.com wrote:
 The Python website is undergoing an overhaul for better looks. Is there 
 anything like a forum where it is being discussed. I mean where the schedule 
 for this is being maintained or the same is being discussed?

https://github.com/python/pythondotorg/

Kushal
-- 
CPython Core Developer
http://fedoraproject.org
http://kushaldas.in
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Uniform Function Call Syntax (UFCS)

2014-06-07 Thread Ian Kelly
On Sat, Jun 7, 2014 at 12:45 AM, jongiddy jongi...@gmail.com wrote:
 The language D has a feature called Uniform Function Call Syntax, which 
 allows instance methods to be resolved using function calls.

 In Python terms, the call:

 x.len()

 would first check if 'x' has a method 'len', and would then look for a 
 function 'len', passing 'x' as the first argument.

 The big wins are:

 - the ability to override functions with more optimal class-specific 
 implementations. (Of course, len() is a bad example, since we already have a 
 way to override it, but there are other functions that do not have a special 
 method).

 - the readability of a.b().c().d() vs c(a.b()).d()

 Here's a few links discussing the feature in D:
 - First, a fairly gentle this is cool post: 
 http://www.kr41.net/2013/08/27/uniform_function_call_syntax_in_d.html
 - Second, an article from the Walter Bright, the creator of D: 
 http://www.drdobbs.com/cpp/uniform-function-call-syntax/232700394

 Has this been discussed or proposed before? I found PEP's 443 and 3124, which 
 provide a form of function overloading, but not reordering.

It's a nice feature in a statically typed language, but I'm not sure
how well it would work in a language as dynamic as Python.  There are
some questions that would need to be addressed.

1) Where should the function (or perhaps callable) be looked for?  The
most obvious place is the global scope.  I think it would be a bit too
far-reaching and inconsistent with other language features to reach
directly inside imported modules (not to mention that it could easily
get to be far too slow in a module with lots of imports). As a result
it would have to be imported using the from module import function
syntax, rather than the somewhat cleaner import module syntax.
While there's nothing wrong with such imports, I'm not sure I like the
thought of the language encouraging them any more than necessary.

Probably local (and by extension nonlocal) scoping is fine also.  This
makes perfect sense to me:

def some_function(x):
def my_local_extension_method(self): return 42
print(x.my_local_extension_method())

2) What about getattr and hasattr?  If I call hasattr(x,
some_method), and x has no such attribute, but there is a function
in the global scope named some_method, should it return True?  I
think the answer is no, because that could mess with duck typing.  Say
I have a function that checks the methods of some object that was
passed in, and it then passes that object on to some other function:

def gatekeeper_for_f(x):
# f behaves badly if passed an x without a key_func,
# so verify that it has one.
if not hasattr(x, 'key_func'):
raise TypeError(x has no key_func)
else:
return f(x)

Okay, so suppose we pass in to gatekeeper_for_f a non-conformant
object, but there happens to be a key_func in our global scope, so
hasattr returns True.  Great!  gatekeeper_for_f can call x.key_func().
But that doesn't mean that *f* can call x.key_func(), if it happened
to be defined in a different global scope.

If we instead have hasattr return False though, and have getattr raise
an exception, then we have this very magical and confusing
circumstance where getattr(x, 'method') raises an exception but
x.method does not.  So I don't think that's really a good scenario
either.

Also the idea makes me nervous in the thought that an incorrect
attribute access could accidentally and somewhat randomly pick up some
object from the environment.  In statically typed languages this isn't
a huge concern, because the extension method has to take an
appropriately typed object as its first argument (and in C# it even
has to be explicitly marked as an extension method), so if you resolve
an extension method by accident, at least it will be something that
makes sense as a method.  Without the static typing you could
mistakenly pick up arbitrary functions that have nothing at all to do
with your object.

But if you want to experiment with the idea, here's a (lightly tested)
mixin that implements the behavior:

import inspect
import types

class ExtensionMethodMixin:
def __getattr__(self, attr):
parent_frame = inspect.currentframe().f_back
if parent_frame:
try:
func = parent_frame.f_locals[attr]
except KeyError:
func = parent_frame.f_globals.get(attr)
if callable(func):
try:
__get__ = func.__get__
except AttributeError:
return types.MethodType(func, self)
else:
return __get__(self, type(self))
return super().__getattr__(attr)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: os.startfile hanging onto the launched app, or my IDE?

2014-06-07 Thread Tim Golden

On 06/06/2014 21:34, Josh English wrote:

I have been using os.startfile(filepath) to launch files I've created
in Python, mostly Excel spreadsheets, text files, or PDFs.

When I run my script from my IDE, the file opens as I expect. But if
I go back to my script and re-run it, the external program (either
Excel, Notepad, or Acrobat Reader) closes all windows and restarts
the program. This can, unfortunately, close other files I am working
on and thus I lose all my changes to those files.

This is happening on Windows 7.

I am not sure if it is Python (2.7.5) or my IDE (PyScripter 2.5.3).

It seems like Python or the IDE is keeping track of things created by
the os.startfile call, but the docs imply this doesn't happen.

Is this a quirk of os.startfile? Is there a cleaner way to get
Windows to open files without tying back to my program?


I'm not 100% sure what your scenario is, but you can certainly help 
yourself and us by running the same test on the raw interpreter and then 
under PyScripter to determine if the behaviour is to do with IDLE or 
with Python itself.


My half-guess is that PyScripter starts a new process to run your code, 
possibly killing any pre-existing process first. That's if I've 
understood the situation you're describing.


Could you come back with a little more detail? Specifically: whether 
what you're seeing happens only from within PyScripter, or only not from 
within PyScripter, or something else?


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


Re: How to use imported function to get current globals

2014-06-07 Thread Chris Angelico
On Sun, Jun 8, 2014 at 3:40 AM, 1989lzhh 1989l...@gmail.com wrote:
 Here is the code
 m1.py
 def f():
 print globals()

 m2.py
 from m1 import f
 f()# how to get current module's globals?

As Ian said, you almost certainly do not want to do this. But if you
have a solid use-case that involves finding the caller's globals, you
can do it (in CPython - no idea about other Pythons) with the
backtrace.

Normally, passing dictionaries around is going to be MUCH more useful.
(And probably not actually globals(), you almost never want to use
that.)

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


Re: How to use imported function to get current globals

2014-06-07 Thread Ned Batchelder

On 6/7/14 1:40 PM, 1989lzhh wrote:

Here is the code
m1.py
def f():
 print globals()

m2.py
from m1 import f
f()# how to get current module's globals?



Looking at the code you have posted in your two messages so far, it 
seems like you are building something very interesting and ambitious. 
Do you mind talking a bit about what it is?


--
Ned Batchelder, http://nedbatchelder.com

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


Re: Automating windows media player on win7

2014-06-07 Thread MRAB

On 2014-06-06 14:39, Deogratius Musiige wrote:

Thanks a lot mate.

You just made my day.
I have looked around the net but cannot find the controls available.

I would like to be able to:
- get current playing track
- get wmplayer state (playing/paused/stopped)
- get the selected sound device


[snip]
Here's a bit more. Note how it seems to need short sleeps after certain
actions (I don't know why!):

#! python2.7
# -*- coding: utf-8 -*-
import pywintypes
from win32com.client import Dispatch
from time import sleep

tunes = [./plays.wav, ./plays.wav, ./plays.wav] # Whatever

mp = Dispatch(WMPlayer.OCX)

for name in tunes:
tune = mp.NewMedia(name)
mp.CurrentPlaylist.AppendItem(tune)

mp.Controls.Play()
sleep(0.25)

for i in range(len(tunes)):
print Current tune is, mp.Controls.CurrentItem.Name

print 'Playing current tune'
mp.Controls.PlayItem(mp.Controls.CurrentItem)
print 'mp.Status says', mp.Status

sleep(5)

print 'Pausing'
mp.Controls.Pause()
print 'mp.Status says', mp.Status

sleep(2)

print 'Resuming'
mp.Controls.Play()
print 'mp.Status says', mp.Status
sleep(5)

mp.Controls.Next()
sleep(0.25)

mp.Controls.Stop()

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


Re: OT: This Swift thing

2014-06-07 Thread Steven D'Aprano
On Sat, 07 Jun 2014 11:13:42 -0400, Dennis Lee Bieber wrote:

 About a decade later, said manager retired and confessed that the choice
 of Pascal was a mistake

There's Pascal and there's Pascal. Standard Pascal, I admit, is woefully 
unsuitable for real world work. But Pascal with suitable extensions was 
good enough for the first 6 generations of the Macintosh operating system 
and key applications, at a time when *nobody* was even coming close to 
doing what the Mac was capable of. (Admittedly, a certain number of the 
core OS libraries, most famously Quickdraw, were handwritten in assembly 
by a real genius.) By the mid-80s, Apple's SANE (Standard Apple Numeric 
Environment) was quite possibly the best environment for doing IEEE-754 
numeric work anywhere. But of course, Macintoshes were toys, right, and 
got no respect, even when the Mac G4 was the first PC powerful enough to 
be classified by US export laws as a supercomputer.

[Disclaimer: Pascal on the Mac might have been far ahead of the pack when 
it came to supporting IEEE-754, but it didn't have the vast number of 
(variable-quality) Fortran libraries available on other systems. And 
while it is true that the G4 was classified as a supercomputer, that was 
only for four months until the Clinton administration changed the laws. 
Apple, of course, played that for every cent of advertising as it could.]



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: try/except/finally

2014-06-07 Thread Ethan Furman

On 06/06/2014 11:22 AM, Ned Batchelder wrote:

On 6/6/14 1:47 PM, Frank B wrote:


Ok; thanks for the underscore and clarification.  Just need to adjust my 
thinking a bit.


Did this come up in real code?  I've seen this point about finally/return 
semantics a number of times, but haven't seen
real code that needed adjusting based on it.


I don't remember if I almost had this in real code or if I learned about it first, but it can definitely be a gotcha. 
It seems to me that if the try block exits with an explicit return, and then the finally block exits with an explicit 
return, some kind of error ought to be raised.


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


Re: OT: This Swift thing

2014-06-07 Thread Steven D'Aprano
On Sat, 07 Jun 2014 14:11:27 -0400, Roy Smith wrote:

 And, why do you need a library routine to touch a memory location, when
 you can just dereference an integer? :-)

And in one sentence we have an explanation for 90% of security 
vulnerabilities before PHP and SQL injection attacks...

C is not a safe language, and code written in C is not safe. Using C for 
application development is like shaving with a cavalry sabre -- harder 
than it need be, and you're likely to remove your head by accident.




-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: try/except/finally

2014-06-07 Thread Chris Angelico
On Sun, Jun 8, 2014 at 8:49 AM, Ethan Furman et...@stoneleaf.us wrote:
 I don't remember if I almost had this in real code or if I learned about it
 first, but it can definitely be a gotcha. It seems to me that if the try
 block exits with an explicit return, and then the finally block exits with
 an explicit return, some kind of error ought to be raised.

I'd go a little simpler: A return statement inside a finally block is
code smell.

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



Re: OT: This Swift thing

2014-06-07 Thread Roy Smith
In article 5393a264$0$29988$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 On Sat, 07 Jun 2014 14:11:27 -0400, Roy Smith wrote:
 
  And, why do you need a library routine to touch a memory location, when
  you can just dereference an integer? :-)
 
 And in one sentence we have an explanation for 90% of security 
 vulnerabilities before PHP and SQL injection attacks...
 
 C is not a safe language, and code written in C is not safe. Using C for 
 application development is like shaving with a cavalry sabre -- harder 
 than it need be, and you're likely to remove your head by accident.

I never claimed C was a safe language.  I assume you've seen the classic 
essay, http://www-users.cs.york.ac.uk/susan/joke/foot.htm ?

And, no, I don't think C is a good application language (any more).  
When it first came out, it was revolutionary.  A lot of really amazing 
application software was written in it, partly because the people 
writing in it were some of the smartest guys around.  But, that was 40 
years ago.  We've learned a lot about software engineering since then.  

We've also got machines that are so fast, it's not longer critical that 
we squeeze out every last iota of performance.  Oh, but wait, now we're 
trying to do absurd things like play full-motion video games on phones, 
where efficiency equates to battery life.  Sigh.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: try/except/finally

2014-06-07 Thread Roy Smith
In article mailman.10867.1402184850.18130.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 A return statement inside a finally block is code smell.

Not to my nose.  It seems like a perfectly reasonable thing to do.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to use imported function to get current globals

2014-06-07 Thread 1989lzhh


发自我的 iPhone

 在 Jun 8, 2014,4:52,Chris Angelico ros...@gmail.com 写道:
 
 On Sun, Jun 8, 2014 at 3:40 AM, 1989lzhh 1989l...@gmail.com wrote:
 Here is the code
 m1.py
 def f():
print globals()
 
 m2.py
 from m1 import f
 f()# how to get current module's globals?
 
 As Ian said, you almost certainly do not want to do this. But if you
 have a solid use-case that involves finding the caller's globals, you
 can do it (in CPython - no idea about other Pythons) with the
 backtrace.
   Could you give an example ? I do want to get the caller's globals, so I can 
expose something into current module implicitly. Thanks!
  Liu 
zhenhai
 
 Normally, passing dictionaries around is going to be MUCH more useful.
 (And probably not actually globals(), you almost never want to use
 that.)
 
 ChrisA
 -- 
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-07 Thread Chris Angelico
On Sun, Jun 8, 2014 at 10:09 AM, Roy Smith r...@panix.com wrote:
 We've also got machines that are so fast, it's not longer critical that
 we squeeze out every last iota of performance.  Oh, but wait, now we're
 trying to do absurd things like play full-motion video games on phones,
 where efficiency equates to battery life.  Sigh.

Efficiency will never stop being important. Efficiency will also never
be the one most important thing. No matter how much computing power
changes, those statements are unlikely to be falsified...

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


Re: How to use imported function to get current globals

2014-06-07 Thread Chris Angelico
On Sun, Jun 8, 2014 at 10:28 AM, 1989lzhh 1989l...@gmail.com wrote:


 发自我的 iPhone

 在 Jun 8, 2014,4:52,Chris Angelico ros...@gmail.com 写道:

 On Sun, Jun 8, 2014 at 3:40 AM, 1989lzhh 1989l...@gmail.com wrote:
 Here is the code
 m1.py
 def f():
print globals()

 m2.py
 from m1 import f
 f()# how to get current module's globals?

 As Ian said, you almost certainly do not want to do this. But if you
 have a solid use-case that involves finding the caller's globals, you
 can do it (in CPython - no idea about other Pythons) with the
 backtrace.
Could you give an example ? I do want to get the caller's globals, so I 
 can expose something into current module implicitly. Thanks!

Frankly, no. I don't want to encourage implicitly exposing something
like that! Why do you want that, rather than something explicit and
clear?

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


Re: OT: This Swift thing

2014-06-07 Thread Gregory Ewing

Michael Torrie wrote:

Technically C doesn't either, except via subroutines in libc, though C
does have pointers which would be used to access memory.


The Pascal that Apple used had a way of casting an
int to a pointer, so you could do all the tricks
you can do with pointers in C.

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


Re: try/except/finally

2014-06-07 Thread Mark Lawrence

On 08/06/2014 01:12, Roy Smith wrote:

In article mailman.10867.1402184850.18130.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:


A return statement inside a finally block is code smell.


Not to my nose.  It seems like a perfectly reasonable thing to do.



I agree, the code smell is the return in the except block.

--
My fellow Pythonistas, ask not what our language can do for you, ask 
what you can do for our language.


Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


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


Re: OT: This Swift thing

2014-06-07 Thread Gregory Ewing

Dennis Lee Bieber wrote:

Not standard Pascal... It had pointer types, but no means to stuff
an integer into the pointer variable in order to dereference it as a memory
address...


Although most implementations would let you get the same
effect by abusing variant records (the equivalent of a
C union).


What is an interrupt --
typically a handler (function) address stored in a fixed location used by
the CPU when an external hardware signal goes high... Nothing prevents one
from writing that handler in C and using C's various casting operations to
stuff it into the vector memory.


Most CPU architectures require you to use a special
return from interrupt instruction to return from
a hardware interrupt handler. So you need at least
a small assembly language stub to call a handler
written in C, or a C compiler with a non-standard
extension to generate that instruction.

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


Re: Uniform Function Call Syntax (UFCS)

2014-06-07 Thread Gregory Ewing

Ian Kelly wrote:


It's a nice feature in a statically typed language, but I'm not sure
how well it would work in a language as dynamic as Python.


Also it doesn't sit well with Python's one obvious
way to do it guideline, because it means there are
*two* equally obvious ways to call a function.

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


Re: try/except/finally

2014-06-07 Thread Roy Smith
In article mailman.10871.1402189805.18130.python-l...@python.org,
 Mark Lawrence breamore...@yahoo.co.uk wrote:

 On 08/06/2014 01:12, Roy Smith wrote:
  In article mailman.10867.1402184850.18130.python-l...@python.org,
Chris Angelico ros...@gmail.com wrote:
 
  A return statement inside a finally block is code smell.
 
  Not to my nose.  It seems like a perfectly reasonable thing to do.
 
 
 I agree, the code smell is the return in the except block.

That's not setting my nose on end either.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re:How to use imported function to get current globals

2014-06-07 Thread Dave Angel
1989lzhh 1989l...@gmail.com Wrote in message:
 Here is the code
 m1.py
 def f():
 print globals()
 
 m2.py
 from m1 import f
 f()# how to get current module's globals?
 

As others have said, it's probably a bad idea.  I can think of 3
 reasons to try: teacher said so, writing a debugger, 
 transliterating code from a crude language into python.

Could you elaborate on what you really want? Which of those two
 modules is your main script? Which code in which module is trying
 to get which module's globals?  And is the connection static or
 dynamic? And do you want a snapshot of them, or to be able to
 modify and track changes? 




-- 
DaveA

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


Re:try/except/finally

2014-06-07 Thread Dave Angel
Frank B fbick...@gmail.com Wrote in message:
 Ok; this is a bit esoteric.
 
 So finally is executed regardless of whether an exception occurs, so states 
 the docs.
 
 But, I thought, if I return from my function first, that should take 
 precedence.
 
 au contraire
 
 Turns out that if you do this:
 
 try:
   failingthing()
 except FailException:
   return 0
 finally:
   return 1
 
 Then finally really is executed regardless... even though you told it to 
 return.
 
 That seems odd to me.
 

The thing that's odd to me is that a return is permissible inside
 a finally block. That return
should be at top level,  even with the finally line. And of course
 something else should be in the body of the finally
 block.

If you wanted the finally block to change the return value,  it
 should do it via a variable.

retval = 0 
try:
 failingthing()
except FailException:
 return retval
finally:
 retval =1 
return something

I imagine the finally clause was designed to do cleanup, like
 closing files.  And it certainly predated the with statement.
 

-- 
DaveA

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


Re: OT: This Swift thing

2014-06-07 Thread Steven D'Aprano
On Sat, 07 Jun 2014 20:09:37 -0400, Roy Smith wrote:

 We've also got machines that are so fast, it's not longer critical that
 we squeeze out every last iota of performance.  Oh, but wait, now we're
 trying to do absurd things like play full-motion video games on phones,
 where efficiency equates to battery life.  Sigh.

That's where there needs to be a concerted push to develop more efficient 
CPUs and memory, in the engineering sense of efficiency (i.e. better 
power consumption, not speed). In desktop and server class machines, 
increasing speed has generated more and more waste heat, to the point 
where Google likes to build its server farms next to rivers to reduce 
their air conditioning costs. You can't afford to do that on a battery.

Even for desktops and servers, I'd prefer to give up, say, 80% of future 
speed gains for a 50% reduction in my electricity bill.



-- 
Steven D'Aprano
http://import-that.dreamwidth.org/
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: try/except/finally

2014-06-07 Thread Rustom Mody
On Sunday, June 8, 2014 5:17:21 AM UTC+5:30, Chris Angelico wrote:
 On Sun, Jun 8, 2014 at 8:49 AM, Ethan Furman  wrote:
  I don't remember if I almost had this in real code or if I learned about it
  first, but it can definitely be a gotcha. It seems to me that if the try
  block exits with an explicit return, and then the finally block exits with
  an explicit return, some kind of error ought to be raised.

 I'd go a little simpler: A return statement inside a finally block is
 code smell.

Some people¹ think that gotos are a code-smell.

And since both return and exceptions are thinly veiled gotos, what we
have here are two smells outsmelling each other.

¹ I am not exactly those people.
A chap called E W Dijkstra made the statement: Goto statement considered 
harmful and became famous.
The chap who taught me programming said to me: What the goto does to 
control structure, the assignment does to data structure
He did not become famous.
However in my view he made the more intelligent statement
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python 3.2 has some deadly infection

2014-06-07 Thread rurpy
On 06/05/2014 05:02 PM, Steven D'Aprano wrote:
[...]
 But Linux Unicode support is much better than Windows. Unicode support in 
 Windows is crippled by continued reliance on legacy code pages, and by 
 the assumption deep inside the Windows APIs that Unicode means 16 bit 
 characters. See, for example, the amount of space spent on fixing 
 Windows Unicode handling here:
 
 http://www.utf8everywhere.org/

While not disagreeing with the the general premise of that page, it 
has some problems that raise doubts in my mind about taking everything 
the author says at face value.

For example

  Q: Why would the Asians give up on UTF-16 encoding, which saves 
  them 50% the memory per character?
  [...] in fact UTF-8 is used just as often in those [Asian] countries. 

That is not my experience, at least for Japan.  See my comments in 
  https://mail.python.org/pipermail/python-ideas/2012-June/015429.html
where I show that utf8 files are a tiny minority of the text files 
found by Google.

He then gives a table with the size of utf8 and utf16 encoded contents
(ie stripped of html stuff) of an unnamed Japanese wikipedia page to 
show that even without a lot of (html-mandated) ascii, the space savings 
are not very much compared to the theoretical 50% savings he stated:

   Dense text (Δ UTF-8)
   UTF-8   ... 222 KB (0%)
   UTF-16  ... 176 KB (−21%)

Note that he calculates the space saving as (utf8-utf16)/utf8.
Yet by that metric the theoretical saving is *NOT* 50%, it is 33%.
For example 1000 Japanese characters will use 2000 bytes in utf16
and 3000 in utf8.

I did the same test using
  http://ja.wikipedia.org/wiki/%E7%B9%94%E7%94%B0%E4%BF%A1%E9%95%B7
I stripped html tags, javascript and redundant ascii whitespace characters
The stripped utf-8 file was 164946 bytes, the utf-16 encoded version of
same was 117756.  That gives (using the (utf8-utf16)/utf16 metric he used 
to claim 50% idealized savings) 40% which is quite a bit closer to the 
idealized 50% than his 21%.

I would have more faith in his opinions about things I don't know
about (such as unicode programming on Windows) if his other info
were more trustworthy.  IOW, just because it's on the internet doesn't 
mean it's true.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: OT: This Swift thing

2014-06-07 Thread Marko Rauhamaa
Roy Smith r...@panix.com:

 The original MacOS was written in Pascal (both applications and
 kernel). Being able to touch memory locations or registers requires no
 more than a few short glue routines written in assembler.

Pascal is essentially equivalent to C, except Pascal has a cleaner
syntax. I like the fact that the semicolon is a separator. Also, the
variable declaration syntax is done more smartly in Pascal. And the
pointer/array confusion in C is silly.


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


Re: How to use imported function to get current globals

2014-06-07 Thread 1989lzhh
thanks all you guys. I have find the solution which is quite simple by using 
sys._frame(1).f_locals in function to get the caller's scope
The following is my user case:
I am writing a tool to translate python code to cython code then compiled using 
decorate.

jit, build=make(mymodule)
#jit function collect python code and signature then translate to cython code
@jit('int(int)',
locals='''
int b;
''')
def f(a):
b=1
return a+1

build()# compile cython code and load compiled module then expose compiled 
function to current namespace. So this is my purpose to get caller's scope
f()# now f is a compiled function 



发自我的 iPhone

 在 Jun 8, 2014,10:24,Dave Angel da...@davea.name 写道:
 
 1989lzhh 1989l...@gmail.com Wrote in message:
 Here is the code
 m1.py
 def f():
print globals()
 
 m2.py
 from m1 import f
 f()# how to get current module's globals?
 
 As others have said, it's probably a bad idea.  I can think of 3
 reasons to try: teacher said so, writing a debugger, 
 transliterating code from a crude language into python.
 
 Could you elaborate on what you really want? Which of those two
 modules is your main script? Which code in which module is trying
 to get which module's globals?  And is the connection static or
 dynamic? And do you want a snapshot of them, or to be able to
 modify and track changes? 
 
 
 
 
 -- 
 DaveA
 
 -- 
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue21456] skip 2 tests in test_urllib2net.py if _ssl module not present

2014-06-07 Thread Remi Pointel

Remi Pointel added the comment:

Are you ok with this diff reworked?

--
Added file: http://bugs.python.org/file35505/Lib_test_test_urllib2net_py.diff

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



[issue21682] Refleak in idle_test test_autocomplete

2014-06-07 Thread Saimadhav Heblikar

Saimadhav Heblikar added the comment:

The patch fixes the refleak. Importing EditorWindow, was perhaps the cause. It 
uses a dummy editwin instead. 

With reference to the current test, was there a particular reason to import 
real EditorWindow module?

--
keywords: +patch
Added file: http://bugs.python.org/file35506/issue21682.diff

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



[issue21597] Allow turtledemo code pane to get wider.

2014-06-07 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I ran the patched code but have not looked at the code itself. Pending such a 
look, I would consider committing it if we cannot do better, as it solves both 
issues. However, there are two visual issues.

1. The minor one: The blue label does not have drop shadows, the red/yellow 
buttons do. I suspect the intent is to differentiate something that cannot be 
pressed from things that can. But the effect at the boundary is  bit jarring. 
On the bottem, the buttons are underlined in black, the label not. On the top, 
the button have a very light shading that makes them look narrower than they 
are. I wonder if it would look better if the label has shadows to match, or if 
there were a small separation between the labels and buttons (horizonatal 
padding on the label?). If you understand what is bother me, see if you can 
come up with something that looks better than you. Even post a couple of 
alternatives, if you want.

2. More important: when I move the slider right, the text widen and the canvas 
narrows relatively smoothly. When I go the other way, to the left, a trail of 
vertical line is left behind for perhaps a third of a second. The right 
scrollbar, the vertical canvas bars, jiggles back and forth about a few mm, as 
if it were not fixed in place but attached to springs and dragged by the 
canvas. This happens even with both panes empty. It looks pretty bad.

I wonder if this has anything to do with mixing grid and pack. An experiment 
would be to put an empty PanedWindow into a window and see if it behaves as 
badly.  I have a decent system, and moving - work almost ok, so something 
seems wrong.

--
stage: needs patch - patch review

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



[issue21684] inspect.signature bind doesn't include defaults or empty tuple/dicts

2014-06-07 Thread Berker Peksag

Changes by Berker Peksag berker.pek...@gmail.com:


--
nosy: +yselivanov

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



[issue18910] IDle: test textView.py

2014-06-07 Thread Ned Deily

Ned Deily added the comment:

It looks like the 2.7 checkin has caused a number of buildbots to fail.  
Examples:

http://buildbot.python.org/all/builders/AMD64%20Ubuntu%20LTS%202.7/builds/1094/steps/test/logs/stdio

==
ERROR: idlelib.idle_test.test_textview (unittest.loader.ModuleImportFailure)
--
ImportError: Failed to import test module: idlelib.idle_test.test_textview
Traceback (most recent call last):
  File /opt/python/2.7.langa-ubuntu/build/Lib/unittest/loader.py, line 254, 
in _find_tests
module = self._get_module_from_name(name)
  File /opt/python/2.7.langa-ubuntu/build/Lib/unittest/loader.py, line 232, 
in _get_module_from_name
__import__(name)
  File 
/opt/python/2.7.langa-ubuntu/build/Lib/idlelib/idle_test/test_textview.py, 
line 11, in module
requires('gui')
  File /opt/python/2.7.langa-ubuntu/build/Lib/test/test_support.py, line 359, 
in requires
raise ResourceDenied(_is_gui_available.reason)
ResourceDenied: Tk unavailable due to TclError: no display name and no $DISPLAY 
environment variab [...]

and:

http://buildbot.python.org/all/builders/AMD64%20Snow%20Leop%202.7/builds/440/steps/test/logs/stdio

==
ERROR: idlelib.idle_test.test_textview (unittest.loader.ModuleImportFailure)
--
ImportError: Failed to import test module: idlelib.idle_test.test_textview
Traceback (most recent call last):
  File 
/Users/buildbot/buildarea/2.7.murray-snowleopard/build/Lib/unittest/loader.py,
 line 254, in _find_tests
module = self._get_module_from_name(name)
  File 
/Users/buildbot/buildarea/2.7.murray-snowleopard/build/Lib/unittest/loader.py,
 line 232, in _get_module_from_name
__import__(name)
  File 
/Users/buildbot/buildarea/2.7.murray-snowleopard/build/Lib/idlelib/idle_test/test_textview.py,
 line 11, in module
requires('gui')
  File 
/Users/buildbot/buildarea/2.7.murray-snowleopard/build/Lib/test/test_support.py,
 line 359, in requires
raise ResourceDenied(_is_gui_available.reason)
ResourceDenied: gui tests cannot run without OS X window manager

--
nosy: +ned.deily
resolution: fixed - 
stage: resolved - needs patch
status: closed - open

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



[issue21627] Concurrently closing files and iterating over the open files directory is not well specified

2014-06-07 Thread STINNER Victor

STINNER Victor added the comment:

The _posixsubprocess module is not compiled on Windows.

--

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



[issue18910] IDle: test textView.py

2014-06-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Please don't create Tk object at module creating stage. I afraid this will 
break unittest discoverity.

--
nosy: +serhiy.storchaka

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



[issue21682] Refleak in idle_test test_autocomplete

2014-06-07 Thread Terry J. Reedy

Terry J. Reedy added the comment:

This concerns me. I expect that we will eventually want to test a live 
EditorWindow or subclass. It appears that root.destroy does not clear all the 
widgets created by EditorWindow(root=root). My guess it that something is 
created without passing in root, so that tkinter._default_root gets used 
instead. This needs investigation.

I actually ran into this problem before, though not in full form, as I did not 
commit test_formatparagraph.py with EditorWindow(). I used a mock containing a 
method extracted from EditorWindow that does not cause problems, after noting 
the following.

# A real EditorWindow creates unneeded, time-consuming baggage and
# sometimes emits shutdown warnings like this:
# warning: callback failed in WindowList class '_tkinter.TclError'
# : invalid command name .55131368.windows.
# Calling EditorWindow._close in tearDownClass prevents this but causes
# other problems (windows left open).

Why did I commit this with EditorWindow used as is? Because I forgot the above, 
written last August and did not think to see how easy it would be to mock the 
minimum needed. I need to make sure to put DO NOT USE EditorWindow ... in 
README.txt.

I did not get the error message in several all ok runs. We can worry later 
about using mock Text for a non-gui alternative. Thanks Zack for catching this 
and Saimadhav to fixing it.

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

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



[issue18910] IDle: test textView.py

2014-06-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +zach.ware

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



[issue18910] IDle: test textView.py

2014-06-07 Thread Terry J. Reedy

Terry J. Reedy added the comment:

The 3.4 stable buildbots are green except for two that ran test_idle ok.
The problem is that in 2.7, unittest.loader does not catch ResourceDenied at 
module level whereas is does in 3.4. The only indication that there should be a 
difference is that the 3.x doc has Skipped modules will not have setUpModule() 
or tearDownModule() run.

I am puzzled though, since the manual says this was added in 3.1 and 2.7 came 
out after. Also, I presume that 2.7 test.regrtest honors the SkipTest raised by 
2.7 test_support.import_module, which is usually used at module level. 

If someone wants to revert the patch, go ahead. I have to get some sleep before 
I do anything (it is 5 am).
--

Please don't create Tk object at module creating stage.
I didn't. I intentionally put TK stuff inside setUpModule so it would happen at 
test running stage.

--

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



[issue17552] Add a new socket.sendfile() method

2014-06-07 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Looking back at this I think a send_blocksize argument is necessary after 
all. shutil.copyfileobj() has it, so is ftplib.FTP.storbinary() and  httplib 
(issue 13559) which will both be using socket.sendfile() once it gets included.
Updated patch is in attachment. If there are no other objections I'd be for 
committing this next week or something as I'm pretty confident with the current 
implementation.

--
Added file: http://bugs.python.org/file35507/socket-sendfile7.patch

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



[issue17552] Add a new socket.sendfile() method

2014-06-07 Thread Charles-François Natali

Charles-François Natali added the comment:

 Looking back at this I think a send_blocksize argument is necessary after 
 all. shutil.copyfileobj() has it, so is ftplib.FTP.storbinary() and  httplib 
 (issue 13559) which will both be using socket.sendfile() once it gets 
 included.

Those APIs are really poor, please don't cripple sendfile() to mirror them.

Once again, a send_blocksize argument doesn't make sense, you won't
find it anywhere else. All that's needed is start offset and a
size/length argument.

--

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



[issue17552] Add a new socket.sendfile() method

2014-06-07 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

I agree it is not necessary for sendfile() (you were right).
Do not introducing it for send(), though, poses some questions. 
For instance, should we deprecate or ignore 'blocksize' argument in ftplib as 
well?
Generally speaking, when using send() there are circumstances where you might 
want to adjust the number of bytes to read from the file, for instance:

- 1: set a small blocksize (say 512 bytes) on systems where you have a limited 
amount of memory

- 2: set a big blocksize (say 256000) in order to speed up the transfer / use 
less CPU cycles; on very fast networks (e.g. LANs) this may result in a 
considerable speedup (I know 'cause I conducted these kind of tests in 
pyftpdlib: https://code.google.com/p/pyftpdlib/issues/detail?id=94).

--

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



[issue17552] Add a new socket.sendfile() method

2014-06-07 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

...speaking of which, now that I look back at those benchmarks it looks like 
65536 bytes is the best compromise (in my latest patch I used 16348).

--

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



[issue21491] race condition in SocketServer.py ForkingMixIn collect_children

2014-06-07 Thread Charles-François Natali

Charles-François Natali added the comment:

Here's a patch fixing both issues.

--
keywords: +needs review, patch
nosy: +haypo, pitrou
stage:  - patch review
Added file: http://bugs.python.org/file35508/socketserver_reap.diff

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



[issue21677] Exception context set to string by BufferedWriter.close()

2014-06-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch. It fixes also the same error in TextIOWrapper.

--
assignee:  - serhiy.storchaka
keywords: +patch
stage:  - patch review
versions: +Python 2.7, Python 3.5
Added file: 
http://bugs.python.org/file35509/io_nonnormalized_error_on_close.patch

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



[issue21669] Custom error messages when print exec are used as statements

2014-06-07 Thread Nick Coghlan

Nick Coghlan added the comment:

Updated patch with the heuristics factored out into a helper function, with a 
more detailed explanation and additional logic to handle compound statements.

 def foo():
... print bar
  File stdin, line 2
print bar
^
SyntaxError: Missing parentheses in call to 'print'

It's still just basic string hackery, though. The one liner handling, for 
example, relies on the fact that :whitespaceprint  and :whitespaceexec  
are going to be uncommon outside Python 2 code being ported to Python 3, so it 
just looks for the first colon on the line and checks from there, without 
worrying about slice notation or dicts.

--
Added file: 
http://bugs.python.org/file35510/issue21669_custom_error_messages_v2.diff

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



[issue21685] zipfile module doesn't properly compress odt documents

2014-06-07 Thread Raimondo Giammanco

New submission from Raimondo Giammanco:

Steps to reproduce
¯¯
-1- Create a document.odt containing an input (text) field and a conditional 
text field; the latter will show a different text based upon the content of the 
input text field. [use attached example.odt]
-2- Edit the file by means of following code

from zipfile import ZipFile, ZIP_DEFLATED
document = '/tmp/example.odt' # SET ME PLEASE
S2b, R2b = 'SUBST'.encode(), 'REPLACEMENT'.encode()
with ZipFile(document,'a', ZIP_DEFLATED) as z:
xmlString = z.read('content.xml')
xmlString = xmlString.replace(S2b, R2b)
z.writestr('content.xml', xmlString)

-3- Open example.odt with *office

As `REPLACEMENT' is the requested string, one expect to see the relevant 
conditional text
What happens: the LO function doesn't recognize the string, unless one do not 
retype it manually

Omitting ZIP_DEFLATED parameter prevents this behaviour from happen (so letting 
zipfile use the default no-compression method) 


tested on
Python 2.7.3 and Python 3.2.3
Ubuntu 12.04 amd64
LibreOffice Version 4.0.4.2

--
components: Library (Lib)
files: example.odt
messages: 219933
nosy: rai
priority: normal
severity: normal
status: open
title: zipfile module doesn't properly compress odt documents
type: behavior
versions: Python 3.2
Added file: http://bugs.python.org/file35511/example.odt

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



[issue21592] Make statistics.median run in linear time

2014-06-07 Thread Julian Taylor

Julian Taylor added the comment:

for median alone a multiselect is probably overkill (thats why I mentioned the 
minimum trick)

but a selection algorithm is useful on its own for all of python and then a 
multiselect should be considered.
Of course that means it would need to be implemented in C like sorted() so you 
actually have a significant performance gain that makes adding a new python 
function worthwhile.

Also just to save numpys honor, you are benchmarking python list - numpy array 
conversion and not the actual selection in your script with the numpy 
comparison. The conversion is significantly slower than the selection itself. 
Also select2b is inplace while np.partition is out of place. Repeated inplace 
selection typically gets faster as the number of required swaps goes down and 
can even be constant in time if the requested value does not change.
With that fixed numpy outperforms pypy by about a factor 2 (but pypys 
performance is indeed quite impressive as it is far more generic)

--

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



[issue21684] inspect.signature bind doesn't include defaults or empty tuple/dicts

2014-06-07 Thread R. David Murray

Changes by R. David Murray rdmur...@bitdance.com:


--
nosy: +r.david.murray

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



[issue21685] zipfile module doesn't properly compress odt documents

2014-06-07 Thread SilentGhost

SilentGhost added the comment:

Raimondo, the documentation clearly states that the compression method is 
either inherited from ZipInfo instance (when that one is passed) or set to 
ZIP_STORED otherwise. Since you're not passing ZipInfo instance, but the string 
(as the first argument to .writestr), therefore the compression method is set 
to ZIP_STORED. If you're not set it to ZIP_DEFLATED explicitly, it would work 
as you expect it. In either case, this behaviour is in accordance with the 
documentation.

--
nosy: +SilentGhost

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



[issue21667] Clarify status of O(1) indexing semantics of str objects

2014-06-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 6ffb6909c439 by Nick Coghlan in branch '3.4':
Issue #21667: Clarify string data model description
http://hg.python.org/cpython/rev/6ffb6909c439

New changeset 7c120e77d6f7 by Nick Coghlan in branch 'default':
Merge issue #21667 from 3.4
http://hg.python.org/cpython/rev/7c120e77d6f7

--
nosy: +python-dev

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



[issue21667] Clarify status of O(1) indexing semantics of str objects

2014-06-07 Thread Nick Coghlan

Nick Coghlan added the comment:

I've merged the character-code point clarifications, without the 
implementation detail section.

For the time being, that leaves doesn't provide O(1) indexing of strings as 
the kind of discrepancy that often makes an appearance in differences from the 
CPython reference implementation section that many alternative implementations 
include.

--
resolution:  - later
stage:  - resolved
status: open - closed
type:  - enhancement

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



[issue21569] PEP 466: Python 2.7 What's New preamble changes

2014-06-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7c28b3a92f40 by Nick Coghlan in branch '2.7':
Updates to Python 2.7 What's New preamble
http://hg.python.org/cpython/rev/7c28b3a92f40

--
nosy: +python-dev

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



[issue21569] PEP 466: Python 2.7 What's New preamble changes

2014-06-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset d23cea976f46 by Nick Coghlan in branch '3.4':
Issue #21569: sync Python 2.7 What's New with 2.7 version
http://hg.python.org/cpython/rev/d23cea976f46

New changeset b167df2912d6 by Nick Coghlan in branch 'default':
Merge issue #21569 from 3.4
http://hg.python.org/cpython/rev/b167df2912d6

--

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



[issue21569] PEP 466: Python 2.7 What's New preamble changes

2014-06-07 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
resolution:  - fixed
stage:  - resolved
status: open - closed

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



[issue21592] Make statistics.median run in linear time

2014-06-07 Thread Steven D'Aprano

Steven D'Aprano added the comment:

On Sat, Jun 07, 2014 at 01:02:52PM +, Julian Taylor wrote:
 but a selection algorithm is useful on its own for all of python and 
 then a multiselect should be considered.

I like the idea of a select and/or multiselect for 3.5. As a 
new feature, it cannot go into 3.4.

--

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



[issue18141] tkinter.Image.__del__ can throw an exception if module globals are destroyed in the wrong order

2014-06-07 Thread Jan Kanis

Jan Kanis added the comment:

I tried changing the last block in turtulemodule/__init__.py to

if __name__ == '__main__':
demo = DemoWindow()
print(ENTERING mainloop)
demo.root.mainloop()
print(Bye)

but that does not solve the problem:

 python3 -m turtledemo
ENTERING mainloop
Exception ignored in: bound method PhotoImage.__del__ of tkinter.PhotoImage 
object at 0x7ffef193b948
Traceback (most recent call last):
  File /home/jan/test/lib/python3.4/tkinter/__init__.py, line 3330, in __del__
TypeError: catching classes that do not inherit from BaseException is not 
allowed

so still the same error. (Although it is probably still good to make that 
change.)

Tested on cpython revision dfcb64f51f7b, so the same as I originally made the 
bugreport from.

--

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



[issue21686] IDLE - Test hyperparser

2014-06-07 Thread Saimadhav Heblikar

New submission from Saimadhav Heblikar:

Test for idlelib.HyperParser
5 lines not tested. Any suggestion on how to hit those lines welcome.
Will submit backport 2.7 once the patch for 3.4 is OK.

--
components: IDLE
files: test-hyperparser.diff
keywords: patch
messages: 219942
nosy: jesstess, sahutd, terry.reedy
priority: normal
severity: normal
status: open
title: IDLE - Test hyperparser
versions: Python 2.7, Python 3.4, Python 3.5
Added file: http://bugs.python.org/file35512/test-hyperparser.diff

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



[issue8840] truncate() semantics changed in 3.1.2

2014-06-07 Thread Mark Lawrence

Mark Lawrence added the comment:

Is any more work needed here as msg106725 asks about updating doc strings?

--
nosy: +BreamoreBoy

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



[issue21687] Py_SetPath: Path components separated by colons

2014-06-07 Thread Florian Walch

New submission from Florian Walch:

The documentation for Py_SetPath [1] states:

 The path components should be separated by semicolons.

I believe this should not say semicolons, but colons; the default path as 
output by Py_GetPath is separated by colons.

[1] https://docs.python.org/3/c-api/init.html#c.Py_SetPath

--
assignee: docs@python
components: Documentation
messages: 219944
nosy: docs@python, fwalch
priority: normal
severity: normal
status: open
title: Py_SetPath: Path components separated by colons
type: behavior
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue15707] PEP 3121, 384 Refactoring applied to signal module

2014-06-07 Thread Mark Lawrence

Mark Lawrence added the comment:

PEP 384 is listed as finished while 3121 is accepted so what if anything needs 
to be done here?  I've checked https://docs.python.org/devguide/experts.html 
and nobody is listed against the signal module.  The patch is C code which I 
don't have the knowledge to comment on, sorry about that.

--
nosy: +BreamoreBoy

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



[issue12673] SEGFAULT error on OpenBSD (sparc)

2014-06-07 Thread Remi Pointel

Remi Pointel added the comment:

For your information, this bug has been fixed in OpenBSD and the developper has 
contacted the NetBSD developper:
http://marc.info/?l=openbsd-techm=140209064821540w=2

So I think we could close this issue because it's a system issue, not Python.

--

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



[issue8576] test_support.find_unused_port can cause socket conflicts on Windows

2014-06-07 Thread Mark Lawrence

Mark Lawrence added the comment:

msg104677, msg104822 and msg104845 refer to various commits but msg104955 
suggests that a follow up is needed so where do we stand with this issue?

--
nosy: +BreamoreBoy

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



[issue9012] Separate compilation of time and datetime modules

2014-06-07 Thread Mark Lawrence

Mark Lawrence added the comment:

msg111078 refers to r82035 for Visual Studio 2005 (VC8) builds.  Given that 
http://code.activestate.com/lists/python-dev/131023/ refers to VC14 for 3.5 can 
we close this as out of date?

--
nosy: +BreamoreBoy

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



[issue21666] Argparse exceptions should include which argument has a problem

2014-06-07 Thread paul j3

paul j3 added the comment:

First, 'parse_intermixed_args' on stack is not relevant.  It's from an 
unreleased patch that we worked on.

What matters is the 'print_help', invoked probably with a '-h'.

The error message that normally specifies the problem argument is produced by 
ArgumentError.  The HelpFormatter does not raise such an error.  ArgumentError 
is usually used for parsing errors; this is a formatting one.  It's not 
produced by faulty commandline values.

If you must put strings like '%)` in the help line, use RawTextHelpFormatter.  
Otherwise HelpFormatter assumes the help line has valid format expressions like 
'%(default)s'.

Or you could write your own HelpFormatter subclass with a modified 
'_expand_help' method, one which wraps the 'self._get_help_string(action) % 
params' in a 'try' block.  Probably too draconian a measure for a rare problem. 
:)  

It's an interesting problem, but I don't think it warrants any code changes.

--
nosy: +paul.j3

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



[issue8576] test_support.find_unused_port can cause socket conflicts on Windows

2014-06-07 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
nosy:  -brian.curtin

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



[issue8576] test_support.find_unused_port can cause socket conflicts on Windows

2014-06-07 Thread Paul Moore

Paul Moore added the comment:

TBH, I don't think I ever took this any further. As noted, the earlier patches 
fixed the failures I was hitting.

It looks like Python 3.4 now has *two* definitions of find_unused_port, in 
test.test_support and in test.support. And test_asyncio and test_ftplib also 
use the function now.

--

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



[issue8576] test_support.find_unused_port can cause socket conflicts on Windows

2014-06-07 Thread Paul Moore

Changes by Paul Moore p.f.mo...@gmail.com:


--
nosy:  -pmoore

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



[issue21600] mock.patch.stopall doesn't work with patch.dict to sys.modules

2014-06-07 Thread fumihiko kakuma

fumihiko kakuma added the comment:

Hi michael,
Certainly, thank you for your many advices. I attached the new patch file.

--
Added file: http://bugs.python.org/file35513/support_patch_dict_by_stopall.diff

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



[issue10002] Installer doesn't install on Windows Server 2008 DataCenter R2

2014-06-07 Thread Mark Lawrence

Mark Lawrence added the comment:

msg121605 says the OP isn't seeing issues with this so I'd guess this can be 
closed?

--
nosy: +BreamoreBoy

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



[issue21687] Py_SetPath: Path components separated by colons

2014-06-07 Thread eryksun

eryksun added the comment:

A Windows path uses : after the drive letter, e.g. C:\\Windows, so the 
delimiter is a semicolon on Windows. Other platforms use a colon.

CPython uses DELIM, which is defined in osdefs.h. This header isn't included by 
Python.h.

http://hg.python.org/cpython/file/c0e311e010fc/Include/osdefs.h

--
nosy: +eryksun

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



[issue10503] os.getuid() documentation should be clear on what kind of uid it is referring

2014-06-07 Thread Greg

Greg added the comment:

Here's a wording change in the documentation to clarify this.

--
keywords: +patch
nosy: +εσχατοκυριος
Added file: http://bugs.python.org/file35514/mywork.patch

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



[issue13143] os.path.islink documentation is ambiguous

2014-06-07 Thread Yayoi Ukai

Yayoi Ukai added the comment:

Documentation is updated to be more clear

--
keywords: +patch
nosy: +terab
Added file: http://bugs.python.org/file35515/mywork.patch

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



[issue21548] pydoc -k IndexError on empty docstring

2014-06-07 Thread Yuyang Guo

Yuyang Guo added the comment:

Made change based on Terry J. Reedy's suggestion

--
keywords: +patch
nosy: +Yuyang.Guo
Added file: http://bugs.python.org/file35516/issue21548.patch

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



[issue7424] NetBSD: segmentation fault in listextend during install

2014-06-07 Thread Ned Deily

Ned Deily added the comment:

See issue12673 msg219946.  Apparently this was caused by a long-standing BSD 
sparc bug.

--
nosy: +ned.deily
resolution:  - third party
stage: test needed - resolved
status: open - closed

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



[issue18141] tkinter.Image.__del__ can throw an exception if module globals are destroyed in the wrong order

2014-06-07 Thread Jan Kanis

Jan Kanis added the comment:

I have verified that DemoWindow._destroy(self) indeed gets called before the 
exception is raised. 

I did a bisect, on the default branch the bug was introduced by commit 
f0833e6ff2d2: Issue #1545463: Global variables caught in reference cycles are 
now garbage-collected at shutdown.

I will try bisecting the 3.3 branch to se where the bug stops appearing.

--

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



[issue15569] Doc doc: incorrect description of some roles as format-only

2014-06-07 Thread Emily Zhao

Emily Zhao added the comment:

I moved the 3 misplaced roles (envvar, keyword, and option) and changed the 
description for the new section per Terry's suggestions. Patch is attached and 
needs to go in the devguide repo.

https://docs.python.org/devguide/docquality.html#helping-with-the-developers-guide

--
keywords: +patch
nosy: +emily.zhao
Added file: http://bugs.python.org/file35517/issue15569.patch

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



[issue21671] CVE-2014-0224: OpenSSL upgrade to 1.0.1h on Windows required

2014-06-07 Thread Georg Brandl

Georg Brandl added the comment:

Well, it's entirely logical to follow our own policies :)

--

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



[issue21688] Improved error msg for make.bat htmlhelp

2014-06-07 Thread Olive Kilburn

New submission from Olive Kilburn:

Currently if someone runs make.bat htmlhelp without first installing Htmlhelp 
Workshop, it outputs: 
c:\program not a valid . . . .

This isn't very informative if you don't know you need Htmlhelp Workshop. The 
included patch has make.bat give a more helpful message. If this isn't a good 
fix(?), I could try clarifying the readme instead.

--
components: Windows
files: mywork.patch
keywords: patch
messages: 219961
nosy: Olive.Kilburn
priority: normal
severity: normal
status: open
title: Improved error msg for make.bat htmlhelp
type: enhancement
versions: Python 3.5
Added file: http://bugs.python.org/file35518/mywork.patch

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



  1   2   >