[issue24980] Allow for providing 'on_new_thread' callback to 'concurrent.futures.ThreadPoolExecutor'

2015-09-01 Thread Joshua Harlow

New submission from Joshua Harlow:

In situations where thread-local variables need to be setup it is quite useful 
to be able to hook into the thread creation process, so that as each new thread 
is spun up by the ThreadPoolExecutor that the threads created initially call 
into a provided callback (the callback can then setup thread local state as 
needed).

--
messages: 249501
nosy: harlowja
priority: normal
severity: normal
status: open
title: Allow for providing 'on_new_thread' callback to 
'concurrent.futures.ThreadPoolExecutor'

___
Python tracker 

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



[issue7175] Define a standard location and API for configuration files

2015-09-01 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

On Sep 01, 2015, at 07:15 PM, Glyph Lefkowitz wrote:

>There are other advantages to following the XDG spec.  If we follow it
>correctly (and not, like Barry suggested, start adding random other
>directories like ~/.python)

I was really just suggesting reading from other locations for backward
compatibility.

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Nathaniel Smith

Nathaniel Smith added the comment:

> I do understand your predicament. Can you live with just a special case for 
> modules? __class__ assignment is full of non-portable special cases already.

Not only can I live with it, but -- unless I misunderstand your meaning -- this 
is exactly the approach that I am advocating and have submitted a patch to 
implement :-).

--

___
Python tracker 

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



[issue17849] Missing size argument in readline() method for httplib's class LineAndFileWrapper

2015-09-01 Thread Garfield222

Garfield222 added the comment:

Same error happens if http_proxy="223.19.230.181:80" variable is set.

--
nosy: +Garfield222

___
Python tracker 

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



[issue24978] Contributing to Python 2x and 3x Documentation. Translation to Russian.

2015-09-01 Thread Brett Cannon

Brett Cannon added the comment:

Is it time we start managing translations somehow? Or at least have a link off 
of docs.python.org to various translations so they are easier to discover?

--
nosy: +brett.cannon

___
Python tracker 

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



netcdf read

2015-09-01 Thread jorge . conrado


Hi,


I'm starting in the Python scripts. I run this script:


import numpy as np

import netCDF4

f = netCDF4.Dataset('uwnd.mon.ltm.nc','r')


f.variables


and I had the message:


netcdf4.py
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'netcdf4' is not defined


What can I do to solve this.



I typed  this three lines:


import netCD4

f = netCDF4.Dataset('uwnd.mon.ltm.nc','r')


f.variables


and it work.


Please, why my script didn't work.


Conrado


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


Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Laura Creighton
In a message of Wed, 02 Sep 2015 00:57:22 +1000, "Steven D'Aprano" writes:
>Let's suppose somebody passes me a file descriptor to work with. It could
>come from somewhere else, but for the sake of discussion let's pretend I
>create it myself this way:

>Q1:  In this example, I know that I opened the fd in write mode, because I
>did it myself. But since I'm not actually opening it, how do I know what
>mode to use in the call to fdopen? Is there something I can call to find
>out what mode a file descriptor has been opened with?

for POSIX things use fnclt.  YOu have to parese the bits yourself
and I always have to look that up to see what the grubby details
are.  No clue what you do on windows.

Don't go around closing things you don't know are open.  They
could be some other processes' thing.

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


[issue24980] Allow for providing 'on_new_thread' callback to 'concurrent.futures.ThreadPoolExecutor'

2015-09-01 Thread Joshua Harlow

Changes by Joshua Harlow :


--
versions: +Python 3.6

___
Python tracker 

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



[issue24980] Allow for providing 'on_new_thread' callback to 'concurrent.futures.ThreadPoolExecutor'

2015-09-01 Thread Joshua Harlow

Changes by Joshua Harlow :


--
components: +Library (Lib)

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Pull request version of patch is here:

https://bitbucket.org/larry/cpython350/pull-requests/9/fix-issue-24912-disallow-reassigning-the/diff

(identical to issue24912-v2.patch except for the addition of a NEWS entry)

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Guido van Rossum

Guido van Rossum added the comment:

OK, then I think it's between you and Serhiy.

--

___
Python tracker 

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



[issue17849] Missing size argument in readline() method for httplib's class LineAndFileWrapper

2015-09-01 Thread Garfield222

Garfield222 added the comment:

This error occurs when using youtube-dl 
Complete log is here:
https://github.com/rg3/youtube-dl/issues/6727

--

___
Python tracker 

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



Re: Does mkstemp open files only if they don't already exist?

2015-09-01 Thread Laura Creighton
In a message of Wed, 02 Sep 2015 00:57:45 +1000, Chris Angelico writes:
>On Wed, Sep 2, 2015 at 12:45 AM, Steven D'Aprano  wrote:
>> I assume the answer is "Yes", but is it safe to expect that
>> tempfile.mkstemp() will only create a file that doesn't already exist? I
>> presume that there's no chance of it over-writing an existing file (say,
>> due to a race-condition).
>
>It depends on OS support, but with that, yes, it is guaranteed to be
>safe; the file is opened with an exclusivity flag. Check your system's
>man pages for details, or here:
>
>http://linux.die.net/man/3/open
>
>O_EXCL|O_CREATE makes an "atomic file creation" operation which will
>fail if another process is doing the same thing. I'm not sure how
>mkstemp() handles that failure, but my guess/expectation is that it
>would pick a different file name and try again.
>
>ChrisA
>-- 
>https://mail.python.org/mailman/listinfo/python-list


I remember discussion on the mercurial mailing list about
somebody who had a problem with this in conjunction with a
virus scanner that really wanted to get in and do things
to the poor temp files.

see: https://selenic.com/pipermail/mercurial-devel/2009-February/010197.html

for a very, very long thread about it.

Apparantly, you can get windows to complain that you cannot create a
file because it already exists, and it doesn't go back and try this
again for you.

But at the time I found the discussion puzzling, as my thought
was 'why are these people using mkstemp directly, instead of
tempfile.NamedTemporaryFile which seems to be what they want.

But I found this thread looking for a different problem with a
mercurial repository that we had that was corrupted, a year or so
after the thread was written, so I didn't want to go back and ask them
about it _then_.

Then in the general excitement --"Your raid system is buggy!  It is
inserting sludge in your files!"  I forgot about this puzzlement.
Until now.

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


Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread eric



On Tue, Sep 1, 2015 at 12:20 PM, Marko Rauhamaa  
wrote:

Steven D'Aprano :

 I believe that Marko is wrong. It is not so easy to compile Python 
to
 machine language for real machines. That's why the compiler targets 
a

 virtual machine instead.


Somehow Guile manages it even though Scheme is at least as dynamic a
language as Python.


I'm wondering if any of the VM lessons learned with forth environments 
would help?


https://en.wikipedia.org/wiki/Threaded_code




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


Re: How to compare lists

2015-09-01 Thread Rustom Mody
On Tuesday, September 1, 2015 at 12:54:08 PM UTC+5:30, Jahn wrote:
> 1.
> How can I save 256 lists, each list has 32 values( hexadecimal numbers)
> 2.
> How to compare the saved lists with another 256 lists ( that are read online 
> and have the 
> same structure as the list one)?
> ( the first list must be saved in the  previous step)

To add to what the others have said/asked:

Many times programmers want sets but they are programmed(!!) to think "Lists!"
This can be because for example
>>> [1,2,3] == [2,1,3]
False
>>> {1,2,3} == {2,1,3}
True
>>> [1,2,3,3] == [1,2,3]
False
>>> {1,2,3,3} == {1,2,3}
True
>>> list(set([1,2,1,3,4,4,]))
[1, 2, 3, 4]

[Though theres no guarantee of the order of the last (that I know) ]

ie you may prefer sets to lists when order and/or repetition dont signify

> 
> E.g

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


[issue24978] Contributing to Python 2x and 3x Documentation. Translation to Russian.

2015-09-01 Thread Georg Brandl

Georg Brandl added the comment:

Someone will have to step up to manage this effort. The technical side is 
pretty much solved with sphinx-i18n.

