virtualenvwrapper 3.0 - Python 3 support

2012-01-30 Thread Doug Hellmann
What is virtualenvwrapper
=

virtualenvwrapper is a set of extensions to Ian Bicking's virtualenv
tool. The extensions include wrappers for creating and deleting
virtual environments and otherwise managing your development workflow,
making it easier to work on more than one project at a time without
introducing conflicts in their dependencies.

What's New in 3.0
=

This release adds Python 3 support, thanks in large part to the efforts of 
Daniel Kraus. Tested under Python 2.6, 2.7, and 3.2.

Installing
==

Visit the virtualenvwrapper project page 
(http://www.doughellmann.com/projects/virtualenvwrapper/) 
for download links and installation instructions.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Reading Adobe PDF File

2012-01-30 Thread Matej Cepl

On 29.1.2012 06:52, Shrewd Investor wrote:

Or do I need to find a way to convert a PDF file into a text file?  If
so how?


http://en.wikipedia.org/wiki/Pdftotext ?
--
http://mail.python.org/mailman/listinfo/python-list


Re: PyPI - how do you pronounce it?

2012-01-30 Thread Neil Cerutti
On 2012-01-28, Chris Angelico ros...@gmail.com wrote:
 On Sat, Jan 28, 2012 at 8:57 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 Obviously that's pronounced Fin-tim-lin-bin-whin-bim-lim-bus-stop-F'tang-
 F'tang-Ol?-Biscuitbarrel.

 Ah, it's of British origin then.

The British pronunciation of Beauchamp created a minor incident
at Yeoman of the Guard auditions this weekend.

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


add two strings

2012-01-30 Thread contro opinion
 s1='\x45'
 s2='\xe4'
 s1+s2
'E\xe4'
 print  s1+s2
E

why  s1+s2  not  =  '\x45\xe4'??
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Reading Adobe PDF File

2012-01-30 Thread Adam Tauno Williams
On Sat, 2012-01-28 at 21:59 -0800, Chris Rebert wrote:
 On Sat, Jan 28, 2012 at 9:52 PM, Shrewd Investor clt...@gmail.com wrote:
  I have a very large Adobe PDF file.  I was hoping to use a script to
  extract the information for it.  Is there a way to loop through a PDF
  file using Python?
 Haven't used it myself, but:
 http://www.unixuser.org/~euske/python/pdfminer/

It is very prone to hanging and/or crashing.  I haven't yet found a
really reliably way to read text from a PDF.

PyPDF provides a PdfFileReader class with an extractText method.  The
output is indeed the text although it can be a bit thorny to look at.

  Or do I need to find a way to convert a PDF file into a text file?  If
  so how?
 The pdf2txt.py script from the same package happens to do exactly this.


-- 
System  Network Administrator [ LPI  NCLA ]
http://www.whitemiceconsulting.com
OpenGroupware Developer http://www.opengroupware.us
Adam Tauno Williams

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


Re: add two strings

2012-01-30 Thread Dave Angel

On 01/30/2012 08:02 AM, contro opinion wrote:

s1='\x45'
s2='\xe4'
s1+s2

'E\xe4'

print  s1+s2

E

why  s1+s2  not  =  '\x45\xe4'??


It is.  E is  \x45.  That's plain ASCII and documented everywhere.



--

DaveA

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


Re: PyPI - how do you pronounce it?

2012-01-30 Thread Chris Angelico
On Mon, Jan 30, 2012 at 11:12 PM, Neil Cerutti ne...@norwich.edu wrote:

 The British pronunciation of Beauchamp created a minor incident
 at Yeoman of the Guard auditions this weekend.

What about Sir Richard Chumley, the Left Tenant of the Tower?

Although this is now quite off-topic for this list...

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


Re: PyPI - how do you pronounce it?

2012-01-30 Thread Neil Cerutti
On 2012-01-30, Chris Angelico ros...@gmail.com wrote:
 On Mon, Jan 30, 2012 at 11:12 PM, Neil Cerutti ne...@norwich.edu wrote:

 The British pronunciation of Beauchamp created a minor incident
 at Yeoman of the Guard auditions this weekend.

 What about Sir Richard Chumley, the Left Tenant of the
 Tower?

 Although this is now quite off-topic for this list...

Very true. Our Feebee's couldn't even manage to agree on Heigh
Ho. PyPI clearly ought not to be pronounced on sentence of death.

-- 
Neil Cerutti
-- 
http://mail.python.org/mailman/listinfo/python-list


IDLE not setting current directory in its path

2012-01-30 Thread gujax
Hi,
When I open python shell and change to any directory, the sys.path
always shows ' '. This means it has temporarily added the current
directory to its path i.e., sys.path shows [' ', other paths]

I can then load any module from the current directory even though the
current directory is not listed in the PYTHONPATH..

When I do the same with IDLE, it shows the name of the current
directory i.e.,  ['name1', other paths...] instead of showing [' ',
other paths..].

Therefore, when I change the directory to some other directory say
'name2' and type sys.path, I get the same name as the original
directory which I started with (i.e., name1, while name2 is not added
to the path automatically as done by ' ').

Therefore, I am unable to load any modules from this current changed
directory.

In short how to configure IDLE to automatically add current directory
to its path without typing every time
sys.path.append..
Any help is appreciated.
Thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


PMW+BLT on windows, any chance?

2012-01-30 Thread Giacomo Boffi
on my linux box i have a small python program that draws some 2-d line
graphs in a window aside a graphical interface to change the problem
data

as you may have guessed from the subject line, the gui widgets are
done with help from PMW [1], and the graps are done by the PMW -
BLT[2] interface

now i'd like to port the whole mess to windows to give it away to
unix-impaired people, but i cannot find a precompiled BLT for my
window (virtual)box

otoh, even if i find such a rare pearl, every reference i found on
google implies that BLT 2.4z works with tk8.5 while python 2.7 comes
with tk 8.5

1. is it possible to do what i wish to do?
2. is it worth?
3. if it is impossible or unworty, i'd better rewrite my program to
   use which graphics library?

tia,
gb

[1] Python Mega Widgets is a pure python implementation of complex,
expandable widgets built on tkinter, i use its input widgets
because they do data validation
[2] Blt is a library that enhances tcl/tk adding some useful stuff, in
my case i use the 2-d graph widget
-- 
We have met the enemy and he is us.
--- Pogo.
-- 
http://mail.python.org/mailman/listinfo/python-list


except clause syntax question

2012-01-30 Thread Charles Yeomans
To catch more than one exception type in an except block, one writes

except (A, B, C) as e:

I'm wondering why it was decided to match tuples, but not lists:

except [A, B, C] as e:

The latter makes more sense semantically to me -- catch all exception types in 
a list as opposed to catch this single thing composed of three exception 
types.


Charles Yeomans


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


Re: except clause syntax question

2012-01-30 Thread Aaron

On 01/30/2012 06:41 PM, Charles Yeomans wrote:

To catch more than one exception type in an except block, one writes

except (A, B, C) as e:

I'm wondering why it was decided to match tuples, but not lists:

except [A, B, C] as e:

The latter makes more sense semantically to me -- catch all exception types in a list 
as opposed to catch this single thing composed of three exception types.


Charles Yeomans




Then,  semantically, shouldn't it be a set?
--
http://mail.python.org/mailman/listinfo/python-list


Re: except clause syntax question

2012-01-30 Thread Charles Yeomans

On Jan 30, 2012, at 12:56 PM, Aaron wrote:

 On 01/30/2012 06:41 PM, Charles Yeomans wrote:
 To catch more than one exception type in an except block, one writes
 
 except (A, B, C) as e:
 
 I'm wondering why it was decided to match tuples, but not lists:
 
 except [A, B, C] as e:
 
 The latter makes more sense semantically to me -- catch all exception types 
 in a list as opposed to catch this single thing composed of three 
 exception types.
 
 
 Charles Yeomans
 
 
 
 Then,  semantically, shouldn't it be a set?

Why, I suppose that would make even more sense.


Charles Yeomans
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: except clause syntax question

2012-01-30 Thread Mel Wilson
Charles Yeomans wrote:

 To catch more than one exception type in an except block, one writes
 
 except (A, B, C) as e:
 
 I'm wondering why it was decided to match tuples, but not lists:
 
 except [A, B, C] as e:
 
 The latter makes more sense semantically to me -- catch all exception
 types in a list as opposed to catch this single thing composed of three
 exception types.

I've always been perfectly fine with sometimes treating tuples as immutable 
sequences, so I'm +0 on saying more sense semantically, but given that the 
exception list can be a variable, I'm not sure what the gain is by keeping 
it immutable.

#---
#!/usr/bin/env python
# -*- coding: ASCII -*-
'''Demonstrate catching variable exceptions.
'''
def excepter (a, exceptions):
try:
1.0/a
'Number ' + a
except exceptions as e:
print '!!! *** EXCEPTER CAUGHT ONE *** !!!'
print repr (e)

#~ excepter (0, [ZeroDivisionError])
excepter (0, (ZeroDivisionError,))
excepter (1, (ZeroDivisionError,TypeError))
excepter (1, (ZeroDivisionError,))

 #---

excepter called with the list catches nothing, of course.


Mel.
-- 
http://mail.python.org/mailman/listinfo/python-list


Condition.wait() behavior with timeout

2012-01-30 Thread Ross Boylan
The Python 2.7 documents for the threading module says, in part,
wait([timeout])¶

Wait until notified or until a timeout occurs. If the calling
thread has not acquired the lock when this method is called, a
RuntimeError is raised.

This method releases the underlying lock, and then blocks until
it is awakened by a notify() or notifyAll() call for the same
condition variable in another thread, or until the optional
timeout occurs. Once awakened or timed out, it re-acquires the
lock and returns.

First, the documentation does not say what the return value is.  I was
hoping it was True or False depending on whether a timeout occurred, as
Event.wait().

Second, the Once awakened or timed out, it re-acquires the lock and
returns sounds very strange.  If there was a timeout then an attempt to
acquire the lock will block until it is released.  Since there was no
notify there almost certainly will be no release() immediately after the
tiemout.  Which would make the timeout pretty useless (since the thread
that called wait() blocks even after the timeout expires), and might
cause a race on the condition object.

I've googled around, but haven't found anything quite on topic.
http://bugs.python.org/issue1175933 from 2005 requested adding a timeout
to Condition.wait(), a proposal rejected in 2009.  Clearly it's there
now.

http://www.gossamer-threads.com/lists/python/dev/761847 complains there
is no return value from wait and so no way to determine if a timeout
occurred.   One response was
quote
GR How am I supposed to know if it was notified or if it timed out? 

Normally you wouldn't have to know. The logic of your program should be 
such that you wait until a certain condition is satisfied. After each 
wait you usually check that condition anyway, like: 
/quote
http://bugs.python.org/issue1175933#msg48141 also refers to the need to
check things after returning from wait().  But both of these cases seem
to refer to a scenario in which there are many workers waiting on the
condition, not one with notify() and a single thread waiting (which is
what I'm thinking about).  The thread does say there is no return value;
it seems to me it would be useful to document that if it's still true
(or True :).

Can anyone help me understand what's going on?

Thanks.
Ross Boylan

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


Re: IDLE not setting current directory in its path

2012-01-30 Thread Terry Reedy

On 1/30/2012 10:06 AM, gujax wrote:

Hi,
When I open python shell and change to any directory, the sys.path
always shows ' '.


It actually shows '' (without a space).


When I do the same with IDLE, it shows the name of the current
directory i.e.,  ['name1', other paths...] instead of showing [' ',
other paths..].


This issue is under consideration at
http://bugs.python.org/issue13506
I will be looking at the patch soon.

--
Terry Jan Reedy

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


Disable use of pyc file with no matching py file

2012-01-30 Thread Roy Smith
Every so often (typically when refactoring), I'll remove a .py file and forget 
to remove the corresponding .pyc file.  If I then import the module, python 
finds the orphaned .pyc and happily imports it.  Usually leading to confusing 
and hard to debug failures.

Is there some way to globally tell python, Never import a .pyc unless the 
corresponding .py file exits?  Perhaps some environment variable I could set 
in my .login file?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PyPI - how do you pronounce it?

2012-01-30 Thread André Malo
* Chris Angelico wrote:

 Hopefully this will be a step up from Rick's threads in usefulness,
 but I'm aware it's not of particularly great value!
 
 How do you pronounce PyPI? Is it:
 * Pie-Pie?
 * Pie-Pip, but without the last p? (same as above but short i)
 * Pie-Pea-Eye?
 * Something else?

I actually always pronounce it Python Package Index. That's unambiguous
(and can't be confused with things like peepee and stuff.)

nd
-- 
Das Verhalten von Gates hatte mir bewiesen, dass ich auf ihn und seine
beiden Gefährten nicht zu zählen brauchte -- Karl May, Winnetou III

Im Westen was neues: http://pub.perlig.de/books.html#apache2
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Disable use of pyc file with no matching py file

2012-01-30 Thread Miki Tebeka
Not that I'm aware of.

I have a script that run the test suite, one of the first commands (before 
calling nosetests) is:
find . -name '*.py[co]' -exec rm {} \;

This makes sure the tests run in a clean environment.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Disable use of pyc file with no matching py file

2012-01-30 Thread Terry Reedy

On 1/30/2012 4:30 PM, Roy Smith wrote:

Every so often (typically when refactoring), I'll remove a .py file
and forget to remove the corresponding .pyc file.  If I then import
the module, python finds the orphaned .pyc and happily imports it.
Usually leading to confusing and hard to debug failures.

Is there some way to globally tell python, Never import a .pyc
unless the corresponding .py file exits?


Upgrade to 3.2.

--
Terry Jan Reedy

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


Re: speaking at PyCon

2012-01-30 Thread Roy Smith
Wow.  As somebody who has given plenty of talks, I can tell you this is an 
awesome checklist (and most of it not specific to PyCon).

Let me add one suggestion -- never, ever, ever, type a URL into a browser 
connected to the internet in front of a live audience.  You never know when 
you're going to make a typo and something *totally* not what you expected will 
fill the screen.  If you absolutely insist on ignoring the good advice about 
not doing live demos, at least bookmark your urls and click on the bookmark.  
DAMHIKT.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: speaking at PyCon

2012-01-30 Thread Devin Jeanpierre
On Mon, Jan 30, 2012 at 6:48 PM, Roy Smith r...@panix.com wrote:
 Wow.  As somebody who has given plenty of talks, I can tell you this is an 
 awesome checklist (and most of it not specific to PyCon).

 Let me add one suggestion -- never, ever, ever, type a URL into a browser 
 connected to the internet in front of a live audience.  You never know when 
 you're going to make a typo and something *totally* not what you expected 
 will fill the screen.  If you absolutely insist on ignoring the good advice 
 about not doing live demos, at least bookmark your urls and click on the 
 bookmark.  DAMHIKT.

I have to ask... was it python.com?

-- Devin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: except clause syntax question

2012-01-30 Thread Steven D'Aprano
On Mon, 30 Jan 2012 12:41:00 -0500, Charles Yeomans wrote:

 To catch more than one exception type in an except block, one writes
 
 except (A, B, C) as e:
 
 I'm wondering why it was decided to match tuples, but not lists:
 
 except [A, B, C] as e:

Simplicity.

If you also allow lists, then why not allow arbitrary sequences? What 
about iterators, do you allow them? That could be awkward, because 
iterators can only be run through once. Dictionaries are also iterable, 
so once you allow arbitrary iterables, you get dicts. The whole thing 
becomes a mess. Better to keep it simple and only allow a single 
canonical collection type, and in Python, that type is tuple, not list.

Tuples are that canonical collection type because they have a number of 
desirable properties:

- Tuples are small and memory efficient, using the smallest amount of
  memory needed to hold their items. Lists typically carry a block of
  spare memory, to make insertions fast.

- Consequently the Python virtual machine can create them rapidly and
  efficiently.

- Tuples are immutable, so you don't have to worry about passing one to a
  function and having the function modify it behind your back.

- Tuples are ordered, for the times where that matters.

- Since the typical use-case is to iterate over the items in fixed order,
  there's no need to pay the extra expense for a dict or set.

- Tuples are simple to write: in general you only need commas between
  items. Sometimes, to avoid ambiguity or change the precedence of
  calculation, you also need round brackets (parentheses for Americans).
  Except clauses are one of those times.

- Frozensets and sets are ruled out for historical reasons: they didn't
  exist until Python 2.3. Besides, which would you rather write?

  (abc, def)
  frozenset([abc, def])

- Sets and lists are ruled out because they are mutable, both require
  much more memory, and sets have a heavier computational burden.



 The latter makes more sense semantically to me -- catch all exception
 types in a list as opposed to catch this single thing composed of
 three exception types.

Then you are labouring under a misunderstanding. You're not catching a 
tuple, because tuples are never thrown. You're catching any of the 
exceptions that are contained in that tuple.

Both lists and tuples *are* single things in themselves. Both lists and 
tuples are containers:

A list is a single thing that contains other things. 

A tuple is a single thing that contains other things.




-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: except clause syntax question

2012-01-30 Thread Devin Jeanpierre
On Mon, Jan 30, 2012 at 7:00 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Mon, 30 Jan 2012 12:41:00 -0500, Charles Yeomans wrote:

 To catch more than one exception type in an except block, one writes

 except (A, B, C) as e:

 I'm wondering why it was decided to match tuples, but not lists:

 except [A, B, C] as e:

 Simplicity.

-snip-

I agree with the snipped, but would also like to add that regardless
of why it might be so, tuples do appear to be the canonical type for
collections that need to be typechecked -- not just for except; it's a
consistent thing that if you're going to do something with X, or a
bunch of X's, then it's either an X or a tuple of X's. For example,
string formatting with % works this way, as does isinstance(a, X).

-- Devin
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: speaking at PyCon

2012-01-30 Thread python
Roy,

 Let me add one suggestion -- never, ever, ever, type a URL into a browser 
 connected to the internet in front of a live audience. You never know when 
 you're going to make a typo and something *totally* not what you expected 
 will fill the screen.  

Great advice!

Years ago I did a presentation on Python and then launched a browser to
give a tour of the Python website.

When I went to enter the URL, I accidentally typed in python.com (which
at the time was an adult website) vs. python.org.

Talk about getting your audience's attention!!

Malcolm

BTW: Great tips Eric - thanks for sharing.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: IDLE not setting current directory in its path

2012-01-30 Thread Terry Reedy

On 1/30/2012 3:15 PM, Terry Reedy wrote:


This issue is under consideration at
http://bugs.python.org/issue13506


It should be fixed before the next Python releases.

--
Terry Jan Reedy

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


Re: add two strings

2012-01-30 Thread David Lambert

On 01/30/2012 07:02 AM, contro opinion wrote:

 s1='\x45'
 s2='\xe4'
 s1+s2
'E\xe4'
 print  s1+s2
E

why  s1+s2  not  =  '\x45\xe4'??


It is, but '\x45' is ASCII 'E', and '\xe4' is not a printable character:
 print '\x45'
E
 print  '\xe4'


Try printing s1 and s2 separately in your example.

HTH,

Dave.

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


Killing threads, and os.system()

2012-01-30 Thread Laurent Claessens

Hello all


  I've a program that launches a lot of  threads and each of them 
launches a os.system(my_command).


My program also keeps a list of the launched threads, so I can make 
for loops on the threads.



My aim is to kill everything with ctrl-C (KeyboardInterrupt).

Of course I tried to do

try:
   [...]
except KeyboardInterrupt :
   for task in task_list :
  task.stop()
  #task_list is the list of threads to be killed


It does not work.

How can I produce an emergency stop of all processes, including the 
externals programs that were called by os.system() ?


My aim is of course to write an ultimate log file containing the status 
of the program when KeyboardInterupt was raised. (if not, the unix 
command kill does the job ;) )



Thanks for any help
have a good day
Laurent
--
http://mail.python.org/mailman/listinfo/python-list


[issue4966] Improving Lib Doc Sequence Types Section

2012-01-30 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

Good point, without doing the split in both, any doc merges in this section 
will be a nightmare. OK, with the caveat that the initial 3.2 version may gloss 
over some issues that no longer apply in 3.3 (specifically the narrow/wide 
split), I'll make a new branch in the sandbox so the changes will be once again 
based on 3.2.

--

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



[issue13856] xmlrpc / httplib changes to allow for certificate verification

2012-01-30 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 I think, I was using wrong terminology, by 'sending' I meant, 'using' the 
 ca_file in the client to verify Server's certificates.

Then I still don't understand your remarks. You said is there any
reason for the clients in the stdlib are not carrying a ca_file,
but this isn't actually true: clients in the stdlib *do* carry
the CA file and *do* perform verification, see ftplib, nntplib,
imaplib, http.client, etc. It's just that it was forgotten in
xmlrpc.client.

--

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 I think that one of available types of time values returned by os.stat() 
 should
 allow to directly pass these values to os.futimens() and os.utimensat(), which
 expect (time_sec, time_nsec) tuples.

If we choose to give the possibility to get decimal.Decimal objects,
we should also patch some functions to support Decimal objects, like
datetime.datetime.fromtimestamp() (today, it just works, because a
Decimal object can be converted to float). We may accept Decimal in
os.futimens() and os.utimensat(), but I am not sure for this
particular case.

To come back to my format solution, we can also support classical C
structures to interact with C functions (in Python or more directly
using ctypes):
 - timeval: (secs, usec) where sec and usec are int
 - timespec: (secs, nsec) where sec and nsec are int

Or we may introduce conversion functions from other types like float,
Decimal or another type.

--

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



[issue13703] Hash collision security issue

2012-01-30 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Rather than the  empty string for off I suggest an explicit string
 that makes it clear what the meaning is.  PYTHONHASHSEED=disabled
 perhaps.
 
 Agreed, if we can have a single env var that is preferred.  It is more
 obvious that the PYTHONHASHSEED env var. has no effect when it is set
 to a special value rather than when it is set to something but it is
 configured to be ignored by a _different_ env var.

I think this is bike-shedding. The requirements for environment
variables are
a) with no variable set, it must not do randomization
b) there must be a way to seed from the platform's RNG
Having an explicit seed actually is no requirement, so I'd propose
to drop PYTHONHASHSEED instead.

