Python for Qt version 1.0.0~beta3 salmiak released

2011-01-07 Thread Renato Araujo Oliveira Filho
The PySide team is happy to announce the third beta release of PySide:
Python for Qt. New versions of some of the PySide toolchain components
apiextractor, shiboken, libpyside have been released as well.

This is a source code release only; we hope our community packagers will
be providing provide binary packages shortly. To acquire the source code
packages, refer to our download wiki page [1] or pull the relevant
tagged versions from our git repositories [2].

Major changes since 1.0.0~beta2
===

This is a bugfix release. Since beta2, a total of 35 high-priority
bugs have been fixed. See the list of fixed bugs at the end of this message.

Path towards 1.0 release


There are still some outstanding bugs in our Bugzilla [3]. To have these
fixed, we plan to do a new beta in two weeks. After that we will
check the possibility of a release candidate or other beta before 1.0.


About PySide


PySide is the Nokia-sponsored Python Qt bindings project, providing
access to not only the complete Qt 4.7 framework but also Qt Mobility,
as well as to generator tools for rapidly generating bindings for any
Qt-based libraries.

The PySide project is developed in the open, with all facilities you'd
expect from any modern OSS project such as all code in a git repository
[2], an open Bugzilla [5] for reporting bugs, and an open design
process [4]. We welcome any contribution without requiring a transfer of
copyright.

List of bugs fixed
==

379 QGLWidget.bindTexture is missing
404 Tests fail both in pyside-qt.46+0.4.0 and pyside-qt.46+0.4.1
460 pyside-uic can't deal with QWizard
473 pyside tools lack manpages
474 Enums in non-generated namespaces aren't generated either.
481 mimeData() missing from QListWidget, QTreeWidget, QTableWidget
493 __eq__ and friends not implemented for QKeyEvent == QKeySequence
495 Broken rich compare operators if they use an object-type as parameter
502 Delegate generated editor widget is killed on C++ before its time
503 There's no bindings for QSslCertificate
506 Segmentation fault
514 Static method QByteArray.fromRawData is missing from QtCore
515 Global qAddPostRoutine function missing on QtCore
544 QtCore.QRect missing binding for method getCoords
546 Python crash on exit
547 QTreeWidget segmentation fault
549 [patch] QGraphicsWidget::getContentsMargins() and
QGraphicsWidget::getWindowFrameMargins() not available
554 Inner classes don't work and give us a segfault
557 Segmentation fault in QDeclarativeComponent.loadUrl()
558 print attribute of a QWebFrame cannot be accessed normally (syntax 
error)
561 pyside-uic generates invalid code when tab name is not translatable
563 Unhandled signal emitting with invalid signature (which leads to
application crash)
567 Compilation error - PySide
569 QTableWidgetItem is missing binding of __lt__ to operator
570 Link to old wiki
572 Giving unicode value as 'body' argument to WebView's load method
crashes python
573 Problème avec fonction print() de QPrintPreviewWidget
576 QWidget.setParent( None ) producing orphaned Widgets which won't die
577 Reference to QString in docs
578 QtNetwork_basic_auth_test (Timeout)
580 lock (Timeout)
581 phonon_basic_playing_test (Timeout)
583 add a new QDatetime init function with 6 argument
585 QTreeWidgetItem disappear
587 Test: protected (Failed)


References
==

[1] http://developer.qt.nokia.com/wiki/PySideDownloads
[2] http://qt.gitorious.org/pyside
[3] http://bugs.openbossa.org/
[4] http://www.pyside.org/docs/pseps/psep-0001.html

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

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


[ANN] Leipzig Python User Group - Meeting, January 11, 2011, 08:00pm

2011-01-07 Thread Stefan Schwarzer
=== Leipzig Python User Group ===