I think this is something the PSF should sponsor. (I wrote a proposal to the 
board a while ago, but I couldn't find a candidate to do it.)

--
nosy: +georg.brandl

___
Python tracker 

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



[issue24975] Python 3.5 can't compile AST involving PEP 448 unpacking

2015-09-01 Thread Brett Cannon

Brett Cannon added the comment:

Do we not have a test that compiles the entire stdlib using the ast module? We 
used to have one for the old compiler package. If don't have such a test we 
should probably add it even if it requires a -u option.

--
nosy: +brett.cannon

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Guido van Rossum

Guido van Rossum added the comment:

If we don't reach an agreement we should fall back to Serhiy's (1) only.

Eugene: Without more motivation that sounds like very questionable 
functionality to want to add to modules. I don't have time to read the 
discussion that led up to this, but modules are *intentionally* dumb. We 
already have classes and instances.

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Mark Shannon

Mark Shannon added the comment:

I think Nathaniel and Eugene argument that you cannot replace the module in 
sys.modules safely in erroneous.

Immediately after the module is created by importlib it is inserted into 
sys.modules. The code object for the module is then executed.
At that point, when the module code starts executing, no code outside the 
module has executed since the module was created and the import lock is held so 
no other thread will be able to import the module.
Therefore the only code that can see the module object is the module's own code.

Given a custom subclass of module that overrides __getattr__ to fetch values 
from the original module's __dict__, then an instance of that class can be 
inserted into sys.modules before any imports or calls to code that would access 
sys.modules, and the substitution of the module can be done safely.

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Guido van Rossum

Guido van Rossum added the comment:

I don't think I told you to do it this way -- that message of mind sounded 
pretty noncommittal in all directions.

I do understand your predicament. Can you live with just a special case for 
modules? __class__ assignment is full of non-portable special cases already.

Given how close we are to the release we should tread with a lot of care here 
-- rolling back a diff is also a big liability.

Maybe the "right" solution is to allow __dict__ assignment for modules. But 
we're too close to the release to add that. Perhaps we can revisit the right 
way to do it for 3.6?

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Guido van Rossum

Guido van Rossum added the comment:

PS. I have very little time this week or next to review everything -- if we 
don't find a reasonable compromise it *will* be rolled back.

--

___
Python tracker 

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



[issue24980] Allow for providing 'on_new_thread' callback to 'concurrent.futures.ThreadPoolExecutor'

2015-09-01 Thread Eric Fried

Changes by Eric Fried :


--
nosy: +2uasimojo

___
Python tracker 

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



[issue24980] Allow for providing 'on_new_thread' callback to 'concurrent.futures.ThreadPoolExecutor'

2015-09-01 Thread Joshua Harlow

Joshua Harlow added the comment:

Initial possible patch.

--
keywords: +patch
type: enhancement -> 
Added file: http://bugs.python.org/file40318/add_future_callback.patch

___
Python tracker 

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



Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Chris Angelico
On Wed, Sep 2, 2015 at 2:20 AM, Marko Rauhamaa  wrote:
> In fact, the shebang notation turns any single .py file into such an
> executable. The problem is if you break your program into modules. Java,
> of course, solved a similar problem with .jar files (but still wouldn't
> jump over the final hurdle of making the .jar files executable).

The time machine strikes again! Python supports zip file execution,
which gives you the same benefit as a .jar file, plus you can slap on
a shebang and run the whole thing!

Anyone for some pyzza?

https://www.python.org/dev/peps/pep-0441/

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


Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Ian Kelly
On Mon, Aug 31, 2015 at 11:45 PM, Luca Menegotto
 wrote:
> Il 31/08/2015 19:48, Mahan Marwat ha scritto:
>
>> If it hasn't been considered all that useful, then why
>
>> the tools like cx_freeze, pytoexe are doing very hard!
>
> Well, I consider those tools useless at all!
> I appreciate Python because, taken one or two precautions, I can easily port
> my code from one OS to another with no pain.
> So, why should I loose this wonderful freedom?

You don't. You can still take your unbundled code and port it just as
easily as before.

What is gained from those tools is the ability to easily distribute
your code to (Windows) users who aren't knowledgable or interested in
maintaining a Python installation on their system. It's something that
you don't likely use unless you have a specific need to do that,
however.

At my previous job where IT had everybody on Windows, we published our
code with batch file launchers onto the internal file server and
maintained several Python installations there to run them with, rather
than maintain them on the systems of 200+ users plus lab computers.
With that setup we didn't require cx_freeze, but we used it in some
cases for better network performance (it's typically faster to
download one large file from the network than hundreds of small
files).
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: netcdf read

2015-09-01 Thread Chris Angelico
On Wed, Sep 2, 2015 at 3:23 AM,   wrote:
> I'm starting in the Python scripts. I run this script:
>
>
> import numpy as np
>
> import netCDF4
>
> f = netCDF4.Dataset('uwnd.mon.ltm.nc','r')
>
>
> f.variables
>
>
> and I had the message:
>
>
> netcdf4.py
> Traceback (most recent call last):
>   File "", line 1, in 
> NameError: name 'netcdf4' is not defined
>
>
> What can I do to solve this.

My crystal ball tells me you're probably running Windows.

On Windows, there's no difference between "netcdf4.py" and
"netCDF4.py", so when you ask Python to "import netCDF4", it finds
your program and imports that. To resolve this, just rename your
script to something else, and delete any "netcdf4.pyc" or related
files. Then try running it under the new name, and you should be fine.

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


Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Laura Creighton
>But are Guile programs small?  I the OP made a categorisation error,
>confusing correlation with causation.  (i.e. the presence of
>feathers makes a animal able to fly).

s/I the/I think the/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24934] django_v2 benchmark not working in Python 3.6

2015-09-01 Thread Brett Cannon

Brett Cannon added the comment:

I would still rather wait until Django 1.9.0 is officially released else we are 
benchmarking alpha code which doesn't seem worth it. With Python 3.6.0 not due 
out until about 15 months after 1.9.0 comes out I think going 3 months without 
a Django benchmark for 3.6 is acceptable.

--

___
Python tracker 

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



[issue24934] django_v2 benchmark not working in Python 3.6

2015-09-01 Thread Brett Cannon

Changes by Brett Cannon :


--
assignee:  -> brett.cannon

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The c0d25de5919e changeset consists of three parts:

1) Fixes a bug (disallow an assignment of incompatible __class__ that happens 
to have the same __basesize__).
2) Allows __class__ assignment for module type.
3) Allows __class__ assignment for other types, in particular non-heap builtin 
types.

I think we should keep (1) and disallow (3). (2) is questionable and I for 
disallowing it too (special cases aren't special enough to break the rules). It 
is too little time left to 3.5 release, we will have more time to discuss this 
for 3.6.

Nataniel's new patch without special casing ModuleType would be good to me.

--

___
Python tracker 

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



Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Laura Creighton
In a message of Tue, 01 Sep 2015 19:20:51 +0300, Marko Rauhamaa writes:
>Somehow Guile manages it even though Scheme is at least as dynamic a
>language as Python.

But are Guile programs small?  I the OP made a categorisation error,
confusing correlation with causation.  (i.e. the presence of
feathers makes a animal able to fly).

Laura

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


[issue24980] Allow for providing 'on_new_thread' callback to 'concurrent.futures.ThreadPoolExecutor'

2015-09-01 Thread Joshua Harlow

Changes by Joshua Harlow :


--
type:  -> enhancement

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Eugene Toder

Eugene Toder added the comment:

Guido: IIUC the general intention is to support @property and __getattr__ style 
hooks on the module level. Assigning to sys.modules[name] from the module 
itself is a bit too late -- there's already a global dict for this module, and 
no way to create a module from an existing dict, so you end up with two global 
namespaces which is annoying (but admittedly people live with that). One way 
around that is to set up import hooks, but this is also annoying, and leaks 
module implementation outside of its code.

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Guido van Rossum wrote:
> But first, why is it so important to assign the __class__ of a module?  It 
> seems somebody is trying to make modules into what they weren't meant to be.

Because you told me to do it this way on python-dev :-(

https://mail.python.org/pipermail/python-dev/2014-December/137430.html

The goal is to make it possible for projects (e.g. numpy) to safely issue a 
deprecation warning when people access certain module-level constants.

The reason this is difficult is that we have several almost-conflicting 
requirements:

1) we want to be able to override special methods like __getattr__ and __dir__ 
on modules. And it'd nice if we could have access to things like properties and 
__repr__ too.

2) we can't control the type used to originally construct the module, because 
the module object is constructed before the first line of our code is run.

3) we want sys.modules[our_module].__dict__ to always refer to the namespace 
where __init__.py is executing, for reasons described at the top of msg249446. 
This is not currently possible when replacing the module object in-place -- if 
you make a new module object, then now you have the old module's namespace and 
the new module's namespace, and are responsible for manually keeping them in 
sync. (This is not a case where "let's do more of those" applies ;-).)

Other solutions that were previously considered (in two threads on python-dev 
and python-ideas with 40+ messages each) include:

- tackling (1) directly by defining a new set of special-purpose hooks just for 
modules (e.g. make ModuleType.__getattr__ check for a special 
__module_getattr__ function in the module namespace and call it). This is what 
Marc-Andre is suggesting now (msg249473). OTOH it would be nice to re-use the 
existing class mechanism instead of reimplementing parts of it just for modules.