However, I really suggest to let the patch author (Dave Malcolm)
design the API within the constraints.

--

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



[issue12892] UTF-16 and UTF-32 codecs should reject (lone) surrogates

2012-01-30 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

Thanks for the patch!

  * fix an error in the error handler for utf-16-le. (In, Python3.2 
 b'\xdc\x80\x00\x41'.decode('utf-16-be', 'ignore') returns \x00 
 instead of A for some reason)

This should probably be done on a separate patch that will be applied to 
3.2/3.3 (assuming that it can go to 3.2).  Rejecting surrogates will go in 3.3 
only.  (Note that lot of Unicode-related code changed between 3.2 and 3.3.)

 Should we really reject lone surrogates for UTF-7?

No, I meant only UTF-8/16/32; UTF-7 is fine as is.

--

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 I think that one of available types of time values returned by os.stat() 
 should allow to directly pass these values to os.futimens() and 
 os.utimensat(), which expect (time_sec, time_nsec) tuples.

Oh, I realized that these two functions were added to Python 3.3, so
it is not too late to change their API. I would prefer to limit the
number of timestamp formats: Python 3.2 has float and datetime, I (and
Martin) propose to add Decimal to Python 3.3 (to get nanosecond
resolution). (sec, nsec) is a new format, except if Python 3.2 has
already functions expecting such tuple?

