odt2sphinx 0.2 released

2012-05-31 Thread Christophe de Vienne
Hello,

odt2sphinx 0.2 is now available on pypi :

http://pypi.python.org/pypi/odt2sphinx/.

Odt2sphinx convert OpenDocument Text file(s) to one or several .rst
files suitable for Sphinx.

Changes
---

* Now supports python 3
* Explicitely added PIL as a dependency (issue #2).

Regards,

Christophe de Vienne
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: SfePy 2012.2

2012-05-31 Thread Robert Cimrman

I am pleased to announce release 2012.2 of SfePy.

Description
---
SfePy (simple finite elements in Python) is a software for solving
systems of coupled partial differential equations by the finite element
method. The code is based on NumPy and SciPy packages. It is distributed
under the new BSD license.

Home page: http://sfepy.org
Downloads, mailing list, wiki: http://code.google.com/p/sfepy/
Git (source) repository, issue tracker: http://github.com/sfepy

Highlights of this release
--
- reimplemented acoustic band gaps code using the homogenization engine
- high order quadrature rules
- unified dot product and mass terms, lots of other term updates/fixes,
- updated the PDE solver application

For full release notes see http://docs.sfepy.org/doc/release_notes.html#id1
(rather long and technical).

Best regards,
Robert Cimrman and Contributors (*)

(*) Contributors to this release (alphabetical order):

Vladimír Lukeš, Andre Smit
--
http://mail.python.org/mailman/listinfo/python-announce-list

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


PyCon DE 2012 - Today: Deadline for Talk and Tutorial Proposals

2012-05-31 Thread Mike Müller
Dear Pythonistas,

The last day of May marks the last chance to submit a talk
or tutorial proposal for PyCon DE 2012. Don't miss this chance
to speak at the largest gathering of the German-speaking
Python community.

Talks and tutorials in English are welcome if you are not
comfortable with German.

Please spread the word and let other, interested people know
about this deadline.

Cheers,
Mike


PyCon DE 2012 - Call for Papers
===

The second PyCon DE will be held October 29 - November 3, 2012
in Leipzig Germany. We ask you to submit your proposal for a talk [2].
Details of the call are below in German.

The conference language will be German. However, talks in English by
non-native German speakers will be accepted.


PyCon DE 2012 - Aufruf zur Vorträgen
=

Ab sofort kann jeder, der sich für Python interessiert, einen Vortragsvorschlag
für die PyCon DE 2012 einreichen [1]. Es gibt nur zwei Bedingungen: Das Thema
sollte interessant sein, und es sollte etwas mit Python zu tun haben. Für die
zweite Python-Konferenz sind wir an einer breiten Themenpalette interessiert,
die das ganze Spektrum der Entwicklung, Nutzung und Wirkung von Python zeigt.
Folgende Tracks sind geplant:

Python als Programmiersprache
-

* Fortgeschrittene Programmierung, zum Beispiel Metaprogramming
* CPython
* Python-Kernentwicklung
* Python-Implementierungen (PyPy,  Jython, IronPython)
* Python 3
* Zukünftige Entwicklungen

Webanwendungen mit Python
-

* Web-Frameworks für Python
* Best Practises für die Python-Programmierung
* Kombination von Python und JavaScript
* Contentmanagement mit Python

Anwendungsbereiche
--

* Wissenschaftliche Anwendungen mit Python
* Python für Finanz-Anwendungen
* Lehre mit Python / Python als erste Programmiersprache
* Python im Unternehmensumfeld
* Systemintegration mit Python
* Grafische Nutzerschnittstellen (GUIs)
* Datenbankanwendungen mit Python
* Python für die Hardware-Steuerung

Softwareentwicklung
---

* Testen von Python-Programmen
* Agile Entwicklung mit Python
* Algorithmen mit Python
* Datenstrukturen mit Python
* Design-Patterns mit Python
* Parallele Programmierung mit Python
* Einbetten von Python in andere Anwendungen

Werkzeuge
-

* Packaging von Python-Bibliotheken
* Deployment von Python-Anwendungen
* IDEs für Python
* Plattformen wie GAE, EC2

Python-Community


* Marketing für Python
* Python, Open Source und Entwickler-Gemeinschaft

Mehr ...


Ihr Themenbereich ist nicht aufgelistet, wäre aber aus Ihrer Sicht für die
PyCon DE interessant? Kein Problem. Reichen Sie Ihren Vortragsvorschlag einfach
ein. Auch wir können nicht alle Anwendungsbereiche von Python überschauen.
Vortragstage sind der 30. und 31. Oktober sowie der 1. November 2012.

Es gibt zwei Vortragsformate:

Standard-Vortrag -- 20 Minuten Vortrag + 5 Minuten Diskussion
Lang-Vortrag -- 45 Minuten Vortrag + 10 Minuten Diskussion

Die Vortragszeit wird strikt eingehalten. Bitte testen Sie die Länge Ihres
Vortrags. Lassen Sie gegebenenfalls ein paar Folien weg. Die Vortragssprache ist
Deutsch. In begründeten Ausnahmefällen können Vorträge auch auf Englisch
gehalten werden. Bitte fragen Sie uns dazu. Bitte reichen Sie Ihren Vortrag auf
über die Konferenz-Website [2] ein bis zum 31.05.2012 ein. Wir entscheiden bis
zum 30. Juni 2012 über die Annahme der Vorträge.

[1] http://2012.de.pycon.org/news/2012/05/07/call-for-papers/
[2] http://2012.de.pycon.org/proposals/submit/talk/

PyCon DE 2012 - Call for Tutorials
==

The second PyCon DE will be held October 29 - November 3, 2012
in Leipzig, Germany. We ask you to submit your proposal for a tutorial [1].
Details of the call are below in German.

The conference language will be German. However, tutorials in English by
non-native German speakers will be accepted.


PyCon DE 2012 - Aufruf zu Tutorials
===

Wir rufen alle erfahrenen Python-Nutzer auf, Bewerbungen für Tutorials für die
PyCon DE 2012 einzureichen. Die Tutorials finden am 29. Oktober 2012 im Rahmen
der PyCon DE (http://de.pycon.org) statt. Ein Tutorial soll drei Stunden dauern.

Die Themen der Tutorials können Einführung in Python, fortgeschrittene Themen,
Web-Frameworks oder andere große Python-Bibliotheken sowie typische
Softwareentwicklungsarbeiten wie Testen oder Versionskontrolle mit Python sein.

Bitte reichen Sie Ihren Vorschlag bis zum 31. Mai 2012 über
Konferenz-Website [1] ein.

Der Vorschlag muss Folgendes enthalten:

* Titel
* Kurzbeschreibung des Inhaltes
* Zielgruppe (Anfänger, Fortgeschrittene, Experten)
* stichpunktartige Gliederung des Tutorials mit Zeitangaben zu den einzelnen
  Punkten (die Summe muss 180 Minuten betragen)

Jedes Tutorial umfasst zwei Blöcke mit je 90 Minuten mit einer halbstündigen
Pause. Eine Person kann Vorschläge für zwei Tutorials 

[ANN] bzr 2.5.1 released

2012-05-31 Thread Vincent Ladeuil

Hi all,

Here comes our new stable release: 2.5.1

Bazaar http://bazaar.canonical.com/ is a Canonical project and part of
the GNU project http://gnu.org/ to produce a free operating system.

This is a bugfix release. Upgrading is recommended for all users on
earlier 2.5 releases.

2.5.1 contains all known bug fixes for all stable releases (including
the ones we made for the previous stable series).

Thanks to all participants, whether you sent merge proposals, comments,
suggestions and feedback, we very much appreciate all of them.

Bazaar is now available for download from
https://launchpad.net/bzr/2.5/2.5.1/ as a source tarball.

Installers are available for OSX from the url above, windows ones are on
their way.

2.5.1 has also been uploaded to ubuntu.

The detailed changelog is available below,

Vincent

External Compatibility Breaks
*

None.

New Features


None.

Improvements


* ``bzr rmbranch`` now supports removing colocated branches.
  (Jelmer Vernooij, #920653)

* ``bzr rmbranch`` no longer removes active branches unless ``--force``
  is specified. (Jelmer Vernooij, #922953)

Bug Fixes
*

* Connecting with HTTPS via HTTP now correctly uses the host name of the
  destination rather than the proxy when checking certificates.
  (Martin Packman, #944696)

* Fixed merge tool availability checking and invocation to search the
  Windows App Path registry in addition to the PATH. (Gordon Tyler, #939605)

* Fixed problem with getting errors about failing to open /dev/tty when using
  Bazaar Explorer to sign commits. (Mark Grandi, #847388)

* Fix UnicodeEncodeError when translated progress task messages contain
  non-ascii text. (Martin Packman, #966934)

* Make sure configuration options can provide their own help topic.
  (Jelmer Vernooij, #941672)

Documentation
*

* The alpha-quality texinfo sphinx builder has been deprecated. Sphinx =
  1.1.2 now provides a better one. Most of the documentation can now be
  generated to the texinfo format with ``make texinfo-sphinx``. This will
  generate both the ``.texi`` files and the ``.info`` ones.
  (Vincent Ladeuil, #940164)

API Changes
***

None.

Testing
***

* Add support for pyftpdlib = 0.7.0 and drop support for previous pyftpdlib
  versions. (Vincent Ladeuil, #956027)

* Run smoketest for setup.py isolated in a tempdir. (Martin Packman, #140874)

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

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


Mémento Python 3

2012-05-31 Thread Laurent Pointal
Hello,

Here is an announce for a Mémento Python 3 (in French - English version will 
come later). It targets students learning basics of algorithmic and 
programming, some remarks are related to common errors we can see in 
practical courses. It dont cover object oriented programming.

http://perso.limsi.fr/pointal/python:memento


For a heavier document, the Abrégé Dense Python 3.1 is still here:

http://perso.limsi.fr/pointal/python:abrege

A+
L.Pointal

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

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


How to suppress exception printing to console?

2012-05-31 Thread Qi

Hi guys,

I have an application that embedding Python into C++.
When any exception occurred in C++ code, PyErr_SetString will
be called to propagate the exception to Python.

The problem is, some unit tests trigger exception on intention.
So it's OK to have the exceptions. But Python will still print
the exception to console, polluting the unit test output.

My question is, is there any way to disable exception reporting
to console from either C++ or Python code?


Thanks


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


Re: How to suppress exception printing to console?

2012-05-31 Thread Gelonida N

On 05/31/2012 09:57 AM, Qi wrote:

Hi guys,

I have an application that embedding Python into C++.
When any exception occurred in C++ code, PyErr_SetString will
be called to propagate the exception to Python.

The problem is, some unit tests trigger exception on intention.
So it's OK to have the exceptions. But Python will still print
the exception to console, polluting the unit test output.

My question is, is there any way to disable exception reporting
to console from either C++ or Python code?




Did you try to reassign sys.stderr to '/dev/null/ or another file?

This works of course only if no other code wants to write to sys.stderr.



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


colorbar of image

2012-05-31 Thread Mireille . Hagbe . Ngom

that is my script

from matplotlib import pyplot
img = pyplot.imread('image.png')
pyplot.imshow(img)
pyplot.show()

the problem is i want to display either colorbar associated to the  
image and image or just  colorbar associated to the image when i  
download image.png.how can i do?


tk's

mireille


This message was sent using IMP, the Internet Messaging Program.


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


Re: Maintaining Multiple Copies of Python (Linux)

2012-05-31 Thread Oscar Benjamin
On 31 May 2012 02:41, Nicholas Fitzkee nfitz...@gmail.com wrote:

 On Wednesday, May 30, 2012 7:55:33 PM UTC-5, Ben Finney wrote:

  The consensus solution for this is ‘virtualenv’
  URL:http://pypi.python.org/pypi/virtualenv.
 
  It is so popular as a solution for the kinds of problems you describe
  that its functionality will come into core Python, as discussed in PEP
  405 URL:http://www.python.org/dev/peps/pep-0405/, for Python 3.3.
 
  Until you start using Python 3.3, you can install ‘virtualenv’ as a
  third-party package.

 Thanks, Ben.

 I took a look at this, and I'm a little confused.  First, it doesn't seem
 all that different from ./configure --prefix=ENV with the exception that
 you save a little space re-using some libraries.  Second, it really doesn't
 solve my problem, because if ENV/bin/python is my PATH, it can still be
 confused with /usr/bin/python.  What am I missing?


Don't place it on your PATH. I would just use the explicit path of the
virtualenv binary so that I knew which one I was running. If you want to
access it from a name such as my-python2.7 on PATH then create a symlink
pointing to the virtualenv binary. Make sure the symlink is on your path
i.e. in somewhere like /usr/bin if it is needed for all users or just ~\bin
if it only needed for 1 user.

e.g.:
$ ln -s ENV/bin/python ~/bin/my-python2.7



 Thanks again,
 Nick
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Object cleanup

2012-05-31 Thread psaff...@googlemail.com
Thanks for all the responses.

It looks like none of the BeautifulSoup objects have __del__ methods, so I 
don't think that can be the problem.

To answer your other question, guppy was the best match I came up with when 
looking for a memory profile for Python (or more specifically Heapy):

http://guppy-pe.sourceforge.net/#Heapy

On Thursday, May 31, 2012 2:51:52 AM UTC+1, Steven D#39;Aprano wrote:
 
 The destructor doesn't get called into the last reference is gone.
 

That makes sense, so now I need to track down why there are references to the 
object when I don't think there should be. Are there any systematic methods for 
doing this?

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


Templating library which generates HTML+JS for interfacing RESTfully?

2012-05-31 Thread Alec Taylor
Are there any templating libraries—e.g.: Jinja2, Django Template Engine, Mako 
etc—which can be used to interface over REST, XMLRPC xor JSONRPC?

My use-cases follow:
1. Generate a website, e.g.: to run from example.com (currently every 
templating language does this out of the box)
2. Generate the JS, HTML and CSS to put into a mobile phone app (PhoneGap)
3. Generate JavaScript widget code for pasting onto your site (see footnote 
[1] for popular examples)

My current plan is to write the entire client using HTML, CSS 
(twitter-bootstrap responsive) and JavaScript—e.g.: with Backbone.js—allowing 
me to use that same client code for the website and PhoneGap clients. With that 
done, the widgets wouldn't be too difficult to extrapolate.

However, this seems like a really complex way of doing things, especially when 
taking into consideration checks requiring login, forced redirects and more 
fine grained RBAC.

Is there a templating language which can easily interface via REST (XML xor 
JSON), XMLRPC xor JSONRPC?

Thanks for all information and suggestions,

Alec Taylor

[1] | The example JavaScript widgets:
- DISQUS gives the following snippet:
 `script type=text/javascript 
src=http://example.disqus.com/combination_widget.js?num_items=5hide_mods=0color=bluedefault_tab=peopleexcerpt_length=200;/scripta
 href=http://disqus.com/;Powered by Disqus/a`

- Facebook gives the following snippet:
 `div id=fb-root/divscript(function(d, s, id) {var js, fjs = 
d.getElementsByTagName(s)[0];if (d.getElementById(id)) return;js = 
d.createElement(s); js.id = id;js.src = 
//connect.facebook.net/en_US/all.js#xfbml=1appId=237216179703726;fjs.parentNode.insertBefore(js,
 fjs);}(document, 'script', 'facebook-jssdk'));/script`
 `div class=fb-like data-send=true data-width=450 
data-show-faces=true/div`

- Twitter gives the following snippet:
 `script charset=utf-8 
src=http://widgets.twimg.com/j/2/widget.js;/scriptscriptnew 
TWTR.Widget({version: 2,type: 'profile',rpp: 4,interval: 3,width: 
250,height: 300,theme: {shell: {background: '#33',color: '#ff'},tweets: 
{background: '#00',color: '#ff',links: '#4aed05'}},features: 
{scrollbar: false,loop: false,live: false,behavior: 
'all'}}).render().setUser('twitter').start();/script`
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Object cleanup

2012-05-31 Thread Oscar Benjamin
On 31 May 2012 11:57, psaff...@googlemail.com psaff...@googlemail.comwrote:

 Thanks for all the responses.

 It looks like none of the BeautifulSoup objects have __del__ methods, so I
 don't think that can be the problem.

 To answer your other question, guppy was the best match I came up with
 when looking for a memory profile for Python (or more specifically Heapy):

 http://guppy-pe.sourceforge.net/#Heapy

 On Thursday, May 31, 2012 2:51:52 AM UTC+1, Steven D#39;Aprano wrote:
 
  The destructor doesn't get called into the last reference is gone.
 

 That makes sense, so now I need to track down why there are references to
 the object when I don't think there should be. Are there any systematic
 methods for doing this?


http://mg.pov.lt/blog/hunting-python-memleaks.html

http://pypi.python.org/pypi/objgraph




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

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


Re: Tkinter deadlock on graceful exit

2012-05-31 Thread Matteo Landi
On Thu, May 31, 2012 at 3:42 AM, Terry Reedy tjre...@udel.edu wrote:
 On 5/30/2012 6:19 PM, Matteo Landi wrote:

 On May/28, Matteo Landi wrote:

 Hi list,
 recently I started to work on an application [1] which makes use of the
 Tkinter
 module to handle interaction with the user.  Simply put, the app is a
 text
 widget displaying a file filtered by given criteria, with a handy feature
 that
 the window is raised each time a new line is added to the widget.

 The application mainly consists of three threads:  the first one, the
 file
 processor, reads the file, filters the lines of interest, and pushes them
 into
 a shared queue (henceforth `lines_queue`);  the second one, the
 gui_updater,
 pops elements from `lines_queue`, and schedule GUI updates using the
 `after_idle` method of the Tkinter module;  finally the last one, the
 worker
 spawner, receives commands by the gui (by means of a shared queue,
 `filters_queue`), and drives the application, terminating or spawning new
 threads.

 For example, let's see what happens when you start the application, fill
 the
 filter entry and press Enter button:
 1 the associated even handler is scheduled (we should be inside the
 Tkinter
   mainloop thread), and the filter is pushed into `filters_queue`;
 2 the worker spawner receives the new filter, terminate a possibly
 running
   working thread, and once done, create a new file processor;
 3 the file processor actually processes the file and fills the
 `lines_queue`
   with the lines matching given filter;
 4 the gui updater schedules GUI updates as soon as items are pushed into
   `lines_queue`
 5 Tkinter mainloop thread updates the gui when idle

 What happens when the main window is closed?  Here is how I implemented
 the
 graceful shutdown of the app:
 1 a quit event is scheduled and a _special_ message is pushed into both
   `filter_queue` and `lines_queue`
 2 the gui updater threads receives the _special_ message, and terminates
 3 the worker spawner receives the message, terminates the working thread
 and
   interrupts her execution.
 4 Tk.quit() is called after the quit event handler, and we finally quit
 the
   mainloop

 Honestly speaking, I see no issues with the algorithm presented above;
  however,
 if I close the window in the middle of updates of the text widget, the
 applications hangs indefinitely.  On the other hand, everything works as
 expected if I close the app when the file processor, for example, is
 waiting for
 new content to filter.

 I put some logging messages to analyze the deadlock (?!), and noticed
 that both
 the worker spawner and the file processor are terminated correctly.  The
 only
 thread still active for some strange reasons, is the gui updater.

 Do you see anything wrong with the description presented above?  Please
 say so,
 because I can't figure it out!


 Since no-one else answered, I will ask some questions based on little
 tkinter experience, no thread experience, and a bit of python-list reading.

 1. Are you only using tkinter in one thread? (It seems like so from the
 above)?

Yes, provided that `after_idle` queues a job for the gui thread


 2. Is root.destroy getting called, as in 24.1.2.2. A Simple Hello World
 Program in the most recent docs? (I specify 'most recent' because that
 example has been recently revised because the previous version sometimes
 left tkinter hanging for one of the code paths, perhaps similar to what you
 describe.

No, I'm not calling the destroy method of the main window but, why
that only happens while doing gui updates?


 3. Have you tried making the gui thread the master thread? (I somehow expect
 that the gui thread should be the last to shut down.)

No but, same question as above.

I'm not home right now, so I will try those solutions as soon as
possible.  Thanks.


Cheers,
Matteo


 --
 Terry Jan Reedy

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



-- 
http://www.matteolandi.net/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to suppress exception printing to console?

2012-05-31 Thread Steven D'Aprano
On Thu, 31 May 2012 15:57:08 +0800, Qi wrote:

 Hi guys,
 
 I have an application that embedding Python into C++. When any exception
 occurred in C++ code, PyErr_SetString will be called to propagate the
 exception to Python.
 
 The problem is, some unit tests trigger exception on intention. 

I'm sorry, I don't understand what you mean by on intention.


 So it's
 OK to have the exceptions. But Python will still print the exception to
 console, polluting the unit test output.

Are you using the Python unittest module, or C++ unit tests?

Python's unittest catches and suppresses exceptions, so it should not be 
printing exceptions except as part of the normal unittest output.

 
 My question is, is there any way to disable exception reporting to
 console from either C++ or Python code?

If your unit tests are raising exceptions, your tests are broken. They 
should either raise expected exceptions, in which case the exception is a 
passing test, or they are failing tests, or they are bugs in your test 
code. Fix the failing tests and the bugs in the test code, don't hide 
them.



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


Re: How to suppress exception printing to console?

2012-05-31 Thread Qi

On 2012-5-31 21:31, Steven D'Aprano wrote:

The problem is, some unit tests trigger exception on intention.


I'm sorry, I don't understand what you mean by on intention.


I mean the exception is expected.
The test will only pass if the embedded Python code raise
certain exception.


Are you using the Python unittest module, or C++ unit tests?

Python's unittest catches and suppresses exceptions, so it should not be
printing exceptions except as part of the normal unittest output.


I use a C++ unit test framework.



My question is, is there any way to disable exception reporting to
console from either C++ or Python code?


If your unit tests are raising exceptions, your tests are broken. They
should either raise expected exceptions, in which case the exception is a
passing test, or they are failing tests, or they are bugs in your test
code. Fix the failing tests and the bugs in the test code, don't hide
them.


No, I'm not hiding the exception.
I'm trying to hide the exception report text because it's not
necessary since the exception is expected.


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


Re: How to suppress exception printing to console?

2012-05-31 Thread Ulrich Eckhardt
Am 31.05.2012 09:57, schrieb Qi:
 I have an application that embedding Python into C++.
 When any exception occurred in C++ code, PyErr_SetString will
 be called to propagate the exception to Python.

The first sentence is clear. The second sentence rather sounds as if you
were implementing a Python module in C++. This is the opposite to
embedding Python in C++, it's rather embedding C++ in Python. Or is it a
C++ function called by Python which in turn was embedded by C++?


 The problem is, some unit tests trigger exception on intention.
 So it's OK to have the exceptions. But Python will still print
 the exception to console, polluting the unit test output.

I can only guess what you are doing, maybe you should provide a simple
piece of code (or, rather, one C++ piece and a Python piece) that
demonstrates the issue. What I could imagine is that the Python
interpreter shuts down with something it considers an unhandled
exception, which it then prints to stdout before exiting. When
embedding, that shouldn't happen from just calling a Python function in
a loaded script, those should just make the error available to the C++
side via PyErr functions etc.


 My question is, is there any way to disable exception reporting
 to console from either C++ or Python code?

What I found useful when embedding was that I could assign to sys.stdout
in order to redirect the output. In my case, the target was a window and
not a console. I'd consider that a workaround though. I really suspect
that Python considers the error unhandled and therefore dumps the info
to stdout.

Good luck!

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


Re: sqlite INSERT performance

2012-05-31 Thread duncan smith

On 31/05/12 06:15, John Nagle wrote:

On 5/30/2012 6:57 PM, duncan smith wrote:

Hello,
I have been attempting to speed up some code by using an sqlite
database, but I'm not getting the performance gains I expected.


SQLite is a lite database. It's good for data that's read a
lot and not changed much. It's good for small data files. It's
so-so for large database loads. It's terrible for a heavy load of
simultaneous updates from multiple processes.



Once the table is created the data will not be changed at all. 
Corresponding integer codes will have to be generated for columns. (I 
want to do this lazily because some columns might never be needed for 
output files, and processing all columns was relatively expensive for my 
initial solution.) After that it's a series of 'SELECT a, b, ... FROM 
table WHERE f=g ORDER by a, b, ...' style queries dumped to space 
separated text files.



However, wrapping the inserts into a transaction with BEGIN
and COMMIT may help.



Unfortunately there's no discernible difference.


If you have 67 columns in a table, you may be approaching the
problem incorrectly.



Quite possibly. I have defined start and end points. The data are 
contained in text files. I need to do the mapping to integer codes and 
generate output files for subsets of variables conditional on the levels 
of other variables. (I was doing the subsequent sorting separately, but 
if I'm using SQL I guess I might as well include that in the query.) The 
output files are inputs for other (C++) code that I have no control over.


Any approach that doesn't consume large amounts of memory will do. Cheers.

Duncan

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


Re: sqlite INSERT performance

2012-05-31 Thread Jon Clements
On Thursday, 31 May 2012 16:25:10 UTC+1, duncan smith  wrote:
 On 31/05/12 06:15, John Nagle wrote:
  On 5/30/2012 6:57 PM, duncan smith wrote:
  Hello,
  I have been attempting to speed up some code by using an sqlite
  database, but I'm not getting the performance gains I expected.
 
  SQLite is a lite database. It's good for data that's read a
  lot and not changed much. It's good for small data files. It's
  so-so for large database loads. It's terrible for a heavy load of
  simultaneous updates from multiple processes.
 
 
 Once the table is created the data will not be changed at all. 
 Corresponding integer codes will have to be generated for columns. (I 
 want to do this lazily because some columns might never be needed for 
 output files, and processing all columns was relatively expensive for my 
 initial solution.) After that it's a series of 'SELECT a, b, ... FROM 
 table WHERE f=g ORDER by a, b, ...' style queries dumped to space 
 separated text files.
 
  However, wrapping the inserts into a transaction with BEGIN
  and COMMIT may help.
 
 
 Unfortunately there's no discernible difference.
 
  If you have 67 columns in a table, you may be approaching the
  problem incorrectly.
 
 
 Quite possibly. I have defined start and end points. The data are 
 contained in text files. I need to do the mapping to integer codes and 
 generate output files for subsets of variables conditional on the levels 
 of other variables. (I was doing the subsequent sorting separately, but 
 if I'm using SQL I guess I might as well include that in the query.) The 
 output files are inputs for other (C++) code that I have no control over.
 
 Any approach that doesn't consume large amounts of memory will do. Cheers.
 
 Duncan

It might be worth checking out https://sdm.lbl.gov/fastbit/ which has Python 
bindings (nb: the library itself takes a while to compile), but I'm not I00% 
sure it would meet all your requirements.

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


colorbar of image

2012-05-31 Thread mhagbeng

that is my script

from matplotlib import pyplot
img = pyplot.imread('image.png')
pyplot.imshow(img)
pyplot.show()

the problem is i want to display either colorbar associated to the 
image and image or just  colorbar associated to the image when i 
download image.png.how can i do?


tk's

mireille

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


reading txt file

2012-05-31 Thread Ahmed, Shakir
HI:
I am trying to read a txt file and dump the columns in an access database 
table. But getting problem:

 Unhandled exception while debugging...
Traceback (most recent call last):
  File C:\WindDuration\Reading_test.py, line 14, in module
my_length_1 = nmAddrList[1]
IndexError: list index out of range

Getting error when it is reading to second line.

The txt file is attached here and I need only 2,8,11,14,15 columns to dump in 
the table.


Any help is highly appreciated.

Thanks
sa



We value your opinion. Please take a few minutes to share your comments on the 
service you received from the District by clicking on this 
linkhttp://my.sfwmd.gov/portal/page/portal/pg_grp_surveysystem/survey%20ext?pid=1653.
FL Dade   Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  88kt 10/24 07

FL Monroe Existing   Existing   Existing   10/24 11E [04]  
10/24 12E [05]  10/24 15E [08]  94kt 10/24 07

FL CollierExisting   Existing   Existing   10/24 12E [05]  
10/24 13E [06]  10/24 15E [08]  104kt 10/24 0

FL BrowardExisting   Existing   Existing   10/24 13E [06]  
10/24 14E [07]  10/24 16E [09]  93kt 10/24 08

FL LeeExisting   Existing   Existing   10/24 10E [03]  
10/24 12E [05]  10/24 15E [08]  89kt 10/24 07

FL Hendry Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  100kt 10/24 0

FL Palm Beach Existing   Existing   Existing   10/24 14E [07]  
10/24 15E [08]  10/24 17E [10]  93kt 10/24 08

FL Charlotte  Existing   Existing   Existing   10/24 10E [03]  
10/24 12E [05]  10/24 15E [08]  76kt 10/24 07

FL Glades Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  91kt 10/24 09

FL Martin Existing   Existing   Existing   10/24 14E [07]  
10/24 15E [08]  10/24 17E [10]  92kt 10/24 11

FL St Lucie   Existing   Existing   10/24 08E  10/24 14E [06]  
10/24 15E [08]  10/24 17E [10]  89kt 10/24 11

FL Okeechobee Existing   Existing   Existing   10/24 13E [06]  
10/24 15E [08]  10/24 17E [10]  83kt 10/24 09

FL Highlands  Existing   Existing   Existing   10/24 12E [05]  
10/24 14E [07]  10/24 16E [09]  74kt 10/24 09

FL Desoto Existing   Existing   Existing   10/24 09E [02]  
10/24 12E [05]  10/24 15E [08]  67kt 10/24 08

FL Sarasota   Existing   Existing  
10/24 11E [04]  10/24 15E [08]  59kt 10/24 07

FL ManateeExisting   Existing  
10/24 11E [04]  10/24 15E [08]  56kt 10/24 07

FL Hardee Existing   Existing  
10/24 12E [05]  10/24 16E [09]  60kt 10/24 08

FL Pinellas   Existing  
   10/24 13E [06]  43kt 10/24 07

FL HillsborougExisting   Existing  
10/24 08E [01]  10/24 15E [08]  50kt 10/24 07

FL Polk   Existing   Existing  
10/24 13E [06]  10/24 16E [09]  60kt 10/24 09

FL OsceolaExisting   Existing   10/24 10E  10/24 11E [01]  
10/24 14E [07]  10/24 17E [10]  64kt 10/24 10

FL Indian RiveExisting   Existing   10/24 09E  10/24 14E [05]  
10/24 15E [08]  10/24 17E [10]  76kt 10/24 11

FL BrevardExisting   Existing   10/24 10E  10/24 13E [03]  
10/24 15E [08]  10/24 18E [11]  67kt 10/24 11

FL Orange Existing   10/24 09E 
10/24 13E [04]  10/24 17E [10]  53kt 10/24 11

FL Seminole   Existing  
   10/24 17E [10]  48kt 10/24 10

FL Lake   Existing  
   10/24 16E [09]  46kt 10/24 09

FL Sumter Existing  
   10/24 15E [08]  43kt 10/24 08

FL Pasco  Existing  
   10/24 15E [08]  43kt 10/24 08

FL Hernando   Existing  
   10/24 15E [08]  40kt 10/24 08

FL Citrus Existing  
   10/24 13E [06]  37kt 10/24 10

FL Marion Existing  
   10/24 15E [08]  39kt 10/24 10

FL VolusiaExisting  
   10/24 18E [11]  48kt 10/24 10

FL Flagler10/24 08E 
   10/24 16E [08]  40kt 10/24 11

FL Putnam 10/24 09E 
   10/24 16E [07]  38kt 10/24 12

FL St Johns   10/24 11E 
   

Re: reading txt file

2012-05-31 Thread MRAB

On 31/05/2012 16:02, Ahmed, Shakir wrote:

HI:
I am trying to read a txt file and dump the columns in an access database 
table. But getting problem:


 Unhandled exception while debugging...

Traceback (most recent call last):
   File C:\WindDuration\Reading_test.py, line 14, inmodule
 my_length_1 = nmAddrList[1]
IndexError: list index out of range

Getting error when it is reading to second line.

The txt file is attached here and I need only 2,8,11,14,15 columns to dump in 
the table.


Any help is highly appreciated.


Most of the lines end with \n followed by \r\n, so when you read
those lines you get a line of data followed by a blank line.

The simplest solution is just to skip blank lines.
--
http://mail.python.org/mailman/listinfo/python-list


Re: sqlite INSERT performance

2012-05-31 Thread duncan smith

On 31/05/12 17:06, Jon Clements wrote:

On Thursday, 31 May 2012 16:25:10 UTC+1, duncan smith  wrote:

On 31/05/12 06:15, John Nagle wrote:

On 5/30/2012 6:57 PM, duncan smith wrote:

Hello,
I have been attempting to speed up some code by using an sqlite
database, but I'm not getting the performance gains I expected.


SQLite is a lite database. It's good for data that's read a
lot and not changed much. It's good for small data files. It's
so-so for large database loads. It's terrible for a heavy load of
simultaneous updates from multiple processes.



Once the table is created the data will not be changed at all.
Corresponding integer codes will have to be generated for columns. (I
want to do this lazily because some columns might never be needed for
output files, and processing all columns was relatively expensive for my
initial solution.) After that it's a series of 'SELECT a, b, ... FROM
table WHERE f=g ORDER by a, b, ...' style queries dumped to space
separated text files.


However, wrapping the inserts into a transaction with BEGIN
and COMMIT may help.



Unfortunately there's no discernible difference.


If you have 67 columns in a table, you may be approaching the
problem incorrectly.



Quite possibly. I have defined start and end points. The data are
contained in text files. I need to do the mapping to integer codes and
generate output files for subsets of variables conditional on the levels
of other variables. (I was doing the subsequent sorting separately, but
if I'm using SQL I guess I might as well include that in the query.) The
output files are inputs for other (C++) code that I have no control over.

Any approach that doesn't consume large amounts of memory will do. Cheers.

Duncan


It might be worth checking out https://sdm.lbl.gov/fastbit/ which has Python 
bindings (nb: the library itself takes a while to compile), but I'm not I00% 
sure it would meet all your requirements.

Jon


Interesting. It might actually be more useful for the types of query 
performed by the C++ part of the application. I tried something based on 
bitwise operations on integers but couldn't quite match the performance 
of the recursive algorithm implemented (by others) in C++. Cheers.


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


Re: reading txt file

2012-05-31 Thread Terry Reedy

On 5/31/2012 11:02 AM, Ahmed, Shakir wrote:

When you want to start a new thread, make sure you start a new thread 
and do not post as a response to another thread. This will get lost as a 
response to 'How to suppress ...'.


Is this a homework, hobby, or work exercise?


I am trying to read a txt file and dump the columns in an access database table.


It is good that you posted the traceback. Some beginners omit that. But 
we usually also need to see the code that caused the problem -- but just 
that code. It is best if one can produce a minimal file that exhibits 
the problem.



Unhandled exception while debugging...

Traceback (most recent call last):
   File C:\WindDuration\Reading_test.py, line 14, inmodule
 my_length_1 = nmAddrList[1]
IndexError: list index out of range

Getting error when it is reading to second line.


 The txt file is attached here

Attachments do not work well on lists. They get omitted from responses. 
First *3* lines, copy and pasted:


FL Dade   Existing   Existing   Existing   10/24 12E 
[05]  10/24 14E [07]  10/24 16E [09]  88kt 10/24 07


FL Monroe Existing   Existing   Existing   10/24 11E 
[04]  10/24 12E [05]  10/24 15E [08]  94kt 10/24 07


I suspect your problem is with the blank line(s) between data lines, but 
I cannot tell for sure without your code. In any case, you have to skip 
them.


FL Desoto Existing   Existing   Existing   10/24 09E 
[02]  10/24 12E [05]  10/24 15E [08]  67kt 10/24 08


FL Sarasota   Existing   Existing 
   10/24 11E [04]  10/24 15E [08]  59kt 10/24 07


This data file is column-oriented and has missing values indicated by 
blank space. So you cannot separate fields with the .split method. 
Instead, you have to slice out each field with a pair of indexes.


To facilitate column counting, I would put a temporary line like
01234567890123456789012345678901234567890123456789... at the top.
(I also still have a special 'document rule' meant for this purpose. It 
is marked in 1/10 inch increments to count characters printed in a fixed 
10 chars per inch font such as Courier.)


There is also text at the bottom after a separator line
-- ...
so you will have to catch that and stop there.

--
Terry Jan Reedy

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


Re: cmd2, an extenstion of cmd that parses its argument list

2012-05-31 Thread Adam Tauno Williams
On Thu, 2012-04-26 at 12:16 -0700, anntzer@gmail.com wrote: 
 On Sunday, March 18, 2012 10:12:24 PM UTC-7, anntz...@gmail.com wrote:
  Dear all,
  I would like to announce the first public release of cmd2, an extension of 
  the standard library's cmd with argument parsing, here: 
  https://github.com/anntzer/cmd2.
 Due to an already existing Cmd2 on PyPI, I have renamed the project to 
 parsedcmd, which is also a better description of what the module does.
 https://github.com/anntzer/parsedcmd 
  Cmd2 is an extension built around the excellent cmd module of the standard
  library.  Cmd allows one to build simple custom shells using ``do_*`` 
  methods,
  taking care in particular of the REPL loop and the interactive help.  
  However,
  no facility is given for parsing the argument line (do_* methods are passed 
  the
  rest of the line as a single string argument).
  With Cmd2, ``do_*`` methods are type-annotated, either using Python 3's
  function annotation syntax, or with an ad-hoc ``annotate`` decorator, 
  allowing
  the dispatcher to parse the argument list for them.

This is much the same functionality added to Cmd by Cmd2.

Perhaps you could collaborate with Cmd2's author and merge your two
extensions.


signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cmd2, an extenstion of cmd that parses its argument list

2012-05-31 Thread Adam Tauno Williams
On Thu, 2012-05-31 at 15:21 -0400, Adam Tauno Williams wrote: 
 On Thu, 2012-04-26 at 12:16 -0700, anntzer@gmail.com wrote: 
  On Sunday, March 18, 2012 10:12:24 PM UTC-7, anntz...@gmail.com wrote:
   Dear all,
   I would like to announce the first public release of cmd2, an extension 
   of the standard library's cmd with argument parsing, here: 
   https://github.com/anntzer/cmd2.
  Due to an already existing Cmd2 on PyPI, I have renamed the project to 
  parsedcmd, which is also a better description of what the module does.
  https://github.com/anntzer/parsedcmd 
   Cmd2 is an extension built around the excellent cmd module of the standard
   library.  Cmd allows one to build simple custom shells using ``do_*`` 
   methods,
   taking care in particular of the REPL loop and the interactive help.  
   However,
   no facility is given for parsing the argument line (do_* methods are 
   passed the
   rest of the line as a single string argument).
   With Cmd2, ``do_*`` methods are type-annotated, either using Python 3's
   function annotation syntax, or with an ad-hoc ``annotate`` decorator, 
   allowing
   the dispatcher to parse the argument list for them.
 This is much the same functionality added to Cmd by Cmd2.
 Perhaps you could collaborate with Cmd2's author and merge your two
 extensions.

Since you split() the string in argument parsing document values cannot
contain whitespace; such as -file=Yo Yo Ma Ma.txt.  Perhaps using
shlex() or some other means to initially break-up the strings would be a
better option?



signature.asc
Description: This is a digitally signed message part
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: cmd2, an extenstion of cmd that parses its argument list

2012-05-31 Thread Antony Lee
I am already using shlex.split() (this is a customizable hook).

On Thu, May 31, 2012 at 03:42:19PM -0400, Adam Tauno Williams wrote:
 On Thu, 2012-05-31 at 15:21 -0400, Adam Tauno Williams wrote: 
  On Thu, 2012-04-26 at 12:16 -0700, anntzer@gmail.com wrote: 
   On Sunday, March 18, 2012 10:12:24 PM UTC-7, anntz...@gmail.com wrote:
Dear all,
I would like to announce the first public release of cmd2, an extension 
of the standard library's cmd with argument parsing, here: 
https://github.com/anntzer/cmd2.
   Due to an already existing Cmd2 on PyPI, I have renamed the project to 
   parsedcmd, which is also a better description of what the module does.
   https://github.com/anntzer/parsedcmd 
Cmd2 is an extension built around the excellent cmd module of the 
standard
library.  Cmd allows one to build simple custom shells using ``do_*`` 
methods,
taking care in particular of the REPL loop and the interactive help.  
However,
no facility is given for parsing the argument line (do_* methods are 
passed the
rest of the line as a single string argument).
With Cmd2, ``do_*`` methods are type-annotated, either using Python 3's
function annotation syntax, or with an ad-hoc ``annotate`` decorator, 
allowing
the dispatcher to parse the argument list for them.
  This is much the same functionality added to Cmd by Cmd2.
  Perhaps you could collaborate with Cmd2's author and merge your two
  extensions.
 
 Since you split() the string in argument parsing document values cannot
 contain whitespace; such as -file=Yo Yo Ma Ma.txt.  Perhaps using
 shlex() or some other means to initially break-up the strings would be a
 better option?
 


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


Re: python3 raw strings and \u escapes

2012-05-31 Thread ru...@yahoo.com
On 05/30/2012 09:07 AM, ru...@yahoo.com wrote:
 On 05/30/2012 05:54 AM, Thomas Rachel wrote:
 Am 30.05.2012 08:52 schrieb ru...@yahoo.com:

 This breaks a lot of my code because in python 2
re.split (ur'[\u3000]', u'A\u3000A') ==  [u'A', u'A']
 but in python 3 (the result of running 2to3),
re.split (r'[\u3000]', 'A\u3000A' ) ==  ['A\u3000A']

 I can remove the r prefix from the regex string but then
 if I have other regex backslash symbols in it, I have to
 double all the other backslashes -- the very thing that
 the r-prefix was invented to avoid.

 Or I can leave the r prefix and replace something like
 r'[ \u3000]' with r'[  ]'.  But that is confusing because
 one can't distinguish between the space character and
 the ideographic space character.  It also a problem if a
 reader of the code doesn't have a font that can display
 the character.

 Was there a reason for dropping the lexical processing of
 \u escapes in strings in python3 (other than to add another
 annoyance in a long list of python3 annoyances?)

 Probably it is more consequent. Alas, it makes the whole stuff
 incompatible to Py2.

 But if you think about it: why allow for \u if \r, \n etc. are
 disallowed as well?

 Maybe the blame is elsewhere then...  If the re module
 interprets (in a regex string) the 2-character string
 consisting of r'\' followed by 'n' as a single newline
 character, then why wasn't re changed for Python 3 to
 interpret the 6-character string, r'\u3000' as a single
 unicode character to correspond with Python's lexer no
 longer doing that (as it did in Python 2)?

 And is there no choice for me but to choose between the two
 poor choices I mention above to deal with this problem?

 There is a 3rd one: use   r'[ ' + '\u3000' + ']'. Not very nice to read,
 but should do the trick...

 I guess the +s could be left out allowing something
 like,

   '[ \u3000]' r'\w+ \d{3}'

 but I'll have to try it a little; maybe just doubling
 backslashes won't be much worse.  I did that for years
 in Perl and lived through it.

Just for some closure, there are many places in my code
that I had/have to track down and change.  But the biggest
problem so far is a lexer module that is structured as many
dozens of little functions, each with a docstring that is
a regex string.

The only way I found change these and maintain sanity was
to go through them and remove the r prefix from any strings
that contain \u literals, and then double any other
backslashes in the string.

Since these are docstrings, creating them with executable
code was awkward, and using adjacent string concatenation
led to a very confusing mix of string styles.  Strings that
used concatenation often had a single logical regex structure
(eg a character set [...]) split between two strings.
The extra quote characters were as visually confusing as
doubled backslashes in many cases.

Strings with doubled backslashes, although harder to read
were, were much easier to edit reliably and in their way,
more regular.  It does make this module look very Perlish
though... :-)
-- 
http://mail.python.org/mailman/listinfo/python-list


[RELEASED] Python 3.3.0 alpha 4

2012-05-31 Thread Georg Brandl
On behalf of the Python development team, I'm happy to announce the
fourth alpha release of Python 3.3.0.

This is a preview release, and its use is not recommended in
production settings.

Python 3.3 includes a range of improvements of the 3.x series, as well
as easier porting between 2.x and 3.x.  Major new features and changes
in the 3.3 release series are:

* PEP 380, syntax for delegating to a subgenerator (yield from)
* PEP 393, flexible string representation (doing away with the
  distinction between wide and narrow Unicode builds)
* A C implementation of the decimal module, with up to 80x speedup
  for decimal-heavy applications
* The import system (__import__) is based on importlib by default
* The new packaging module (also known as distutils2, and released
  standalone under this name), implementing the new packaging formats
  and deprecating distutils
* The new lzma module with LZMA/XZ support
* PEP 405, virtual environment support in core
* PEP 420, namespace package support
* PEP 3151, reworking the OS and IO exception hierarchy
* PEP 3155, qualified name for classes and functions
* PEP 409, suppressing exception context
* PEP 414, explicit Unicode literals to help with porting
* PEP 418, extended platform-independent clocks in the time module
* PEP 412, a new key-sharing dictionary implementation that
  significantly saves memory for object-oriented code
* The new faulthandler module that helps diagnosing crashes
* The new unittest.mock module
* The new ipaddress module
* A collections.ChainMap class for linking mappings to a single unit
* Wrappers for many more POSIX functions in the os and signal
  modules, as well as other useful functions such as sendfile()
* Hash randomization, introduced in earlier bugfix releases, is now
  switched on by default

For a more extensive list of changes in 3.3.0, see

http://docs.python.org/3.3/whatsnew/3.3.html (*)

To download Python 3.3.0 visit:

http://www.python.org/download/releases/3.3.0/

Please consider trying Python 3.3.0 with your code and reporting any bugs
you may notice to:

http://bugs.python.org/


Enjoy!

(*) Please note that this document is usually finalized late in the release
cycle and therefore may have stubs and missing entries at this point.

--
Georg Brandl, Release Manager
georg at python.org
(on behalf of the entire python-dev team and 3.3's contributors)

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


Re: python3 raw strings and \u escapes

2012-05-31 Thread Chris Angelico
On Fri, Jun 1, 2012 at 6:28 AM, ru...@yahoo.com ru...@yahoo.com wrote:
 ... a lexer module that is structured as many
 dozens of little functions, each with a docstring that is
 a regex string.

This may be a good opportunity to take a step back and ask yourself:
Why so many functions, each with a regular expression in its
docstring?

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


Re: python3 raw strings and \u escapes

2012-05-31 Thread ru...@yahoo.com
On 05/31/2012 03:10 PM, Chris Angelico wrote:
 On Fri, Jun 1, 2012 at 6:28 AM, ru...@yahoo.com ru...@yahoo.com wrote:
 ... a lexer module that is structured as many
 dozens of little functions, each with a docstring that is
 a regex string.

 This may be a good opportunity to take a step back and ask yourself:
 Why so many functions, each with a regular expression in its
 docstring?

Because that's the way David Beazley designed Ply?
 http://dabeaz.com/ply/

Personally, I think it's an abuse of docstrings but
he never asked me for my opinion...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to suppress exception printing to console?

2012-05-31 Thread Steven W. Orr

On 5/31/2012 3:57 AM, Qi wrote:


I have an application that embedding Python into C++.
When any exception occurred in C++ code, PyErr_SetString will
be called to propagate the exception to Python.

The problem is, some unit tests trigger exception on intention.
So it's OK to have the exceptions. But Python will still print
the exception to console, polluting the unit test output.

My question is, is there any way to disable exception reporting
to console from either C++ or Python code?



How about a big hammer?

try:
main()
except Exception:
sys.exit(1)
else:
sys.exit(0)


--
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
--
http://mail.python.org/mailman/listinfo/python-list


Re: How to suppress exception printing to console?

2012-05-31 Thread Qi

On 2012-5-31 23:01, Ulrich Eckhardt wrote:

Am 31.05.2012 09:57, schrieb Qi:
The first sentence is clear. The second sentence rather sounds as if you
were implementing a Python module in C++. This is the opposite to
embedding Python in C++, it's rather embedding C++ in Python. Or is it a
C++ function called by Python which in turn was embedded by C++?


I think it's bidirectional.
In C++ I use PyRun_SimpleString to run some Python code, then
C++ code can get object from Python code, or call Python function.
Also Python code can call C++ code.

I think that's called binding?



I can only guess what you are doing, maybe you should provide a simple
piece of code (or, rather, one C++ piece and a Python piece) that
demonstrates the issue. What I could imagine is that the Python
interpreter shuts down with something it considers an unhandled
exception, which it then prints to stdout before exiting. When
embedding, that shouldn't happen from just calling a Python function in
a loaded script, those should just make the error available to the C++
side via PyErr functions etc.



PyRun_SimpleString(SomeCppFunc(1, 2));

SomeCppFunc is C++ function bound to Python, and in SomeCppFunc
it detects the parameter mismatch (such as it expects the first
parameter to be a string), it throws an exception.
Then the C++ binding code catches the exception, and call
PyErr_SetString to propagate it to Python.

Then Python will print the error message to console.
What I want to do is to suppress the error message printing...



What I found useful when embedding was that I could assign to sys.stdout
in order to redirect the output. In my case, the target was a window and
not a console. I'd consider that a workaround though. I really suspect
that Python considers the error unhandled and therefore dumps the info
to stdout.


Can I redirect sys.stdout in C++?


Thanks


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


[issue14673] add sys.implementation

2012-05-31 Thread Eric Snow

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

Thanks for taking the time for the review, Barry.  Again, sorry I broke the 
review link.  It shouldn't be a problem any more.

 Barry A. Warsaw ba...@python.org added the comment:

 I'm inclined to go with the as_simple_namespace patch.  As you say,
 the pro are that this is a much better fit for this use case, while
 the con is that this does kind of sneak in a new type.  Given that
 the type is not exposed in the API, that doesn't bother me.  One
 other possibility would be to move all that code to sysmodule.c as
 static functions, and then it definitely won't be available outside
 sys.

 OTOH, I do think this could eventually be a useful type to expose,
 however the current behavior of its repr filtering out _names would
 have to be removed in that case.  However, that's a useful filter for
 sys.implementation and it doesn't bother me, since you can always
 repr sys.implementation.__dict__ to get the whole thing.

 On balance, my recommendation would be to keep it the way you have
 it, but perhaps mention this on python-dev, and watch the technicolor
 bikeshed go psychedelic.

:)  I'll bring it up on python-dev.


 A few other comments as we discussed in irc:

 dir(sys.implementation) should return something useful, not traceback

Not sure what I was doing to block the lookup from object, but it's working now.

So...Fixed.


 There are a few PEP 7 violations, e.g. brace placements that should
 be fixed

Done.


 I was looking at _namespace_init() and a few things bothered me.  I
 thought this might be superfluous and that you'd be able to just
 inline the PyDict_Update() calls, but now I'm not so sure.  AFAICT,
 Python's documentation is silent on whether *args and *kwds in a
 tp_init function can be NULL or not, and I definitely see cases where
 similar checks are made in other types.  So I think with that in
 mind, you must assume they *can* be NULL.  But then I'm not sure the
 assertions are useful or correct.

Yeah, they're mostly an artifact of copying code.  However, I'm glad they 
triggered your explanation. ;)

 Take this scenario:

 namespace_init() gets args==NULL.  Your assertion doesn't trigger,
 but PyObject_Size(NULL) sets an exception and returns -1.  Your
 conditional doesn't check for an error condition in PyObject_Size()
 so you'll incorrectly swallow (temporarily) that exception.  At the
 very least, you need to check for PyObject_Size()  0.  Don't forget
 too that those assertions can get compiled away.

 I think I'd rather see a PyTuple_Size(args) conditional here for the
 args parameter.  If it's not a tuple, you'll get an exception set, so
 check for size  0.  If size  0, then you can set the TypeError and
 return -1 explicitly.

Pretty sure I understand.  Let me know if my new patch says otherwise.  wink

So...Done.


 Similarly, just call PyDict_Update(kwds) and return its value.  If
 kwds is neither a dict nor has a .keys() method (including if its
 NULL), an exception will be set so everything should work correctly
 (see _PyObject_CallMethodId() in abstract.c, which is what
 PyDict_Update() boils down to).

Done.  This was a case of prematurely optimizing.


 At least, I'm nearly certain that's safe :)

 Moving on...

 namespace_repr() also has some PEP 7 violations (brace position,
 extra blank lines).  Please fix these.

Done.


 Is it ever possible to get into namespace_repr() with ns-ns_dict
 being NULL?  I think it's impossible.  You might rewrite the if
 (d == NULL) check with an assertion.

Done.


 I think you're leaking the PyList_New(0) that you put in `pairs`
 after you PyUnicode_Join() it.  PyUnicode_Join() doesn't decref its
 second argument and your losing the original referenced object when
 you assign `pairs` to its result.

Good Catch.  Fixed.


 I find the mix of inline error returns and `goto error` handling in
 namespace_repr() somewhat confusing.  I wonder if it would be more
 readable (and thus auditable) if there was consistent use of `goto
 error` with more XDECREFs?  If you feel like it, please try that out.

I've given it a go.  :)


 That's it for now.  Please submit another patch for the
 as_simple_namespace case and I'll take another look.  Also, if you
 send a message to python-dev about the introduction of the namespace
 object, I'll follow up with my support of that option.

 Thanks, this is looking great!

Thanks again for all your support through this process!

--
Added file: 
http://bugs.python.org/file25767/issue14673_as_simple_namespace_2.diff

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



[issue14673] add sys.implementation

2012-05-31 Thread Eric Snow

Changes by Eric Snow ericsnowcurren...@gmail.com:


Added file: http://bugs.python.org/file25768/issue14673_docs_and_tests_2.diff

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



[issue14673] add sys.implementation

2012-05-31 Thread Eric Snow

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

 History with dictproxy means I'm also OK with new type by stealth.
 Perhaps add some tests to check type(sys.implementation)() does
 something sane?

Test added.  Here's what happens:

   cls = type(sys.implementation)
   cls()
  namespace()
   cls(x=1, y=2)
  namespace(x=1, y=2)

Though it's not immediately a problem, vars(cls(x=1, y=2)) returns {}, 
while ns=cls(x=1, y=2); vars(ns) returns {'x': 1, 'y': 2}!

Certainly it's a corner case, but it could indicate a more sinister problem.  
Regardless, I'll track down the root cause and fix it.  As far as I can tell, 
this odd behavior does not impact sys.implementation.

--

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



[issue14673] add sys.implementation

2012-05-31 Thread Eric Snow

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

@Barry: FWIW, the kwds passed to namespace_init was NULL when no keyword 
arguments were used.  Easy enough to handle though.

--

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



[issue14966] Fully document subprocess.CalledProcessError

2012-05-31 Thread Nick Coghlan

New submission from Nick Coghlan ncogh...@gmail.com:

CalledProcessError provides a nice encapsulation for a returncode, the original 
command and any partial output. The API should be officially documented so that 
third party subprocess.Popen convenience wrappers can use it easily.

--
assignee: docs@python
components: Documentation
keywords: easy
messages: 161984
nosy: docs@python, ncoghlan
priority: normal
severity: normal
status: open
title: Fully document subprocess.CalledProcessError
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3

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



[issue10376] ZipFile unzip is unbuffered

2012-05-31 Thread Serhiy Storchaka

Serhiy Storchaka storch...@gmail.com added the comment:

The patch updated to reflect Martin's stylistic comments.

Sorry for the delay, Martin. I have not received an email with your review from 
2012-05-13, and only today accidentally discovered your comments in Rietveld. 
It seems to have been some bug in Rietveld.

--
Added file: http://bugs.python.org/file25769/zipfile_optimize_read_2.patch

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



[issue14944] Setup Usage documentation for pydoc, idle 2to3

2012-05-31 Thread A.M. Kuchling

Changes by A.M. Kuchling li...@amk.ca:


--
nosy: +akuchling

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



[issue14945] Setup Usage documentation for selected stdlib modules

2012-05-31 Thread A.M. Kuchling

Changes by A.M. Kuchling li...@amk.ca:


--
nosy: +akuchling

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



[issue14963] Use an iterative implementation for contextlib.ExitStack.__exit__

2012-05-31 Thread alon horev

alon horev alo...@gmail.com added the comment:

that was indeed trickier, but overriding the __context__ attribute did the 
trick.

--
Added file: http://bugs.python.org/file25770/14963.2.patch

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



[issue14899] Naming conventions and guidelines for packages and namespace packages

2012-05-31 Thread Alexis Metaireau

Changes by Alexis Metaireau ale...@notmyidea.org:


--
nosy: +alexis

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



[issue14007] xml.etree.ElementTree - XMLParser and TreeBuilder's doctype() method missing

2012-05-31 Thread Eli Bendersky

Eli Bendersky eli...@gmail.com added the comment:

* Another problem: the C implementation of XMLParser does not take 3 positional 
args, but only 2. Although the 'html' arg is documented as unsupported, it 
should still be taken and silently ignored, similarly to the Python version

--

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



[issue14909] Fix incorrect use of *Realloc() and *Resize()

2012-05-31 Thread Roundup Robot

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

New changeset 588ea940e5e3 by Kristjan Valur Jonsson in branch 'default':
Issue #14909: A number of places were using PyMem_Realloc() apis and
http://hg.python.org/cpython/rev/588ea940e5e3

--
nosy: +python-dev

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



[issue14909] Fix incorrect use of *Realloc() and *Resize()

2012-05-31 Thread Kristján Valur Jónsson

Changes by Kristján Valur Jónsson krist...@ccpgames.com:


--
resolution:  - fixed
status: open - closed

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



[issue14964] distutils2.utils.resolve_name cleanup

2012-05-31 Thread Ronny Pfannschmidt

Ronny Pfannschmidt ronny.pfannschm...@gmail.com added the comment:

my change is a unrelated cleanup
but the ideas in the patch look good

the attribute error addition seems relevant

i'll adapt my patch to raise the original import error for toplevel import 
failure and accumuplate the attrbute name so it can raise the correct error

--

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



[issue14967] distutils2.utils.resolve_name cannot be implemented to give correct errors in all situations

2012-05-31 Thread Ronny Pfannschmidt

New submission from Ronny Pfannschmidt ronny.pfannschm...@gmail.com:

due to the lack of a marker that denotes where the module ends and the 
attribute starts, unrelated import errors can break the tryerror chain at 
unexpected places and the code can pass on to the recursive getattr chain, 
giving a completely different error instead of the real error

this is not solvable without a marker or really nasty hacks o track subsequent 
imports

--
assignee: eric.araujo
components: Distutils2
messages: 161990
nosy: Ronny.Pfannschmidt, alexis, eric.araujo, tarek
priority: normal
severity: normal
status: open
title: distutils2.utils.resolve_name cannot be implemented to give correct 
errors in all situations

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



[issue14967] distutils2.utils.resolve_name cannot be implemented to give correct errors in all situations

2012-05-31 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

the current code works as expected. Why not leaving it like this since your 
change seem to be comsetics only ?

--

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



[issue14967] distutils2.utils.resolve_name cannot be implemented to give correct errors in all situations

2012-05-31 Thread Tarek Ziadé

Tarek Ziadé ziade.ta...@gmail.com added the comment:

can you give an example of a bad error ?

--

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



[issue14967] distutils2.utils.resolve_name cannot be implemented to give correct errors in all situations

2012-05-31 Thread Tarek Ziadé

Changes by Tarek Ziadé ziade.ta...@gmail.com:


--
resolution:  - duplicate
superseder:  - Improve error reporting for packaging.util.resolve_name

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



[issue14967] distutils2.utils.resolve_name cannot be implemented to give correct errors in all situations

2012-05-31 Thread Ronny Pfannschmidt

Ronny Pfannschmidt ronny.pfannschm...@gmail.com added the comment:

to correctly implement it we need the : separator back

with the separator the import specification is no longer ambigious,
and we can use one exact import, and an error will always be an error

--

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



[issue14967] distutils2.utils.resolve_name cannot be implemented to give correct errors in all situations

2012-05-31 Thread Ronny Pfannschmidt

Ronny Pfannschmidt ronny.pfannschm...@gmail.com added the comment:

an example of creating a wrong error would be something like the following:

there is a package foo.bar, which does a wrong import in __init__.py
we want to resolve the name foo.bar.something

we'd get the error that foo has no attribute bar

--

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



[issue14964] distutils2.utils.resolve_name cleanup

2012-05-31 Thread Ronny Pfannschmidt

Ronny Pfannschmidt ronny.pfannschm...@gmail.com added the comment:

updated the patch with more detailed errors

--
Added file: http://bugs.python.org/file25771/resolve_name.patch

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



[issue14968] Section Inplace Operators of :mod:`operator` should be a subsection

2012-05-31 Thread Lars Buitinck

New submission from Lars Buitinck l.j.buiti...@uva.nl:

The section Inplace Operators of the module docs for operator now show up in 
TOC at http://docs.python.org/dev/library/. I don't think that's intended as it 
does not describe a separate module.

--
assignee: docs@python
components: Documentation
files: operator-module-docs.patch
keywords: patch
messages: 161996
nosy: docs@python, larsmans
priority: normal
severity: normal
status: open
title: Section Inplace Operators of :mod:`operator` should be a subsection
type: enhancement
versions: Python 3.3
Added file: http://bugs.python.org/file25772/operator-module-docs.patch

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



[issue14964] distutils2.utils.resolve_name cleanup

2012-05-31 Thread Ronny Pfannschmidt

Ronny Pfannschmidt ronny.pfannschm...@gmail.com added the comment:

i missused hg export, here is a corrected patch

--
Added file: http://bugs.python.org/file25773/resolve_name.patch

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



[issue14969] Restore sys.exc_clear()?

2012-05-31 Thread Nick Coghlan

New submission from Nick Coghlan ncogh...@gmail.com:

When adding the test case for #14963, I discovered that contextlib.ExitStack 
can't *quite* reproduce the exception handling of nested with statements.

The problem arises when the original exception gets suppressed by one of the 
handlers, but an outer handler raises a *new* exception, then nested with 
statements will correctly indicate that there was no exception context active 
when the new exception was raised (since the inner with statement will fully 
clear the exception state).

By contrast, when using ExitStack, the interpreter will add the original 
exception from inside the body of the with statement as the context for the 
*new* exception, even though the inner exception had been suppressed before the 
outer one was encountered.

Restoring sys.exc_clear() *might* allow this discrepancy to be resolved by 
explicitly clearing the exception state when one of the callbacks indicates 
that the current exception has been handled (although it might be trickier than 
that, if the problem is actually due to caching the exception state inside the 
with cleanup code in the eval loop)

--
components: Interpreter Core, Library (Lib)
messages: 161998
nosy: ncoghlan
priority: normal
severity: normal
stage: needs patch
status: open
title: Restore sys.exc_clear()?
type: enhancement
versions: Python 3.3

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



[issue14963] Use an iterative implementation for contextlib.ExitStack.__exit__

2012-05-31 Thread Roundup Robot

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

New changeset fc73e6ea9e73 by Nick Coghlan in branch 'default':
Issue #14963: Added test cases for contextlib.ExitStack exception handling 
behaviour (Initial patch by Alon Horev)
http://hg.python.org/cpython/rev/fc73e6ea9e73

--
nosy: +python-dev

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



[issue14963] Use an iterative implementation for contextlib.ExitStack.__exit__

2012-05-31 Thread Roundup Robot

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

New changeset c0c7618762e5 by Nick Coghlan in branch 'default':
Close #14963: Use an iterative algorithm in contextlib.ExitStack.__exit__ 
(Patch by Alon Horev)
http://hg.python.org/cpython/rev/c0c7618762e5

--
resolution:  - fixed
stage: test needed - committed/rejected
status: open - closed

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



[issue14963] Use an iterative implementation for contextlib.ExitStack.__exit__

2012-05-31 Thread Nick Coghlan

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

Interesting - it turns out we can't fully reproduce the behaviour of nested 
with statements in ExitStack (see the new reference test I checked in, as well 
as #14969)

I added one technically redundant variable to the implementation to make it 
more obviously correct to the reader, as well as a test that ensures the stack 
can handle ridiculous numbers of callbacks without failing (a key advantage of 
using a single frame rather than one frame per callback)

While it isn't mandatory, we prefer it if contributors submit Contributor 
Agreements even for small changes. If you're happy to do that, I consider 
emailing a scanned or digitally photographed copy of the signed form as 
described here to be the simplest currently available approach: 
http://www.python.org/psf/contrib/

--
resolution: fixed - 
stage: committed/rejected - test needed
status: closed - open

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



[issue14970] -v command line option is broken

2012-05-31 Thread Kristján Valur Jónsson

New submission from Kristján Valur Jónsson krist...@ccpgames.com:

Using the -v command line option to diagnose import problem is no longer 
useful.  In stead of lines like this in version 2.7:

import UserDict # from 
D:\p4\games\branches\development\MAIN\eve\dust\tool\bin/../../../../carbon/src/stackless/Lib/UserDict.py

we now get:
import 'textwrap' # _frozen_importlib.SourceFileLoader object at 
0x02E14438

I don't even know what a _frozen_importlib.SourceFileLoader is.

--
components: Interpreter Core
messages: 162002
nosy: kristjan.jonsson
priority: normal
severity: normal
status: open
title: -v command line option is broken
type: behavior
versions: Python 3.3

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



[issue14970] -v command line option is broken

2012-05-31 Thread Martin v . Löwis

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

See http://hg.python.org/cpython/file/default/Lib/importlib/_bootstrap.py
for the source of SourceFileLoader.

--
nosy: +loewis

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



[issue14952] Cannot run regrtest with amd64/debug on windows

2012-05-31 Thread Kristján Valur Jónsson

Kristján Valur Jónsson krist...@ccpgames.com added the comment:

I've found what is wrong.
There is a problem with _multiprocessing.pyd on 64 bit debug builds.
Why this manifests itself as it does, I don´t know.  Someone must be silencinng 
the proper import error.

this is most likely a build config error, that I will fix.

--

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



[issue14952] Cannot run regrtest with amd64/debug on windows

2012-05-31 Thread Roundup Robot

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

New changeset c7b16e2be71a by Kristjan Valur Jonsson in branch 'default':
Issue #14952: Fix incorrect output dll names for win64/debug builds, causing
http://hg.python.org/cpython/rev/c7b16e2be71a

--
nosy: +python-dev

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



[issue14952] Cannot run regrtest with amd64/debug on windows

2012-05-31 Thread Kristján Valur Jónsson

Changes by Kristján Valur Jónsson krist...@ccpgames.com:


--
resolution:  - fixed
status: open - closed

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



[issue14970] -v command line option is broken

2012-05-31 Thread Kristján Valur Jónsson

Kristján Valur Jónsson krist...@ccpgames.com added the comment:

Yes, I found that.  The line in question is, however, this:
 _verbose_message('import {!r} # {!r}', name, loader)
(_bootstrap.py:1254).

Unfortunately, I see no way to get at the line from which the import occurred 
here.  The loader itself is not useful for that.  Perhaps the author of 
importlib knows more, e.g. whether the feature to know whence an import 
originates is useful or has been dropped.

--

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



[issue14938] 'import my_pkg.__init__' creates duplicate modules

2012-05-31 Thread Brett Cannon

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

I see what you mean about the discrepancy, but you don't need to complicate the 
constructor to get the desired result. If you have is_package() check if the 
module name ends in __init__ to skip the package check and just say False (e.g. 
only if the path ends in __init__ but the module name does not) then you will 
get your desired semantics out of is_package (since this is what find_loader() 
is doing).

--

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



[issue14970] -v command line option is broken

2012-05-31 Thread Brett Cannon

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

The information is still there, just in a different output line (i.e. 
http://hg.python.org/cpython/file/c7b16e2be71a/Lib/importlib/_bootstrap.py#l735 
outputs the same info, just on its own line). I couldn't keep the old format as 
the code has been shifted around enough compared to how import.c was structured 
that reproducing the same output would have required a code refactor and 
contortion that wasn't worth it. I did my best to make sure no useful data was 
left out (and actually there is more since the loader is now also stated so you 
always have that info instead of only what Python's included loaders provide).

--
nosy: +brett.cannon

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



[issue14970] -v command line option is broken

2012-05-31 Thread Brett Cannon

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

I am setting this as pending since I consider the total output acceptable, but 
if Kristján has specific issues he wants to bring up or change he still can.

--
status: open - pending

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



[issue14970] -v command line option is broken

2012-05-31 Thread Kristján Valur Jónsson

Kristján Valur Jónsson krist...@ccpgames.com added the comment:

Oh dear, silly me.
I misunderstood the point of -v _and_ misunderstood the output of 2.7 I was 
quoting.
I was looking for a way to find out where the import originated from, not which 
file would be imported as a result.

Import errors, along with pickling errors, are some of the most annoying ones 
to debug, because they tend to require so much detective work.

Ok, I'll close this then.  Sorry about the noise.

--
resolution:  - invalid
status: pending - closed

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



[issue14962] When changing IDLE configuration all text in shell window loses highlighting

2012-05-31 Thread Roger Serwy

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

Attached is a patch to fix this issue. 

The ModifiedColorDelegator already marks everything before iomark as SYNC'ed. 
This is good, as the ColorDelegator should not be trying to colorize STDOUT 
text as Python code. 

Resetting the ColorDelegator in _rmcolorizer in EditorWindow.py calls 
.removecolors(). The patch modifies this method to only remove tags *after* the 
iomark.

--
keywords: +patch
Added file: http://bugs.python.org/file25774/issue14962.patch

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



[issue14970] -v command line option is broken

2012-05-31 Thread Brett Cannon

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

Not a problem. =)

If you want to know where an import originated from, you can probably do 
something as simple as overload builtins.__import__ with a version that does a 
quick stack look to see where the previous call is coming from.

--

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



[issue14962] When changing IDLE configuration all text in shell window loses highlighting

2012-05-31 Thread Roundup Robot

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

New changeset 1a4e99460438 by Ned Deily in branch '2.7':
Issue #14962: Update text coloring in IDLE shell window after changing
http://hg.python.org/cpython/rev/1a4e99460438

New changeset 9d0c3a835bfe by Ned Deily in branch '3.2':
Issue #14962: Update text coloring in IDLE shell window after changing
http://hg.python.org/cpython/rev/9d0c3a835bfe

New changeset 86f62adb09cf by Ned Deily in branch 'default':
Issue #14962: merge
http://hg.python.org/cpython/rev/86f62adb09cf

--
nosy: +python-dev

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



[issue14962] When changing IDLE configuration all text in shell window loses highlighting

2012-05-31 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

LGTM, thanks.  Applied for release in 2.7.4, 3.2.4, and 3.3.0.

--
nosy: +ned.deily
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
versions: +Python 2.7

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



[issue14971] (unittest) loadTestsFromName does not work on method with a decorator

2012-05-31 Thread Alessandro Piccione

New submission from Alessandro Piccione alessandro.piccione...@gmail.com:

Steps to reproduce the problem.
1. Create a module (ex. name it test) 
2. Create a file in it (ex. mainTest.py) with a class (ex. MainTest) derived 
from TestCase.
3. Create a test method in that class, (ex. test_base), prefix it with test.
4. Create a decorator (ex. clear_args) and use it on the test method 
5. Create a test suite with the function loadTestsFromName of TestLoader 
class and make a TestRunner run it (I use a TextTestRunner). 
suite = 
unittest.TestLoader().loadTestsFromName('test.mainTest.MainTest.test_base')
unittest.TextTestRunner(verbosity=2).run(suite)


It is expected that the test is run (it runs without decorator).
It gives an error: no such test method in class 'test.mainTest.MainTest': 
wrapper.
wrapper is the name of the returned function in the decorator.


I'm using Python 2.7.3 on Windows 7 64bit.
I search loadTestsFromName decorator without results, so I decided to report 
as new issue. This is my first report, I admit I've not read any 
guide/instructions.

--
components: None
messages: 162015
nosy: alex.75
priority: normal
severity: normal
status: open
title: (unittest) loadTestsFromName does not work on method with a decorator
type: behavior
versions: Python 2.7

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



[issue14938] 'import my_pkg.__init__' creates duplicate modules

2012-05-31 Thread Ronan Lamy

Ronan Lamy ronan.l...@gmail.com added the comment:

That would force the Loaders to know how to convert a module name into a file 
path, which isn't the case now since FileLoader.get_filename() is just a shim 
that returns self.path. So I'd rather add an optional argument to FileLoader. 
Actually, I feel that the clean solution would be to have packages be a 
separate Loader class, but that would be a significant change...

--

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



[issue14971] (unittest) loadTestsFromName does not work on method with a decorator

2012-05-31 Thread R. David Murray

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

I don't think this is documented anywhere (and should be).  I believe what you 
need to do is use functools.wraps on your wrapper function.

--
assignee:  - docs@python
components: +Documentation -None
nosy: +docs@python, michael.foord, r.david.murray
versions: +Python 3.2, Python 3.3

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



[issue14814] Implement PEP 3144 (the ipaddress module)

2012-05-31 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

It's funny how raising the test coverage _always_ uncovers lurking bugs in 
obscure branches. :) Patch attached, let me know if I got it wrong – would 
commit otherwise.

A few quick side-note: does the __version__ variable make sense in stdlib?

--
Added file: http://bugs.python.org/file25775/fix-type-error.diff

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



[issue6721] Locks in python standard library should be sanitized on fork

2012-05-31 Thread Richard Oudkerk

Richard Oudkerk shibt...@gmail.com added the comment:

Attached is an updated version of Charles-François's reinit_locks.diff.

Changes:

* Handles RLock by assuming that if self-count != 0 when we acquire
  the lock, then the lock must have been reinitialized by 
PyThread_ReInitLocks().

* Applies existing fork tests for Lock to RLock.

* Fixes capitalization issues with 
PyThread_ReInitLocks()/PyThread_ReinitLocks().

* Defines PyThread_ReInitLocks() to be empty on non-pthread platforms.

Note that RLock._is_owned() is unreliable after a fork until RLock.acquire() 
has been called.

Also, no synchronization has been added for the list of locks.  Are 
PyThread_allocate_lock() and PyThread_free_lock() supposed to be safe to call 
while not holding the GIL?

--
Added file: http://bugs.python.org/file25776/reinit_locks_2.diff

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



[issue14635] telnetlib uses select instead of poll - limited to FD_SETSIZE fds

2012-05-31 Thread Akintayo Holder

Akintayo Holder akint...@google.com added the comment:

Hi,

telnet.read_until() and telnet.expect() will use select.poll() instead of 
select.select() on systems where poll() is available.

The patch also includes updates to test_telnetlib, the read_until() tests were 
changed to test the case where poll() is unavailable. We also added unit tests 
for expect(), these are a copy of the read_until() tests.

This patch is against 2.7.

Akintayo

--
nosy: +akintayo
Added file: http://bugs.python.org/file25777/telnet_expect_read_until_using_poll

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



[issue14969] Restore sys.exc_clear()?

2012-05-31 Thread alon horev

alon horev alo...@gmail.com added the comment:

Another possible solution is to explicitly set an exception's 
__supress_context__ attribute to False (right now impossible because it's the 
default value). 
If a user can 'turn on' the flag when attaching a different exception (raise X 
from Y), why not allow 'turning it off'? (symmetry anyone?) right now it is set 
to False by default and changed to true when 'raising from'.
I suggest changing the default to None, allowing the user to explicitly say: 
I'm no longer in the previous exception's context.

Feels a bit like solving our hack with another hack (:

And about the PSF contrib agreement, I'll do it as soon as I'm near a printer. 
too bad we're using pens and not RSA private keys for signatures (-:

   thanks, Alon

--
nosy: +alonho

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



[issue14972] listcomp with nested classes

2012-05-31 Thread josmiley

New submission from josmiley joel-murie...@sfr.fr:

# this runs with python2.7, not with python3.2
class Foo(object):

class Bar(object):
pass

Attr = [Bar()for n in range(10)]

# solved in this way ...
class Foo(object):

class Bar(object):
pass

Attr = []
for n in range(10): Attr.append(Bar())

--
messages: 162022
nosy: josmiley
priority: normal
severity: normal
status: open
title: listcomp with nested classes
type: behavior
versions: Python 3.2

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



[issue14972] listcomp with nested classes

2012-05-31 Thread Florent Xicluna

Florent Xicluna florent.xicl...@gmail.com added the comment:

Simpler test case:

class A:
   x = 42
   y = [x for _ in '1']


The semantics of list comprehension changed with Python 3.
However, I do not see this specific behavior documented somewhere.

http://docs.python.org/dev/whatsnew/3.0.html#changed-syntax

--
components: +Interpreter Core
nosy: +flox
versions: +Python 3.3

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



[issue14972] listcomp with nested classes

2012-05-31 Thread Alex Gaynor

Changes by Alex Gaynor alex.gay...@gmail.com:


--
nosy: +alex

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



[issue14972] listcomp with nested classes

2012-05-31 Thread Westley Martínez

Westley Martínez aniko...@gmail.com added the comment:

$ python
Python 3.2.3 (default, Apr 23 2012, 23:35:30) 
[GCC 4.7.0 20120414 (prerelease)] on linux2
Type help, copyright, credits or license for more information.
 class A:
... x = 42
... y = [x for _ in '1']
... 
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 3, in A
  File stdin, line 3, in listcomp
NameError: global name 'x' is not defined
 x = 42
 class A:
... x = 12
... y = [x for _ in '1']
... 
 A.y
[42]

It seems that the list comprehension is looking at the module's scope as 
opposed to the class scope.  This definitely seems incorrect to me.

--
nosy: +anikom15

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



[issue14973] restore python2 unicode literals in ru strings

2012-05-31 Thread rurpy the second

New submission from rurpy the second ru...@yahoo.com:

PEP 414 proposes restoring the u string prefix (semantically as a noop) to 
make porting from Python2 easier.  I would like to propose that ru-strings 
also interpret embedded \u unicode literals in the python2 fashion (as a 
single unicode character) rather than in the python 3.2 fashion (as 6 
characters).

Many Python2 programs use unicode literals in strings because they can be 
represented and displayed in source code with the ascii character set.  For 
example, I often write ur \u3000\u3042\t rather than ur  あ because the 
former is much clearer in source code than the latter and does not require the 
viewer to have a Japanese font installed.

However such a string must be manually converted for Python3 because the former 
string has a very different meaning in Python3 than Python2.  The equivalent in 
Python3 is  \u3000\u3042\\t.  AFAIK, 2to3 does not fix this.  Because there 
are no longer unicode literals in Python3 raw strings, any string with a 
unicode literal *has* to be a non-raw string (AFAICT).  This means that strings 
used as regexes, that have a lot of backslashes and have unicode literals, must 
have the backslashes doubled.  Doubling the backslashes in the above example is 
trivial but it is not trival in more realistic regexes.  This was one of the 
main reasons for having raw strings in Python2 I thought.  It is unfortunate 
that one looses this ability (in the presence of unicode literals) in Python3.

When I raised this issue on the Python user's list [*1], Terry Reedy made the 
suggestion that since the u string prefix was being reintroduced for python 
3.3, that having the prefix also restore the python2 unicode literal handling 
would not introduce any incompatibilties and would greatly increase the ease of 
porting to Python3 for some programs.[*2]  He subsequently raised the issue on 
the dev list.[*3]

An argument might be made that this is an extra feature that would encourage 
the use of the u-prefix beyond that of easing porting from Python2.  Perhaps 
so but there is currently a hole in Python's capability that is difficult to 
work around, and I've seen no other proposals to fix it.  So it seems to me 
that the benefits of this proposal greatly outweigh that somewhat purist 
argument.

[*1] http://mail.python.org/pipermail/python-list/2012-May/1292870.html
[*2] http://mail.python.org/pipermail/python-list/2012-May/1292887.html
[*3] http://mail.python.org/pipermail/python-dev/2012-May/119760.html

--
components: Unicode
messages: 162025
nosy: ezio.melotti, rurpy2
priority: normal
severity: normal
status: open
title: restore python2 unicode literals in ru strings
type: enhancement
versions: Python 3.3

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



[issue14972] listcomp with nested classes

2012-05-31 Thread R. David Murray

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

This is doubtless a result of the way the class namespace scope is handled, 
coupled with the fact that in Python3 list comprehensions have a local scope.  
The class scope is a somewhat unique beast.  I agree that this is unfortunate, 
but I have a feeling that doing anything about it is distinctly non-trivial.

--
nosy: +r.david.murray

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



[issue14974] rename packaging.pypi to packaging.index

2012-05-31 Thread Alexis Metaireau

New submission from Alexis Metaireau ale...@notmyidea.org:

PyPI is the name of a particular index, whereas index is a generic term.

So ISTM that it would be better to use the latter, semantically-wise.

--
assignee: alexis
components: Distutils2
messages: 162027
nosy: alexis, tarek
priority: normal
severity: normal
stage: needs patch
status: open
title: rename packaging.pypi to packaging.index
type: enhancement
versions: Python 3.3

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



[issue14814] Implement PEP 3144 (the ipaddress module)

2012-05-31 Thread Roundup Robot

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

New changeset bd2c2def77a7 by Hynek Schlawack in branch 'default':
#14814: Remove stale __hex__ method from ipaddress
http://hg.python.org/cpython/rev/bd2c2def77a7

--

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



[issue14974] rename packaging.pypi to packaging.index

2012-05-31 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

While I can see your point, I think that index is way too generic. I also 
think that the pypi term is overloaded with both meanings.

--
nosy: +hynek

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



[issue14975] import unicodedata, DLL load failed on Python 2.7.3

2012-05-31 Thread YF

New submission from YF yfdyh...@gmail.com:

Before I use the Python 2.7.2 on Windows XP, today I tried to upgrade to the 
Python 2.7.3, but encountered a problem.
When running any .py file encountered import unicodedata or directly run the 
command always returns:
Traceback (most recent call last):
..
import unicodedata
ImportError: DLL load failed: 找不到指定的程序。
找不到指定的程序 corresponding English is Cannot find the specified program.

I unable provide more information because I am only a user rather than 
developer.

After that, I manually delete C:\Python27\DLLs\unicodedata.pyd file (this 
step must be, otherwise no effect), then reinstall (Repair) Python 2.7.2 the 
problem disappeared.

--
components: Unicode
messages: 162030
nosy: ezio.melotti, yfdyh000
priority: normal
severity: normal
status: open
title: import unicodedata, DLL load failed on Python 2.7.3
type: compile error
versions: Python 2.7

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



[issue6721] Locks in python standard library should be sanitized on fork

2012-05-31 Thread lesha

lesha pybug.20.le...@xoxy.net added the comment:

I am really alarmed by the reinit_locks patches.

I scanned the comment history, and looked at the patch. I may have missed 
something, but it looks to me like the basic behavior is this:

After fork(), all locks are replaced by brand-new lock objects that are NOT 
locked.

*Grim Prediction*: This is going to cause some disastrous, unexpected, and 
hilarious data loss or corruption for somebody.

Here is why:

  class MySQLConn:

def __init__(self):
  self.lock = Lock()

def doWork(self):
  self.lock.acquire()
  # do a sequence of DB operations that must not be interrupted,
  # and cannot be made transactional.
  self.lock.release()

Run this in a thread:

  def thread1(conn):
while True:
  conn.doWork()
  time.sleep(0.053)

Run this in another thread:

  def thread2(conn):
while True:
  conn.doWork()
  time.sleep(0.071)

Run this in a third thread:

  def thread2():
while True:
  subprocess.call([ls, -l])
  time.sleep(0.3)

With reinit_locks(), this will eventually break horribly. 

a) fork() is called with the DB lock held by thread1.
b) Some time passes before the child gets to exec().
c) In that time, the child's thread2 gets to doWork(). 
d) Simultaneously, the parent's doWork is still running and holding a lock.
e) Thanks to reinit_locks, the child's thread2 does not have a lock, and it 
will merrily proceed to corrupt the parent's work.

So I think this approach is basically doomed.

I think my approach of marking _some_ locks as safe to reinit upon fork is 
workable (i.e. to solve the bad interaction with logging or import). 

However, there's also an orthogonal approach that might work well:

1) Right before the first thread gets created in any Python program, fork off a 
fork() server. 

From then on, subprocess will only use the fork server to call commands.

Thoughts?

--

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



[issue14972] listcomp with nested classes

2012-05-31 Thread Hynek Schlawack

Changes by Hynek Schlawack h...@ox.cx:


--
nosy: +hynek

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



[issue14971] (unittest) loadTestsFromName does not work on method with a decorator

2012-05-31 Thread Michael Foord

Michael Foord mich...@voidspace.org.uk added the comment:

Whilst functools.wraps would fix the problem it still sounds like a bug (or at 
the very least a reasonable feature request).

--

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



[issue14959] ttk.Scrollbar in Notebook widget freezes

2012-05-31 Thread Ned Deily

Ned Deily n...@acm.org added the comment:

Another data point: I just tried the same test using a Python 3.2.3 linked with 
an X11 Tk 8.5 (MacPorts) rather than the ActiveState Cocoa Tk 8.5.11 
(python.org Python).  I was not able to get the test to fail with X11 Tk so 
that tends to support the idea that the root cause is somewhere in Aqua Tk.

--
status: pending - open

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



[issue6721] Locks in python standard library should be sanitized on fork

2012-05-31 Thread Richard Oudkerk

Richard Oudkerk shibt...@gmail.com added the comment:

 a) fork() is called with the DB lock held by thread1.
 b) Some time passes before the child gets to exec().
 c) In that time, the child's thread2 gets to doWork(). 
 d) Simultaneously, the parent's doWork is still running and holding a lock.
 e) Thanks to reinit_locks, the child's thread2 does not have a lock, and 
 it will merrily proceed to corrupt the parent's work.

You seem to be saying that all three threads survive the fork.

I think forkall() on Solaris acts like that, but the normal fork() function 
does not.  Only the thread which performs fork() will survive in the child 
process.

So doWork() never runs in the child process, and the lock is never used in the 
child process.

--

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



[issue14975] import unicodedata, DLL load failed on Python 2.7.3

2012-05-31 Thread Martin v . Löwis

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

I do not believe that this is a problem in Python. Instead, it appears that 
your Python installation got corrupted somehow.

I recommend to run a virus scanner.

--
nosy: +loewis

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



[issue6721] Locks in python standard library should be sanitized on fork

2012-05-31 Thread lesha

lesha pybug.20.le...@xoxy.net added the comment:

 I think forkall() on Solaris acts like that, but the normal fork() 
 function does not.  Only the thread which performs fork() will survive 
 in the child process.

Sorry, brain fail. A slightly more contrived failure case is this:

subprocess.Popen(
  ..., 
  preexec_fn=lambda: conn.doWork()
)

Everything else is the same.

Another failure case is:

  class MySQLConn:
... doWork as before ...

def __del__(self):
  self.doWork()

Followed by:

  def thread3(conn):
while True:
  subprocess.call(['nonexistent_program']) 
  time.sleep(0.1)

The destructor will fire in the child and corrupt the parent's data.

An analogous example is:

  conn = MySQLConn()
  start_thread1(conn)
  start_thread2(conn):
  while True:
if os.fork() == 0:  # child
  raise Exception('doom')  # triggers destructor

Basically, it is really really dangerous to release locks that protect any 
resources that are not copied by fork (i.e. network resources, files, DB 
connections, etc, etc).

--

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



[issue14969] Use __suppress_context__ in contextlib.ExitStack.__exit__

2012-05-31 Thread Nick Coghlan

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

Electronic contributor forms are actually on the PSF wishlist. We'll get there 
some day (maybe after the website update).

Getting back to the problem at hand, I think you might be on to something with 
the idea of exploiting PEP 409 to handle this. Specifically, where we reraise a 
caught exception when there are no exception details active, we should be able 
to replace the bare raise with something like:

# A containing with statement will automatically add the exception
# context back in after it gets suppressed. Avoid displaying it.
if suppressed_exc and exc_details == (None, None, None):
raise exc from None
raise

That way, the exception *display* of escaping exceptions will still match that 
of nested with statements, even though the attributes are subtly different 
(__suppress_context__ being set to True, rather than __context__ being None)

--
title: Restore sys.exc_clear()? - Use __suppress_context__ in 
contextlib.ExitStack.__exit__

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



[issue6721] Locks in python standard library should be sanitized on fork

2012-05-31 Thread Gregory P. Smith

Gregory P. Smith g...@krypto.org added the comment:

Anyone using a preexec function in subprocess has already declared that they 
like deadlocks so that isn't an issue. :)

--

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



[issue6721] Locks in python standard library should be sanitized on fork

2012-05-31 Thread lesha

lesha pybug.20.le...@xoxy.net added the comment:

Deadlocks are dandy, but corruption is cruel.

--

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



  1   2   >