- tackling (2) directly via wacky stuff like preparsing the file to check for 
special markers that tell the import machinery what ModuleType subclass to 
instantiate before the module starts executing (similar to how __future__ 
imports work)

- tackling (3) by adding some new special machinery to module objects, like the 
ability to replace their __dict__ attribute. This is what Eugene Toder is 
suggesting now (msg249483).

The advantage of allowing __class__ assignment on ModuleType instances is that 
it solves all these problems by using an existing feature rather than adding 
any new ones.

(I also tried the strategy of switching ModuleType to just *be* a heap type and 
avoid all these issues, but unfortunately it turns out that this would have 
broken the stable ABI so I gave up on that.)

The diff from 3.4 to 3.5rc2+the attached patch consists of uncontroversial bug 
fixes, plus two lines of code in typeobject.c that cause module subtypes to be 
treated similarly to heap types with respect to __class__ assignment:

-if (!(newto->tp_flags & Py_TPFLAGS_HEAPTYPE) ||
-!(oldto->tp_flags & Py_TPFLAGS_HEAPTYPE)) {
+if (!(PyType_IsSubtype(newto, _Type) &&
+  PyType_IsSubtype(oldto, _Type)) &&
+(!(newto->tp_flags & Py_TPFLAGS_HEAPTYPE) ||
+ !(oldto->tp_flags & Py_TPFLAGS_HEAPTYPE))) {

These two lines of code solve an important user-facing issue for numpy, and are 
far simpler than any of the other proposed solutions. This approach was 
reviewed by python-dev, and has stood through the entire pre-release cycle so 
far without anyone producing a single argument yet for why it will cause any 
problem whatsoever.

I'm very sorry for introducing the bug with immutable types, and for not 
initially addressing it with the seriousness that it deserved. But that bug is 
fixed now, and unless someone can name an actual problem with the above two 
lines then I don't see why their association with a now-fixed bug is any reason 
to go rehash the entire discussion from scratch.

--

___
Python tracker 

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



[issue7175] Define a standard location and API for configuration files

2015-09-01 Thread Glyph Lefkowitz

Glyph Lefkowitz added the comment:

XDG_CONFIG_HOME is not generally set to anything; the default of ~/.config is 
usually fine. However, the point is that you _can_ set it to point at a 
different location.  The relevant specification is here:

http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

The biggest reason I strongly believe we should follow a specification is that 
Python is not the only software on the system.  If I am an ops person that has 
to deal with Python and Ruby and Java and C software all the time, *any* 
consistency is a big help.  We don't have to follow *this* specification, but 
we should follow *some* specification (although this specific one looks like a 
good one to me).  The Python community has no special expertise deciding on 
locations for configuration files, and so we should not be trying to invent a 
new and better place for them.

There are other advantages to following the XDG spec.  If we follow it 
correctly (and not, like Barry suggested, start adding random other directories 
like ~/.python), users can easily switch between configuration environments by 
switching the XDG environment variables (both XDG_CONFIG_DIRS and 
XDG_CONFIG_HOME), which would be a handy way of ignoring both user-specified 
config files _and_ system-specified ones, to get a pristine virtualenv-like 
separation between different config files.

Given that they are going to need to set these env vars anyway to redirect 
spec-compliant libraries that their application may be using, it would be nice 
to just have _one_ set of meta-configuration variables rather than one for 
Python and one for C and one for Ruby and so on.  Consider the fact that 
distutils respects "CFLAGS", and did not feel the need to invent 
"DISTUTILS_FLAGS_FOR_THE_C_COMPILER".

--

___
Python tracker 

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



[issue24971] os.environ.get() does not return the Environment Value in Linux

2015-09-01 Thread Francis Greaves

Francis Greaves added the comment:

Well since posting the last item it is now working correctly
Thank you for your help

--

___
Python tracker 

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



[issue24976] Arithmetic/precision bug when using floating-point numbers

2015-09-01 Thread Andrew

New submission from Andrew:

I just recently discovered this bug, but when adding or subtracting a number 
and a precision error occurs when using at least 1 floating-point number in the 
operation. For example, 1 - 0.98 should output 0.02, but instead outputs 
0..020018 (at least on my machine).

Included is a simple script showing what happens, just when incrementing or 
decrementing by 0.01 from 0 to 1.

I am running Python 3.4.3 on a 64-bit Arch Linux machine.

--
components: Interpreter Core
files: weirdpythonbug.py
messages: 249458
nosy: videogames4all
priority: normal
severity: normal
status: open
title: Arithmetic/precision bug when using floating-point numbers
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file40313/weirdpythonbug.py

___
Python tracker 

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



[issue24968] Python 3 raises Unicode errors with the xxx.UTF-8 locale

2015-09-01 Thread Roberto Sánchez

Roberto Sánchez added the comment:

Ok, that makes sense, besides David pointed me about another opened issue that 
could help to solve cases like this: http://bugs.python.org/issue15216 If the 
encoding is wrong because the environment but we can change the initial stream 
encodings (in stdin/out) easily we have a powerful tool to adapt our scripts 
and patch broken locales like the generated with SSH sessions.

--

___
Python tracker 

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



Re: How to compare lists

2015-09-01 Thread Peter Otten
Jahn wrote:

> 1.
> How can I save 256 lists, each list has 32 values( hexadecimal numbers)
> 2.
> How to compare the saved lists with another 256 lists ( that are read
> online and have the same structure as the list one)?
> ( the first list must be saved in the  previous step)

You are giving details, but they aren't significant. You can save 256 lists 
with 32 numbers just like you would save 257 or 2560 with 23 numbers. How 
you should save them is largely dependent on how you are using them later. 
Simple methods are pickle.dump() or json.dump().

But what is the problem you are trying to solve by comparing these lists? 
Are you just looking online for lists matching the local ones? Do you want 
to find missing/extra lists? Or are you even looking for changes within the 
lists? 

How are the online lists provided? Are they text files, is there an API, or 
do you have to screenscrape them from web pages?

Please provide a little more context.

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


[issue7175] Define a standard location and API for configuration files

2015-09-01 Thread flying sheep

flying sheep added the comment:

no, sorry, but ~/.python is wrong on linux.

there exists a standard about where things belong:

http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html

it says that configuration stuff belongs into `XDG_CONFIG_HOME`, with a 
fallback to `~/.config/`

i propose to add the `appdirs` module to the stdlib so that programs finally 
don’t have to guess and hack around this kind of things.

https://pypi.python.org/pypi/appdirs

--
nosy: +flying sheep

___
Python tracker 

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



[issue24971] os.environ.get() does not return the Environment Value in Linux

2015-09-01 Thread Francis Greaves

Francis Greaves added the comment:

OK, David, so what have I done wrong to not export it correctly?
in my .bashrc I have this
export XRIT_DECOMPRESS_PATH="/usr/local/bin/xRITDecompress"
so I would expect it to work.
Can you please clarify?
Many thanks

--

___
Python tracker 

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



Re: How to compare lists

2015-09-01 Thread Chris Angelico
On Tue, Sep 1, 2015 at 3:08 PM, Jahn  wrote:
> 1.
> How can I save 256 lists, each list has 32 values( hexadecimal numbers)
> 2.
> How to compare the saved lists with another 256 lists ( that are read online 
> and have the
> same structure as the list one)?
> ( the first list must be saved in the  previous step)
>
> E.g

You seem to have missed out your example, but I'll guess at what
you're talking about. Correct me if I'm wrong, and we'll move on from
there.

You want to take a sequence of 32 numbers and see if it's exactly the
same sequence as some others. The easiest way to do this is with a
tuple, rather than a list; then you can simply do an equality check,
and they'll be checked recursively. If you want to ask, more simply,
"does this 32-value unit exist in my collection of 256 acceptable
32-value units", then a set will serve you well. You can stuff tuples
of integers into your set, and then query the set for a particular
tuple.

Does that help at all? If not, guide me to the problem you're actually
solving. :)

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


[issue24934] django_v2 benchmark not working in Python 3.6

2015-09-01 Thread Berker Peksag

Berker Peksag added the comment:

I just downloaded Django-1.8.zip (florin.papa, 2015-08-27 11:49) and opened 
Django-1.8/django/__init__.py to check the Django version:

VERSION = (1, 9, 0, 'alpha', 0)

I think GitHub lets you download the master branch by default. I'd suggest to 
download the source release of Django 1.8.4 at 
https://pypi.python.org/pypi/Django/1.8.4

--
nosy: +berker.peksag

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Doh, apparently I did once know about issue23726 and then forgot. Good catch.

Technically we could add a __class__ field to ModuleType directly, but I think 
then the ModuleType __class__ setter would basically need to be an exact 
reimplementation of everything that object_set_class already does? (Since it 
would still need to check that this particular ModuleType subclass was 
layout-compatible etc. -- e.g. no new __slots__.) And the end result would 
behave identically to the patch I just posted, except we'd replace a 2 line 
check in typeobject.c with some really complicated and bug-prone code in 
moduleobject.c? I don't think it buys us anything.

--

___
Python tracker 

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



[issue24976] Arithmetic/precision bug when using floating-point numbers

2015-09-01 Thread Ezio Melotti

Ezio Melotti added the comment:

Thanks for the report, however this is not a Python bug.
See: https://docs.python.org/3/tutorial/floatingpoint.html

--
nosy: +ezio.melotti
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



Re: Extra AttributeError inside property - possible bug ?

2015-09-01 Thread Peter Otten
dunric...@gmail.com wrote:

> Hello,
> 
> bellow is a simple Python2 example of a class which defines __getattr__
> method and a property, where AttributeError exception is raised:
> 
> from __future__ import print_function
> 
> class MyClass(object):
> def __getattr__(self, name):
> print('__getattr__ <<', name)
> raise AttributeError(name)
> return 'need know the question'
> 
> @property
> def myproperty(self):
> print(self.missing_attribute)
> return 42
> 
> my_inst = MyClass()
> print(my_inst.myproperty)
> 
> # produces following output
> __getattr__ << missing_attribute
> __getattr__ << myproperty
> Traceback (most recent call last):
>   File "a.py", line 84, in 
> main()
>   File "a.py", line 74, in main
> print('==', my_inst.myproperty)
>   File "a.py", line 36, in __getattr__
> raise AttributeError(name)
> AttributeError: myproperty
> 
> 
> By the documentation
> https://docs.python.org/2/reference/datamodel.html#object.__getattr__ , if
> class defines __getattr__ method, it gets called at AttributeError
> exception and should return a computed value for name, or raise (new)
> AttributeError exception.
> 
> Why is __getattr__ called 2nd time, with 'myproperty' argument ?!?
> self.myproperty does exist and also at first call of __getattr__ new
> AttributeException with 'missing_attribute' is raised. I can't see any
> reason for this behavior.

I believe this is an implementation accident, the code is not keeping track 
of the exact origin of the AttributeError. Until recently generators showed 
analogous behaviour and swallowed StopIterations:

$ cat stopiteration.py
from __future__ import generator_stop

def stop():
raise StopIteration


def f(items):
for item in items:
yield item
stop()


for item in f("abc"):
print(item)
$ python3.5 -x stopiteration.py # abusing -x to skip the __future__ import
a
$ python3.5 stopiteration.py
a
Traceback (most recent call last):
  File "stopiteration.py", line 10, in f
stop()
  File "stopiteration.py", line 4, in stop
raise StopIteration
StopIteration

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "stopiteration.py", line 13, in 
for item in f("abc"):
RuntimeError: generator raised StopIteration

If the AttributeError behaviour were to be changed a similar transition 
period would be required, so no Python prior to 3.6 would be affected.

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


[issue24966] shutil.get_terminal_size() throws ValueError if stdout is detached, no fallback

2015-09-01 Thread Roberto Sánchez

Roberto Sánchez added the comment:

Yeah, sorry, actually I was thinking in the stdin/out section, the detach() doc 
itself is Ok, the problem comes when is called in stdin/out.

--

___
Python tracker 

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



How to compare lists

2015-09-01 Thread Jahn


1.
How can I save 256 lists, each list has 32 values( hexadecimal numbers)
2.
How to compare the saved lists with another 256 lists ( that are read online 
and have the 
same structure as the list one)?
( the first list must be saved in the  previous step)

E.g


Thanks

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


[issue23517] datetime.utcfromtimestamp rounds results incorrectly

2015-09-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset abeb625b20c2 by Victor Stinner in branch 'default':
Issue #23517: Add "half up" rounding mode to the _PyTime API
https://hg.python.org/cpython/rev/abeb625b20c2

--
nosy: +python-dev

___
Python tracker 

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



[issue23517] datetime.utcfromtimestamp rounds results incorrectly

2015-09-01 Thread STINNER Victor

STINNER Victor added the comment:

Ok, I fixed the issue in Python 3.6. Example with the initial message:

$ python2.7 -c 'import datetime; 
print(datetime.datetime.utcfromtimestamp(1424817268.274).microsecond); 
print(datetime.datetime.utcfromtimestamp(-1424817268.274).microsecond)'
274000
726000

$ python3.6 -c 'import datetime; 
print(datetime.datetime.utcfromtimestamp(1424817268.274).microsecond); 
print(datetime.datetime.utcfromtimestamp(-1424817268.274).microsecond)'
274000
726000

I wrote:
"On Python < 3.3, datetime.datetime.fromtimestamp(float) doesn't use exactly 
ROUND_HALF_EVEN, but it looks more to "round half away from zero" (the decimal 
module doesn't seem to support this exact rounding method)."

I was wrong: it's decimal.ROUND_HALF_UP in fact.

I will backport the change to Python 3.4 and 3.5. Since this issue was defined 
as a bugfix, it should be fixed in Python 3.5.1 (too late for 3.5.0).

--

___
Python tracker 

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



Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Chris Angelico
On Wed, Sep 2, 2015 at 6:08 AM, Marko Rauhamaa  wrote:
> Laura Creighton :
>
>> But are Guile programs small?
>
> They can be tiny because libguile-2.0.so, the interpreter, is a dynamic
> library and is installed on the computer. It's barely different from how
> compiled C programs can be a few kilobytes in size because libc.so is
> dynamic.

And compiled C programs are notoriously hard to distribute. Can you
pick up a Guile binary and carry it to another computer? Do you have
to absolutely perfectly match the libguile version, architecture,
build settings, etc?

Also... how is this different from distributing .pyc files and
expecting people to have a Python interpreter?

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


Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Steven D'Aprano
On Wed, 2 Sep 2015 02:20 am, Marko Rauhamaa wrote:

> Steven D'Aprano :
> 
>> I believe that Marko is wrong. It is not so easy to compile Python to
>> machine language for real machines. That's why the compiler targets a
>> virtual machine instead.
> 
> Somehow Guile manages it even though Scheme is at least as dynamic a
> language as Python.

It's not about the dynamicism precisely, it's about what counts as primitive
data types and operations.

What are the primitives in Scheme? In Python, the primitives are pretty
complex. I don't know how accurate this page is:

https://en.wikibooks.org/wiki/Scheme_Programming/Scheme_Datatypes

but it suggests that Scheme primitives are quite close to the machine. That
may keep the runtime small.


> I never said a compiler would translate Python to (analogous) machine
> language. I said you could easily turn CPython into a dynamic library
> (run-time environment) and write a small bootstrapper that you package
> into an executable archive with the Python code (whether .py or .pyc).
> What results is a single executable that you can run analogously to any
> other command.

Provided you have the correct version of the dynamic library installed in
the correct place. 

But this doesn't solve the problem of being able to distribute a single
executable file that requires no pre-installed libraries, which is the
problem cx_freeze and pytoexe are made to solve. They solve the case when
you can't assume that there is a Python run-time environment available.

If you are going to require a Python run-time environment, let's call
it "pylib", then you might as well require the python compiler and standard
library be installed. (In the case of C, that's not the case, a distinct
run-time environment makes sense, as the compile-time and run-time
environments are sharply delineated in C. One certainly wouldn't want to
have to re-compile the average C application each and every time you run
it.)

Maybe you could separate the REPL and remove it from pylib, but that's
probably quite small, it might not make that much of a difference to the
total size.

Maybe you could build a pylib that was significantly smaller than the Python
interpreter plus stdlib. That's fine, I'm not arguing it can't be done. I'm
arguing that it's not *easy*, if it were easy somebody likely would have
done it by now.

I don't know the state of the art here. Does Cython work in this space? How
about Nuitka?


> In fact, the shebang notation turns any single .py file into such an
> executable.

I trust that you're not actually arguing that distributing .py files meets
the requirement for a standalone application.


> The problem is if you break your program into modules. Java, 
> of course, solved a similar problem with .jar files (but still wouldn't
> jump over the final hurdle of making the .jar files executable).

You can distribute your Python app as a zip file, except of course you still
need the Python interpreter to be installed.



-- 
Steven

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


[issue17849] Missing size argument in readline() method for httplib's class LineAndFileWrapper

2015-09-01 Thread Martin Panter

Martin Panter added the comment:

Left some review comments. But I don’t completely understand the test case. Is 
it true there are proxies that do not send a HTTP status line (like HTTP/1.0 
200 Connection Established), but do sned the rest of the HTTP header section? 
This is what the test case seems to be modelling:

Client to proxy request:
b"CONNECT foo:80 HTTP/1.0\r\n"
b"\r\n"

Proxy (plus tunnelled?) response, minus a status line:
b"X-Foo: bar\r\n"
b"\r\n"
b"hello world"

It seems more likely that the proxies related to this bug are misbehaving, or 
there is some other network problem. Of the proxies mentioned in this report 
that are accessible to me, both of them do not appear to accept CONNECT 
requests at all. As soon as the first CONNECT line is send, a HTML blob saying 
“400 Bad Request” is received, without any HTTP header at all.

--
nosy: +martin.panter

___
Python tracker 

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



[issue23517] datetime.utcfromtimestamp rounds results incorrectly

2015-09-01 Thread Larry Hastings

Larry Hastings added the comment:

> too late for 3.5.0

How's that?

--

___
Python tracker 

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



[issue23517] datetime.utcfromtimestamp rounds results incorrectly

2015-09-01 Thread Roundup Robot

Roundup Robot added the comment:

New changeset b690bf218702 by Victor Stinner in branch 'default':
Issue #23517: datetime.datetime.fromtimestamp() and
https://hg.python.org/cpython/rev/b690bf218702

--

___
Python tracker 

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



[issue17849] Missing size argument in readline() method for httplib's class LineAndFileWrapper

2015-09-01 Thread Martin Panter

Martin Panter added the comment:

A test case with data like this would make more sense to me:

# Response without HTTP status line or header, modelling responses sent by
# some proxies that do not support CONNECT
body = b"400 Bad Request"

--

___
Python tracker 

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



[issue24982] shutil.make_archive doesn't archive empty directories

2015-09-01 Thread Eugene Kolo

New submission from Eugene Kolo:

Zip file is sometimes known to only contain files and the paths to them, but it 
can also have have empty folders, they are zero length files with a flag set.

make_archive just ignores empty directories, I propose that there should either 
be a flag, or it should include empty directories by default.

--
components: Library (Lib)
messages: 249522
nosy: eugenek
priority: normal
severity: normal
status: open
title: shutil.make_archive doesn't archive empty directories
type: behavior
versions: Python 2.7

___
Python tracker 

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



Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Cameron Simpson

On 02Sep2015 08:01, Cameron Simpson  wrote:

One circumstance where you might use fdopen and _not_ want .close to close the 
underlying service is when you're handed a file descriptor over which you're 
supposed to perform some I/O, and the I/O library functions use high level 
files. In that case you might want code like this:

fd2 = os.dup(fd)
fp = open(fd2, 'a+b') # or whatever mode
... do stuff, perhaps passing fp to a library function ...
fp.close()

fd2 is not closed, but fd is still open for further use.


Um, "fd2 _is_ closed". Whoops.

Cheers,
Cameron Simpson 

Freedom is the right to be wrong, not the right to do wrong.
- John G. Riefenbaker
--
https://mail.python.org/mailman/listinfo/python-list


[issue24975] Python 3.5 can't compile AST involving PEP 448 unpacking

2015-09-01 Thread Brett Cannon

Brett Cannon added the comment:

Created issue #24981 to track the test case idea.

--

___
Python tracker 

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



[issue24981] Add a test which uses the ast module to compile the stdlib

2015-09-01 Thread Brett Cannon

New submission from Brett Cannon:

Issue #24975 shows that we can easily end up with holes in support from the ast 
module. We should probably make sure we have a test that goes through the 
entire stdlib, Does an ast.parse(), and then passes the result to compile() to 
verify no exceptions are raised. We should either avoid the test/ directory or 
blacklist specific files which will fail because they are designed to be 
syntactically incorrect. The test can also be behind a -u flag if it turns out 
to be an expensive test.

--
components: Tests
messages: 249516
nosy: brett.cannon
priority: normal
severity: normal
stage: test needed
status: open
title: Add a test which uses the ast module to compile the stdlib
versions: Python 3.6

___
Python tracker 

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



Re: netcdf read

2015-09-01 Thread Jason Swails
On Tue, Sep 1, 2015 at 2:07 PM, Chris Angelico  wrote:

> On Wed, Sep 2, 2015 at 3:23 AM,   wrote:
> > I'm starting in the Python scripts. I run this script:
> >
> >
> > import numpy as np
> >
> > import netCDF4
> >
> > f = netCDF4.Dataset('uwnd.mon.ltm.nc','r')
> >
> >
> > f.variables
> >
> >
> > and I had the message:
> >
> >
> > netcdf4.py
> > Traceback (most recent call last):
> >   File "", line 1, in 
> > NameError: name 'netcdf4' is not defined
> >
> >
> > What can I do to solve this.
>
> My crystal ball tells me you're probably running Windows.
>

​Or Mac OS X.  Unless you go out of your way to specify otherwise, the
default OS X filesystem is case-insensitive.

All the best,
Jason
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24891] race condition in initstdio() (python aborts running under nohup)

2015-09-01 Thread Yi Ding

Yi Ding added the comment:

I'm not sure this is a race condition. There's a crash every single time python 
is started when running the test.sh script under nohup.

If it's a race condition, it should only happen some of the time, not every 
single time.

Can you reeevaluate the priority?

--

___
Python tracker 

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



Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Marko Rauhamaa
Laura Creighton :

> But are Guile programs small?

They can be tiny because libguile-2.0.so, the interpreter, is a dynamic
library and is installed on the computer. It's barely different from how
compiled C programs can be a few kilobytes in size because libc.so is
dynamic.

Emacs is a lisp interpreter. As part of its installation, emacs dumps
core, and the executable core file is installed as the editor we know
and love. That way, the most useful lisp modules are already preloaded
in the binary, executable image of the editor.

On my machine, the emacs executable is 15 megabytes in size.


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


[issue24975] Python 3.5 can't compile AST involving PEP 448 unpacking

2015-09-01 Thread Yury Selivanov

Yury Selivanov added the comment:

Larry,

I created a PR for you: 
https://bitbucket.org/larry/cpython350/pull-requests/10/issue-24975-fix-ast-compilation-for-pep/diff

Brett,

Should we do that in a separate issue targeting 3.6 only?

--

___
Python tracker 

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



[issue24981] Add a test which uses the ast module to compile the stdlib

2015-09-01 Thread Yury Selivanov

Changes by Yury Selivanov :


--
nosy: +yselivanov

___
Python tracker 

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



Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Grant Edwards
On 2015-09-01, Laura Creighton  wrote:

> Don't go around closing things you don't know are open.  They
> could be some other processes' thing.

I don't understand.  Closing a file descriptor that isn't open is
harmless, isn't it?  Closing one that _is_ open only affects the
current process.  If other processes had the same fd open, it's still
open for them.

-- 
Grant Edwards   grant.b.edwardsYow! FUN is never having to
  at   say you're SUSHI!!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Low level file descriptors and high-level Python files

2015-09-01 Thread Cameron Simpson

On 01Sep2015 11:56, random...@fastmail.us  wrote:

On Tue, Sep 1, 2015, at 10:57, Steven D'Aprano wrote:

Q3:  I could probably answer Q2 myself if I knew how to check whether a
fd
was open or not. With a file object, I can inspect file_obj.closed and it
will tell me whether the file is open or not. Is there an equivalent for
file descriptors?


Well, if you try to call os.close, or any other operation for that
matter, it will raise an OSError with errno=EBADF.


os.fstat might be safer. It won't have side effects.

As additional remarks:

Underwhat circumstances would you imagine probing an fd like this? For what 
purpose? It feels like a code smell for know having enough situational 
awareness, and then you're into guesswork world.


One circumstance where you might use fdopen and _not_ want .close to close the 
underlying service is when you're handed a file descriptor over which you're 
supposed to perform some I/O, and the I/O library functions use high level 
files. In that case you might want code like this:


 fd2 = os.dup(fd)
 fp = open(fd2, 'a+b') # or whatever mode
 ... do stuff, perhaps passing fp to a library function ...
 fp.close()

fd2 is not closed, but fd is still open for further use.

Cheers,
Cameron Simpson 

This is not a bug. It's just the way it works, and makes perfect sense.
   - Tom Christiansen 
I like that line. I hope my boss falls for it.
   - Chaim Frenkel 
--
https://mail.python.org/mailman/listinfo/python-list


[issue24929] _strptime.TimeRE should not enforce range in regex

2015-09-01 Thread Steve Yeung

Steve Yeung added the comment:

I'm not sure what format I'm supposed to provide the test in. I attached a file 
that has the diff of the changes I made, and how the error message is changed 
(and improved!) in both datetime and time.

--
Added file: http://bugs.python.org/file40319/file

___
Python tracker 

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



Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Laura Creighton
If I understand what you are saying, then I think what you are
looking for is not a compiler, but docker.
see: https://www.docker.com/
in particular https://www.docker.com/whatisdocker

PyPy used this to produce portable PyPy binaries.  See:
https://github.com/squeaky-pl/portable-pypy/blob/master/README.rst

Why did we need to make portable PyPy binaries?

>From the PyPy downloads page:

Linux binaries and common distributions

Linux binaries are dynamically linked, as is usual, and thus might
not be usable due to the sad story of linux binary
compatibility. This means that Linux binaries are only usable on
the distributions where they were created unless you're ready to hack
your system by adding symlinks to the libraries it tries to open.

We had to make versions for debian stable and unstable, and all the
different versions of RHEL, and Centos, and Suse and  every time
we turned around somebody made a new linux distribution, with new and
different versions of shared libraries, located in some new creative
idea of where the best place was to put such things.  And we had to make 32
bit and 64 bit versions, and versions for x86 and for ARM and the list
went on, and on, and on.  This made releases far harder than they
needed to be, and, from the user end meant that people had to work
rather hard just to figure out what version of pypy they should
download from our site.   Lots of people never could quite figure
it out, though we tried to help them on the pypy mailing list and
over irc ...

So finally, we used docker to make a portable version of pypy, which
you can use to biuld your own version of pypy from the nightly
sources, for instance.

I think that this is what you are looking for, as well.  But go read
up on docker and see if it suits.

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


Re: How to compare lists

2015-09-01 Thread Laura Creighton
In a message of Tue, 01 Sep 2015 07:08:48 +0200, "Jahn" writes:
>1.
>How can I save 256 lists, each list has 32 values( hexadecimal numbers)
>2.
>How to compare the saved lists with another 256 lists ( that are read online 
>and have the 
>same structure as the list one)?
>( the first list must be saved in the  previous step)

'Saving' can mean many things, depending on context. You can save a
reference to your list which will last as long as that reference is
in scope in your program.  If you only need to save it for as
long as it takes you to read in another value, also done in the
same scope of your program, this will be fine.

If, on the other hand you want to get your next values you want
to compare things to, by running a program, either this one or
a different one, tomorrow, next week, then you will probably want
to save your list in a file somewhere.

And if you want to save it in a way that you won't lose the data,
even if your disk drive breaks, your house burns down and all your
posessions are destroyed ... then you probably want to save it
in the cloud someplace -- and make sure that the data is mirrored
because data centres burn down, on occasion, as well.

So that is the first problem.  'What do you mean by save?'  which
is related to 'How and when are you getting these lists, anyway?'
The next problem is similar.  'What do you mean by same?'

Here is a list:  ['Anders', 'Sigbritt', 'Eva']
and here is another list: ['Eva', 'Sigbritt', 'Anders']

They aren't equal.  But are they 'the same'?  This isn't a
programming question, but a question of 'How is your problem
defined?'  You need to know the answer to this before you can
write your code, which may mean asking the problem giver
to clarify what he or she meant by 'same'.

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


[issue24912] The type of cached objects is mutable

2015-09-01 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

FWIW: I still think that allowing to change .__class__ on instances of static 
types if wrong and should be undone. If we want to make this a feature of the 
language we should have a PEP and the associated discussion to be able to judge 
and document the possible consequences of such a change. This ticket is the 
wrong place for such a discussion.

Regarding you module object change: Why don't you propose a change on the 
object itself instead of trying to monkey patch it via a mod.__class__ 
replacement ? E.g. by defining a hook in the object to set which then permits 
whatever modification you'd like to make.

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 01.09.2015 04:38, Nathaniel Smith wrote:
> Mark Lemburg wrote:
>> Python code will generally assume that it can trust
>> builtin types. It doesn't expect 42 + 2 to clear out the root dir,
>> just because some package installed from PyPI happens to feel in the
>> mood for Easter eggs :-)
> 
> The only reason that'd be possible though is because you went and ran some 
> untrusted code with permissions allowing it to clear out the root dir -- the 
> only way to set up this "exploit" is to run untrusted Python code. Basically 
> you've handed someone a gun, and now you're worried because this patch gives 
> them a new and particularly rube-goldbergian method for pulling the trigger...