We will meet on Tuesday, January, 11th, 8:00 pm at the
training center of Python Academy in Leipzig, Germany
( http://www.python-academy.com/center/find.html ).

Food and soft drinks are provided. Please send a short
confirmation mail to i...@python-academy.de, so we can
prepare appropriately.

Everybody who uses Python, plans to do so or is interested
in learning more about the language is welcome.

While the meeting language will be mainly German, we will
provide English translation if needed.

Current information about the meetings are at
http://www.python-academy.com/user-group .

Stefan


== Leipzig Python User Group ===

Wir treffen uns am Dienstag, 11. Januar 2011 um 20:00 Uhr
im Schulungszentrum der Python Academy in Leipzig
( http://www.python-academy.de/Schulungszentrum/anfahrt.html ).

Für das leibliche Wohl wird gesorgt. Eine Anmeldung unter
i...@python-academy.de wäre nett, damit wir genug Essen
besorgen können.

Willkommen ist jeder, der Interesse an Python hat, die
Sprache bereits nutzt oder nutzen möchte.

Viele Grüße
Stefan
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: Resolve circular reference

2011-01-07 Thread moerchendiser2k3
 Force what?

 j refers to i, i refers to Foo, Foo refers to A. Therefore A should be
 alive.

Oh, sorry. Force the deletion of A.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Resolve circular reference

2011-01-07 Thread moerchendiser2k3
 Force what?
 j refers to i, i refers to Foo, Foo refers to A. Therefore A should be
 alive.


Oh, sorry. Force the deletion of instance Foo(A) and Bar(B).
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: [PyQt] Working with PyQt and Pydev

2011-01-07 Thread Fabio Zadrozny
On Thu, Jan 6, 2011 at 9:32 AM, Rohit Coder 
passionate_program...@hotmail.com wrote:

  I installed the PyDev plugin into Aptana Stdui 3 Beta. Someone suggested
 me to use PyQt for Python GUI app, and so I downloaded and installed PyQt.
 But when I open Aptana Studio, I could see a new menu added with the name
 PyDev, but there is nothing for PyQt.


 In the Windows Start Meny item list, I could see a folder named PyQt and
 when I open it, there are few tools like Designer.


 When Designer is run, it opens Qt IDE for designing Forms like Visual
 Studio and the files have the extension .ui.

 I want to know how to integrate PyQt and PyDev. Do I need to use them
 separately by adding the .ui files to PyDev and then adding Python core code
 for functionality?


After you design your class in the Qt Designer, you need to run pyuic to
convert the .ui file to a python file (which you'd probably subclass in
another module to add your own code, as you don't want to mess the
automatically generated file). If you want, you can add a builder (project 
properties  builders) to run pyuic when a .ui file is changed, so you don't
have to go to the console to ask pyuic to be rerun every time you change the
file.

Cheers,

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


Re: Rewriting __getattr__

2011-01-07 Thread Jean-Michel Pichavant

kost BebiX wrote:

Hi everyone!
I just saw a bug (?) in bson.dbref:DBRef.__getattr__

Here's they're code:
def __getattr__(self, key):
return self.__kwargs[key]

And when you do copy.deepcopy on that object it will raise you KeyError. So 
here's a small piece of code that reproduces the problem:

  

from http://docs.python.org/reference/datamodel.html

About __getattr__
This method should return the (computed) attribute value or raise an 
AttributeError 
http://docs.python.org/library/exceptions.html#exceptions.AttributeError 
exception.


The code you provided raises a KeyError thus methods such as 'getattr' 
will fail as they expect an AttributeError exception.


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


Re: Rewriting __getattr__

2011-01-07 Thread kost BebiX
You're absolutely right! Now try to do except Keyerror: raise AttributeError 
and it will also fail. But why?

07.01.2011, 15:45, Jean-Michel Pichavant jeanmic...@sequans.com:
 kost BebiX wrote:

  Hi everyone!
  I just saw a bug (?) in bson.dbref:DBRef.__getattr__

  Here's they're code:
  def __getattr__(self, key):
  return self.__kwargs[key]

  And when you do copy.deepcopy on that object it will raise you KeyError. So 
 here's a small piece of code that reproduces the problem:

 from http://docs.python.org/reference/datamodel.html

 About __getattr__
 This method should return the (computed) attribute value or raise an
 AttributeError
 http://docs.python.org/library/exceptions.html#exceptions.AttributeError
 exception.

 The code you provided raises a KeyError thus methods such as 'getattr'
 will fail as they expect an AttributeError exception.

 JM

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

-- 
jabber: kost-be...@ya.ru
-- 
http://mail.python.org/mailman/listinfo/python-list


VipIMAGE 2011 – ECCOMAS Thematic Conference – 2n d ANNOUNCE and CALL

2011-01-07 Thread tava...@fe.up.pt
--

International ECCOMAS Thematic Conference VipIMAGE 2011 - III ECCOMAS
THEMATIC
CONFERENCE ON COMPUTATIONAL VISION AND MEDICAL IMAGE PROCESSING
12-14th October 2011, Olhão, Algarve, Portugal
www.fe.up.pt/~vipimage

2nd ANNOUNCE and CALL for PAPERS AND THEMATIC SESSIONS

We would appreciate if you could distribute this information by your
colleagues and co-workers.

--

Dear Colleague,

We would like to call your attention to the International Conference
VipIMAGE 2011 - III ECCOMAS THEMATIC CONFERENCE ON COMPUTATIONAL
VISION AND MEDICAL IMAGE PROCESSING that will be held in Real Marina
Hotel  Spa, Olhão, Algarve, Portugal, on October 12-14, 2011.


Possible Topics (not limited to)

- Signal and Image Processing
- Computational Vision
- Medical Imaging
- Physics of Medical Imaging
- Tracking and Analysis of Movement
- Simulation and Modeling
- Image Acquisition
- Shape Reconstruction
- Objects Segmentation, Matching, Simulation
- Data Interpolation, Registration, Acquisition and Compression
- 3D Vision
- Virtual Reality
- Software Development for Image Processing and Analysis
- Computer Aided Diagnosis, Surgery, Therapy, and Treatment
- Computational Bioimaging and Visualization
- Telemedicine Systems and their Applications


Invited Lecturers

- Armando J. Pinho - University of Aveiro, Portugal
- Irene M. Gamba - The University of Texas at Austin, USA
- Marc Pollefeys - ETH Zurich, Switzerland
- Marc Thiriet - Universite Pierre et Marie Curie (Paris VI), France
- Xavier Roca Marvà - Autonomous University of Barcelona, Spain
- Stan Sclaroff - Boston University, USA


Thematic Sessions

Proposals to organize Thematic Session within VipIMAGE 2011 are mostly
welcome.
Proposals for Thematic Sessions should be submitted by email to the
conference co-chairs (tava...@fe.up.pt, rna...@fe.up.pt)


Thematic Sessions Confirmed

- Simultaneous MR-PET imaging
- Satellite image analysis for environmental risk assessment


Publications

The proceedings book will be published by the Taylor  Francis Group
and indexed by Thomson Reuters Conference Proceedings Citation Index,
IET Inspect and Elsevier Scopus.
A book with 20 invited works from the best ones presented in
VipIMAGE2011 (extended versions) will be published by Springer.
The organizers will encourage the submission of extended versions of
the accepted papers to related International Journals; in particular,
for special issues dedicated to the conference.


Important dates

- Deadline for Thematic Sessions proposals: 15th January 2011
- Deadline for Extended Abstracts: 15th March 2011
- Authors Notification: 15th April 2011
- Deadline for Full Papers: 15th June 2011


Awards

best paper award and best student paper award are going to be
given to the author(s) of two papers presented at the conference,
selected by the Organizing Committee based on the best combined marks
from the Scientific Committee and Session Chairs.


We are looking forward to see you in Algarve next October.

Kind regards,

João Manuel R. S. Tavares
Renato Natal Jorge
(conference co-chairs)

PS. For further details please see the conference website at:
www.fe.up.pt/~vipimage
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rewriting __getattr__

2011-01-07 Thread Jean-Michel Pichavant

kost BebiX wrote:

You're absolutely right! Now try to do except Keyerror: raise AttributeError 
and it will also fail. But why?

07.01.2011, 15:45, Jean-Michel Pichavant jeanmic...@sequans.com:
  

kost BebiX wrote:



 Hi everyone!
 I just saw a bug (?) in bson.dbref:DBRef.__getattr__

 Here's they're code:
 def __getattr__(self, key):
 return self.__kwargs[key]

 And when you do copy.deepcopy on that object it will raise you KeyError. So 
here's a small piece of code that reproduces the problem:
  

from http://docs.python.org/reference/datamodel.html

About __getattr__
This method should return the (computed) attribute value or raise an
AttributeError
http://docs.python.org/library/exceptions.html#exceptions.AttributeError
exception.

The code you provided raises a KeyError thus methods such as 'getattr'
will fail as they expect an AttributeError exception.

JM

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



  

please don't top post :)

It fails because you simply did not returned any value (with your class 
A example).


class A(object):
   def __init__(self):
   self.d = {}
   def __getattr__(self, key):
   try:
   *return* self.d[key]
   except KeyError:
   raise AttributeError


works fine with deepcopy

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


Re: PEP: possibility of inline using of a symbol instead of import

2011-01-07 Thread Carl Banks
On Jan 6, 7:28 am, dmitrey dmitrey.kros...@scipy.org wrote:
 hi all,
 I have th PEP (I'm not sure something like that hadn't been proposed
 although):
 very often in a Python file header the following lines are present,
 like:
 from MyModule1 import myFunc1
 import MyModule2 as mm2
 from MyModule3 import myFunc3 as mf3
 etc

 and after several pages of code they are using somewhere, maybe only
 one time, e.g.
 r1 = myFunc1(...)
 r2 = mm2.myFunc2(...)
 r3 = mf3(...)
 It makes programs less clear, you have to scroll several pages of code
 in IDE to understand what it refers to.

 I propose to add possibility of using a symbol instead (for simplicity
 I use @ here, that is already reserved for decorators, thus it should
 be other symbol, maybe from Unicode although for simplicity to type it
 I would prefer something ordinary like $ or ` or !).

 e.g. instead of

 import MyModule
 (...lots of code...)
 r = MyModule.myFunc(...)

 someone could just type in the single place

 r = @MyModule.myFunc(...)

 Also, import MyModule2 as mm2 could be replaced to mere
 mm2 = @MyModule2
 and from MyModule3 import myFunc3 as mf3 could be replaced to mere
 mf3 = @MyModule3.myFunc3.

 As for __import__(ModuleTextName), it could be replaced to something
 like @(ModuleTextName) or @{ModuleTextName} or @[ModuleTextName].


I actually wouldn't mind this; in fact Python's importing mechanism is
bad enough that a complete overhaul might not be a bad thing.

But, first of all, one can already do in-line imports in Python with
the __import__ built-in function (and I used to do this frequently in
throwaway scripts before list comprehensions were added).  For
instance, a one-liner to generate a password would be this:

python -c 'for i in xrange(8):
__import__(sys).stdout.write(__import__(random).choice(__import__(string).letters))'

Today a better way to do it would be like this:

python -c 'import random,string; print
.join(random.choice(string.letters) for i in xrange(8))'

But that's a digression.

The problem with in-line imports is that it can lead to deadlock in
multithreaded programs, so for the most part it's a good idea to avoid
importing within functions.

Therefore, a syntax for it would really be needed to gain full
benefit.  This would allow the compiler to scan the file to collect a
list of prerequisite modules.  In my mind, the module itself wouldn't
import the dependencies itself, it simply lists prerequisites and
leaves it to the runtime to ensure that they've been imported.

A side benefit to this is to keep module namespaces clean.

Main drawback is that it makes accessing symbols in deepely nested
packages unwieldy (since presumably you'd have to write out the fully-
qualified name).  Meh, I pretty much avoid deeply nested packages, and
typically spell out the fully-qualified module names anyway.  So not
my problem.

As for listing imports at the top of the program--I can't say I have
much use for it.  Sometimes it helps to see a list of prerqequisites
in one place, but I can't say it's the most useful thing ever, and
anyway it's misleading since the imports can become stale.  I'd rather
not have to stop and scroll up ten pages to add an import to the top
of the module when I suddenly need to access time.sleep or
itertools.count.

So, pending a better syntax, I'll give it a +0; and the only reason I
don't give it a +1 is it's such a drastic change.

The syntax probably would deserve a lot of thought (being such a
drastic change) but drawing from C++ a postfix operator would seem to
fit.

sys:: - evaulates to the sys module
sys::version - evaluates to sys.version
xml::etree::ElementTree:: - as expected

That has the unfortunate effect of making Python look like C++ though.


Won't ever happen though.


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


Re: PEP: possibility of inline using of a symbol instead of import

2011-01-07 Thread Carl Banks
On Jan 6, 8:32 am, Tim Harig user...@ilthio.net wrote:
 2. Your so-called PEP probably clashes with Python's use of @ for
         decorators.

He said it was just for simplicity's sake.


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


Close stdout socket on CGI after fork with subprocess

2011-01-07 Thread Thibaud Roussillat
Hi,

I work with Python 2.4 and CGI.

I have a CGI which call a Python script in background process and return
result before background task is finished.

Actually, the browser displays response but it is waiting for end of
background task because the socket is not closed.

Internet told me that I must close the stdout file descriptor
(sys.stdout.close()) to close the socket but it doesn't work.

The background task is launched via subprocess.Popen and is attached to the
root process on ps command.

Any idea ?

Thanks

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


Re: Rewriting __getattr__

2011-01-07 Thread kost BebiX
07.01.2011, 16:22, Jean-Michel Pichavant jeanmic...@sequans.com:
 kost BebiX wrote:

  You're absolutely right! Now try to do except Keyerror: raise 
 AttributeError and it will also fail. But why?

  07.01.2011, 15:45, Jean-Michel Pichavant jeanmic...@sequans.com;:
  kost BebiX wrote:
   Hi everyone!
   I just saw a bug (?) in bson.dbref:DBRef.__getattr__

   Here's they're code:
   def __getattr__(self, key):
   return self.__kwargs[key]

   And when you do copy.deepcopy on that object it will raise you KeyError. 
 So here's a small piece of code that reproduces the problem:
  from http://docs.python.org/reference/datamodel.html

  About __getattr__
  This method should return the (computed) attribute value or raise an
  AttributeError
  http://docs.python.org/library/exceptions.html#exceptions.AttributeError
  exception.

  The code you provided raises a KeyError thus methods such as 'getattr'
  will fail as they expect an AttributeError exception.

  JM

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

 please don't top post :)

 It fails because you simply did not returned any value (with your class
 A example).

 class A(object):
 def __init__(self):
 self.d = {}
 def __getattr__(self, key):
 try:
 *return* self.d[key]
 except KeyError:
 raise AttributeError

 works fine with deepcopy

 JM

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

Sorry for top posting, didn't know about that) I'm quote new to posting to 
mailing lists.

Well, actually the code you showed doesn't work)

 class A(object):
.. def __init__(self):
.. self.d = {}
.. def __getattr__(self, key):
.. try:
.. return self.d[key]
.. except KeyError:
.. raise AttributeError
 from copy import deepcopy
 a = A()
 deepcopy(a)
Exception RuntimeError: 'maximum recursion depth exceeded while calling a 
Python object' in type 'exceptions.AttributeError' ignored
Exception RuntimeError: 'maximum recursion depth exceeded while calling a 
Python object' in type 'exceptions.AttributeError' ignored
0: __main__.A object at 0xda0250


-- 
jabber: k...@ya.ru
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rewriting __getattr__

2011-01-07 Thread Jean-Michel Pichavant

kost BebiX wrote:

Sorry for top posting, didn't know about that) I'm quote new to posting to 
mailing lists.

Well, actually the code you showed doesn't work)

  

class A(object):


.. def __init__(self):
.. self.d = {}
.. def __getattr__(self, key):
.. try:
.. return self.d[key]
.. except KeyError:
.. raise AttributeError
  

from copy import deepcopy
a = A()
deepcopy(a)


Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python 
object' in type 'exceptions.AttributeError' ignored
Exception RuntimeError: 'maximum recursion depth exceeded while calling a Python 
object' in type 'exceptions.AttributeError' ignored
0: __main__.A object at 0xda0250


  

It does work as I pasted it with python2.5.
recursion problems often occur when overriding __getattr__ or 
__getattribute__ *AND* accessing self attributes using self.attr form 
inside the method.


try to change

   return self.d[key]

into

   return object.__getattribute__(self, 'd')[key]

Just speculating though, I cannot test since I don't reproduce the problem.


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


Re: Streaming templating languages for use as WSGI body.

2011-01-07 Thread Michael Ströder
Alice Bevan–McGregor wrote:
 On 2011-01-06 11:11:27 -0800, Adam Tauno Williams said:
 On Thu, 2011-01-06 at 11:07 -0800, Alice Bevan–McGregor wrote:
 On 2011-01-06 10:00:39 -0800, Adam Tauno Williams said:
 With HTTP/1.0 [and WSGI is HTTP/1.0 only] you have to provide a
 Content-Length header - so you have to generate the entire response
 at once [however you want to muddy at once].

 Both of these statements are false.

 Both these statements are true!  I suggest you consult the HTTP spec.
 
 It's generally polite to provide direct references, either sections or
 actual links when asking someone to RTFM.  No matter, examining the
 HTTP/1.0 RFC (conveniently chopped up and HTML-ified by the w3) I find
 evidence to support your argument:
 
 http://www.w3.org/Protocols/HTTP/1.0/draft-ietf-http-spec.html#Entity-Body

As I read section 7.2.2 (Length) the Content-length header is only required in
HTTP *requests* if the body contains data. According to the text it's not
required in HTTP *responses*.

Ciao, Michael.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rewriting __getattr__

2011-01-07 Thread kost BebiX
07.01.2011, 17:14, Jean-Michel Pichavant jeanmic...@sequans.com:
 kost BebiX wrote:

  Sorry for top posting, didn't know about that) I'm quote new to posting to 
 mailing lists.

  Well, actually the code you showed doesn't work)
  class A(object):
  .. def __init__(self):
  .. self.d = {}
  .. def __getattr__(self, key):
  .. try:
  .. return self.d[key]
  .. except KeyError:
  .. raise AttributeError
  from copy import deepcopy
  a = A()
  deepcopy(a)
  Exception RuntimeError: 'maximum recursion depth exceeded while calling a 
 Python object' in type 'exceptions.AttributeError' ignored
  Exception RuntimeError: 'maximum recursion depth exceeded while calling a 
 Python object' in type 'exceptions.AttributeError' ignored
  0: __main__.A object at 0xda0250

 It does work as I pasted it with python2.5.
 recursion problems often occur when overriding __getattr__ or
 __getattribute__ *AND* accessing self attributes using self.attr form
 inside the method.

 try to change

 return self.d[key]

 into

 return object.__getattribute__(self, 'd')[key]

 Just speculating though, I cannot test since I don't reproduce the problem.

 JM

Yeap, that works. So, is it a python 2.6 bug? Because documentation says that 
__getattr__ is called only after property was not found (and __getattr__ was 
actually invented in a way that you can use self inside it).

-- 
jabber: k...@ya.ru
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rewriting __getattr__

2011-01-07 Thread Steven D'Aprano
On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote:

 Well, actually the code you showed doesn't work)

Actually, it does. It just prints a warning message as well. Look 
carefully:


 class A(object):
 .. def __init__(self):
 .. self.d = {}
 .. def __getattr__(self, key):
 .. try:
 .. return self.d[key]
 .. except KeyError:
 .. raise AttributeError
 from copy import deepcopy
 a = A()
 deepcopy(a)
 Exception RuntimeError: 'maximum recursion depth exceeded while calling
 a Python object' in type 'exceptions.AttributeError' ignored 
 Exception RuntimeError: 'maximum recursion depth exceeded while calling
 a Python object' in type 'exceptions.AttributeError' ignored 
 0: __main__.A object at 0xda0250


The last thing printed is the deepcopied object.


I've tested the above code in Python versions 2.4 through 3.2 and the 
only one that prints that message is 2.6.


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


Re: Resolve circular reference

2011-01-07 Thread Carl Banks
On Jan 7, 3:58 am, moerchendiser2k3 googler.
1.webmas...@spamgourmet.com wrote:
  Force what?
  j refers to i, i refers to Foo, Foo refers to A. Therefore A should be
  alive.

 Oh, sorry. Force the deletion of instance Foo(A) and Bar(B).

If you don't want j to keep i alive, you should look at weak
referencing.  (Look at the documentation for the weakref module.
Also, this has nothing to do with A and B being C-defined types; this
exact same behavior would happen even with Python types.)


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


os.system and loggers

2011-01-07 Thread Tim
hi, I'm using a 3rd-party python program that uses the python logging
facility and also makes calls to os.system. I'm trying to capture its
output to a file.

In my own code, I've taken control of the loggers that are setup in
the other program by removing its StreamHandler and replacing with
FileHander. But when it comes to the call to os.system I'm at a loss.

I want to capture the stdout from that os.system call in my
FileHandler. I thought this might work, before I call the other
program's class/method:
sys.stdout = getLogger('status').handlers[0].stream

but no dice. Is there any clean way to get what I want? If not, I
guess I'll override the other method with my own, but it will
basically be a bunch of code copied with os.sytem replaced with
subprocess, using getLogger('status').handlers[0].stream for stdout/
stderr.

thanks,
--Tim Arnold
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Streaming templating languages for use as WSGI body.

2011-01-07 Thread Alice Bevan–McGregor

On 2011-01-07 07:17:33 -0800, Michael Ströder said:

As I read section 7.2.2 (Length) the Content-length header is only 
required in HTTP *requests* if the body contains data. According to the 
text it's not required in HTTP *responses*.


You are correct; I mis-read that section in my haste.

- Alice.


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


Re: Rewriting __getattr__

2011-01-07 Thread kost BebiX
07.01.2011, 23:48, Fuzzyman fuzzy...@gmail.com:
 On Jan 7, 3:18 pm, kost BebiX k...@ya.ru; wrote:

  07.01.2011, 17:14, Jean-Michel Pichavant jeanmic...@sequans.com;:
  kost BebiX wrote:
  šSorry for top posting, didn't know about that) I'm quote new to posting 
 to mailing lists.
  šWell, actually the code you showed doesn't work)
  šclass A(object):
  š.. def __init__(self):
  š.. self.d = {}
  š.. def __getattr__(self, key):
  š.. try:
  š.. return self.d[key]
  š.. except KeyError:
  š.. raise AttributeError
  šfrom copy import deepcopy
  ša = A()
  šdeepcopy(a)
  šException RuntimeError: 'maximum recursion depth exceeded while calling 
 a Python object' in type 'exceptions.AttributeError' ignored
  šException RuntimeError: 'maximum recursion depth exceeded while calling 
 a Python object' in type 'exceptions.AttributeError' ignored
  š0: __main__.A object at 0xda0250
  It does work as I pasted it with python2.5.
  recursion problems often occur when overriding __getattr__ or
  __getattribute__ *AND* accessing self attributes using self.attr form
  inside the method.
  try to change
  return self.d[key]
  into
  return object.__getattribute__(self, 'd')[key]
  Just speculating though, I cannot test since I don't reproduce the problem.
  JM
  Yeap, that works. So, is it a python 2.6 bug? Because documentation says 
 that __getattr__ is called only after property was not found (and 
 __getattr__ was actually invented in a way that you can use self inside it).

 That is true (that __getattr__ is called only if the attribute doesn't
 exist), however deepcopy works by creating a new instance *without*
 calling __init__. When it is copying the attributes self.d *doesn't*
 exist initially. You should work around this case in your __getattr__
 if you want your object to be deep-copyable.

 Michael Foord
 --
 http://www.voidspace.org.uk/

Yeah, but, I mean, shouldn't deepcopy copy the attributes before it gets to 
calling __getattr__?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rewriting __getattr__

2011-01-07 Thread kost BebiX
07.01.2011, 17:47, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
 On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote:

  Well, actually the code you showed doesn't work)

 Actually, it does. It just prints a warning message as well. Look
 carefully:

  class A(object):
  .. def __init__(self):
  .. self.d = {}
  .. def __getattr__(self, key):
  .. try:
  .. return self.d[key]
  .. except KeyError:
  .. raise AttributeError
  from copy import deepcopy
  a = A()
  deepcopy(a)
  Exception RuntimeError: 'maximum recursion depth exceeded while calling
  a Python object' in type 'exceptions.AttributeError' ignored
  Exception RuntimeError: 'maximum recursion depth exceeded while calling
  a Python object' in type 'exceptions.AttributeError' ignored
  0: __main__.A object at 0xda0250

 The last thing printed is the deepcopied object.

 I've tested the above code in Python versions 2.4 through 3.2 and the
 only one that prints that message is 2.6.

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

So maybe it should be fixed in 2.6? When I'll have time I'll look at copy.py in 
different python's. Maybe there's the answer)
Thanks anyway.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Rewriting __getattr__

2011-01-07 Thread Steven D'Aprano
On Fri, 07 Jan 2011 23:54:24 +0200, kost BebiX wrote:

 07.01.2011, 17:47, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info:
 On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote:

  Well, actually the code you showed doesn't work)

 Actually, it does. It just prints a warning message as well. Look
 carefully:
[...]
 I've tested the above code in Python versions 2.4 through 3.2 and the
 only one that prints that message is 2.6.

 So maybe it should be fixed in 2.6? When I'll have time I'll look at
 copy.py in different python's. Maybe there's the answer) Thanks anyway.


Before you spend too much (i.e. any) time trying to fix this, I think 
that Python 2.6 is now only accepting security fixes.

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


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


Re: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac?

2011-01-07 Thread Jason Swails
MacPorts!  They include a nifty little package called python_select that
lets you switch default python versions on-the-fly and organizes everything
for you perfectly.  I have python 2.4, 2.5, 2.6, 2.7, 3.2, and the system
default 2.6.1 all installed, and

python_select python27
python_select python32
python_select python26-apple

switches seamlessly between them.  (I have so many versions to test script
compatibility, not because I'm an avid collector).  In any case, this seems
to be an ideal solution.

All the best,
Jason

On Thu, Jan 6, 2011 at 5:25 PM, Bill Felton
subscripti...@cagttraining.comwrote:

 On Jan 6, 2011, at 3:46 PM, Ned Deily wrote:

 In article 775a9d45-25b5-4a16-9fe5-6217fd67f...@cagttraining.com,

 Bill Felton subscripti...@cagttraining.com wrote:

 I'm new to python, trying to learn it from a variety of resources,
 including

 references posted recently to this list.

 I'm going through /www.openbookproject.net/thinkCSpy/ and find it makes
 use

 of gasp, which apparently is not compatible with 3.1.

 I've also seen various resources indicate that one can install both Python

 2.7 and Python 3.1 -- but when I did this, I get no end of problems in the

 2.7 install.  IDLE, in particular, fails rather spectacularly, even if I

 launch it directly from the Python 2.7 directory in which it resides.

 So, either I've been misled and should only try to have one or the other.
  OR

 I'm missing some (probably simple) step that's mucking me up.

 Help?


 Yes, you can have multiple versions of Python installed on Mac OS X.  In

 fact, Apple ships multiple versions of Python with OS X (2.6 and 2.6

 with OS X 10.6, for example).  Starting with Python 2.7, python.org

 offers two variants of OS X installers, one is 32-bit-only and works on

 all versions of OS X 10.3.9 through OS X 10.6, the other supports 64-bit

 execution and only works on 10.6 (as of 2.7.1).  Unfortunately, there

 are some major interaction problems between Tkinter, Python's GUI

 toolkit which is used by IDLE, and the Tcl/Tk 8.5 supplied by Apple in

 OS X 10.6.  I'm assuming you installed the 64-bit version.  If so, until

 the problem is resolved in the next maintenance release of Python 2.7, I

 suggest you download and install the 32-bit-only version of Python 2.7.1

 which does not have those problems.



 Thank you, Ned!  Installing what appeared to be the 'old OS' version seems
 to fix my difficulty.
 IDLE now works fine without hanging, I can enter code, save, check syntax,
 and run from the 'new window'.
 And 3.1 still works as before.

 regards,
 Bill

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




-- 
Jason M. Swails
Quantum Theory Project,
University of Florida
Ph.D. Graduate Student
352-392-4032
-- 
http://mail.python.org/mailman/listinfo/python-list


apscheduler error

2011-01-07 Thread linna li
I tried to use the apscheduler and used the sample code below from the
tutorial, but got the error message: Exception in thread APScheduler
(most likely raised during interpreter shutdown). What's going on
here? I really appreciate any help!

from apscheduler.scheduler import Scheduler

sched = Scheduler()
sched.start()

def some_job():
print Decorated job

sched.add_interval_job(some_job,minutes=1)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Can I have both Python 2.7 and Python 3.1 at the same time on the Mac?

2011-01-07 Thread Ned Deily
In article 
aanlktiknv-bymg+pxmtmrcv5mqqikdolezjclmebe...@mail.gmail.com,
 Jason Swails jason.swa...@gmail.com wrote:
 MacPorts!  They include a nifty little package called python_select that
 lets you switch default python versions on-the-fly and organizes everything
 for you perfectly.  I have python 2.4, 2.5, 2.6, 2.7, 3.2, and the system
 default 2.6.1 all installed, and
 
 python_select python27
 python_select python32
 python_select python26-apple
 
 switches seamlessly between them.  (I have so many versions to test script
 compatibility, not because I'm an avid collector).  In any case, this seems
 to be an ideal solution.

Unfortunately, that's not a complete solution.  The biggest hole is that 
it does not automatically solve the problem of scripts installed into 
the particular version's framework bin directory, neither all of the 
current scripts included in the standard python distribution nor 3rd 
party version-dependent scripts, things like easy_install, pip, etc.  
The former is easily fixed, the latter is harder to automate. The 
python.org installers take the route of providing a shell script app for 
each version to modify your shell login profile to insert that version's 
bin directory at the head of the $PATH env variable.  Modifying a shell 
profile is clearly not a particularly clean solution but it does 
actually work whereas python_select, in general, does not.

-- 
 Ned Deily,
 n...@acm.org

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


Re: apscheduler error

2011-01-07 Thread Steven D'Aprano
On Fri, 07 Jan 2011 17:08:28 -0800, linna li wrote:

 I tried to use the apscheduler and used the sample code below from the
 tutorial, but got the error message: Exception in thread APScheduler
 (most likely raised during interpreter shutdown). What's going on here?
 I really appreciate any help!


I've tried your code in every version of Python from 2.4 through 3.2, and 
get an exception on the very first line every time:

ImportError: No module named apscheduler.scheduler


I think you will need to give some more detail... what version of Python 
are you running, and what is apschedular?

Also, please copy and paste the exact error message, in full, including 
the traceback. Don't summarise it, retype it, or paraphrase it.





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


Re: apscheduler error

2011-01-07 Thread Chris Rebert
On Fri, Jan 7, 2011 at 6:09 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Fri, 07 Jan 2011 17:08:28 -0800, linna li wrote:
 I tried to use the apscheduler and used the sample code below from the
 tutorial, but got the error message: Exception in thread APScheduler
 (most likely raised during interpreter shutdown). What's going on here?
 I really appreciate any help!


 I've tried your code in every version of Python from 2.4 through 3.2, and
 get an exception on the very first line every time:

 ImportError: No module named apscheduler.scheduler


 I think you will need to give some more detail... what version of Python
 are you running, and what is apschedular?

A quick Google search suggests it's http://packages.python.org/APScheduler/

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


Re: Rewriting __getattr__

2011-01-07 Thread kost BebiX
08.01.2011, 02:20, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info:
 On Fri, 07 Jan 2011 23:54:24 +0200, kost BebiX wrote:

  07.01.2011, 17:47, Steven D'Aprano
  steve+comp.lang.pyt...@pearwood.info;:
  On Fri, 07 Jan 2011 16:47:55 +0200, kost BebiX wrote:
   Well, actually the code you showed doesn't work)
  Actually, it does. It just prints a warning message as well. Look
  carefully:

 [...]

  I've tested the above code in Python versions 2.4 through 3.2 and the
  only one that prints that message is 2.6.
  So maybe it should be fixed in 2.6? When I'll have time I'll look at
  copy.py in different python's. Maybe there's the answer) Thanks anyway.

 Before you spend too much (i.e. any) time trying to fix this, I think
 that Python 2.6 is now only accepting security fixes.

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

 --
 Steven

Too bad (I mean, it's not too bad, because this thing can break other's 2.6 
code that somehow depends on that). Now when I'll install 2.7 I'll have to 
remember about this bug when coding)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Close stdout socket on CGI after fork with subprocess

2011-01-07 Thread Kushal Kumaran
On Fri, Jan 7, 2011 at 8:08 PM, Thibaud Roussillat
thibaud.roussil...@gmail.com wrote:
 Hi,

 I work with Python 2.4 and CGI.

 I have a CGI which call a Python script in background process and return
 result before background task is finished.

 Actually, the browser displays response but it is waiting for end of
 background task because the socket is not closed.

 Internet told me that I must close the stdout file descriptor
 (sys.stdout.close()) to close the socket but it doesn't work.

 The background task is launched via subprocess.Popen and is attached to the
 root process on ps command.


This means that the parent process finished before the child.  Call
wait() on the Popen object to wait for the child to terminate.
Depending on how you create the Popen object, the child process may
inherit your own stdout.  In that case, the child process may be
keeping the socket open after the parent dies.

-- 
regards,
kushal
-- 
http://mail.python.org/mailman/listinfo/python-list


student question

2011-01-07 Thread John
 q_file = open(questions_location) #opens the document successfully
 for line in q_file:
print line

# prints document successfully
 line
# prints last line of document
 for line in q_file:
print line # prints nothing

...why does it print nothing?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: student question

2011-01-07 Thread Corey Richardson
On 01/07/2011 09:42 PM, John wrote:
 q_file = open(questions_location) #opens the document successfully
 for line in q_file:
   print line
 
 # prints document successfully
 line
 # prints last line of document
 for line in q_file:
   print line # prints nothing
 
 ...why does it print nothing?

IIRC, iterating through the lines in a file moves the cursor (is that
the correct term?) to the end of the file. After the first one, use
q_file.seek(0) to go back to the start. I think.

~Corey Richardson
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: student question

2011-01-07 Thread John
On Jan 7, 6:47 pm, Corey Richardson kb1...@aim.com wrote:
 On 01/07/2011 09:42 PM, John wrote:

  q_file = open(questions_location) #opens the document successfully
  for line in q_file:
             print line

  # prints document successfully
  line
  # prints last line of document
  for line in q_file:
             print line # prints nothing

  ...why does it print nothing?

 IIRC, iterating through the lines in a file moves the cursor (is that
 the correct term?) to the end of the file. After the first one, use
 q_file.seek(0) to go back to the start. I think.

 ~Corey Richardson

fantastic. thanks, corey!
-- 
http://mail.python.org/mailman/listinfo/python-list


How to read ansic file into a pre-defined class?

2011-01-07 Thread Ying Zu
How to read ansic file into a pre-defined class?

I have a series of files written in the following format,

2 # number of classes
100   # number of items for the first class object
0   foo
1   foo
...
99  foo
150   # number of items for the second class object
0   bar
1   bar
...
149 bar

ultimately I want to read the file to two *structs* (sorry for my C 
jargon,
just started playing with Python), with attributes number_of_items and
data_array.

I wrote a simply code to read and split each line into a list, then try 
to 
tell the meaning of each line by the number of elements of each line list 
and
the its position in the file. But it is definitely not the way Python 
should
be used.

Any ideas on how to implement a more elegant yet efficient python version?

Thanks.
meaning of each line by counting the number of elements 
-- 
http://mail.python.org/mailman/listinfo/python-list


How to read ansic file into a pre-defined class?

2011-01-07 Thread Ying Zu
How to read ansic file into a pre-defined class?

I have a series of files written in the following format,

2 # number of classes
100   # number of items for the first class object 
0   foo
1   foo
...
99  foo
150   # number of items for the second class object 
0   bar
1   bar
...
149 bar

ultimately I want to read the file to two *structs* (sorry for my C
jargon, just started playing with Python), with attributes
number_of_items and data_array.

I wrote a simply code to read and split each line into a list, then
try to tell the meaning of each line by the number of elements of
each line list and the its position in the file. But it is
definitely not the way Python should be used.

Any ideas on how to implement a more elegant yet efficient python
version?

Thanks.



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


Re: apscheduler error

2011-01-07 Thread Adam Tauno Williams
On Fri, 2011-01-07 at 17:08 -0800, linna li wrote: 
 I tried to use the apscheduler and used the sample code below from the
 tutorial, but got the error message: Exception in thread APScheduler
 (most likely raised during interpreter shutdown). What's going on
 here? I really appreciate any help!
 
 from apscheduler.scheduler import Scheduler
 
 sched = Scheduler()
 sched.start()
 
 def some_job():
 print Decorated job
 
 sched.add_interval_job(some_job,minutes=1)

I see this same error when I run this code (python-2.6.5-3.3.1.x86_64)

I develop an application that uses APScheduler
http://pypi.python.org/pypi/APScheduler/1.0, the scheduler works very
well.  But I haven't used it in exactly this manner.

If I add -
import time
time.sleep(300)
- to the end of your script I don't get the error; and the job actually
gets run [the scheduler thread won't stop the main thread, and thus the
script, from exiting].

The author of APScheduler has an eponymously named channel on FreeNode,
he can probably answer your question exactly.

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


More Help with python .find fucntion

2011-01-07 Thread Keith Anthony
My previous question asked how to read a file into a strcuture
a line at a time.  Figured it out.  Now I'm trying to use .find
to separate out the PDF objects.  (See code)  PROBLEM/QUESTION:
My call to lines[i].find does NOT find all instances of endobj.
Any help available?  Any insights?

#!/usr/bin/python

inputfile =  file('sample.pdf','rb')# This is PDF with which we 
will work
lines = inputfile.readlines()   # read file one line at a time

linestart = []  # Starting address for each line
lineend = []# Ending address for each line
linetype = []

print len(lines)# print number of lines

i = 0   # define an iterator, i
addr = 0# and address pointer

while i  len(lines):   # Go through each line
linestart = linestart + [addr]
length = len(lines[i])
lineend = lineend + [addr + (length-1)]
addr = addr + length
i = i + 1

i = 0
while i  len(lines):   # Initialize line types as 
normal
linetype = linetype + ['normal']
i = i + 1

i = 0
while i  len(lines):   # 
if lines[i].find(' obj')  0:
linetype[i] = 'object'
print At address ,linestart[i],object found at line ,i,: , 
lines[i]
if lines[i].find('endobj')  0:
linetype[i] = 'endobj'
print At address ,linestart[i],endobj found at line ,i,: , 
lines[i]
i = i + 1



-- 
- --- -- -
Posted with NewsLeecher v4.0 Final
Web @ http://www.newsleecher.com/?usenet
--- -  -- -

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


Re: More Help with python .find fucntion

2011-01-07 Thread Chris Rebert
On Fri, Jan 7, 2011 at 8:43 PM, Keith Anthony kanth...@woh.rr.com wrote:
 My previous question asked how to read a file into a strcuture
 a line at a time.  Figured it out.  Now I'm trying to use .find
 to separate out the PDF objects.  (See code)  PROBLEM/QUESTION:
 My call to lines[i].find does NOT find all instances of endobj.
 Any help available?  Any insights?

 #!/usr/bin/python

 inputfile =  file('sample.pdf','rb')            # This is PDF with which we 
 will work
 lines = inputfile.readlines()                   # read file one line at a time

 linestart = []                                  # Starting address for each 
 line
 lineend = []                                    # Ending address for each line
 linetype = []

 print len(lines)                                # print number of lines

 i = 0                                           # define an iterator, i
 addr = 0                                        # and address pointer

 while i  len(lines):                           # Go through each line
    linestart = linestart + [addr]
    length = len(lines[i])
    lineend = lineend + [addr + (length-1)]
    addr = addr + length
    i = i + 1

 i = 0
 while i  len(lines):                           # Initialize line types as 
 normal
    linetype = linetype + ['normal']
    i = i + 1

 i = 0
 while i  len(lines):                           #
    if lines[i].find(' obj')  0:
        linetype[i] = 'object'
        print At address ,linestart[i],object found at line ,i,: , 
 lines[i]
    if lines[i].find('endobj')  0:
        linetype[i] = 'endobj'
        print At address ,linestart[i],endobj found at line ,i,: , 
 lines[i]
    i = i + 1

Your code can be simplified significantly.
In particular:
- Don't add single-element lists. Use the list.append() method instead.
- One seldom manually tracks counters like `i` in Python; use range()
or enumerate() instead.
- Lists have a multiply method which gives the concatenation of n
copies of the list.

Revised version (untested obviously):

inputfile =  file('sample.pdf','rb')# This is PDF with
which we will work
lines = inputfile.readlines()   # read file one line at a time

linestart = []  # Starting address for each line
lineend = []# Ending address for each line
linetype = ['normal']*len(lines)

print len(lines)# print number of lines

addr = 0# and address pointer

for line in lines: # Go through each line
   linestart.append(addr)
   length = len(line)
   lineend.append(addr + (length-1))
   addr += length

for i, line in enumerate(lines):
   if line.find(' obj')  0:
   linetype[i] = 'object'
   print At address ,linestart[i],object found at line ,i,: , line
   if line.find('endobj')  0:
   linetype[i] = 'endobj'
   print At address ,linestart[i],endobj found at line ,i,: , line


As to the bug: I think you want != -1 rather than  0 for your
conditionals; remember that Python list/string indices are 0-based.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Error invalid syntax while statement

2011-01-07 Thread Garland Fulton
I don't understand what I'm doing wrong i've tried several different cases
for what i am doing here. Will someone please point my error out.

Thank you.


  1 #!/bin/bash/python
  2 import math
  3 try:
  4 x = int(input(Enter your number: ))
  5 if( 0  x | x  2147483647):
  6 raise Exception()
  7 else:
  8 end = 0
  9 count = 0
 10 count1 = x
 11 counter = 0
 12 print(end: , end)
 13 print(count: , count)
 14 print(count1: , count1)
 15 print(counter: , counter
 16
 17   while (end == 0):  #
---returns syntax error on this while statement
 18   if(count  x):
 19
 20   sol = math.pow(count, 2) + math.pow(count1, 2)
 21   count += 1
 22   count1 -= 1
 23   print(end: , end)
 24   print(count: , count)
 25   print(count1: , count1)
 26   print(counter: , counter
 27   if( sol == x):
 28   counter += x
 29   else:
 30   end = 1
 31 except Exception as ran:
 32print(Value not within range, ran)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error invalid syntax while statement

2011-01-07 Thread Chris Rebert
On Fri, Jan 7, 2011 at 9:18 PM, Garland Fulton stacks...@gmail.com wrote:
 I don't understand what I'm doing wrong i've tried several different cases
 for what i am doing here. Will someone please point my error out.
 Thank you.

   1 #!/bin/bash/python

This shebang undoubtedly erroneous.

   5     if( 0  x | x  2147483647):

One normally writes that using boolean or rather than the bitwise
operator. Also, the parentheses are completely unnecessary visual
clutter.

  15         print(counter: , counter

Where's the closing parenthesis?

  17               while (end == 0):                              #
 ---returns syntax error on this while statement

Always include the exact error message + traceback in the future.

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error invalid syntax while statement

2011-01-07 Thread Ned Deily
In article 
aanlktik2eii-mwhg-eh_xe9kfhiylhyefzpvm7yzg...@mail.gmail.com,
 Garland Fulton stacks...@gmail.com wrote:
 I don't understand what I'm doing wrong i've tried several different cases
 for what i am doing here. Will someone please point my error out.

  15 print(counter: , counter

Missing ) on line 15.

-- 
 Ned Deily,
 n...@acm.org

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


Re: More Help with python .find fucntion

2011-01-07 Thread Steven D'Aprano
On Fri, 07 Jan 2011 22:43:54 -0600, Keith Anthony wrote:

 My previous question asked how to read a file into a strcuture a line at
 a time.  Figured it out.  Now I'm trying to use .find to separate out
 the PDF objects.  (See code)  PROBLEM/QUESTION: My call to lines[i].find
 does NOT find all instances of endobj. Any help available?  Any
 insights?
 
 #!/usr/bin/python
 
 inputfile =  file('sample.pdf','rb')# This is PDF with which
 we will work 
 lines = inputfile.readlines()   # read file
 one line at a time

That's incorrect. readlines() reads the entire file in one go, and splits 
it into individual lines.


 linestart = []  # Starting address for
 each line
 lineend = []# Ending
 address for each line
 linetype = []

*raises eyebrow*

How is an empty list a starting or ending address?

The only thing worse than no comments where you need them is misleading 
comments. A variable called linestart implies that it should be a 
position, e.g. linestart = 0. Or possibly a flag.


 print len(lines)# print number of lines
 
 i = 0   # define an iterator, i

Again, 0 is not an iterator. 0 is a number.


 addr = 0# and address pointer

 while i  len(lines):   # Go through each line
 linestart = linestart + [addr]
 length = len(lines[i])
 lineend = lineend + [addr + (length-1)] addr = addr + length
 i = i + 1

Complicated and confusing and not the way to do it in Python. Something 
like this is much simpler:


linetypes = []  # note plural
inputfile =  open('sample.pdf','rb')  # Don't use file, use open.

for line_number, line in enumerate(inputfile):
# Process one line at a time. No need for that nonsense with manually
# tracked line numbers, enumerate() does that for us.
# No need to initialise linetypes.
status = 'normal'
i = line.find(' obj')
if i = 0:
print Object found at offset %d in line %d % (i, line_number)
status = 'object'
i = line.find('endobj')
if i = 0:
print endobj found at offset %d in line %d % (i, line_number)
if status == 'normal': status = 'endobj'
else: status = 'object  endobj'  # both found on the one line
linetypes.append(status)
# What if obj or endobj exist more than once in a line?



One last thing... if PDF files are a binary format, what makes you think 
that they can be processed line-by-line? They may not have lines, except 
by accident.


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


Re: Error invalid syntax while statement

2011-01-07 Thread Garland Fulton
On Fri, Jan 7, 2011 at 8:28 PM, Ned Deily n...@acm.org wrote:

 In article
 aanlktik2eii-mwhg-eh_xe9kfhiylhyefzpvm7yzg...@mail.gmail.com,
  Garland Fulton stacks...@gmail.com wrote:
  I don't understand what I'm doing wrong i've tried several different
 cases
  for what i am doing here. Will someone please point my error out.

   15 print(counter: , counter

 Missing ) on line 15.

 --
  Ned Deily,
  n...@acm.org

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



  1 #!/bin/bash/python
  2 import math
  3 try:
  4 x = int(input(Enter your number: ))
  5 if 0   x  2147483647:
  6 raise Exception()
  7 else:
  8 end = 0
  9 count = 0
 10 count1 = x
 11 counter = 0
 12 print(end: , end)
 13 print(count: , count)
 14 print(count1: , count1)
 15 print(counter: , counter)
 16
 17   while end == 0:  #
---returns syntax error on this while statement
 18   if(count  x):
 19
 20   sol = math.pow(count, 2) + math.pow(count1, 2)
 21   count += 1
 22   count1 -= 1
 23   print(end: , end)
 24   print(count: , count)
 25   print(count1: , count1)
 26   print(counter: , counter)
 27   if sol == x:
 28   counter += x
 29   else:
 30   end = 1
 31 except Exception as ran:
 32print(Value not within range, ran)


  File blah.py, line 17
while (end == 0):  #
---returns syntax error on this while statement
^
IndentationError: unexpected indent

Thank you and I'm sorry for the very blind question, it was because of the
missing par-ends  I have spent a while on this won't happen again. What is
wrong with my shebang line?
Thank you for the syntax tips!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error invalid syntax while statement

2011-01-07 Thread Chris Rebert
On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton stacks...@gmail.com wrote:
snip
   1 #!/bin/bash/python
snip
 What is
 wrong with my shebang line?

Its path is invalid (unless you're using a *very* weird system).
/bin/bash is the bash shell executable; bash is completely unrelated
to Python. Further, /bin/bash is a file, not a directory.

The shebang for Python is normally one of the following:
#!/usr/bin/env python
#!/usr/bin/python

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Error invalid syntax while statement

2011-01-07 Thread Garland Fulton
On Fri, Jan 7, 2011 at 8:55 PM, Chris Rebert c...@rebertia.com wrote:

 On Fri, Jan 7, 2011 at 9:46 PM, Garland Fulton stacks...@gmail.com
 wrote:
 snip
1 #!/bin/bash/python
 snip
  What is
  wrong with my shebang line?

 Its path is invalid (unless you're using a *very* weird system).
 /bin/bash is the bash shell executable; bash is completely unrelated
 to Python. Further, /bin/bash is a file, not a directory.

 The shebang for Python is normally one of the following:
 #!/usr/bin/env python
 #!/usr/bin/python

 Cheers,
 Chris
 --
 http://blog.rebertia.com



Great I have learned a ton and these questions will not arise again.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: apscheduler error

2011-01-07 Thread Alice Bevan–McGregor

Howdy!

On 2011-01-07 17:08:28 -0800, linna li said:
I tried to use the apscheduler and used the sample code below from the 
tutorial, but got the error message: Exception in thread APScheduler 
(most likely raised during interpreter shutdown). What's going on here? 
I really appreciate any help!


After talking a bit with Alex Grönholm it seems this is an issue raised 
fairly often (not always in the context of this package) and is not 
really a problem with APScheduler.  It has far more to do with 
attempting to start a thread, then immediately exiting the main thread. 
That's not how threading is supposed to be used, so don't do it.  ;)


APScheduler 2.0 adds some improved examples, according to Alex, that 
don't suffer the problem demonstrated by the short code snippit you 
provided.


A package of mine, TurboMail, suffers from the same threading issue if 
used improperly; you enqueue e-mail, it starts a thread, then you 
immediately exit.  TM tries to work around the issue, but in most cases 
that workaround does not work properly.  (You get strange uncatchable 
exceptions printed on stderr though AFIK the e-mail does get sent 
correctly, your application may hang waiting for the thread pool to 
drain if you have a minimum thread count option set.)


I hope this clears things up a bit,

- Alice.


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


[issue10845] test_multiprocessing failure under Windows

2011-01-07 Thread Terry J. Reedy

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

On xp, changing from -m test to -m test.regrtest removed the extra craziness 
during and after the test run that I reported on pydev.

I think making at least a tempory fix to whatever -m test runs should be a 
release blocker so only individual tests and not the test process are broken. 
If necessary, just refuse to run under windows and say to use test.regrtest as 
before. (I believe I did use -m test.regrtest on 3.1 and 2.7 as -m test is not 
implemented for those.)

--
nosy: +terry.reedy

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-07 Thread Pierre Quentel

Pierre Quentel pierre.quen...@gmail.com added the comment:

Option 1 is impossible, because the CGI script sometimes has no control on the 
stream : for instance on a shared web host, it will receive sys.stdin as a text 
stream

I also vote for option 3 ; explaining that if no argument is passed, the 
program will use sys.stdin.buffer (or the result of sys.stdin.detach() : I 
guess it's the same ?), and that if an argument is passed, it must provide an 
attribute buffer (or a method detach() ?) as the binary layer of the stream

BTW, I didn't have time to finish the versions of cgi.py and tests, my next 
slot is this week-end

--

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



[issue9920] test_cmath on atan fails on AIX

2011-01-07 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
status: pending - closed

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



[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

2011-01-07 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

[Nick]
 @Mark: I don't think that follows. [...]
 If the exporter actually needs to release buffer specific 
 resources, then it should maintain an internal data structure keyed off 
 the Py_buffer address.

Ah, okay.  So that would make issue 9990 just a documentation problem, right?

--

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



[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

2011-01-07 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 an internal data structure keyed off 
 the Py_buffer address.

If we're using the Py_buffer address coming into getbuffer as a key, then we 
probably shouldn't be using a stack address, since it would be difficult to 
guarantee uniqueness that way.

--

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



[issue10512] regrtest ResourceWarning - unclosed sockets and files

2011-01-07 Thread STINNER Victor

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

Le vendredi 07 janvier 2011 à 02:19 +, Nadeem Vawda a écrit :
 Most of these leaks seem to stem from the fact that socket.SocketIO.close() 
 doesn't behave as documented. According to its docstring, it is meant to 
 decrement the underlying socket's refcount, and close it if the refcount 
 drops to zero. However, to do this job it calls socket._decref_socketios(), 
 which is defined as follows:
 
 def _decref_socketios(self):
 if self._io_refs  0:
 self._io_refs -= 1
 if self._closed:
 self.close()
 
 Clearly, this doesn't do what the docstring describes. Changing the second 
 conditional from if self._closed: to if self._io_refs = 0: disposes of 
 all but one of the ResourceWarnings, but also breaks 8 tests in test_socket. 
 It seems that the tests expect a socket to remain open after all referring 
 SocketIO objects have been closed, which contradicts the docstring for 
 SocketIO.close(). I suppose I should open a separate issue for this.

Can you please open a new issue for that?

Victor

--

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-07 Thread STINNER Victor

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

We may also accept TextIOWrapper (eg. sys.stdin) *and*
BufferedReader/FileIO (eg. sys.stdin.buffer). It is possible to test the
type of the stream. With a TextIOWrapper, the raw buffer can be read
using stream.buffer.

But for StringIO/BytesIO: only BytesIO should be accepted.

--

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



[issue10812] Add some posix functions

2011-01-07 Thread Ross Lagerwall

Ross Lagerwall rosslagerw...@gmail.com added the comment:

  it's a bit asymmetric that gethostname is in the socket
  module and supports Windows, and sethostname is in the POSIX
  module. It would be useful to have a gethostname in the POSIX
  module also which is a) POSIX only and b) supports embedded
  NUL bytes.

According to the spec for gethostname(), the hostname that it returns is 
null-terminated so it won't support embedded NUL bytes. Should we still add it 
anyway?

--

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



[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

2011-01-07 Thread Nick Coghlan

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

It only needs to be unique for the lifetime of the buffer reference - for a 
Py_buffer struct on the stack, by the time the relevant C stack frame goes 
away, ReleaseBuffer should already have been called.

--

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



[issue9990] PyMemoryView_FromObject alters the Py_buffer after calling PyObject_GetBuffer when ndim 1

2011-01-07 Thread Nick Coghlan

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

As per the discussion over in issue #10181, I've changed my position on this 
issue.

Since the PEP isn't explicit on the exact semantics here, I think we should be 
guided by the memoryview behaviour and make it official that bf_releasebuffer 
implementations shouldn't trust the contents of the passed in Py_buffer struct. 
Instead, if that information is important, the exporter should create an 
internal data structure that preserves the necessary detail and merely use the 
Py_buffer address as an identifier to locate the internal copy.

--

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



[issue4953] cgi module cannot handle POST with multipart/form-data in 3.0

2011-01-07 Thread Glenn Linderman

Glenn Linderman v+pyt...@g.nevcal.com added the comment:

Pierre said:
Option 1 is impossible, because the CGI script sometimes has no control on the 
stream : for instance on a shared web host, it will receive sys.stdin as a text 
stream

I say:
It is the user code of the CGI script that calls CGI.FieldStorage.  So the user 
could be required (option 1) to first tweak the stdin to be bytes, one way or 
another.  I don't understand any circumstance where a Python CGI script doesn't 
have control over the settings of the Python IO Stack that it is using to 
obtain the data... and the CGI spec is defined as a bytestream, so it must be 
able to read the bytes.

Victor said:
It is possible to test the type of the stream.

I say:
Yes, why just assume (as I have been) that the initial precondition is the 
defaults that Python imposes.  Other code could have interposed something else. 
 The user should be allowed to pass in anything that is a TextIOWrapper, or a 
BytesIO, and CGI should be able to deal with it.  If the user passes some other 
type, it should be assumed to produce bytes from its read() API, and if it 
doesn't the user gets what he deserves (an error).  Since the default Python 
sys.stdin is a TextIOWrapper, having CGI detect that, and extract its .buffer 
to use for obtaining bytes, should work fine.  If the user already tweaked 
sys.stdin to be a BytesIO (.buffer or detach()), CGI should detect and use 
that.  If the user substitutes a different class, it should be bytes, and that 
should be documented, the three cases that could work.

--

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



[issue9990] PyMemoryView_FromObject alters the Py_buffer after calling PyObject_GetBuffer when ndim 1

2011-01-07 Thread Nick Coghlan

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

The alternative (if we declare that clients should treat Py_buffer contents as 
completely read-only) is to update memoryview to include a separate orig_view 
field that would never be touched. The GetBuffer and ReleaseBuffer calls would 
then use orig_view, with dup_buffer used to copy the data into the main view 
field before modifying it.

However, this approach greatly complicates the bf_getbuffer and 
bf_releasebuffer implementations, since memoryview could no longer pass the 
supplied Py_buffer pointer straight through to the underlying implementation.

Instead, for each call to bf_getbuffer, it would need to create a new Py_buffer 
struct, use that for the GetBuffer call to the underlying object, copy the 
contents over to the passed in buffer (modifying the shape information as 
appropriate for any slicing that is in effect), then, in bf_releasebuffer, use 
the passed in pointer to find the right Py_buffer struct to use in the 
ReleaseBuffer call.

Putting the onus on exporters to be suspicious of the contents of the Py_buffer 
objects handed to bf_releasebuffer implementations actually seems like the more 
robust approach in the long run.

--

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



[issue10813] Suppress adding decimal point for places=0 in moneyfmt()

2011-01-07 Thread Raymond Hettinger

Changes by Raymond Hettinger rhettin...@users.sourceforge.net:


--
priority: normal - low

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



[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

2011-01-07 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 by the time the relevant C stack frame goes away, ReleaseBuffer should 
 already have been called.

Hmm. I'm not sure I understand how/when that would happen.  Looking at the 
current py3k code, in Objects/memoryobject.c at line 92, we have:

PyObject *
PyMemoryView_FromObject(PyObject *base)
{
PyMemoryViewObject *mview;
Py_buffer view;

if (!PyObject_CheckBuffer(base)) {
PyErr_SetString(PyExc_TypeError,
cannot make memory view because object does 
not have the buffer interface);
return NULL;
}

if (PyObject_GetBuffer(base, view, PyBUF_FULL_RO)  0)
return NULL;

mview = (PyMemoryViewObject *)PyMemoryView_FromBuffer(view);
if (mview == NULL) {
PyBuffer_Release(view);
return NULL;
}

return (PyObject *)mview;
}

So here 'view' is being allocated on the stack, and its address passed to 
PyObject_GetBuffer;  PyBuffer_Release isn't called (except when an error 
happens) before the function exits and the stack frame becomes invalid.

Sorry for the odd questions;  it's clear to me that I'm misunderstanding 
something fundamental, but I'm struggling to figure out what.

--

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



[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

2011-01-07 Thread Nick Coghlan

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

Ah, sorry - no, I misunderstood the question. I think that example actually 
*is* a bug in the memoryview implementation. The GetBuffer call should use the 
persistent address (mview-view) that will be used in the ReleaseBuffer call, 
as per Antoine's patch on issue 9990.

--

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



[issue10686] email.Generator should use unknown-8bit encoded words for headers with 8 bit data

2011-01-07 Thread R. David Murray

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

Well, unknown-8bit is registered as a charset with IANA.  It is registered 
specifically for use in message bodies, but as a registered charset it should 
be acceptable in headers as well.  There is no similar registration for just 
'unknown', but it sounds like mailers may be more likely to accept it if it 
exists in the wild.

I'm hoping to fix this before the RC (which is tomorrow, which means fixing it 
today), so your suggestion of making the 'unknown charset' token configurable 
is a good one.  I'm not so worried about providing a way to reject such 
headers, since this incarnation of email makes a point of not throwing errors 
on parsing, and if you read binary messages with unknown bytes the best thing 
to do is generate the outgoing message with BytesGenerator, in which case you 
get the unknown bytes back without the rfc2047 munging.

--

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



[issue2973] _ssl compiler warnings

2011-01-07 Thread Antoine Pitrou

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

Well, it merely means that OpenSSL has changed the const-ness of some of their 
APIs over time. As I said I see no warnings with the most recent OpenSSL 
versions. Buildbots will tell you the same story: for example, no warnings 
under OS X Snow Leopard, some under OS X Leopard (which is older).

--

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



[issue10851] further extend ssl SNI and ciphers API

2011-01-07 Thread Antoine Pitrou

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

 as a further extension to issue #5639 (sni) and issue #8322 this patch
 provides the ability to set ciphers in the  SSLContext.wrap_socket and
 server_hostname in ssl.wrap_socket. This just makes all the ssl apis
 look the same. Restructured the documentation associated with these
 functions to all be around the wrap_socket method.

Ah! I actually don't want these APIs to look the same. In the long term,
I would like SSLContext to become the preferred API, with
ssl.wrap_socket only being supported for backwards compatibility.
The huge parameter list in ssl.wrap_socket() is really a mistake due to
it having evolved quite organically.

--

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



[issue8109] Server-side support for TLS Server Name Indication extension

2011-01-07 Thread Antoine Pitrou

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

 Server side SNI is still missing.

Right, re-opening.

--
resolution: duplicate - 
stage:  - needs patch
status: closed - open
superseder: Support TLS SNI extension in ssl module - 
title: Support for TLS Server Name Indication extension - Server-side support 
for TLS Server Name Indication extension
versions: +Python 3.3 -Python 2.7, Python 3.2

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



[issue10853] SSL/TLS sni use in smtp, pop, imap, nntp, ftp client libs by default

2011-01-07 Thread Antoine Pitrou

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

Duplicate posting of #10852.

--
resolution:  - duplicate
status: open - closed
superseder:  - SSL/TLS sni use in smtp,pop,imap,nntp,ftp client libs by default

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



[issue10852] SSL/TLS sni use in smtp, pop, imap, nntp, ftp client libs by default

2011-01-07 Thread Antoine Pitrou

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

Oops, I hadn't noticed you had closed it.

--
nosy: +pitrou
resolution: duplicate - 
status: closed - open

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



[issue1641] asyncore delayed calls feature

2011-01-07 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson

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



[issue8684] improvements to sched.py

2011-01-07 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
nosy: +mark.dickinson

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



[issue10686] email.Generator should use unknown-8bit encoded words for headers with 8 bit data

2011-01-07 Thread Barry A. Warsaw

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

I'm a little uncomfortable with relying on a non-standards track RFC for this 
interpretation, and I'm also not sure I'd say that the email package is a 
transport agent, but in cases where it's acting on the user's behalf (i.e. 
headers created programmatically rather than parsed), I can get on board with 
that.  Your interpretation and approach to the fix seems reasonable, and I 
don't have any better ideas.

--

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



[issue10854] Output DLL name in error message of ImportError when DLL is missing

2011-01-07 Thread anatoly techtonik

New submission from anatoly techtonik techto...@gmail.com:

When an extension could not be loaded, because it requires some DLL that is 
missing, Python shows the following error message:

  ImportError: DLL load failed: The specified module could not be found.

It will help tremendously in debugging extension problems if the missing DLL 
name is specified in error message.

--
components: Extension Modules
messages: 125649
nosy: techtonik
priority: normal
severity: normal
status: open
title: Output DLL name in error message of ImportError when DLL is missing
type: resource usage
versions: Python 2.7

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



[issue10854] Output DLL name in error message of ImportError when DLL is missing

2011-01-07 Thread Brian Curtin

Changes by Brian Curtin cur...@acm.org:


--
type: resource usage - feature request
versions: +Python 3.3 -Python 2.7

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



[issue10849] Backport test/__main__

2011-01-07 Thread Benjamin Peterson

Benjamin Peterson benja...@python.org added the comment:

+0.

--

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



[issue10854] Output DLL name in error message of ImportError when DLL is missing

2011-01-07 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

Is it even possible? Each time I tried, the only solutions involved an external 
program like Dependency Walker.

--
nosy: +amaury.forgeotdarc

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



[issue10854] Output DLL name in error message of ImportError when DLL is missing

2011-01-07 Thread Brian Curtin

Brian Curtin cur...@acm.org added the comment:

I'm pretty sure we can't do this, if I understand your request.

Say you have techtonik.pyd as your extension and it depends on foobar.dll. If 
we try to load techtonik.pyd and this pyd can't find or successfully load 
foobar.dll, Python doesn't know about *this* DLL. It just knows that it can't 
load techtonik.pyd, so that's what we'd be able to output, which isn't that 
helpful.

--
nosy: +brian.curtin

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



[issue10854] Output DLL name in error message of ImportError when DLL is missing

2011-01-07 Thread Brian Curtin

Brian Curtin cur...@acm.org added the comment:

Agree with Amaury. depends has always been my solution to this type of problem.

--

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



[issue10855] wave.Wave_read.close() doesn't release file

2011-01-07 Thread Peter Creath

New submission from Peter Creath pjcreath+pyt...@gmail.com:

Calling wave.close() fails to release all references to the file passed in via 
wave.open(filename_or_obj, rb).  As a result, processing many wave files 
produces an IOError of too many files open.

This bug is often masked because this dangling reference is collected if the 
wave object is collected.  However, if the wave object is retained, calling 
wave_obj.close() won't release the reference, and so the file will never be 
closed.

There are two solutions:

1) The workaround: the client program can explicitly close the file object it 
passed to the wave object (file_obj.close()).

2) The bug fix: the wave module can properly release the extra reference to the 
file, by setting self._data_chunk = None in the close() method.  Explanation:

Trunk code (and 2.7.1, and older):

def close(self):
if self._i_opened_the_file:
self._i_opened_the_file.close()
self._i_opened_the_file = None
self._file = None

but note initfp(self, file):
...
self._file = Chunk(file, bigendian = 0)
...
chunk = Chunk(self._file, bigendian = 0)
...
self._data_chunk = chunk
...

therefore close needs to add:

self._data_chunk = None

--
components: Library (Lib)
messages: 125654
nosy: pjcreath
priority: normal
severity: normal
status: open
title: wave.Wave_read.close() doesn't release file
type: resource usage
versions: Python 2.7

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



[issue10856] documentation for ImportError parameters and attributes

2011-01-07 Thread anatoly techtonik

New submission from anatoly techtonik techto...@gmail.com:

Need documentation for ImportError parameters and exception instance attributes.

--
assignee: d...@python
components: Documentation
messages: 125655
nosy: d...@python, techtonik
priority: normal
severity: normal
status: open
title: documentation for ImportError parameters and attributes
type: feature request
versions: Python 2.7, Python 3.3

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



[issue10857] ImportError module attribute

2011-01-07 Thread anatoly techtonik

New submission from anatoly techtonik techto...@gmail.com:

Need ImportError.module attribute to get the name of failed import. Right now 
it requires parsing ImportError.args that is presented in form ('No module 
named zqwer',) that is not pythonic.

--
messages: 125656
nosy: techtonik
priority: normal
severity: normal
status: open
title: ImportError module attribute
type: feature request

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



[issue10686] email.Generator should use unknown-8bit encoded words for headers with 8 bit data

2011-01-07 Thread R. David Murray

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

Well, since unknown-8bit is a registered charset, it should be RFC-valid in an 
encoded word.  Whether or not any other mailer out there is going to be able to 
handle it is a different question.

--

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



[issue10857] ImportError module attribute

2011-01-07 Thread Brian Curtin

Brian Curtin cur...@acm.org added the comment:

Duplicate of #1559549

--
nosy: +brian.curtin
resolution:  - duplicate
stage:  - committed/rejected
status: open - closed
superseder:  - ImportError needs attributes for module and file name

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



[issue10857] ImportError module attribute

2011-01-07 Thread anatoly techtonik

anatoly techtonik techto...@gmail.com added the comment:

Thanks for the pointer. I couldn't find it myself.

--

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



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread anatoly techtonik

anatoly techtonik techto...@gmail.com added the comment:

I think we should investigate deeper why this enhancement request didn't get 
into Python 3.

Another user story is: from xxx import yyy, if yyy not found, the args 
message is ('cannot import name yyy',)

Python4?

label:api

--
nosy: +techtonik

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



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread Brian Curtin

Changes by Brian Curtin cur...@acm.org:


--
versions: +Python 3.3 -Python 3.2

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



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread R. David Murray

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

There's no need for any deeper investigation.  The answer is nobody wrote the 
patch.  If someone writes a good patch, it will go in.

--
nosy: +r.david.murray

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



[issue1559549] ImportError needs attributes for module and file name

2011-01-07 Thread Alexander Belopolsky

Alexander Belopolsky belopol...@users.sourceforge.net added the comment:

 I think we should investigate deeper why this enhancement
 request didn't get into Python 3.

There is nothing to investigate here.  This is a request for a marginal 
improvement and OP did not follow up even though a core developer responded on 
the next day after his post.

The only lesson to be learned from this is that Python improvements should be 
discussed on the tracker or appropriate python mailing lists and not on private 
blogs.

--
nosy: +belopolsky

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



[issue10854] Output DLL name in error message of ImportError when DLL is missing

2011-01-07 Thread anatoly techtonik

anatoly techtonik techto...@gmail.com added the comment:

Can you cross reference the part of code where this error is catched?

Why Python can't get information about the reason .DLL is not loaded?

Is it at least possible to add a hook point at the exact time the import fails 
to insert component that is able to inquiry system about this information (like 
depends)?

--

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



[issue10856] documentation for ImportError parameters and attributes

2011-01-07 Thread Georg Brandl

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

What is there to document?  ImportError has no special attributes or parameters.

--
nosy: +georg.brandl
resolution:  - works for me
status: open - closed

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



[issue10854] Output DLL name in error message of ImportError when DLL is missing

2011-01-07 Thread Brian Curtin

Brian Curtin cur...@acm.org added the comment:

See _PyImport_GetDynLoadFunc in Python/dynload_win.c -- that's where this is 
happening.


 Why Python can't get information about the reason .DLL is not loaded?

Windows does not provide it in the case you are speaking of. If I call 
LoadLibraryEx for techtonik.pyd, either it succeeds because everything is 
there, or it fails because something is not there. We get no information about 
dependency hierarchies failing to load.

--

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



[issue10849] Backport test/__main__

2011-01-07 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

2.6 is right out.

Martin, would you please decide on whether this should be backported to 2.7 and 
3.1?   IMO, the rationale is flimsy (its not hard to run the test suite in 
*any* version) and it goes against our usual policy; however, it is also a 
trivial and isolated patch, making it somewhat harmless.

Also note that 3.1 is very soon to be closed for anything but security fixes.  
Only 2.7 will in long-term maintenance.

--
assignee: benjamin.peterson - loewis
nosy: +loewis
versions:  -Python 2.6

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



[issue10849] Backport test/__main__

2011-01-07 Thread Georg Brandl

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

I thought Benjamin was still RM for 2.7 and 3.1?

--
assignee: loewis - benjamin.peterson
nosy: +georg.brandl

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



[issue10854] Output DLL name in error message of ImportError when DLL is missing

2011-01-07 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

The code is in Python/dynload_win.c

To load an extension module mymodule.pyd, Python calls 
LoadLibrary('/path/to/mymodule.pyd'); when it returns NULL, the code calls 
GetLastError() (which returns 126 in this case) then FormatMessage to get an 
error message.

To get the full path to the .pyd, you can use imp.find_module(), but there is 
nothing else we can do I fear.

--

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



[issue10858] Make source code links less proeminent

2011-01-07 Thread Antoine Pitrou

New submission from Antoine Pitrou pit...@free.fr:

Reading library source code will only be enlightening to expert users, since 
most modules are not academic but real-world implementations, with all the 
complications it entails. Therefore, putting a link at the top of module 
sections is only confusing for most people. I would like to shift these links 
to the bottom of doc pages, where we already have see also links to RFCs and 
the like.

--
assignee: d...@python
components: Documentation
messages: 125669
nosy: d...@python, pitrou, rhettinger
priority: normal
severity: normal
status: open
title: Make source code links less proeminent
versions: Python 2.7, Python 3.2

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



[issue10852] SSL/TLS sni use in smtp, pop, imap, nntp, ftp client libs by default

2011-01-07 Thread Antoine Pitrou

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

I understand this patch relies on #10851. As I said there, I would rather have 
SSLContext become the primary API, and the stdlib standardize on it. Part of 
the stdlib, as you have witnessed, already allows the user to pass a custom 
SSLContext, which is very simple way of allowing for custom user settings. 
There are two open issues for imaplib (#8808) and smtplib (#8809).

--

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



[issue8808] imaplib should support SSL contexts

2011-01-07 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
stage:  - needs patch
versions: +Python 3.3 -Python 3.2

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



[issue8809] smptlib should support SSL contexts

2011-01-07 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
stage:  - needs patch
versions: +Python 3.3 -Python 3.2

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



[issue10856] documentation for ImportError parameters and attributes

2011-01-07 Thread anatoly techtonik

anatoly techtonik techto...@gmail.com added the comment:

ImportError has args and message attributes containing failed module name.

--
status: closed - open

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



[issue10856] documentation for ImportError parameters and attributes

2011-01-07 Thread R. David Murray

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

No it doesn't.  It has an arbitrary message string.  That's the same as all 
other exceptions that don't have special attributes.

--
nosy: +r.david.murray
status: open - closed

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



[issue10808] ssl unwrap fails with Error 0

2011-01-07 Thread Antoine Pitrou

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

As we discussed on IRC, there are two things here:

- unwrap() can give an error because it tries to shutdown the SSL layer 
cleanly, and the other side doesn't support it or is already closed; unwrap() 
is useful mostly if you plan to use the clear-text layer afterwards, otherwise 
you can just call shutdown(socket.SHUT_RDWR) and then close()

- the error message and errnos are totally bogus, but I'm afraid that's because 
of OpenSSL giving us this information.

--
resolution:  - wont fix
status: open - closed
versions: +Python 3.2 -Python 2.6

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



[issue9090] Error code 10035 calling socket.recv() on a socket with a timeout (WSAEWOULDBLOCK - A non-blocking socket operation could not be completed immediately)

2011-01-07 Thread Antoine Pitrou

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

I will not bother backporting myself but an other core developer can do it if 
(s)he desires.

--

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



  1   2   >