I know that the underlying C function expects a timespec structure,
but Python can try to use a higher level API, isn't it?

Decimal is more practical than a tuple because you can just write :
t2-t1 to compute a time delta. Decimal has other advantages (read the
issue for the full list ;-)).

--

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



[issue13868] Add hyphen doc fix

2012-01-30 Thread Boštjan Mejak

Boštjan Mejak bostjan.me...@gmail.com added the comment:

I know that there are a lot of non-hyphenated occurences of floating 
point in Python docs, so I just want to raise awareness about those 
occurences. Can you fix all occurences of floating point (when in a role of 
an adjective) to floating-point throughout Python docs?

As a matter of fact, everything that is an adjective is hyphenated if there are 
2 words that form the adjective.

Example: This is built in. versus This is a built-in method.

--

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



[issue13868] Add hyphen doc fix

2012-01-30 Thread Sandro Tosi

Sandro Tosi sandro.t...@gmail.com added the comment:

On Mon, Jan 30, 2012 at 15:08, Boštjan Mejak rep...@bugs.python.org wrote:
 Can you fix all occurences of floating point (when in a role of 
 an adjective) to floating-point throughout Python docs?

What I was asking is if *you* (since you care about the topic) would
provide a patch fixing all that needs fixing. At that point there will
be people interesting reviewing your patch, instead of people been
told what to do.

Regards,
Sandro

--

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-30 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com added the comment:

(secs, nsecs) tuples are more practical in performance-critical applications 
(e.g. synchronization of timestamps between 2 trees with large number of files).

--

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



[issue13868] Add hyphen doc fix

2012-01-30 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Congratulations: You (again) have found a fundamental error in TAOCP.
Example (Third Edition, page 233):

The following definitions seem to be appropriate for base b, excess q,
floating point numbers ...

--
nosy: +skrah

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 (secs, nsecs) tuples are more practical in performance-critical applications
 (e.g. synchronization of timestamps between 2 trees with large number of 
 files).