I think you're being overly optimistic here. People run unchecked and
unverified code all the time; that's not the same as untrusted, since
trust develops with time and doesn't get reset with each new package
release.

Regardless, the above was only an example. The much more likely thing
to happen is that some code replaces the .__class__ of some unrelated
object by accident via a bug and causes all hell to break loose.

> Except it isn't even a new method; your nasty PyPI package can trivially 
> implement this "easter egg" using only fully-supported features from the 
> stdlib, in any version of Python since 2.5. Here's some nice portable code to 
> do __class__ assignment while dodging *all* the checks in object_set_class:
> 
>   from ctypes import *
>   def set_class(obj, new_class):
>   ob_type_offset = object.__basicsize__ - sizeof(c_void_p)
>   c_void_p.from_address(id(obj) + ob_type_offset).value = id(new_class)
> 
> I mean, obviously ctypes is nasty and breaks the rules, I'm not saying this 
> justifies making __class__ assignment broken as well. But this bug is no more 
> a *security* problem than the existence of ctypes is.

You can disable ctypes easily. OTOH, your patch is inherently changing the
language and making it less secure. There's no way to disable it or
even prevent using it from inside Python. IMO, that's a huge difference.

I also believe that the overall approach is wrong: if you want to add a
feature to Python module objects, please stick to those instead of
changing the overall interpreter semantics.

Some more background:

Replacing .__class__ of class instances is a known and useful Python
feature. However, in the past this was only possible for regular instances,
not for types. With new style classes, this differentiation got
blurred and in Python 3 we only have new style classes, so it may look
like we always wanted this feature to be available. Yet, I'm not sure
whether this was ever intended, or a conscious design decision and
because it creates serious problems for the interpreter, it
definitely needs go through a PEP process first to make everyone
aware of the consequences.

--

___
Python tracker 

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



Re: RPI.GPIO Help

2015-09-01 Thread Johannes Bauer
On 31.08.2015 19:41, John McKenzie wrote:

>  Still checking here and am discussing all this in the Raspberry pi 
> newsgroup. Thanks to the several people who mentioned it.
> 
>  Again, still listening here if anyone has any more to add.

I've had the problem to use interrupt-driven GPIOs on the Pi about two
years back. Here's how I solved it:

http://pastebin.com/gdJaJByU

To explain the message you're getting: If you want to handle GPIOs in
the most resource-efficient way, you use interrupt-driven handling.
Interrupts for GPIOs can be configured to be off, level-triggered or
edge-triggered. For edge-triggering I'm also pretty sure that the type
of edge (rising, falling, both) can be specified.

IIRC (and I might not, been quite some time), these interrupts are
bundled together in GPIO ports ("channels"). All GPIOs in one channel
need to have the same configuration. You cannot have conflicing
configuration between two pins which belong to the same GPIO (and
apparently, your framework is trying to do it).