This is also why I propose an argument to choose the format: everyone
has a different use case and use cases are incompatible. Tuples are
quick to create but has not a practical API, datetime has a nice API
but also issues listed before by Martin (and don't support nanosecond
resolution currently), Decimal has a nice API but is expensive to
create, etc.

--

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-30 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

There is also the fact that we have traditionally exposed thin wrappers around 
posix functions (and then were practical provided Windows emulations).  We 
aren't 100% consistent about this, but we are pretty consistent about it.

--

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



[issue13868] Add hyphen doc fix

2012-01-30 Thread Boštjan Mejak

Boštjan Mejak bostjan.me...@gmail.com added the comment:

For the time being I don't find any other floating point occurences in Python 
docs. I found one and made a patch for it. Please apply the patch.  Thanks.

--

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



[issue10580] Installer sentence in bold

2012-01-30 Thread Boštjan Mejak

Boštjan Mejak bostjan.me...@gmail.com added the comment:

Please apply this patch.

--

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



[issue10580] Installer sentence in bold

2012-01-30 Thread Brian Curtin

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


--
nosy:  -brian.curtin

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



[issue13901] test_get_outputs (test_distutils) failure with --enable-shared on Mac OS X

2012-01-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks for the analysis Ned.  Can you apply your patch to distutils and 
packaging?  Also, what do you think about adding a buildbot configured with 
--enable-shared?

--
components: +Distutils2
nosy: +alexis

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



[issue1625] bz2.BZ2File doesn't support multiple streams

2012-01-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

 I think this support should be backported to Python 2.7 and 3.2.
I think our policy is pretty clear: the module docs did not say multiple 
streams were supported, so when support for them was added it was clearly a new 
feature.

 Current code can't decompress files generated by pbzip2, fairly popular.
That is unfortunate, but I don’t think that the features of one tool, even 
popular, should make us break the policy.  That’s why I concur with Nadeem and 
think that a PyPI backport is the only way to provide multi-streams bz2 to 
previous versions.

Best regards

--

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



[issue13901] test_get_outputs (test_distutils) failure with --enable-shared on Mac OS X

2012-01-30 Thread Ronald Oussoren

Ronald Oussoren ronaldousso...@mac.com added the comment:

I'd prefer a buildbot with --enable-framework and --enable-universalsdk (that 
is, one closer to the options used to build the installer for OSX).

--

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



[issue10910] pyport.h FreeBSD/Mac OS X fix causes errors in C++ compilation

2012-01-30 Thread Ronald Oussoren

Ronald Oussoren ronaldousso...@mac.com added the comment:

The only real fix I found is to introduce Py_ prefixed versions of all 
definitions in ctypes.h that are used in Python (that is Py_isalnum) and use 
that throughout the python source tree.

That's a pretty invasive patch though and would probably be off-limit for 2.7 
and 3.2.

--

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



[issue13609] Add os.get_terminal_size() function

2012-01-30 Thread Zbyszek Szmek

Zbyszek Szmek zbys...@in.waw.pl added the comment:

Here's is an updated version: termsize.diff.6

Following Antoine Pitrou's comment get_terminal_size_raw is renamed back to 
query_terminal_size.

Tests are moved to test_os.py, and there's a new test for query_terminal_size 
-- the output from 'stty size' is parsed. If something fails (e.g. stty is not 
available), the test is skipped.

I noticed that bash uses $LINES, not $ROWS. I have renamed rows to lines 
everywhere, to follow existing convention.

The big remaining question seems to be one function vs. two functions.
I'm still convinced that the high-level two function is better. This issue 
originated in the argparse module, which can use proper terminal size to 
efficiently format messages. Of course argparse must use a function with a 
fallback -- if it cannot query, some default must be used. So argparse would 
implement the high-level function anyway. It might just as well be in os, 
available for others to be used. Anyway, the second function is 18 lines of 
python code (excluding docstring and whitespace) -- a bit too much to copy and 
paste.

--
Added file: http://bugs.python.org/file24369/termsize.diff.6

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Jason R. Coombs

New submission from Jason R. Coombs jar...@jaraco.com:

The Python 2.7.2 docs say this about __import__:

Positive values for level indicate the number of parent directories to 
search relative to the directory of the module calling __import__().

But I find that even when setting level=1, the parent directory is not searched.

I've created this project tree to replicate the issue:

jaraco@devjaraco:~$ tree master
master
├── __init__.py
├── pkgA
│   ├── foo.py
│   └── __init__.py
└── pkgB
├── bar.py
└── __init.py

2 directories, 5 files
jaraco@devjaraco:~$ cat master/pkgA/foo.py

bar = __import__('pkgB', level=1).bar
jaraco@devjaraco:~$ cat master/pkgB/bar.py
var = success

It fails as so with python 2.7.2:

jaraco@devjaraco:~$ python2.7 -c import master.pkgA.foo
Traceback (most recent call last):
  File string, line 1, in module
  File master/pkgA/foo.py, line 2, in module
bar = __import__('pkgB', level=1).bar
ImportError: No module named pkgB