The code I posted does it all by hand (and it's not really hard, as you
can see). I used input and output functionality and do the interrupt
configuration myself (this works through the /proc filesystem on the Pi).

Hope this helps,
Cheers,
Johannes

-- 
>> Wo hattest Du das Beben nochmal GENAU vorhergesagt?
> Zumindest nicht öffentlich!
Ah, der neueste und bis heute genialste Streich unsere großen
Kosmologen: Die Geheim-Vorhersage.
 - Karl Kaos über Rüdiger Thomas in dsa 
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How to compare lists

2015-09-01 Thread jmp

On 09/01/2015 07:08 AM, Jahn wrote:



1.
How can I save 256 lists, each list has 32 values( hexadecimal numbers)
2.
How to compare the saved lists with another 256 lists ( that are read online 
and have the
same structure as the list one)?
( the first list must be saved in the  previous step)

E.g


Thanks



Dumb down your problem to something simpler.

saving 2 lists of 2 numbers.

1/ for saving/loading the list, use pickle if *you* will do the saving 
*and* the loading (don't load from an untrusted file)


2/ To compare 2 lists, simply use the == operator

In [4]: [[1,2], [1,2]] == [[1,2], [1,3]]
Out[4]: False

In [5]: [[1,2], [1,2]] == [[1,2], [1,2]]
Out[5]: True

JM

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


[issue24946] Tkinter tests that fail on linux in tiling window manager

2015-09-01 Thread Florian Bruhin

Florian Bruhin added the comment:

At least with my WM, there is no concept of having floating windows when in 
tiling mode, so I don't think that would be possible.

I also don't think there's a standard way to tell a window manager to not tile 
windows.

What about opening a simple window with a fixed geometry, checking if this was 
changed by the WM, and if it is, skip those tests?

--
nosy: +The Compiler

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> From where I sit this all looks like a massive
> overreaction/misunderstanding: I introduced a bug, the cause is
> obvious, and it's straightforward to fix.

I agree with Nathaniel here. Let's just commit the fix instead of acting like 
irrational beings.

--

___
Python tracker 

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



[issue24829] Use interactive input even if stdout is redirected

2015-09-01 Thread Adam Bartoš

Adam Bartoš added the comment:

How about reconsidering in the case that the machinery around PyOS_Readline is 
rewritten as I suggest in #17620 ?

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Guido, do you have any thoughts on this?

Several of us (me included) think http://hg.python.org/lookup/c0d25de5919e 
probably should not have been done.  Mutating non-heap types crosses an 
implicit boundary that we've long resisted crossing because it opens a can 
worms and has potential to violate our expectations about how the language 
works.

[Mark Shannon]
> Breaking the interpreter in order to facilitate some obscure use case is 
> unacceptable.

[Marc-Andre Lemburg]
I agree with Mark. This feature opens up a security hole large enough to drive 
a train through.

[Benjamin Peterson]
Probably the patch on that bug should be reverted.
  
[Larry Hastings]
As Python 3.5 Release Manager, my official statement is: Eek!

--
assignee:  -> Guido.van.Rossum
nosy: +Guido.van.Rossum, rhettinger

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2015-09-01 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Thanks Raymond. Hi Guido. Sorry about the mess.

My overview of the situation so far, and of the patch currently attached to 
this bug, is here (and a bit in the next post):
  https://bugs.python.org/issue24912#msg249438

>From where I sit this all looks like a massive overreaction/misunderstanding: 
>I introduced a bug, the cause is obvious, and it's straightforward to fix. If 
>we want to fix the bug in the most general manner then that's straightforward 
>but probably more work than we want to do in rc3. If we want to just apply a 
>conservative fix and move on then we have an 8 line patch attached to this bug 
>that does that. Even if we don't apply the patch then there's no security 
>hole, that's just factually incorrect. But it doesn't even matter, because 
>again, we have a patch. If we do apply this patch, then literally the only 
>outcome of all of this will be that __class__ assignment in 3.5 will be (1) 
>less buggy in general, and (2) be allowed, safely, on instances of ModuleType 
>subclasses. I get that the whole concept of __class__ assignment is kinda 
>freaky and unnerving, but I do not understand why some people are insisting 
>that the above needs a PEP...

You know, in fact, note to everyone: I hereby withdraw any suggestion that we 
might want to "fix" the __class__ assignment code to handle the general case 
beyond ModuleType. Obviously this is super controversial and distracting for 
reasons I don't really understand, but I don't have to -- the only reason to 
brought it up in the first place is out of a vague desire to make Python 
"better", and frankly all I care about at this point is that I don't want to 
wait another 2 years before I can safely deprecate module-level constants. So 
let's just apply the attached patch and move on? Nothing broken, no security 
hole, nothing to eek about.

--

___
Python tracker 

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



[issue24946] Tkinter tests that fail on linux in tiling window manager

2015-09-01 Thread Florian Bruhin

Changes by Florian Bruhin :


--
nosy:  -The-Compiler

___
Python tracker 

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



[issue24934] django_v2 benchmark not working in Python 3.6

2015-09-01 Thread Florin Papa

Florin Papa added the comment:

Please download Django from their github website: 
https://github.com/django/django

I checked and their latest stable release - Django 1.8.4 - from 
https://pypi.python.org/pypi/Django still has the getargspec issue.

Apparently the github version is 1.9.0 alpha. I have modified the patch and 
archive accordingly.

--
Added file: http://bugs.python.org/file40314/django_v3.patch

___
Python tracker 

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



[issue24934] django_v2 benchmark not working in Python 3.6

2015-09-01 Thread Florin Papa

Changes by Florin Papa :


Added file: http://bugs.python.org/file40315/Django-1.9.zip

___
Python tracker 

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



[issue24978] Contributing to Python 2x and 3x Documentation. Translation to Russian.

2015-09-01 Thread Eugene

New submission from Eugene:

I am very much begging pardon if this is not the place to ask for, but..

I would like to make a thorough translation of the official Library Reference 
and the beginners guide to Python 2.x 3.x in Russian language.

I am aware this type of translation will be placed at
https://wiki.python.org/moin/RussianLanguage
as current https://docs.python.org/2/ does not allow changing language.

I am pretty much aware the translation should not sound any differently from 
the original in terms of its style, form and overall attitude. And I would also 
like to know, if possible, can this link be promoted somewhere at python.org. I 
am not in the slightest have the intentions of promoting in anywhere but in the 
place where most russian programmers could most definitely find it - at the 
oficial Python website.

Kind regards, Evgeniy.

--
assignee: docs@python
components: Documentation
messages: 249478
nosy: docs@python, overr1de
priority: normal
severity: normal
status: open
title: Contributing to Python 2x and 3x Documentation. Translation to Russian.
type: enhancement
versions: Python 2.7

___
Python tracker 

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



[issue24977] shutil copy to non-existant directory

2015-09-01 Thread Jake Howard

New submission from Jake Howard:

If you try and copy a file using shutil.copy to a directory that doesnt exist, 
it tries to copy the file to the location of the directory, and errors as 
shutil can't open a directory for 'WB' access, throwing an error, that doesnt 
reflect the problem.

--
messages: 249474
nosy: TheOrangeOne
priority: normal
severity: normal
status: open
title: shutil copy to non-existant directory
type: behavior

___
Python tracker 

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



Re: How to compare lists

2015-09-01 Thread Denis McMahon
On Tue, 01 Sep 2015 07:08:48 +0200, Jahn wrote:

> 1.
> How can I save 256 lists, each list has 32 values( hexadecimal numbers)
> 2.
> How to compare the saved lists with another 256 lists ( that are read
> online and have the same structure as the list one)?
> ( the first list must be saved in the  previous step)

Develop code that works for smaller lists. Test it. When it works, try it 
on bigger lists.

For example, you seem to have two very separate requirements:

Save (and presumably read) a list. My favourite mechanism for saving data 
structures is json. Read the json module help. Gogling "python store list 
data" might bring you other suggestions.

Comparing two lists. One method is to step through the members of each 
list in turn, and see if it is in the other list. Another method is to 
check that the lists are the same length, and have the same value at each 
element position. Both may have flaws depending on the exact nature of 
your requirement - and what you consider to be identical lists. Googling 
"python compare lists" may lead you to some ideas.

When you have written and tested your code, if it's not doing what you 
expect, you could come back here and post your code with a description of 
what you think it should do, what it actually does, and why you think 
that's wrong, and we'll try and help you fix.

What we won't do is write your application from scratch.

-- 
Denis McMahon, denismfmcma...@gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue22798] time.mktime doesn't update time.tzname

2015-09-01 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

mktime() does change several global C runtime variables on Linux. See the man 
page on http://linux.die.net/man/3/mktime

However, the Python documentation does not mention anything about having 
time.tzname being tied to the C lib global: 
https://docs.python.org/3.5/library/time.html#time.tzname

So I don't think this qualifies as bug.

Note that those global C variable are not thread-safe, so you can't really 
trust their values relating to anything you've just set using mktime() anyway.

--
nosy: +lemburg

___
Python tracker 

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



[issue22798] time.mktime doesn't update time.tzname

2015-09-01 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

BTW: The most portable way to access the timezone name of a given local time is 
to use strftime() with %Z as format character.

--

___
Python tracker 

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



[issue24974] ICC on Windows 8.1: _decimal fails to compile with default fp model

2015-09-01 Thread Stefan Krah

Stefan Krah added the comment:

Steve: What do you mean by "global option"? The C99 standard says
that FENV_ACCESS (if set), is active until the end of the translation
unit (here: mpdecimal.c).

--

___
Python tracker 

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



Re: execute commands as su on remote server

2015-09-01 Thread harirammanohar159
On Tuesday, 18 August 2015 08:27:33 UTC+5:30, hariramm...@gmail.com  wrote:
> execute commands as su on remote server
> 
> Postby hariram » Mon Aug 17, 2015 4:02 am
> Needed:
> I need to execute commands after doing su to other user on remote server(not 
> sudo which doesn't require password) how i can achieve this using python?
> I googled and came to know that its not possible, so just for confirmation 
> asking again, is it possible ?
> 
> Already Tried:
> Tried paramiko that's too not working.

Hey Laura,

fabric doesnt work for me as fabric works with only up to python 2.7 and we are 
using python 3.3, so we may miss major functionalists if we use 2.7 again in 
the entire project...
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24965] Implement PEP 498: Literal String Formatting