It's conceivable I'm not using this correctly, but if so, I'm unable to find my 
mistake. I've confirmed that foo.__name__ is 'master.pkgA.foo'. I've tried 
using level=2 (in case I was off by one, but that wasn't the case).

--
components: Interpreter Core
messages: 152331
nosy: jason.coombs
priority: normal
severity: normal
status: open
title: ImportError using __import__ and relative level 1
versions: Python 2.7

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



[issue10580] Minor grammar change in Python’s MSI installer

2012-01-30 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
title: Installer sentence in bold - Minor grammar change in Python’s MSI 
installer
versions:  -Python 3.1

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



[issue13851] Packaging distutils2 for Fedora

2012-01-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks for your support of distutils2, but this tracker is the wrong place for 
this bug tracker, as no RPM spec file will be added to the distutils2 repo.  If 
there are bugs in distutils2 that prevent you from making a RPM, please say so, 
otherwise I will close this report (but stay available via private email or the 
distutils-sig mailing list).

--
assignee: tarek - eric.araujo
status: open - pending

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



[issue12804] make test fails on systems without internet access

2012-01-30 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Thanks!

--

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



[issue13609] Add os.get_terminal_size() function

2012-01-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 I noticed that bash uses $LINES, not $ROWS. I have renamed rows to lines 
 everywhere, to follow existing convention.

The stty program has rows and columns commands to set the terminal
size. The tput programs has cols and lines commands to get the
terminal size. The curses library uses (y, x), e.g. it has a
getmaxyx() function. I don't know the most common term, lines or rows.

Extract of 
http://stackoverflow.com/questions/1780483/lines-and-columns-environmental-variables-lost-in-a-script
The variables $LINES and $COLUMNS are shell variables, not
environmental variables, and thus are not exported to the child
process (...)

If I understood correctly, LINES and COLUMNS environment variables are
only set by the user. In a bash script, these variables are wrapper to
ioctl().

The tput program reads TERM environment variable to decide if LINES
and COLUMNS are used or not:
-Ttype indicates  the type of terminal.  Normally this option is
unnecessary, because the default is taken from the environment
variable TERM.  If -T is specified, then the shell variables LINES and
COLUMNS will be ignored,and the operating system will not be queried
for the actual screen size.

Extract of http://pubs.opengroup.org/onlinepubs/7908799/xbd/envvar.html :
--
COLUMNS
A decimal integer  0 used to indicate the user's preferred width
in column positions for the terminal screen or window. (See column
position .) If this variable is unset or null, the implementation
determines the number of columns, appropriate for the terminal or
window, in an unspecified manner. When COLUMNS is set, any
terminal-width information implied by TERM will be overridden. Users
and portable applications should not set COLUMNS unless they wish to
override the system selection and produce output unrelated to the
terminal characteristics. The default value for the number of column
positions is unspecified because historical implementations use
different methods to determine values corresponding to the size of the
screen in which the utility is run. This size is typically known to
the implementation through the value of TERM or by more elaborate
methods such as extensions to the stty utility, or knowledge of how
the user is dynamically resizing windows on a bit-mapped display
terminal. Users should not need to set this variable in the
environment unless there is a specific reason to override the
implementation's default behaviour, such as to display data in an area
arbitrarily smaller than the terminal or window.

LINES
A decimal integer  0 used to indicate the user's preferred number
of lines on a page or the vertical screen or window size in lines. A
line in this case is a vertical measure large enough to hold the
tallest character in the character set being displayed. If this
variable is unset or null, the implementation determines the number of
lines, appropriate for the terminal or window (size, terminal baud
rate, and so forth), in an unspecified manner. When LINES is set, any
terminal-height information implied by TERM will be overridden. Users
and portable applications should not set LINES unless they wish to
override the system selection and produce output unrelated to the
terminal characteristics. The default value for the number of lines is
unspecified because historical implementations use different methods
to determine values corresponding to the size of the screen in which
the utility is run. This size is typically known to the implementation
through the value of TERM or by more elaborate methods such as
extensions to the stty utility, or knowledge of how the user is
dynamically resizing windows on a bit-mapped display terminal. Users
should not need to set this variable in the environment unless there
is a specific reason to override the implementation's default
behaviour, such as to display data in an area arbitrarily smaller than
the terminal or window.
--

 The big remaining question seems to be one function vs. two functions.

Not exactly. I suggested to keep only the simple function in the os
module, and add maybe a function with a higher level API (using
environment variables) in another module (e.g. in shutil).

--

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



[issue13703] Hash collision security issue

2012-01-30 Thread Dave Malcolm

Dave Malcolm dmalc...@redhat.com added the comment:

It's useful for the selftests, so I've kept PYTHONHASHSEED.  However,
I've removed it from the man page; the only other place it's mentioned
(in Doc/using/cmdline.rst) I now explicitly say that it exists just to
serve the interpreter's own selftests.

Am attaching a revised patch, which has the above change, plus some
tweaks to Lib/test/test_hash.py (adds test coverage for the datetime
hash randomization):
  optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-001.patch

Has anyone had a chance to try this patch on Windows?  Martin?  I'm
hoping that it doesn't impose a startup cost in the default
no-randomization cost, and that any startup cost in the -R case is
acceptable.

--
Added file: 
http://bugs.python.org/file24370/optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-001.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13703
___diff -r 73dad4940b88 Doc/library/sys.rst
--- a/Doc/library/sys.rst   Fri Jan 20 11:23:02 2012 +
+++ b/Doc/library/sys.rst   Mon Jan 30 12:29:09 2012 -0500
@@ -220,6 +220,7 @@
:const:`ignore_environment`   :option:`-E`
:const:`verbose`  :option:`-v`
:const:`bytes_warning`:option:`-b`
+   :const:`hash_randomization`   :option:`-R`
= =
 
 
diff -r 73dad4940b88 Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst   Fri Jan 20 11:23:02 2012 +
+++ b/Doc/reference/datamodel.rst   Mon Jan 30 12:29:09 2012 -0500
@@ -1265,6 +1265,8 @@
inheritance of :meth:`__hash__` will be blocked, just as if :attr:`__hash__`
had been explicitly set to :const:`None`.
 
+   See also the :option:`-R` command-line option.
+
 
 .. method:: object.__bool__(self)
 
diff -r 73dad4940b88 Doc/using/cmdline.rst
--- a/Doc/using/cmdline.rst Fri Jan 20 11:23:02 2012 +
+++ b/Doc/using/cmdline.rst Mon Jan 30 12:29:09 2012 -0500
@@ -21,7 +21,7 @@
 
 When invoking Python, you may specify any of these options::
 
-python [-bBdEhiOsSuvVWx?] [-c command | -m module-name | script | - ] 
[args]
+python [-bBdEhiORsSuvVWx?] [-c command | -m module-name | script | - ] 
[args]
 
 The most common use case is, of course, a simple invocation of a script::
 
@@ -215,6 +215,30 @@
Discard docstrings in addition to the :option:`-O` optimizations.
 
 
+.. cmdoption:: -R
+
+   Turn on hash randomization, so that the :meth:`__hash__` values of str,
+   bytes and datetime objects are salted with an unpredictable random value.
+   Although they remain constant within an individual Python process, they
+   are not predictable between repeated invocations of Python.
+
+   This is intended to provide protection against a denial-of-service
+   caused by carefully-chosen inputs that exploit the worst case performance
+   of a dict lookup, O(n^2) complexity.  See:
+
+   http://www.ocert.org/advisories/ocert-2011-003.html
+
+   for details.
+
+   Changing hash values affects the order in which keys are retrieved from
+   a dict.  Although Python has never made guarantees about this ordering
+   (and it typically varies between 32-bit and 64-bit builds), enough
+   real-world code implicitly relies on this non-guaranteed behavior that
+   the randomization is disabled by default.
+
+   See also :envvar:`PYTHONHASHRANDOMIZATION`.
+
+
 .. cmdoption:: -s
 
Don't add user site directory to sys.path
@@ -435,6 +459,24 @@
import of source modules.
 
 
+.. envvar:: PYTHONHASHRANDOMIZATION
+
+   If this is set to a non-empty string it is equivalent to specifying the
+   :option:`-R` option.
+
+
+.. envvar:: PYTHONHASHSEED
+
+   If this is set, it is used as a fixed seed for generating the hash() of
+   the types covered by the :option:`-R` option (or its equivalent,
+   :envvar:`PYTHONHASHRANDOMIZATION`.
+
+   Its purpose is for use in selftests for the interpreter.
+
+   It should be a decimal number in the range [0; 4294967295].  Specifying
+   the value 0 overrides the other setting, disabling the hash random salt.
+
+
 .. envvar:: PYTHONIOENCODING
 
Overrides the encoding used for stdin/stdout/stderr, in the syntax
diff -r 73dad4940b88 Include/object.h
--- a/Include/object.h  Fri Jan 20 11:23:02 2012 +
+++ b/Include/object.h  Mon Jan 30 12:29:09 2012 -0500
@@ -473,6 +473,12 @@
 PyAPI_FUNC(long) _Py_HashDouble(double);
 PyAPI_FUNC(long) _Py_HashPointer(void*);
 
+typedef struct {
+long prefix;
+long suffix;
+} _Py_HashSecret_t;
+PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret;
+
 /* Helper for passing objects to printf and the like */
 #define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj))
 
diff -r 73dad4940b88 Include/pydebug.h
--- a/Include/pydebug.h Fri Jan 20 11:23:02 2012 +
+++ b/Include/pydebug.h Mon Jan 30 12:29:09 2012 -0500
@@ -19,6 +19,7 @@
 PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
 

[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Eric Snow

Eric Snow ericsnowcurren...@gmail.com added the comment:

what value do you see for __package__ in pkgA?

--
nosy: +eric.snow

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



[issue13851] Packaging distutils2 for Fedora

2012-01-30 Thread Vikash Agrawal

Vikash Agrawal vikashagrawal1...@gmail.com added the comment:

hi merwok, 
I didn't know this is the right place for that bug/query. I am still in the 
process of learning packaging, and at this moment I wont be able to tell that 
if its a problem of distutils2 or not, though I do feel that pysetup should 
have installed directly, considering my spec file is correct.

So as o now, the bug is closed, and later I will come with concrete results.

I will be available via private email and I will discuss this issue with 
dmalcolm over IRC

--
status: pending - closed

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



[issue13890] test_importlib failures under Windows

2012-01-30 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 54d7823ec488 by Brett Cannon in branch 'default':
Issue #13890: Fix importlib case-sensitivity tests to not run on Windows.
http://hg.python.org/cpython/rev/54d7823ec488

--
nosy: +python-dev

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



[issue13890] test_importlib failures under Windows

2012-01-30 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 2914ce82bf89 by Brett Cannon in branch 'default':
Issue #13890: Also fix for extension module tests for case-insensitivity.
http://hg.python.org/cpython/rev/2914ce82bf89

--

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



[issue13890] test_importlib failures under Windows

2012-01-30 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
resolution:  - fixed
status: open - closed

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



[issue10910] pyport.h FreeBSD/Mac OS X fix causes errors in C++ compilation

2012-01-30 Thread Bert JW Regeer

Bert JW Regeer ber...@regeer.org added the comment:

In my first comment on this bug post I posted what project has issues with 
this, Botan with Boost.Python on FreeBSD and Mac OS X.

If required I will post how to reproduce this error using that project. If you 
would prefer a simplified test case, unfortunately I don't have the time to dig 
into that and find one.

One way to solve it is by including the Python header before any other file, 
however this is not an option for most 3rd party software that never sees this 
bug because those functions are not redefined for Linux...

--

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

You have a typo in a filename: it should be pkgB/__init__.py (not the missing 
trailing underscores).

--
nosy: +brett.cannon
resolution:  - invalid
status: open - closed

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Jason R. Coombs

Jason R. Coombs jar...@jaraco.com added the comment:

Sorry for the mistake.

I corrected the pkgB package, but the result is the same:

jaraco@devjaraco:~$ tree master
master
├── __init__.py
├── __init__.pyc
├── pkgA
│   ├── foo.py
│   ├── foo.pyc
│   ├── __init__.py
│   └── __init__.pyc
└── pkgB
├── bar.py
└── __init__.py

2 directories, 8 files
jaraco@devjaraco:~$ python2.7 -c 'import master.pkgA; 
print(pkgA.__package__ is {}.format(master.pkgA.__package__)); import 
master.pkgA.foo'
pkgA.__package__ is None
Traceback (most recent call last):
  File string, line 1, in module
  File master/pkgA/foo.py, line 2, in module
bar = __import__('pkgB', level=1).bar
ImportError: No module named pkgB

As you can see, __package__ for pkgA is None. Same is true for 
master.__package__.

--
resolution: invalid - 
status: closed - open

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



[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-30 Thread Justin Wehnes

Justin Wehnes jweh...@gmail.com added the comment:

Just wondering if someone is already working on this or am I free to supply a 
patch?

--
nosy: +jwehnes

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



[issue13703] Hash collision security issue

2012-01-30 Thread Jim Jewett

Jim Jewett jimjjew...@gmail.com added the comment:

On Mon, Jan 30, 2012 at 12:31 PM,  Dave Malcolm dmalc...@redhat.com
added the comment:

 It's useful for the selftests, so I've kept PYTHONHASHSEED.

The reason to read PYTHONHASHSEED was so that multiple members of a
cluster could use the same hash.

It would have been nice to have fewer environment variables, but I'll
grant that it is hard to say use something random that we have *not*
precomputed without either a config file or a magic value for
PYTHONHASHSEED.

-jJ

--

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



[issue13903] New shared-keys dictionary implementation

2012-01-30 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

This would likely require a PEP before having a chance of being considered for 
inclusion.

--
nosy: +rhettinger

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



[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-30 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

Please go ahead!

And Georg is right - the short spelling doesn't handle the first line 
correctly. It also suffers from the trailing whitespace problem that Amaury 
pointed out in my original version.

The tests for the new function should check both those cases (i.e. don't indent 
blank lines, ensure the first line is correctly indented).

--

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



[issue13868] Add hyphen doc fix

2012-01-30 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Wow, does that mean he can cash in a Knuth check?

--
nosy: +georg.brandl

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



[issue8828] Atomic function to rename a file

2012-01-30 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 80ddbd87 by Antoine Pitrou in branch 'default':
Issue #8828: Add new function os.replace(), for cross-platform renaming with 
overwriting.
http://hg.python.org/cpython/rev/80ddbd87

--
nosy: +python-dev

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



[issue8828] Atomic function to rename a file

2012-01-30 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

os.replace() committed in 3.3!

--
resolution:  - fixed
stage: patch review - committed/rejected
status: open - closed

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-30 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 I know that the underlying C function expects a timespec structure,
 but Python can try to use a higher level API, isn't it?

I agree entirely.

--

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



[issue13903] New shared-keys dictionary implementation

2012-01-30 Thread Mark Shannon

Mark Shannon m...@hotpy.org added the comment:

Does this really need a PEP?
There is no new language feature and no change to any API.
It is just saving some memory.

The only possible issue is changing dict repr() ordering, 
but issue 13703 will do that anyway.

--

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



[issue13703] Hash collision security issue

2012-01-30 Thread Dave Malcolm

Dave Malcolm dmalc...@redhat.com added the comment:

I slightly messed up the test_hash.py changes.

Revised patch attached:
  optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-002.patch

--
Added file: 
http://bugs.python.org/file24371/optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-002.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13703
___diff -r e7706bdaaa0d Doc/library/sys.rst
--- a/Doc/library/sys.rst   Fri Jan 27 09:48:47 2012 +0100
+++ b/Doc/library/sys.rst   Mon Jan 30 17:21:17 2012 -0500
@@ -220,6 +220,7 @@
:const:`ignore_environment`   :option:`-E`
:const:`verbose`  :option:`-v`
:const:`bytes_warning`:option:`-b`
+   :const:`hash_randomization`   :option:`-R`
= =
 
 
diff -r e7706bdaaa0d Doc/reference/datamodel.rst
--- a/Doc/reference/datamodel.rst   Fri Jan 27 09:48:47 2012 +0100
+++ b/Doc/reference/datamodel.rst   Mon Jan 30 17:21:17 2012 -0500
@@ -1265,6 +1265,8 @@
inheritance of :meth:`__hash__` will be blocked, just as if :attr:`__hash__`
had been explicitly set to :const:`None`.
 
+   See also the :option:`-R` command-line option.
+
 
 .. method:: object.__bool__(self)
 
diff -r e7706bdaaa0d Doc/using/cmdline.rst
--- a/Doc/using/cmdline.rst Fri Jan 27 09:48:47 2012 +0100
+++ b/Doc/using/cmdline.rst Mon Jan 30 17:21:17 2012 -0500
@@ -21,7 +21,7 @@
 
 When invoking Python, you may specify any of these options::
 
-python [-bBdEhiOsSuvVWx?] [-c command | -m module-name | script | - ] 
[args]
+python [-bBdEhiORsSuvVWx?] [-c command | -m module-name | script | - ] 
[args]
 
 The most common use case is, of course, a simple invocation of a script::
 
@@ -215,6 +215,30 @@
Discard docstrings in addition to the :option:`-O` optimizations.
 
 
+.. cmdoption:: -R
+
+   Turn on hash randomization, so that the :meth:`__hash__` values of str,
+   bytes and datetime objects are salted with an unpredictable random value.
+   Although they remain constant within an individual Python process, they
+   are not predictable between repeated invocations of Python.
+
+   This is intended to provide protection against a denial-of-service
+   caused by carefully-chosen inputs that exploit the worst case performance
+   of a dict lookup, O(n^2) complexity.  See:
+
+   http://www.ocert.org/advisories/ocert-2011-003.html
+
+   for details.
+
+   Changing hash values affects the order in which keys are retrieved from
+   a dict.  Although Python has never made guarantees about this ordering
+   (and it typically varies between 32-bit and 64-bit builds), enough
+   real-world code implicitly relies on this non-guaranteed behavior that
+   the randomization is disabled by default.
+
+   See also :envvar:`PYTHONHASHRANDOMIZATION`.
+
+
 .. cmdoption:: -s
 
Don't add user site directory to sys.path
@@ -435,6 +459,24 @@
import of source modules.
 
 
+.. envvar:: PYTHONHASHRANDOMIZATION
+
+   If this is set to a non-empty string it is equivalent to specifying the
+   :option:`-R` option.
+
+
+.. envvar:: PYTHONHASHSEED
+
+   If this is set, it is used as a fixed seed for generating the hash() of
+   the types covered by the :option:`-R` option (or its equivalent,
+   :envvar:`PYTHONHASHRANDOMIZATION`.
+
+   Its purpose is for use in selftests for the interpreter.
+
+   It should be a decimal number in the range [0; 4294967295].  Specifying
+   the value 0 overrides the other setting, disabling the hash random salt.
+
+
 .. envvar:: PYTHONIOENCODING
 
Overrides the encoding used for stdin/stdout/stderr, in the syntax
diff -r e7706bdaaa0d Include/object.h
--- a/Include/object.h  Fri Jan 27 09:48:47 2012 +0100
+++ b/Include/object.h  Mon Jan 30 17:21:17 2012 -0500
@@ -473,6 +473,12 @@
 PyAPI_FUNC(long) _Py_HashDouble(double);
 PyAPI_FUNC(long) _Py_HashPointer(void*);
 
+typedef struct {
+long prefix;
+long suffix;
+} _Py_HashSecret_t;
+PyAPI_DATA(_Py_HashSecret_t) _Py_HashSecret;
+
 /* Helper for passing objects to printf and the like */
 #define PyObject_REPR(obj) _PyUnicode_AsString(PyObject_Repr(obj))
 
diff -r e7706bdaaa0d Include/pydebug.h
--- a/Include/pydebug.h Fri Jan 27 09:48:47 2012 +0100
+++ b/Include/pydebug.h Mon Jan 30 17:21:17 2012 -0500
@@ -19,6 +19,7 @@
 PyAPI_DATA(int) Py_DontWriteBytecodeFlag;
 PyAPI_DATA(int) Py_NoUserSiteDirectory;
 PyAPI_DATA(int) Py_UnbufferedStdioFlag;
+PyAPI_DATA(int) Py_HashRandomizationFlag;
 
 /* this is a wrapper around getenv() that pays attention to
Py_IgnoreEnvironmentFlag.  It should be used for getting variables like
diff -r e7706bdaaa0d Include/pythonrun.h
--- a/Include/pythonrun.h   Fri Jan 27 09:48:47 2012 +0100
+++ b/Include/pythonrun.h   Mon Jan 30 17:21:17 2012 -0500
@@ -174,6 +174,8 @@
 PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
 PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, 

[issue13837] test_shutil fails with symlinks enabled under Windows

2012-01-30 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
nosy: +skrah

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

Version 5:
 - add datetime and timespec formats: datetime.datetime object and  (sec: 
int, nsec: int)
 - add timestamp optional format to os.stat(), os.lstat(), os.fstat(), 
os.fstatat()
 - support passing the timestamp format as a keyword: 
time.time(format=decimal)

I am not really conviced by the usefulness of timespec format, but it was 
just an example for #11457.

The datetime format is surprising for time.clock() and time.wallclock(), 
these timestamps use an arbitrary start. I suppose that 
time.clock(format=datetime) and time.wallclock(format=datetime) should 
raise a ValueError.

--
Added file: http://bugs.python.org/file24372/time_decimal-5.patch

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


Removed file: http://bugs.python.org/file24367/time_decimal-4.patch

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Brett Cannon

Brett Cannon br...@python.org added the comment:

I see your mistake now: you need to call it as __import__('pkgB', globals(), 
index=1), else __import__ has no clue how to anchor your import in the relative 
package space.

Try that and let me know if it makes it work.

And why exactly are you trying to call __import__ directly? You should be using 
importlib.import_module() for programmatic imports.

--

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



[issue11457] os.stat(): add new fields to get timestamps as Decimal objects with nanosecond resolution

2012-01-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

I attached a more complete patch to the issue #13882: it adds an optional 
timestamp format to os.stat(), os.lstat(), os.fstat(), os.fstatat().

Examples:

$ ./python 
Python 3.3.0a0 (default:2914ce82bf89+, Jan 30 2012, 23:07:24) 
 import os
 s=os.stat(setup.py, timestamp=datetime)
 s.st_mtime - s.st_ctime
datetime.timedelta(0)
 print(s.st_atime - s.st_ctime)
52 days, 1:44:06.191293
 os.stat(setup.py, timestamp=timespec).st_ctime
(1323458640, 702327236)
 os.stat(setup.py, timestamp=decimal).st_ctime
Decimal('1323458640.702327236')

--

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

On Sun, Jan 29, 2012 at 6:42 PM, STINNER Victor rep...@bugs.python.org wrote:
..
 What do you call a constant argument? float and decimal?
 You would prefer a constant like time.FLOAT_FORMAT?
 Or maybe a boolean (decimal=True)?

Yes. This was explained on python-dev not so long ago:

http://mail.python.org/pipermail/python-dev/2010-July/102100.html

The problem is not with the type of the argument (although boolean or
enum argument type is often a symptom pointing to the issue.)  The
issue is that an argument that is never given a variable value at the
call site is usually a sign of an awkward API.  For example, what
would you prefer:

math('log', x)

or

math.log(x)

?


 I chose a string because my first idea was to add a registry to support other 
 format,
 maybe user defined formats, like the one used by Unicode codecs.

With all my respect for MAL, codecs are not my favorite part of the
python library.

One possibility (still awkward IMO) would be to use the return type as
the format specifier.  This would at least require the user to import
datetime or decimal before calling time() with corresponding format.
Few users would tolerate I/O delay when they want to get time with
nanosecond precision.

--

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Jason R. Coombs

Jason R. Coombs jar...@jaraco.com added the comment:

Thanks for the tip Brent. Still, no luck.

jaraco@devjaraco:~$ python2.7 -c 'import master.pkgA; 
print(pkgA.__package__ is {}.format(master.pkgA.__package__)); import 
master.pkgA.foo'
pkgA.__package__ is None
Traceback (most recent call last):
  File string, line 1, in module
  File master/pkgA/foo.py, line 2, in module
bar = __import__('pkgB', globals(), level=1).bar
ImportError: No module named pkgB

I considered importlib, but it is only included for Python 2.7+ and I have to 
support Python 2.6. I'm using programmatic imports for a few  reasons:

1) I'm importing the modules for the side effects, so I don't need or want the 
name in the namespace.
2) If I import it naturally, I get pyflakes warnings that it's an used imports.
3) The order of imports is important. If I place it too early in the imports, 
it doesn't have the state it needs and fails.
4) By placing it in the top of the file with other imports, it's not obvious 
why it's being imported, so requires comments.
5) The most appropriate place to invoke this functionality is in a specific 
function, run_app.

I see now that there is an importlib backport in the cheeseshop for earlier 
versions of Python. Given your recommendation, I'll give that a try.

--

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 One possibility (still awkward IMO) would be to use the return type as
 the format specifier.

Yeah, I already thaught to this idea. The API would be:
 - time.time(format=float)
 - time.time(format=decimal.Decimal)
 - time.time(format=datetime.datetime)
 - time.time(format=?) # for timespec, but I don't think that we need timespec 
in Python which is a object oriented language, we can use better than low level 
strutures
 - os.stat(path, format=decimal.Decimal)
 - etc.

I have to write a function checking that obj is decimal.Decimal or 
datetime.datetime without importing the module. I suppose that it is possible 
by checking obj type (it must be a class) and then obj.__module__.

 This would at least require the user to import
 datetime or decimal before calling time() with corresponding
 format.

Another possibility is what I proposed before in the issue #11457: take a 
callback argument.
http://bugs.python.org/issue11457#msg143738

The callback prototype would be:

def myformat(seconds, floatpart, divisor):
return ...

Each module can implements its own converter and time can provide some builtin 
converts (because I don't want to add something related to time in the decimal 
module for example).

But I don't really like this idea because it requires to decide the API of the 
low level structure of a timestamp (which may change later), and it doesn't 
really solve the issue of import decimal if the converter is in the time 
module.

--

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



[issue13882] Add format argument for time.time(), time.clock(), ... to get a timestamp as a Decimal object

2012-01-30 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

On Mon, Jan 30, 2012 at 6:15 PM, STINNER Victor rep...@bugs.python.org wrote:
 Another possibility is what I proposed before in the issue #11457: take a 
 callback argument.
 http://bugs.python.org/issue11457#msg143738

I think you are over-engineering a complicated solution to a simple
problem.  If you want to add functionality to time module, add a
function with a new name that would mimic appropriate POSIX API and
return a (named) tuple of integers where C function would populate a
struct.  If you write a new high resolution time module - import
decimal at the top of the module and make all your clocks return
seconds as Decimal objects.

--

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



[issue13609] Add os.get_terminal_size() function

2012-01-30 Thread Zbyszek Szmek

Zbyszek Szmek zbys...@in.waw.pl added the comment:

Updated version following comments by Victor Stinner: termsize.diff.7

- os.get_terminal_size() is moved to shutil.get_terminal_size()
- some small doc updates

Victor STINNER wrote:
 I noticed that bash uses $LINES, not $ROWS. I have renamed rows to
 lines everywhere, to follow existing convention.
 The stty program has rows and columns commands to set the terminal
Yes, also struct winsize uses 'rows' and 'cols'. But since we use the variable 
$LINES, it seems better to use 'lines'.

Thanks for the link to SUSv2! I've added a link in the docs, since it adds a 
nice justification to the COLUMNS/query/fallback behaviour.

Now get_terminal_size() lives in shutil. I don't think it matters much, but I 
see the point of keeping os clean.

I also looked at some programs, to see who behaves how.
dpkg - COLUMNS first
aptitude - ignores COLUMNS
git - COLUMNS first
systemctl, loginctl, systemd-cgls (systemd cmdline interface) - COLUMNS first
less, w -  ioctl, COLUMNS as fallback

(Of course this is very unscientific, because I just picked some programs at 
random which I remembered to care about the terminal size).
I guess that the case of 'less' is special, because less is very
much dependent on the terminal and does quite a lot of manipulations on it. 
Otherwise, taking COLUMNS as highest priority seems well established, even if 
not universal.

--
Added file: http://bugs.python.org/file24373/termsize.diff.7

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Eric Snow

Eric Snow ericsnowcurren...@gmail.com added the comment:

Jason: just a warning.  importlib_backport is a relatively naive tool for 
generating the backport from the py3k source.  It's also relatively fragile and 
at this point probably doesn't work with the default branch.

--

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



[issue13703] Hash collision security issue

2012-01-30 Thread Martin

Martin gzl...@googlemail.com added the comment:

 Has anyone had a chance to try this patch on Windows?  Martin?  I'm
 hoping that it doesn't impose a startup cost in the default
 no-randomization cost, and that any startup cost in the -R case is
 acceptable.

Just tested as requested. Is the patch against 3.1 for a reason? Can't
really be compared to earlier results, but get enough weird outliers
that that may not be useful anyway. Also needed the following change:

-+chunk = Py_MIN(size, INT_MAX);
++chunk = size  INT_MAX ? INT_MAX : size;

Summary, looks like extra work in the default case is avoided and
isn't crippling otherwise, though there were a couple of very odd runs
not presented probably due to other disk access.

Vanilla:

timeit PCbuild\python.exe -c import sys;print(sys.version)
3.1.4+ (default, Jan 30 2012, 22:38:52) [MSC v.1500 32 bit (Intel)]

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:10:42 pm, Monday, January 30 2012
Elapsed Time: 0:00:00.218
Process Time: 0:00:00.187
System Calls: 3974
Context Switches: 574
Page Faults:  1696
Bytes Read:   480331
Bytes Written:0
Bytes Other:  190860


Patched:

timeit PCbuild\python.exe -c import sys;print(sys.version)
3.1.4+ (default, Jan 30 2012, 22:55:06) [MSC v.1500 32 bit (Intel)]

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:10:55 pm, Monday, January 30 2012
Elapsed Time: 0:00:00.218
Process Time: 0:00:00.187
System Calls: 3560
Context Switches: 441
Page Faults:  1660
Bytes Read:   461956
Bytes Written:0
Bytes Other:  24926


timeit PCbuild\python.exe -Rc import sys;print(sys.version)
3.1.4+ (default, Jan 30 2012, 22:55:06) [MSC v.1500 32 bit (Intel)]

Version Number:   Windows NT 5.1 (Build 2600)
Exit Time:11:05 pm, Monday, January 30 2012
Elapsed Time: 0:00:00.249
Process Time: 0:00:00.234
System Calls: 3959
Context Switches: 483
Page Faults:  1847
Bytes Read:   892464
Bytes Written:0
Bytes Other:  27090

--

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



[issue13857] Add textwrap.indent() as counterpart to textwrap.dedent()

2012-01-30 Thread Ezra Berch

Ezra Berch ezrabe...@mac.com added the comment:

I've created a patch using the conditional expression in msg151945. The one 
problem I found with it is that when the input string is terminated by a 
newline it removes that newline.

I've added an optional third argument: a function which determines which lines 
are indented. If omitted, the default behavior is to indent non-empty lines.

--
keywords: +patch
nosy: +ezberch
Added file: http://bugs.python.org/file24374/indent.patch

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



[issue13703] Hash collision security issue

2012-01-30 Thread Dave Malcolm

Dave Malcolm dmalc...@redhat.com added the comment:

Am attaching a backport of 
optin-hash-randomization-for-3.1-dmalcolm-2012-01-30-002.patch to 2.6

Randomization covers the str, unicode and buffer types; equality of hashes is 
preserved for these types.

--
Added file: 
http://bugs.python.org/file24375/optin-hash-randomization-for-2.6-dmalcolm-2012-01-30-001.patch

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



[issue13912] ImportError using __import__ and relative level 1

2012-01-30 Thread Eric Snow

Eric Snow ericsnowcurren...@gmail.com added the comment:

The problem is your level is off and the name is incomplete.  
master.pkgA.foo.py should have the following:

__import__('pkgB.bar', master.pkgA.__dict__, level=2).bar

or 

__import__('pkgB.bar', master.pkgA.__dict__, fromlist=['-'], level=2)

--

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



[issue13903] New shared-keys dictionary implementation

2012-01-30 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
assignee:  - rhettinger

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



[issue13903] New shared-keys dictionary implementation

2012-01-30 Thread Raymond Hettinger

Raymond Hettinger raymond.hettin...@gmail.com added the comment:

Changing dictionaries is a big deal.  You're changing many pieces at once (not 
a good idea) including changing tunable parameters that are well-studied (I 
spent a month testing whether 5/8 was better idea that 2/3 for resizing or when 
the ideal small dict size was 4, 8, or 16).  You're changing the meaning of the 
fields in dictobject.h which will likely break any code that relied on those.

The ideas may be good ones but they warrant a good deal of thought.  Dicts 
weren't just slapped together -- the current code is the product to two decades 
of tweaking by engineers who devoted significant time to the task.  It would be 
easy to unknowingly undo some of their work.

--

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

I tested on 3.2, Win 7. sys.path starts with '' on startup, after restart, and 
after ^c interrupt of 'while True: pass'. It start with absolute path when 
running a file from the editor. I believe this is as should be.

I simplified the patch a bit. Its basic idea is to add a parameter with_cwd to 
PyShell.ModifiedInterpreter.transfer_path. That method is called by methods 
start_subprocess and restart_subprocess. start_process is only called by 
PyShell.PyShell.begin. So I think there is no need to propagate the new 
parameter back past the call in start_subprocess.

.restart_subprocess is called in .poll_subprocess, .runcode, 
PyShell.cancel_process, and PyShell.restart_shell. (I am a little puzzled why 
ModifiedInterpreter.runcode calls self.interp.restart_subprocess, as in the 
PyShell methods, instead of self.restart_subprocess, as in poll_subprocess, but 
moving on...)

restart_process needs the new parameter to pass to transfer_path because it 
should be True for F6 Restart Shell and not for F5 Run Module. Roger's patch 
also left the default False for the other calls. I do not know what they do so 
I cannot judge them. Roger, do you know, and did you consider each? (Leaving 
the current behavior for those will at worst not fix something that could be, 
so it is safe.)

restart_shell is *bound* to F6 Restart Shell (which passes the ignored even), 
so the default with_cwd must be True for that binding. It is *called* by a 
function ScriptBinding.py that gets bound, so the call can be altered to pass 
the correct False. I prefer that to making two functions. That call could be 
replaces by a call directly to .interp.restart_subprocess(False) (and 
restart_shell slightly simplified).

I retested after these changes to the patch. It is from TortoiseHG, so should 
apply (after I modified the file paths). Since hacking on idlelib is new for 
me, I would like other eyes and tests before I apply.

--
assignee:  - terry.reedy
Added file: http://bugs.python.org/file24376/issue13506c.diff

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


Removed file: http://bugs.python.org/file24376/issue13506c.diff

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

Whoops, hit submit too soon, before saving tab to space change.

--
Added file: http://bugs.python.org/file24377/issue13506d.diff

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Roger Serwy

Roger Serwy roger.se...@gmail.com added the comment:

I tested your patch and it works. For the sake of completeness, here's what I 
did:

Test 1: Start IDLE in shell mode and run import sys; print(sys.path). The 
first entry should be ''

This is consistent with the behavior of the regular python shell.

Test 2: Restart the shell with Ctrl+F6 (and View-Restart Shell) and repeat 
Test 1. This should give the same result.

Test 3: Create a script in /tmp/a.py with import sys; print(sys.path) as its 
contents. Running this script from the editor gives '/tmp' as the first entry.

This is consistent with the behavior of running python3 /tmp/a.py.

I'd make one minor change to the patch for sake of being explicit in 
ScriptBinding.py:
shell.restart_shell(event, with_cwd=False)

My rationale was to modify only PyShell.py to get the correct behavior. 
Clearly, making a simple modification to ScriptBinding.py gives a much shorter 
solution. I also like your simplification for start_subprocess. 

I did consider each case of default arguments. I developed my patch iteratively 
starting by having with_cwd=False for all function calls that called 
transfer_path so that the existing (incorrect) behavior remained. I then 
modified how these functions were called, setting with_cwd=True in the cases 
where '' needed to be transferred, namely on the shell start and restart from 
within the PyShell window. That is why I introduced 
restart_shell_interactive. I do agree with your reasoning that one function 
call is better than two.

--

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



[issue13701] Remove Decimal Python 2.3 Compatibility

2012-01-30 Thread Ramchandra Apte

Ramchandra Apte maniandra...@gmail.com added the comment:

There is another problem with the code it creates a dummy module when threading 
is not available but now threading imports dummy_threading when threading is 
not available.

Thanks

--

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



[issue13506] IDLE sys.path does not contain Current Working Directory

2012-01-30 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 1b5abba0c808 by Terry Jan Reedy in branch '2.7':
#13506 Add '' to path for interactive interpreter by adding with_cwd parameter
http://hg.python.org/cpython/rev/1b5abba0c808

New changeset 1993aa091d89 by Terry Jan Reedy in branch '3.2':
#13506 Add '' to path for interactive interpreter by adding with_cwd parameter
http://hg.python.org/cpython/rev/1993aa091d89

New changeset acedd92086c5 by Terry Jan Reedy in branch 'default':
Merge 3.2
http://hg.python.org/cpython/rev/acedd92086c5

--
nosy: +python-dev

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