2015-09-01 Thread Eric V. Smith

Eric V. Smith added the comment:

Fixed validate_exprs bug.

--
Added file: http://bugs.python.org/file40316/pep-498-1.diff

___
Python tracker 

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



[issue24974] ICC on Windows 8.1: _decimal fails to compile with default fp model

2015-09-01 Thread Stefan Krah

Stefan Krah added the comment:

On Linux ICC has something like "fast-math" by default.  The situation
is a bit annoying: On Unix ICC defines __GNUC__, but does not really
have all the features. Here ICC defines _MSC_VER, but does not behave
like cl.exe.

[I know it's a hard problem to be fully compatible, so I'm not blaming
the authors.]


What happens if you take the C99 path (starting in mpdecimal.c:48)?

--

___
Python tracker 

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



[issue24974] ICC on Windows 8.1: _decimal fails to compile with default fp model

2015-09-01 Thread Facundo Batista

Changes by Facundo Batista :


--
nosy:  -facundobatista

___
Python tracker 

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



Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Michael Torrie
On 08/31/2015 02:35 AM, Mahan Marwat wrote:
> What I know about an interpreter and a compiler is: they both convert
> source code to machine code and the only difference is, an
> interpreter convert it, line by line while compiler convert the whole
> source file. Now if we compile a C source file on C compiler, it will
> produce a small executable file. But if we compile (freeze) a Python
> source file on Python interpreter (using cx_freeze), it will produce
> a big executable file. Now the thing is C compiler does not embed a C
> compiler inside our program, while the Python interpreter (cx_freeze,
> pytoexe) embed Python interpreter inside our program, what is the
> reason? The question is, why cx_freeze etc... embed Python
> interpreter inside our programs, they are unable to produce machine
> code like C compiler do? Cant we program a language, which is both
> interpreted and compiled? The core developer cant add the compiling
> functionality to Python?

It think your questions have been well answered by others.  But there
are several attempts at making an actual python compiler.  Often this
involve less-dynamic subset of Python.  For example, pypy has a dialect
called rpython which compiles straight to C++ code, and then to machine
code.

Another subset compiler is cython, which is somewhat of a specialized
compiler. It compiles a subset of Python to a binary shared library that
can be imported into a Python program running in the normal interpreter.

The dynamic nature of Python means that probably your best route to
speed is going to be through just-in-time compilation. The pypy project
is an attempt to do JIT with Python. So far the results are very
promising.  Pretty cool since pypy is written in Python and bootstraps
from the standard python interpreter.

Lastly, one attempt at a compiler is nuitka (google it).  It produces
self-contained executables.  Nuitka compiles what it can, and interprets
the rest (if I understand it correctly) by embedding libpython itself in
the executable.  At this time, nuitka isn't focusing on performance,
more correctness.  GvR doesn't really think much of nuitka, but I think
it's a cool project and the developer is a nice guy.  Maybe have its uses.

So far I haven't had a use for nuikta; cPython is enough for me, with
cython for compiling functions that need some more raw speed.  I tend to
use more conventional optimization techniques that work just fine with
the interpreter.  And often the results are fast enough.  For example I
implemented a simple memoization wrapper for a particularly expensive
function that was called a lot, often over the same inputs several
times.  Runtime went from 10 seconds to less than 1.  Enough for me!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue24981] Add a test which uses the ast module to compile the stdlib

2015-09-01 Thread Raymond Hettinger

Raymond Hettinger added the comment:

+1 This is a great idea.

--
nosy: +rhettinger

___
Python tracker 

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



Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Marko Rauhamaa
Steven D'Aprano :

> On Wed, 2 Sep 2015 02:20 am, Marko Rauhamaa wrote:
>> I never said a compiler would translate Python to (analogous) machine
>> language. I said you could easily turn CPython into a dynamic library
>> (run-time environment) and write a small bootstrapper that you
>> package into an executable archive with the Python code (whether .py
>> or .pyc). What results is a single executable that you can run
>> analogously to any other command.
>
> Provided you have the correct version of the dynamic library installed
> in the correct place.

Yes, virtually all Linux software builds upon dynamic libraries that
have been introduced to the linker via ldconfig.

> But this doesn't solve the problem of being able to distribute a single
> executable file that requires no pre-installed libraries, which is the
> problem cx_freeze and pytoexe are made to solve.

I wasn't trying to solve that particular problem. I was simply stating
you could compile (translate, turn) a Python program into a single,
executable file.

> I trust that you're not actually arguing that distributing .py files
> meets the requirement for a standalone application.

If your application consists of a single .py file, why not?

>> The problem is if you break your program into modules. Java, of
>> course, solved a similar problem with .jar files (but still wouldn't
>> jump over the final hurdle of making the .jar files executable).
>
> You can distribute your Python app as a zip file, except of course you
> still need the Python interpreter to be installed.

Again, having a Python interpreter around is not the issue I'm talking
about. I'm talking about the possibility to compile (translate, turn) a
Python program into a single, executable file.

Now, even C programs can suffer from the module problem: you sometimes
need to ship extra dynamic libraries ("modules") with your binary.


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


[issue7175] Define a standard location and API for configuration files

2015-09-01 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

I'm of mixed opinion.  I personally don't like cluttering up my $HOME with a
jillion dotfiles so I appreciate the organization XDG_CONFIG_HOME offers.  But
that also makes things less discoverable.  Looking in XDG_CONFIG_HOME first
with a fallback to $HOME seems like a workable compromise.

--

___
Python tracker 

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



[issue24974] ICC on Windows 8.1: _decimal fails to compile with default fp model

2015-09-01 Thread Zachary Ware

Zachary Ware added the comment:

Steve Dower added the comment:
> fenv_access is not available when compiling with /fp:fast, which is 
> apparently ICC's default.
>
> The proposed workaround here changes that default to /fp:strict, which is a 
> very different model, for all of CPython. I proposed using #pragma 
> float_control to force /fp:strict locally and enable fenv_access, rather than 
> changing the entire build to use /fp:strict (even though fenv_access is not 
> enabled everywhere by default).

Note that I'm not suggesting changing the default for everything to
/fp:strict.  The goal of the project building Python with ICC on
Windows is to change nothing for an MSVC build.  The default floating
point model should not change without a good reason, and this is not
it :)

I'll experiment with your suggestions, Steve and Stefan, discuss it
with Intel, and get back to you here.

--

___
Python tracker 

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



[issue7175] Define a standard location and API for configuration files

2015-09-01 Thread Antoine Pitrou

Antoine Pitrou added the comment:

If this is about existing config files, then we should make sure we don't break 
existing installations. Also, multiple possible locations in the home dir are 
confusing.

If this is about new config files, then ~/.config/python/XXX is probably ok.

I'm not sure what XDG_CONFIG_HOME is but $XDG_CONFIG_HOME doesn't seem defined 
under my shell (Xubuntu 15.04).

--
assignee: eric.araujo -> 
versions: +Python 3.6 -Python 3.3

___
Python tracker 

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



Re: Why Python is not both an interpreter and a compiler?

2015-09-01 Thread Marko Rauhamaa
Steven D'Aprano :

> I believe that Marko is wrong. It is not so easy to compile Python to
> machine language for real machines. That's why the compiler targets a
> virtual machine instead.

Somehow Guile manages it even though Scheme is at least as dynamic a
language as Python.

I never said a compiler would translate Python to (analogous) machine
language. I said you could easily turn CPython into a dynamic library
(run-time environment) and write a small bootstrapper that you package
into an executable archive with the Python code (whether .py or .pyc).
What results is a single executable that you can run analogously to any
other command.

In fact, the shebang notation turns any single .py file into such an
executable. The problem is if you break your program into modules. Java,
of course, solved a similar problem with .jar files (but still wouldn't
jump over the final hurdle of making the .jar files executable).


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


[issue24974] ICC on Windows 8.1: _decimal fails to compile with default fp model

2015-09-01 Thread Steve Dower

Steve Dower added the comment:

fenv_access is not available when compiling with /fp:fast, which is apparently 
ICC's default.

The proposed workaround here changes that default to /fp:strict, which is a 
very different model, for all of CPython. I proposed using #pragma 
float_control to force /fp:strict locally and enable fenv_access, rather than 
changing the entire build to use /fp:strict (even though fenv_access is not 
enabled everywhere by default).

--

___
Python tracker 

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



  1   2   >