Wing IDE 4.1.1 released

2011-11-16 Thread Wingware

Hi,

Wingware has released version 4.1.1 of Wing IDE, an integrated development
environment designed specifically for the Python programming language.

Wing IDE is a cross-platform Python IDE that provides a professional code
editor with vi, emacs, and other key bindings, auto-completion, call tips,
refactoring, context-aware auto-editing, a powerful graphical debugger,
version control, unit testing, search, and many other features.

**Changes in Version 4.1.1**

Highlights of this release include:

* Goto-definition on symbols in the shells
* Expanded and improved auto-editing support (enable this in the Edit 
  Keyboard Personality menu):
  * Auto-closing
  * Auto-enter invocation args
  * Apply quote/comment/paren/etc to selection
  * Auto-enter spaces
  * Insert EOL and indent for new block
  * Continue comment on new line
* Auto-indent when pasting multi-line text in Python code (undo once 
restores

  original indentation)
* Improved Smart Tab key option for Python
* Indent to Match menu and tool bar items toggle indentation to one indent
  position lower if already at matching indent level
* Improved auto-indent of else, elif, except, and finally
* Experimental Turbo auto-completer mode for Python that treats any non-word
  key as a completion key and Ctrl, Alt, and Command as a cancel keys
* Link to docs.python.org in Source Assistant
* Include argument names in auto-completer during invocation
* About 30 other bug fixes and minor improvements

Complete change log:  http://wingware.com/pub/wingide/4.1.1/CHANGELOG.txt

**New Features in Version 4**

Version 4 adds the following new major features:

* Refactoring -- Rename/move symbols, extract to function/method, and 
introduce variable

* Find Uses -- Find all points of use of a symbol
* Auto-Editing -- Reduce typing burden by auto-entering expected code
* Diff/Merge -- Graphical file and repository comparison and merge
* Django Support -- Debug Django templates, run Django unit tests, and more
* matplotlib Support -- Maintains live-updating plots in shell and debugger
* Simplified Licensing -- Includes all OSes and adds Support+Upgrades 
subscriptions


Details on licensing changes:  http://wingware.com/news/2011-02-16

**About Wing IDE**

Wing IDE is an integrated development environment designed specifically for
the Python programming language.  It provides powerful editing, testing, and
debugging features that help reduce development and debugging time, cut down
on coding errors, and make it easier to understand and navigate Python code.
Wing IDE can be used to develop Python code for web, GUI, and embedded
scripting applications.

Wing IDE is available in three product levels:  Wing IDE Professional is
the full-featured Python IDE, Wing IDE Personal offers a reduced feature
set at a low price, and Wing IDE 101 is a free simplified version designed
for teaching beginning programming courses with Python.

Version 4.0 of Wing IDE Professional includes the following major features:

* Professional quality code editor with vi, emacs, and other keyboard
  personalities
* Code intelligence for Python:  Auto-completion, call tips, find uses,
  goto-definition, error indicators, refactoring, context-aware 
auto-editing,

  smart indent and rewrapping, and source navigation
* Advanced multi-threaded debugger with graphical UI, command line 
interaction,

  conditional breakpoints, data value tooltips over code, watch tool, and
  externally launched and remote debugging
* Powerful search and replace options including keyboard driven and 
graphical

  UIs, multi-file, wild card, and regular expression search and replace
* Version control integration for Subversion, CVS, Bazaar, git, 
Mercurial, and

  Perforce
* Integrated unit testing with unittest, nose, and doctest frameworks
* Django support:  Debugs Django templates, provides project setup tools,
  and runs Django unit tests
* Many other features including project manager, bookmarks, code snippets,
  diff/merge tool, OS command integration, indentation manager, PyLint
  integration, and perspectives
* Extremely configurable and may be extended with Python scripts
* Extensive product documentation and How-Tos for Django, matplotlib,
  Plone, wxPython, PyQt, mod_wsgi, Autodesk Maya, and many other frameworks

Please refer to http://wingware.com/wingide/features for a detailed listing
of features by product level.

System requirements are Windows 2000 or later, OS X 10.3.9 or later 
(requires
X11 Server), or a recent Linux system (either 32 or 64 bit).  Wing IDE 
supports

Python versions 2.0.x through 3.2.x and Stackless Python.

For more information, see the http://wingware.com/

**Downloads**

Wing IDE Professional and Wing IDE Personal are commercial software and
require a license to run. A free trial can be obtained directly from the
product when launched.

Wing IDE Pro -- Full-featured product:
http://wingware.com/downloads/wingide/4.1

Wing IDE Personal -- A simplified IDE:

ANN: Spyder v2.1.2

2011-11-16 Thread Pierre Raybaut
Hi all,

On the behalf of Spyder's development team
(http://code.google.com/p/spyderlib/people/list), I'm pleased to
announce that Spyder v2.1.2 has been released and is available for
Windows XP/Vista/7, GNU/Linux and MacOS X:
http://code.google.com/p/spyderlib/

As this is mostly a maintenance release, a lot of bugs were fixed and
some minor features were added:
http://code.google.com/p/spyderlib/wiki/ChangeLog

Spyder is a free, open-source (MIT license) interactive development
environment for the Python language with advanced editing, interactive
testing, debugging and introspection features. Originally designed to
provide MATLAB-like features (integrated help, interactive console,
variable explorer with GUI-based editors for dictionaries, NumPy
arrays, ...), it is strongly oriented towards scientific computing and
software development.
Thanks to the `spyderlib` library, Spyder also provides powerful
ready-to-use widgets: embedded Python console (example:
http://packages.python.org/guiqwt/_images/sift3.png), NumPy array
editor (example: http://packages.python.org/guiqwt/_images/sift2.png),
dictionary editor, source code editor, etc.

Description of key features with tasty screenshots can be found at:
http://code.google.com/p/spyderlib/wiki/Features

On Windows platforms, Spyder is also available as a stand-alone
executable (don't forget to disable UAC on Vista/7). This all-in-one
portable version is still experimental (for example, it does not embed
sphinx -- meaning no rich text mode for the object inspector) but it
should provide a working version of Spyder for Windows platforms
without having to install anything else (except Python 2.x itself, of
course).

Don't forget to follow Spyder updates/news:
  * on the project website: http://code.google.com/p/spyderlib/
  * and on our official blog: http://spyder-ide.blogspot.com/

Last, but not least, we welcome any contribution that helps making
Spyder an efficient scientific development/computing environment. Join
us to help creating your favourite environment!
(http://code.google.com/p/spyderlib/wiki/NoteForContributors)

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

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


Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread Tim Golden

On 16/11/2011 03:38, goldtech wrote:

Hi,

Using Windows. Is there a python shell that has a history of typed in
commands?


Have a look at DreamPie:

http://dreampie.sourceforge.net/

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


unit-profiling, similar to unit-testing

2011-11-16 Thread Ulrich Eckhardt

Hi!

I'm currently trying to establish a few tests here that evaluate certain 
performance characteristics of our systems. As part of this, I found 
that these tests are rather similar to unit-tests, only that they are 
much more fuzzy and obviously dependent on the systems involved, CPU 
load, network load, day of the week (Tuesday is virus scan day) etc.


What I'd just like to ask is how you do such things. Are there tools 
available that help? I was considering using the unit testing framework, 
but the problem with that is that the results are too hard to interpret 
programmatically and too easy to misinterpret manually. Any suggestions?


Cheers!

Uli

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


Re: (don't bash me too hard) Python interpreter in JavaScript

2011-11-16 Thread Amirouche Boubekki
Héllo

I am looking for a way how to bring Python interpreter to JavaScript, in
 order to provide a web-based application with python scripting
 capabilities. The app would have basic IDE for writing and debugging the
 python code, but the interpretation, of course, would be done in
 JavaScript. I'd like to avoid any client-server transactions, so all the
 interpretation should take place on the client side. The purpose of all
 this would be to create educational platform for learning the programming
 in python.


You might be looking for http://www.skulpt.org/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: suppressing import errors

2011-11-16 Thread Andreea Babiuc
Loving the offtopic guys, sorry I have to go back to my problem now..

In the module I want to import I have a few import statements for Maya
commands that don't work outside Maya unless I use the Maya standalone
interpreter.
So before I import this module I need to make sure I import maya and
maya.standalone.
I make sure I place the correct paths in sys.path, but I get the following
error:
import maya.standalone
ImportError:
/apps/Linux64/aw/maya2012/lib/python2.6/site-packages/maya/../../../../lib/libOGSDeviceOGL-2_7.so:
undefined symbol: cgGetParameterBufferIndex
Now, I've googled this error and couldn't find anything on it and I'd have
no idea why it wouldn't work. It's not a python related error so I
understand if you couldn't help me with this, but since you've asked :D

I am thinking of using eval for each line in the module i want to import
(instead of importing it )  and just ignoring the maya related commands.
I can't and shouldn't edit any of these modules, I instead have to parse
them and interpret the parameters types without actually executing the
functions..

Thanks a lot,
Andreea





On 15 November 2011 18:58, Jean-Michel Pichavant jeanmic...@sequans.comwrote:

 David Riley wrote:

 On Nov 15, 2011, at 12:35 PM, Andreea Babiuc wrote:



 On 15 November 2011 17:24, Chris Kaynor ckay...@zindagigames.com
 wrote:
 As with any Python code, you can wrap the import into a try: except
 block.

 try:
  import badModule
 except:

  pass # Or otherwise handle the exception - possibly importing an
 alternative module.


 Hmm, I know this might sound silly, but if it fails I still want to
 import the module and disable those lines of code that are related to the
 reason while the module failed to be imported in the first place.  Even if
 that makes the code not 100% correct.

 Does that make sense ?



 It makes sense.  It probably also makes sense to only do an except
 ImportError, since if there are other errors (say, syntax errors in a
 module you're trying to import, rather than its absence, you probably want
 to know about it.

 To disable code that won't work without the module you're trying to
 import, you can always set flags in your module.  For example, I've got a
 project at work that can use a variety of communications interfaces,
 including using PySerial for serial port comms.  But if someone doesn't
 have PySerial installed, I want it to fail gracefully and just not support
 serial.  So I can do the following:


 try:
   import serial
   _serial_enabled = True
 except ImportError:
   print(PySerial not installed - serial ports not supported!)
   _serial_enabled = False


 And then elsewhere in my module, I can check the value of _serial_enabled
 to see if I should e.g. list the serial ports in available communications
 interfaces.

 Of course, if there's some other error in PySerial (maybe I installed a
 broken version with a syntax error?), that error will get propagated up,
 which is a good thing, because I'd rather know that PySerial is broken than
 just have it tell me it's not installed (which is what would happen if I
 simply caught all exceptions).  Your mileage may vary.

 - Dave



 If I'm not wrong the OP wants to disable the line *in the module being
 imported*, which is kindof silly and doesn't make sense to answer his
 question.

 Anreea, tell us why the module you are importing is failing and if this
 module is yours, we may provide you a proper way to handle this situation
 (though I'm pretty sure everything is in Dave's proposal).

 JM
 PS : @Dave there is a way to avoiding adding symbols to your global
 namespace, assign None to the module's name on import errors. Then before
 using it, just test the module bool value : if serial:
 serial.whateverMethod()




-- 
Blog: Http://andreeababiuc.ro
Photo Portfolio: http://royaa.daportfolio.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Got some problems when using logging Filter

2011-11-16 Thread Jean-Michel Pichavant

sword wrote:

The logging cookbook gives an Filter example, explainning how to add
contextural info to log. I can't figure out how to filter log from it.

Suppose I have 3 file, a.py, b.py and main.py
#file: a.py
import logging

logger=logging.getLogger(__name__)
def print_log():
logger.debug(I'm module a)

#file: b.py just like a.py
import logging
logger=logging.getLogger(__name__)
def print_log():
logger.debug(I'm module b)

#file: main.py
import logging
from logging import Filter
logging.basicConfig(level=logging.DEBUG)
logger=logging.getLogger(main)
logger.debug(This is main process)
logger.addFilter(Filter(a))

And I expected that the console output would contain main and b module
log only. But it turned out that all logs there.  Is it the problem of
root logger?


  

Hi,

First of all, in the code you provided we can't see where you import a  
b, and when you call their respective print_log method.
Secondly,Filter(a) would allow only the a log events, not forbid 
them. quoting the docs: if name is specified, it names a logger which, 
together with its children, will have its events allowed through the 
filter.


As for your problem it may come from the fact that you applied the 
filter to the 'main' logger, while you probably want to add the filter 
to the *root* logger. Your current hierarchy is


root
 - main
 - a
 - b

events fired from 'a' will be handled by the root logger, not the main.
root = logging.getLogger()
root.addFilter('main')
root.addFilter('a')
root.addFilter('b')

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


Re: Got some problems when using logging Filter

2011-11-16 Thread sword
On Nov 16, 7:40 pm, Jean-Michel Pichavant jeanmic...@sequans.com
wrote:
 sword wrote:
  The logging cookbook gives an Filter example, explainning how to add
  contextural info to log. I can't figure out how to filter log from it.

  Suppose I have 3 file, a.py, b.py and main.py
  #file: a.py
  import logging

  logger=logging.getLogger(__name__)
  def print_log():
      logger.debug(I'm module a)

  #file: b.py just like a.py
  import logging
  logger=logging.getLogger(__name__)
  def print_log():
      logger.debug(I'm module b)

  #file: main.py
  import logging
  from logging import Filter
  logging.basicConfig(level=logging.DEBUG)
  logger=logging.getLogger(main)
  logger.debug(This is main process)
  logger.addFilter(Filter(a))

  And I expected that the console output would contain main and b module
  log only. But it turned out that all logs there.  Is it the problem of
  root logger?

 Hi,

 First of all, in the code you provided we can't see where you import a 
 b, and when you call their respective print_log method.
 Secondly,Filter(a) would allow only the a log events, not forbid
 them. quoting the docs: if name is specified, it names a logger which,
 together with its children, will have its events allowed through the
 filter.

 As for your problem it may come from the fact that you applied the
 filter to the 'main' logger, while you probably want to add the filter
 to the *root* logger. Your current hierarchy is

 root
   - main
   - a
   - b

 events fired from 'a' will be handled by the root logger, not the main.
 root = logging.getLogger()
 root.addFilter('main')
 root.addFilter('a')
 root.addFilter('b')

 JM

Thanks for your reply. I tried to edit the source a bit, now the
main.py looks like this:
#main.py
import logging
from logging import Filter
import a
import b

logging.basicConfig(level=logging.DEBUG)
root = logging.getLogger()
root.addFilter(Filter(GoneWithTheWind)) #so I suppose no log msg
would pass this filter

logger = logging.getLogger(main)
logger.debug(main process)
a.print_log()
b.print_log()


And It still prints out all the log msg. :(
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: redis beginner question

2011-11-16 Thread Jabba Laci
 Why do you want to stop redis after your program terminates?  Generally,
 you just start redis up when the system boots and leave it running.

Hi,

OK, so it's more like MySQL or PostgeSQL, i.e. leave the server
running in the background. I wanted to use it like SQLite, i.e. let it
run only when I need it.

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


Multiple threads

2011-11-16 Thread Eduardo Oliva
Hello, I have a py script that reads for all m2ts video files and convert 
them to mpeg using ffmpeg with command line.

What I want to do is:

  I need my script to run 2 separated threads, and then when the first has 
finished, starts the next onebut no more than 2 threads.
  I know that Semaphores would help with that.
  But the problem here is to know when the thread has finished its job, to 
release the semaphore and start another thread.

Any help would be great.

Thank you in advance
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple threads

2011-11-16 Thread Chris Angelico
On Thu, Nov 17, 2011 at 12:48 AM, Eduardo Oliva dut...@gmail.com wrote:
 Hello, I have a py script that reads for all m2ts video files and convert 
 them to mpeg using ffmpeg with command line.

 What I want to do is:

  I need my script to run 2 separated threads, and then when the first has 
 finished, starts the next onebut no more than 2 threads.
  I know that Semaphores would help with that.
  But the problem here is to know when the thread has finished its job, to 
 release the semaphore and start another thread.

First off, it's better in CPython (the most popular Python) to use
multiple processes than multiple threads. That aside, what you're
looking at is a pretty common model - a large number of tasks being
served by a pool of workers.

Have a look at the multiprocessing module, specifically Pool:
Version 2: http://docs.python.org/library/multiprocessing.html
Version 3: http://docs.python.org/py3k/library/multiprocessing.html

Should be fairly straightforward.

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


Re: Multiple threads

2011-11-16 Thread Henrik Faber
On 16.11.2011 14:48, Eduardo Oliva wrote:

   I need my script to run 2 separated threads, and then when the first has 
 finished, starts the next onebut no more than 2 threads.
   I know that Semaphores would help with that.
   But the problem here is to know when the thread has finished its job, to 
 release the semaphore and start another thread.

Absolute standard request, has nothing to do with Python. The way to go
(in Cish pseudocode) is:

thread() {
/* do work */
[...]

/* finished! */
semaphore++;
}

semaphore = 2
while (jobs) {
semaphore--;// will block if pool exhausted
thread();
}

// in the end, collect remaining two workers
semaphore -= 2  // will block until all are finished


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


Re: unit-profiling, similar to unit-testing

2011-11-16 Thread Roy Smith
In article 95bcp8-bft@satorlaser.homedns.org,
 Ulrich Eckhardt ulrich.eckha...@dominolaser.com wrote:

 Hi!
 
 I'm currently trying to establish a few tests here that evaluate certain 
 performance characteristics of our systems. As part of this, I found 
 that these tests are rather similar to unit-tests, only that they are 
 much more fuzzy and obviously dependent on the systems involved, CPU 
 load, network load, day of the week (Tuesday is virus scan day) etc.
 
 What I'd just like to ask is how you do such things. Are there tools 
 available that help? I was considering using the unit testing framework, 
 but the problem with that is that the results are too hard to interpret 
 programmatically and too easy to misinterpret manually. Any suggestions?

It's really, really, really hard to either control for, or accurately 
measure, things like CPU or network load.  There's so much stuff you 
can't even begin to see.  The state of your main memory cache.  Disk 
fragmentation.  What I/O is happening directly out of kernel buffers vs 
having to do a physical disk read.  How slow your DNS server is today.

What I suggest is instrumenting your unit test suite to record not just 
the pas/fail status of every test, but also the test duration.  Stick 
these into a database as the tests run.  Over time, you will accumulate 
a whole lot of performance data, which you can then start to mine.

While you're running the tests, gather as much system performance data 
as you can (output of top, vmstat, etc) and stick that into your 
database too.  You never know when you'll want to refer to the data, so 
just collect it all and save it forever.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: redis beginner question

2011-11-16 Thread Roy Smith
In article mailman.2766.1321449007.27778.python-l...@python.org,
 Jabba Laci jabba.l...@gmail.com wrote:

  Why do you want to stop redis after your program terminates?  Generally,
  you just start redis up when the system boots and leave it running.
 
 Hi,
 
 OK, so it's more like MySQL or PostgeSQL, i.e. leave the server
 running in the background.

That's how I would treat it.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Got some problems when using logging Filter

2011-11-16 Thread Peter Otten
sword wrote:

 Thanks for your reply. I tried to edit the source a bit, now the
 main.py looks like this:
 #main.py
 import logging
 from logging import Filter
 import a
 import b
 
 logging.basicConfig(level=logging.DEBUG)
 root = logging.getLogger()
 root.addFilter(Filter(GoneWithTheWind)) #so I suppose no log msg
 would pass this filter
 
 logger = logging.getLogger(main)
 logger.debug(main process)
 a.print_log()
 b.print_log()
 
 
 And It still prints out all the log msg. :(

Here's a little demo to explore how filtering works:

$ cat demo.py
import logging
class Filter(logging.Filter):
def filter(self, record):
print applying filter, self.name
return True

logging.basicConfig()

loggers = [logging.getLogger(path) for path in [, a, a.b]]
for logger in loggers:
logger.addFilter(Filter(filter@ + logger.name))

[handler] = logging.getLogger().handlers
handler.addFilter(Filter(filter@handler))

for logger in loggers:
logger.critical(whatever)
$ python demo.py
applying filter filter@root
applying filter filter@handler
CRITICAL:root:whatever
applying filter filter@a
applying filter filter@handler
CRITICAL:a:whatever
applying filter filter@a.b
applying filter filter@handler
CRITICAL:a.b:whatever
$

As you can infer from the output only the filter(s) of the original logger 
and of the handler(s) are applied.



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


Re: Multiple threads

2011-11-16 Thread Christian Heimes
Am 16.11.2011 14:48, schrieb Eduardo Oliva:
 Hello, I have a py script that reads for all m2ts video files and convert 
 them to mpeg using ffmpeg with command line.
 
 What I want to do is:
 
   I need my script to run 2 separated threads, and then when the first has 
 finished, starts the next onebut no more than 2 threads.
   I know that Semaphores would help with that.
   But the problem here is to know when the thread has finished its job, to 
 release the semaphore and start another thread.

I suggest a slight different approach: use a queue [1] and create two
worker threads that consume the queue. You don't need multiprocessing
because you are already using multiple processes here (one Python and
two ffmpeg processes).

Christian

[1] http://docs.python.org/library/queue.html

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


Re: Multiple threads

2011-11-16 Thread Thomas Rachel

Am 16.11.2011 14:48 schrieb Eduardo Oliva:

Hello, I have a py script that reads for all m2ts video files and convert them to 
mpeg using ffmpeg with command line.

What I want to do is:

   I need my script to run 2 separated threads, and then when the first has 
finished, starts the next onebut no more than 2 threads.
   I know that Semaphores would help with that.
   But the problem here is to know when the thread has finished its job, to 
release the semaphore and start another thread.

Any help would be great.


I'm not sure if you need threads at all: if you launch a process with 
subprocess, it runs and you only would have to wait() for it. The same 
can be done with two processes.


Pseudocode:

LIMIT = 2

processes = []


def do_waiting(limit):
while len(processes) = limit:
% take the first one...
sp = processes.pop(0)
% wait for it...
st = sp.wait(100)
if is None:
% timeout, not finished yet, push back.
processes.append(sp)
else:
% finished - don't push back, let outer for loop continue.
print sp, has finished with, st

for fname in list:
% launch process ...
sp = subprocess.Popen(...)
% ... and register it.
processes.append(sp)
% If we are on the limit, wait for process to finish.
do_waiting(LIMIT)

do_waiting(1)


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


try - except. How to identify errors unknown in advance?

2011-11-16 Thread Frederic Rentsch
Hi all,


I'd like to log MySQL errors. If I do:

try: (command)
except MySQLdb.OperationalError, e: print e

I may get something like:

(1136, Column count doesn't match value count at row 1)

If I don't know in advance which error to expect, but on the contrary
want to find out which error occurred, I can catch any error by omitting
the name:

except: (handle)

But now I don't have access to the error message 'e'. I'm sure there's a
way and it's probably ridiculously simple.

Frederic



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


Re: Multiple threads

2011-11-16 Thread Jack Keegan
Hi Chris,

On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelico ros...@gmail.com wrote:

 First off, it's better in CPython (the most popular Python) to use
 multiple processes than multiple threads.


I had been looking into treads and process/subprocess myself a while ago
and couldn't decide which would suit what I needed to do best. I'm still
very confused about the whole thing. Can you elaborate on the above a bit
please?

Cheers,

Jack
-- 
The earth is a very small stage in a vast cosmic arena. Think of the rivers
of blood spilled by all those generals and emperors so that in glory and in
triumph they could become the momentary masters of a fraction of a dot.
- Carl Sagan [Pale Blue Dot]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Chris Kaynor
On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch
anthra.nor...@bluewin.ch wrote:
 Hi all,


 I'd like to log MySQL errors. If I do:

        try: (command)
        except MySQLdb.OperationalError, e: print e

 I may get something like:

        (1136, Column count doesn't match value count at row 1)

 If I don't know in advance which error to expect, but on the contrary
 want to find out which error occurred, I can catch any error by omitting
 the name:

        except: (handle)

 But now I don't have access to the error message 'e'. I'm sure there's a
 way and it's probably ridiculously simple.

except Exception, e: (or, in Py3, except Exception as e is prefereed).

Note that you should generally avoid bare except statements except:
as that will catch everything, including KeyboardInterrupt and
SystemExit which may not be desirable.

Even without saving the exception in the except statement, you can get
the type, value, and traceback with the sys.exc_info command. See
http://docs.python.org/library/sys.html#sys.exc_info

For example:

pyimport sys
pytry:
py raise RuntimeError
py except:
py print sys.exc_info()
py
(type 'exceptions.RuntimeError', RuntimeError(), traceback object
at 0x02371588)


 Frederic



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

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


Re: Multiple threads

2011-11-16 Thread Dave Angel

On 11/16/2011 12:00 PM, Jack Keegan wrote:

Hi Chris,

On Wed, Nov 16, 2011 at 1:55 PM, Chris Angelicoros...@gmail.com  wrote:


First off, it's better in CPython (the most popular Python) to use
multiple processes than multiple threads.


I had been looking into treads and process/subprocess myself a while ago
and couldn't decide which would suit what I needed to do best. I'm still
very confused about the whole thing. Can you elaborate on the above a bit
please?

Cheers,

Jack
Threads and processes are a concept that exists in your operating 
system, and Python can use either of them to advantage, depending on the 
problem.  Note that different OS also handle them differently, so code 
that's optimal on one system might not be as optimal on another.  Still, 
some generalities can be made.


Each process is a separate program, with its own address space and its 
own file handles, etc.  You can examine them separately with task 
manager, for example.  If you launch multiple processes, they might not 
even all have to be python, so if one problem can be handled by an 
existing program, just run it as a separate process.   Processes are 
generally very protected from each other, and the OS is generally better 
at scheduling them than it is at scheduling threads within a single 
process.  If you have multiple cores, the processes can really run 
simultaneously, frequently with very small overhead.  The downside is 
that you cannot share variables between processes without extra work, so 
if the two tasks are very interdependent, it's more of a pain to use 
separate processes.


Within one process, you can have multiple threads.  On some OS, and in 
some languages, this can be extremely efficient.  Some programs launch 
hundreds of threads, and use them to advantage.  By default, it's easy 
to share data between threads, since they're in the same address space.  
But the downsides are 1) it's very easy to trash another thread by 
walking on its variables.  2) Python does a lousy job of letting threads 
work independently.  For CPU-bound tasks, using separate threads is 
likely to be slower than just doing it all in one thread.


--

DaveA

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


Re: Multiple threads

2011-11-16 Thread Michael Hunter
On Wed, Nov 16, 2011 at 9:27 AM, Dave Angel d...@davea.name wrote:
 On 11/16/2011 12:00 PM, Jack Keegan wrote:
[...] Processes [...] and the OS is generally better at scheduling them than 
it is at
 scheduling threads within a single process.  If you have multiple cores, the
 processes can really run simultaneously, frequently with very small
 overhead.  [...]

Maybe you are trying to simplify things but in a lot of cases this is
just false.  In at least some operating systems these days a thread is
the basic unit that is scheduled.  Processes are thread containers
that provide other things (fds, separate address space, etc.).  The
comment about multiple cores can be extended to multiple threads on a
core (CMT) but applies to threads as well as processes.  Switching
between processes tends to be heavier weight then switching between
threads in a process because of the needs to change the address space.

Just because Python sucks at threads doesn't make them heavier for the OS.

That doesn't mean you shouldn't use multiprocessing.  The problem
asked about seems a good fit to me to a single python process starting
and managing a set of external converter processes.

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


How to use pySerial under Windows 7 without administrator rights

2011-11-16 Thread furoscame

Hello together,

currently I try to use pySerial under Windows 7. But it is not possible 
to open a serial port without running the script under adminstrator 
rights. Other programs like Terraterm are able to so without 
adminstrator rights. What is the reason for that and is it possible open 
a port without administrator rights in Python?


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


Re: Multiple threads

2011-11-16 Thread Dave Angel

On 11/16/2011 12:55 PM, Michael Hunter wrote:

On Wed, Nov 16, 2011 at 9:27 AM, Dave Angeld...@davea.name  wrote:

On 11/16/2011 12:00 PM, Jack Keegan wrote:
[...] Processes [...] and the OS is generally better at scheduling them than it 
is at
scheduling threads within a single process.  If you have multiple cores, the
processes can really run simultaneously, frequently with very small
overhead.  [...]


Maybe you are trying to simplify things but in a lot of cases this is
just false.  In at least some operating systems these days a thread is
the basic unit that is scheduled.  Processes are thread containers
that provide other things (fds, separate address space, etc.).  The
comment about multiple cores can be extended to multiple threads on a
core (CMT) but applies to threads as well as processes.  Switching
between processes tends to be heavier weight then switching between
threads in a process because of the needs to change the address space.

Just because Python sucks at threads doesn't make them heavier for the OS.

That doesn't mean you shouldn't use multiprocessing.  The problem
asked about seems a good fit to me to a single python process starting
and managing a set of external converter processes.

   Michael



No response is deserved.

--

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


Re: Multiple threads

2011-11-16 Thread Dave Angel

On 11/16/2011 01:22 PM, Dave Angel wrote:

(You're top-posting.  Put your remarks AFTER what you're quoting)

On 11/16/2011 12:52 PM, Jack Keegan wrote:
Ok, I thought that processes would do the same job as threads. So 
would the

general rule be some thing like so:

If I want another piece of work to run (theoretically) along side my 
main

script, and I want to share data between them, I should use a thread and
share data with the thread-safe queue.
If the work I want done can function and complete on its own, go for a
process.

Would that be about right?



Yes, with all the caveats I mentioned before.  With some language 
implementations, and with some operating systems, and on some 
CPU-systems, the guidelines could be different.  They all trade off in 
ways too complex to describe here.


For example, if a thread is mostly doing I/O, it may be just as 
efficient as a separate process, even if sharing data isn't an issue.


And in some languages, sharing data between processes isn't all that 
tough, either.



Well, you sent me a mail without including the list (just use 
Reply-All), and I tried to add the list in.  Unfortunately, I picked the 
wrong one, so i sent this to Tutor by mistake.  I'll try to fix that 
now, sorry.





--

DaveA

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


Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Frederic Rentsch
On Wed, 2011-11-16 at 09:09 -0800, Chris Kaynor wrote:
 On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch
 anthra.nor...@bluewin.ch wrote:
  Hi all,
 
 
  I'd like to log MySQL errors. If I do:
 
 try: (command)
 except MySQLdb.OperationalError, e: print e
 
  I may get something like:
 
 (1136, Column count doesn't match value count at row 1)
 
  If I don't know in advance which error to expect, but on the contrary
  want to find out which error occurred, I can catch any error by omitting
  the name:
 
 except: (handle)
 
  But now I don't have access to the error message 'e'. I'm sure there's a
  way and it's probably ridiculously simple.
 
 except Exception, e: (or, in Py3, except Exception as e is prefereed).
 
 Note that you should generally avoid bare except statements except:
 as that will catch everything, including KeyboardInterrupt and
 SystemExit which may not be desirable.
 
 Even without saving the exception in the except statement, you can get
 the type, value, and traceback with the sys.exc_info command. See
 http://docs.python.org/library/sys.html#sys.exc_info
 
 For example:
 
 pyimport sys
 pytry:
 py raise RuntimeError
 py except:
 py print sys.exc_info()
 py
 (type 'exceptions.RuntimeError', RuntimeError(), traceback object
 at 0x02371588)

Chris, Thanks very much! Great help!

Frederic


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


Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Christian Heimes
Am 16.11.2011 19:39, schrieb Frederic Rentsch:
 pyimport sys
 pytry:
 py raise RuntimeError
 py except:
 py print sys.exc_info()
 py
 (type 'exceptions.RuntimeError', RuntimeError(), traceback object
 at 0x02371588)
 
 Chris, Thanks very much! Great help!

How about using the excellent logging framework instead of rolling your
own stuff? It can print the traceback, too.

 import logging
 logging.basicConfig()
 log = logging.getLogger(mymodule)
 try:
... raise ValueError(test)
... except Exception:
... log.exception(some message)
...
ERROR:mymodule:some message
Traceback (most recent call last):
  File stdin, line 2, in module
ValueError: test

Christian

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


Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread MRAB

On 16/11/2011 17:09, Chris Kaynor wrote:

On Wed, Nov 16, 2011 at 8:57 AM, Frederic Rentsch
anthra.nor...@bluewin.ch  wrote:

Hi all,


I'd like to log MySQL errors. If I do:

try: (command)
except MySQLdb.OperationalError, e: print e

I may get something like:

(1136, Column count doesn't match value count at row 1)

If I don't know in advance which error to expect, but on the contrary
want to find out which error occurred, I can catch any error by omitting
the name:

except: (handle)

But now I don't have access to the error message 'e'. I'm sure there's a
way and it's probably ridiculously simple.


except Exception, e: (or, in Py3, except Exception as e is prefereed).


In Python 3, except Exception as e is not just preferred: it's the
only form.


Note that you should generally avoid bare except statements except:
as that will catch everything, including KeyboardInterrupt and
SystemExit which may not be desirable.


[snip]

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


Re: (n00b) Tkinter trouble

2011-11-16 Thread Jason Swails
On Tue, Nov 15, 2011 at 10:49 PM, Chris Angelico ros...@gmail.com wrote:

 On Wed, Nov 16, 2011 at 2:02 PM, Jason Swails jason.swa...@gmail.com
 wrote:
  Apparently I could not do what I was wanting to (state=DISABLED is not a
  valid option to Toplevel).  What I wanted to do was something similar to
  what the dialogs were doing from tkMessageBox.

 Yes, that would be what you'd want. I wonder, though: Is Toplevel the
 right window class? There may be a better class for a subwindow.
 Again, I'm not familiar with Tkinter, but a quick google suggests that
 Frame or Window might be worth looking into. Ideally, you want the
 window to disable its parent and claim all events.


I think Toplevel is right.  Frame isn't actually a window (a window has to
be its parent), and I've never seen any documentation regarding a Window
class (perhaps it's just meant to be a base class that Toplevel inherits
from?).  I think a separate window needs to be a Toplevel instance (or
instance of a Toplevel-derived class).

Pulling on the tkMessageBox example again, their base Dialog class inherits
from Toplevel.  In any case, I've actually found that Tkinter is relatively
straightforward to learn, despite some of the bashing it's received here
(admittedly I've never tried PyGTK or wxpython or any of the other toolkits
because I want to keep dependencies within the stdlib as much as possible).

Thanks!
Jason
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: redis beginner question

2011-11-16 Thread Rafael Durán Castañeda

El 16/11/11 03:22, Jabba Laci escribió:

Hi,

I'm reading the redis documentation and there is one thing that
bothers me. For redis, you need to start a server on localhost. Is
there an easy way that my Python script starts this server
automatically? Before using my script, I don't want to start
redis-server each time. When my program terminates, the server could
be shut down automatically.

Thanks,

Laszlo
I think you are misunderstanding the docs, on ubuntu (or whatever you 
use) you can do apt-get install redis-server and you'll get what you want.


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


Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread Ben Finney
goldtech goldt...@worldpost.com writes:

 Using Windows. Is there a python shell that has a history of typed in
 commands?

I don't know about MS Windows, but the Python interactive shell can be
linked with the GNU Readline library for managing its command line
URL:http://docs.python.org/library/readline.html including editing
features, tab completion, history management, and a persistent history
file.

You can then use that functionality in your Python interactive startup
file. Here's mine:

=
# $HOME/.pythonrc
# User configuration for interactive Python shell.

import sys
import os
import os.path
import atexit

# Tab completion with readline.
# Cribbed from URL:http://docs.python.org/lib/module-rlcompleter.html.
try:
import readline
except ImportError:
sys.stderr.write(Module readline not available.\n)
else:
import rlcompleter

# Enable tab completion.
readline.parse_and_bind(tab: complete)

# Persistent command history.
histfile = os.path.join(os.environ[HOME], .python_history) 
try:
readline.read_history_file(histfile)
except IOError:
# Existing history file can't be read.
pass 
atexit.register(readline.write_history_file, histfile)

del histfile

del sys, os, atexit

=

Reading the documentation, I see that the ‘readline’ library is only
linked with Python on Unix-alike operating systems. Yet another reason
why MS Windows is not a good choice for developing software I guess.

-- 
 \“The difference between religions and cults is determined by |
  `\  how much real estate is owned.” —Frank Zappa |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Terry Reedy

On 11/16/2011 11:57 AM, Frederic Rentsch wrote:


If I don't know in advance which error to expect, but on the contrary
want to find out which error occurred, I can catch any error by omitting
the name:

except: (handle)

But now I don't have access to the error message 'e'. I'm sure there's a
way and it's probably ridiculously simple.


Bare except is a holdover from when exceptions could be strings rather 
than an instance of a subclass of BaseException. A Python 3 interpreter 
in effect runs code within a try-except block something like this:


try:
your code
except BaseException as __exception__:
print traceback and exit

However, use Exception instead of BaseException in your code unless you 
REALLY know what you are doing and why.


--
Terry Jan Reedy

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


Re: Multiple threads

2011-11-16 Thread Miki Tebeka
You can see an example on how to use multiprocessing.Pool at 
http://pythonwise.blogspot.com/2011/03/convert-oggs-to-mp3-fast-way.html

This is ogg - mp3 but the same idea.
-- 
http://mail.python.org/mailman/listinfo/python-list


pymacs?

2011-11-16 Thread Andrea Crotti
After a long time, and since it was included iin python-mode, I wanted 
to try if I can

get ropemacs working finally.
I have tried many possible things, also in Emacs -Q, and I actually got 
it working

only once, apparently by pure luck with Emacs -Q:

(setq py-load-python-mode-pymacs-p nil)

(setq ca-pymacs-path (expand-file-name 
~/Emacs-configuration/python-mode/pymacs))

(add-to-list 'load-path ca-pymacs-path)
(setenv PYMACS_PYTHON python2.7)
(require 'pymacs)

(pymacs-load ropemacs rope-)
(setq ropemacs-confirm-saving 'nil)

The problem is that this configuration doesn't use python-mode.el but 
the standard python.el,

all my attempts to make this work on my normal configuration failed.
Did anyone got both correctly working?

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


Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread David Robinow
On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 goldtech goldt...@worldpost.com writes:

 Using Windows. Is there a python shell that has a history of typed in
 commands?

 I don't know about MS Windows, but the Python interactive shell can be
 linked with the GNU Readline library for managing its command line
 URL:http://docs.python.org/library/readline.html including editing
 features, tab completion, history management, and a persistent history
 file.

 You can then use that functionality in your Python interactive startup
 file. Here's mine:

 =
 # $HOME/.pythonrc
 # User configuration for interactive Python shell.

 import sys
 import os
 import os.path
 import atexit

 # Tab completion with readline.
 # Cribbed from URL:http://docs.python.org/lib/module-rlcompleter.html.
 try:
    import readline
 except ImportError:
    sys.stderr.write(Module readline not available.\n)
 else:
    import rlcompleter

    # Enable tab completion.
    readline.parse_and_bind(tab: complete)

    # Persistent command history.
    histfile = os.path.join(os.environ[HOME], .python_history)
    try:
        readline.read_history_file(histfile)
    except IOError:
        # Existing history file can't be read.
        pass
    atexit.register(readline.write_history_file, histfile)

    del histfile

 del sys, os, atexit

 =

 Reading the documentation, I see that the ‘readline’ library is only
 linked with Python on Unix-alike operating systems. Yet another reason
 why MS Windows is not a good choice for developing software I guess.

 I'm not sure what documentation you're reading, but your code works fine on
 Windows.   Thanks.  [It is necessary to properly set PYTHONSTARTUP]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread Ben Finney
David Robinow drobi...@gmail.com writes:

 On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney ben+pyt...@benfinney.id.au 
 wrote:
  I don't know about MS Windows, but the Python interactive shell can be
  linked with the GNU Readline library for managing its command line
  URL:http://docs.python.org/library/readline.html
[…]

  Reading the documentation, I see that the ‘readline’ library is only
  linked with Python on Unix-alike operating systems.

  I'm not sure what documentation you're reading

The same documentation I linked to above. Immediately below the title,
it specifies a limited set of platforms: “Platforms: Unix” limiting the
availability of the described module.

 but your code works fine on Windows. Thanks.

I'm glad to know that. Perhaps you could investigate why, and suggest an
update to the above documentation if it's wrong? The bug tracker at
URL:http://bugs.python.org/ would be the appropriate place for such a
suggestion.

-- 
 \“Intellectual property is to the 21st century what the slave |
  `\  trade was to the 16th.” —David Mertz |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread David Robinow
On Wed, Nov 16, 2011 at 6:59 PM, Ben Finney ben+pyt...@benfinney.id.au wrote:
 David Robinow drobi...@gmail.com writes:

 On Wed, Nov 16, 2011 at 4:09 PM, Ben Finney ben+pyt...@benfinney.id.au 
 wrote:
  I don't know about MS Windows, but the Python interactive shell can be
  linked with the GNU Readline library for managing its command line
  URL:http://docs.python.org/library/readline.html
 […]

  Reading the documentation, I see that the ‘readline’ library is only
  linked with Python on Unix-alike operating systems.

  I'm not sure what documentation you're reading

 The same documentation I linked to above. Immediately below the title,
 it specifies a limited set of platforms: “Platforms: Unix” limiting the
 availability of the described module.

 but your code works fine on Windows. Thanks.

 I'm glad to know that. Perhaps you could investigate why, and suggest an
 update to the above documentation if it's wrong? The bug tracker at
 URL:http://bugs.python.org/ would be the appropriate place for such a
 suggestion.

Upon further investigation, it turns out that I'm using pyreadline
from http://pypi.python.org/pypi/pyreadline. I'd forgotten I'd
installed it. No documentation fixes appear to be necessary.

The pyreadline package is a python implementation of GNU readline
functionality it is based on the ctypes based UNC readline package by
Gary Bishop. It is not complete. It has been tested for use with
windows 2000 and windows xp.
  It appears to work in Vista also, at least for the purposes
discussed in this thread.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: try - except. How to identify errors unknown in advance?

2011-11-16 Thread Dan Sommers
On Wed, 16 Nov 2011 17:57:27 +0100, Frederic Rentsch wrote:

 I'd like to log MySQL errors. If I do:
 
   try: (command)
   except MySQLdb.OperationalError, e: print e
 
 I may get something like:
 
   (1136, Column count doesn't match value count at row 1)
 
 If I don't know in advance which error to expect, but on the contrary
 want to find out which error occurred, I can catch any error by omitting
 the name:
 
   except: (handle)
 
 But now I don't have access to the error message 'e'. I'm sure there's a
 way and it's probably ridiculously simple.

except catches any exception that inherits from its argument, and all 
MySQL exceptions inherit from MySQLError, so something like this will 
catch only MySQL exceptions and nothing else:

try: (command)
except MySQLdb.MySQLError as e:
print(e)

Dan

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


How to insert my own module in front of site eggs?

2011-11-16 Thread Roy Smith
I'm trying to use a custom version of mongoengine.  I cloned the git 
repo and put the directory on my PYTHONPATH, but python is still 
importing the system's installed version.  Looking at sys.path, it's 
obvious why:

$ echo $PYTHONPATH 
/home/roy/songza:/home/roy/lib/mongoengine

 pprint.pprint(sys.path)
['',
 '/usr/local/lib/python2.6/dist-packages/selenium-2.0a5-py2.6.egg',
 '/usr/local/lib/python2.6/dist-packages/unittest2-0.5.1-py2.6.egg',
 
'/usr/local/lib/python2.6/dist-packages/pymongo-1.9-py2.6-linux-x86_64.eg
g',
 '/usr/local/lib/python2.6/dist-packages/virtualenv-1.5.2-py2.6.egg',
 '/usr/local/lib/python2.6/dist-packages/mongoengine-0.5.2-py2.6.egg',
 '/home/roy/songza',
 '/home/roy/lib/mongoengine',
 '/usr/lib/python2.6',
 '/usr/lib/python2.6/plat-linux2',
 '/usr/lib/python2.6/lib-tk',
 '/usr/lib/python2.6/lib-old',
 '/usr/lib/python2.6/lib-dynload',
 '/usr/lib/python2.6/dist-packages',
 '/usr/lib/python2.6/dist-packages/PIL',
 '/usr/lib/python2.6/dist-packages/gst-0.10',
 '/usr/lib/pymodules/python2.6',
 '/usr/lib/python2.6/dist-packages/gtk-2.0',
 '/usr/lib/pymodules/python2.6/gtk-2.0',
 '/usr/local/lib/python2.6/dist-packages']

The system eggs come before my path.  I found 
http://mail.python.org/pipermail/distutils-sig/2006-July/006520.html in 
the archives; it explains that eggs come before PYTHONPATH, but doesn't 
explain how to get around this problem.  I emphatically agree with 
Michael Bayer who said:

 I cant think of a  possible scenario where a path would explicitly
 exist in PYTHONPATH,  non-egg or egg, where the user would still like the
 system-wide installation to take precedence

So, is there any way to get my local copy of mongoengine loaded instead 
of the system egg?  I could probably import sys, and do an egg-ectomy on 
sys.path before importing mongoengine, but that's too gross to 
contemplate.
-- 
http://mail.python.org/mailman/listinfo/python-list


staticmethod makes my brain hurt

2011-11-16 Thread Roy Smith
When I run this (python 2.6.1):

class C:
@staticmethod
def foo():
pass

print inside, foo, callable(foo)

print outside, C.foo, callable(C.foo)

I get:

inside staticmethod object at 0x421df0 False
outside function foo at 0x41e6f0 True

I don't understand.  Why is foo not callable inside of the class 
definition?  Where this comes up is that I'm trying to use a callable 
default in mongoengine:

class User(Document):
@staticmethod
def _get_next_id():
  [blah, blah, blah]  
  return id

user_id = IntField(required=True, default=_get_next_id)

The way mongoengine works is if callable(default) is true, it calls 
default() to get the real value to use.  At the point where the 
IntField() call is made, _get_next_id is not callable, and eventually I 
end up with:

ValidationError: staticmethod object at 0x2a3c1a0 could not be 
converted to int
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: staticmethod makes my brain hurt

2011-11-16 Thread alex23
On Nov 17, 12:30 pm, Roy Smith r...@panix.com wrote:
 class C:
     @staticmethod
     def foo():
         pass

     print inside, foo, callable(foo)

 print outside, C.foo, callable(C.foo)

 I don't understand.  Why is foo not callable inside of the class
 definition?

Consider this:

 def foo(): pass
...
 foo = staticmethod(foo)
 callable(foo)
False

A staticmethod by itself does not appear to be callable.

Your internal 'foo' is referring to the staticmethod wrapper. Your
external 'C.foo' refers to the result returned by the class
mechanism's __getattr__, which I'm guessing is munged into a callable
at that point.

Where this comes up is that I'm trying to use a callable
 default in mongoengine:

 class User(Document):
     @staticmethod
     def _get_next_id():
       [blah, blah, blah]
       return id

     user_id = IntField(required=True, default=_get_next_id)

What you're effectively trying to do is use a class before it has been
constructed to help construct itself.

Just define it as a helper function before the class declaration.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: staticmethod makes my brain hurt

2011-11-16 Thread Roy Smith
In article 
e9f5814a-6f0d-4985-aebb-5b68b8c79...@x10g2000prk.googlegroups.com,
 alex23 wuwe...@gmail.com wrote:

 What you're effectively trying to do is use a class before it has been
 constructed to help construct itself.
 
 Just define it as a helper function before the class declaration.

Yes, this is the workaround I ended up with.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python shell that saves history of typed in commands that will persist between reboots

2011-11-16 Thread alex23
On Nov 17, 7:09 am, Ben Finney ben+pyt...@benfinney.id.au wrote:
 You can then use that functionality in your Python interactive startup
 file. Here's mine:

Awesome, thank you for this. I use iPython where ever possible but
there are times where I just can't avoid the default shell and this
will help immensely.

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


Re: staticmethod makes my brain hurt

2011-11-16 Thread Ethan Furman

Roy Smith wrote:

class User(Document):
@staticmethod
def _get_next_id():
  [blah, blah, blah]  
  return id


user_id = IntField(required=True, default=_get_next_id)


If you don't call '_get_next_id()' from any class methods (in other 
words, if you don't need to ever say 'self._gen_next_id()') then you can 
remove the '@staticmethod':


def _get_next_id():
  [blah, blah, blah]
  return id

user_id = IntField(required=True, default=_get_next_id)

If you do need to sometimes call it from a method then still leave off 
the '@staticmethod', and give 'self' a default of 'None':


def _get_next_id(self=None):
  [blah, blah, blah]
  return id

user_id = IntField(required=True, default=_get_next_id)

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


Monitoring/inventory client-server app

2011-11-16 Thread snorble
I'm writing a tool for monitoring the workstations and servers in our
office. I plan to have a server and a client service that runs on each
workstation and reports back to the server (heartbeat, disk free
space, etc).

So far I am considering XMLRPC, or a client service that just
downloads a Python file and runs it.

With XMLRPC I don't know how to easily add features without having to
update every client. Also while playing with XMLRPC I learned that
when you run a registered function, it runs it on the server. I was
hoping it would run on the client, so that when I get the machine's
computer name (or disk space, etc) it will return the client's info.
It seems with XMLRPC I would have to hard code the functionality into
the client (i.e. client gets it's computer name, then calls the XMLRPC
function to pass it to the server)? I was hoping it would work more
like, pass some code to the client to be run on the client, and
report it to the server. Almost XMLRPC in the reverse direction.

With the download-and-run approach, it seems trivially easy to add new
functionality to the clients. Just save the updated Python file to the
server, and clients download it and run it.

Are there any standard approaches to problems like this that can be
recommended? Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: staticmethod makes my brain hurt

2011-11-16 Thread Steven D'Aprano
On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote:

 When I run this (python 2.6.1):
 
 class C:
 @staticmethod
 def foo():
 pass
 print inside, foo, callable(foo)
 
 print outside, C.foo, callable(C.foo)
 
 I get:
 
 inside staticmethod object at 0x421df0 False 
 outside function foo at 0x41e6f0 True
 
 I don't understand.  Why is foo not callable inside of the class
 definition?


This has come up before.

http://bytes.com/topic/python/answers/34396-static-method-object-not-callable

http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callable


However, the fix is not as simple as merely making staticmethod objects 
callable. This was discussed at the 2011 language summit:

http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html

See also this thread:

http://mail.python.org/pipermail/python-dev/2011-March/109090.html



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


Re: staticmethod makes my brain hurt

2011-11-16 Thread Roy Smith
In article 4ec490ec$0$30003$c3e8da3$54964...@news.astraweb.com,
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:

 This has come up before.
 
 http://bytes.com/topic/python/answers/34396-static-method-object-not-callable
 
 http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callabl
 e
 
 
 However, the fix is not as simple as merely making staticmethod objects 
 callable. This was discussed at the 2011 language summit:
 
 http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.h
 tml
 
 See also this thread:
 
 http://mail.python.org/pipermail/python-dev/2011-March/109090.html

Thanks for the links.  It always makes me feel good when I get tripped 
up by something complex and subtle.  It almost makes up for all the 
times when I feel like a dolt because I got tripped up by something 
obvious and elementary...
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: staticmethod makes my brain hurt

2011-11-16 Thread Devin Jeanpierre
 However, the fix is not as simple as merely making staticmethod objects
 callable. This was discussed at the 2011 language summit:

 http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html

 See also this thread:

 http://mail.python.org/pipermail/python-dev/2011-March/109090.html

The notes didn't actually mention what was discussed, but re the
second thread, the issue was not changing staticmethod to be callable.
Making staticmethod callable is fine, but __get__ still has to return
the original function, not self.

The context of the second thread was that staticmethod was imagined as
one way to eliminate the difference between C and Python functions,
when added to a class. But this doesn't quite work, unless
staticmethod.__get__ returned self (which broke for related reasons).
If it returns the original function (as it does now) then the issue is
unresolved: C functions still behave differently from Python
functions, so you can't quite just hide them behind a staticmethod and
let everything remain the same. It doesn't eliminate the difference in
behavior in certain circumstances, e.g.:

class MyClass:
foo = staticmethod(foo)

class MyOtherClass:
foo = MyClass.foo

MyOtherClass().foo() # what happens if foo is builtin vs pure-Python?

In the context of this thread, though, just making it callable without
modifying __get__ is fine. Or at least, I don't see the issue.

Devin

On Wed, Nov 16, 2011 at 11:43 PM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Wed, 16 Nov 2011 21:30:57 -0500, Roy Smith wrote:

 When I run this (python 2.6.1):

 class C:
     @staticmethod
     def foo():
         pass
     print inside, foo, callable(foo)

 print outside, C.foo, callable(C.foo)

 I get:

 inside staticmethod object at 0x421df0 False
 outside function foo at 0x41e6f0 True

 I don't understand.  Why is foo not callable inside of the class
 definition?


 This has come up before.

 http://bytes.com/topic/python/answers/34396-static-method-object-not-callable

 http://bytes.com/topic/python/answers/462734-make-staticmethod-objects-callable


 However, the fix is not as simple as merely making staticmethod objects
 callable. This was discussed at the 2011 language summit:

 http://www.boredomandlaziness.org/2011/03/python-language-summit-rough-notes.html

 See also this thread:

 http://mail.python.org/pipermail/python-dev/2011-March/109090.html



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

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


Re: staticmethod makes my brain hurt

2011-11-16 Thread Dotan Cohen
On Thu, Nov 17, 2011 at 04:30, Roy Smith r...@panix.com wrote:
 When I run this (python 2.6.1):

 class C:
    @staticmethod
    def foo():
        pass

    print inside, foo, callable(foo)

 print outside, C.foo, callable(C.foo)

 I get:

 inside staticmethod object at 0x421df0 False
 outside function foo at 0x41e6f0 True

 I don't understand.  Why is foo not callable inside of the class
 definition?  Where this comes up is that I'm trying to use a callable
 default in mongoengine:

 class User(Document):
    @staticmethod
    def _get_next_id():
      [blah, blah, blah]
      return id

    user_id = IntField(required=True, default=_get_next_id)

 The way mongoengine works is if callable(default) is true, it calls
 default() to get the real value to use.  At the point where the
 IntField() call is made, _get_next_id is not callable, and eventually I
 end up with:

 ValidationError: staticmethod object at 0x2a3c1a0 could not be
 converted to int

Try this (untested):

class C:
   @staticmethod
   def foo():
   pass

   print inside, C.foo, callable(C.foo)



-- 
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com
-- 
http://mail.python.org/mailman/listinfo/python-list


problem in running script file of modeller

2011-11-16 Thread Anushree Tripathi
When I run  mod9.10  model-default.py command on command window.It is
showing that 'import site' failed;use -v for traceback and also error in
opening alignment.ali file.Now what do i have to change.Please reply me as
soon as possible.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Multiple threads

2011-11-16 Thread Jack Keegan
On Wed, Nov 16, 2011 at 6:30 PM, Dave Angel d...@davea.name wrote:

 On 11/16/2011 01:22 PM, Dave Angel wrote:

 (You're top-posting.  Put your remarks AFTER what you're quoting)

 On 11/16/2011 12:52 PM, Jack Keegan wrote:

 Ok, I thought that processes would do the same job as threads. So would
 the
 general rule be some thing like so:

 If I want another piece of work to run (theoretically) along side my main
 script, and I want to share data between them, I should use a thread and
 share data with the thread-safe queue.
 If the work I want done can function and complete on its own, go for a
 process.

 Would that be about right?


 Yes, with all the caveats I mentioned before.  With some language
 implementations, and with some operating systems, and on some CPU-systems,
 the guidelines could be different.  They all trade off in ways too complex
 to describe here.

 For example, if a thread is mostly doing I/O, it may be just as efficient
 as a separate process, even if sharing data isn't an issue.

 And in some languages, sharing data between processes isn't all that
 tough, either.


  Well, you sent me a mail without including the list (just use
 Reply-All), and I tried to add the list in.  Unfortunately, I picked the
 wrong one, so i sent this to Tutor by mistake.  I'll try to fix that now,
 sorry.


Apologies, I usually reply-all and don't usually top-post. Was just rushing
out the door when I responded last time.

Cheers,

Jack

-- 
The earth is a very small stage in a vast cosmic arena. Think of the rivers
of blood spilled by all those generals and emperors so that in glory and in
triumph they could become the momentary masters of a fraction of a dot.
- Carl Sagan [Pale Blue Dot]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: staticmethod makes my brain hurt

2011-11-16 Thread Ian Kelly
On Wed, Nov 16, 2011 at 11:44 PM, Dotan Cohen dotanco...@gmail.com wrote:
 Try this (untested):

 class C:
   @staticmethod
   def foo():
       pass

   print inside, C.foo, callable(C.foo)

If you had tested this, you would have found that you get a NameError,
since C is not yet bound inside the class block where you define it.
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue13406] Deprecation warnings when running the test suite

2011-11-16 Thread Ezio Melotti

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

Should be fixed now.

--
assignee:  - ezio.melotti
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue1486713] HTMLParser : A auto-tolerant parsing mode

2011-11-16 Thread kxroberto

kxroberto kxrobe...@users.sourceforge.net added the comment:

Well in many browsers for example there is a internal warning and error log 
(window). Which yet does not (need to) claim to be a official W3C checker. It 
has positive effect on web stabilization. 
For example just looking now I see the many HTML and CSS warnings and errors 
about the sourceforge site and this bug tracker in the Browsers log - not 
believing that the log covers the bugs 100% ;-)

The events of warnings are easily available here, and calling self.warning, as 
it was, costs quite nothing. I don't see a problem for non-users of this 
feature. And most code using HTMLParser also emits warnings on the next higher 
syntax level, so to not have a black box...
 
As I used a tolerant version of HTMLParser for about a decade, I can say the 
warnings are of the same value in many apps and use case, as to be able to have 
look into a Browsers syntax log. 
The style of stretching a argument to black-white is not reasonable here in 
the world of human edited HTML ;-)

--

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



[issue1486713] HTMLParser : A auto-tolerant parsing mode

2011-11-16 Thread Ezio Melotti

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

The strict/tolerant mode mainly works by using either a strict or a tolerant 
regex.  If the markup is invalid, the strict regex doesn't match and it gives 
an error.  The tolerant regex will match both valid and invalid markup at the 
same time, without distinctions, and that's why there's no way to emit a 
warning for these cases.  I think there are a couple of places where a warning 
could be emitted, but that would just cover a small percentage of the errors.  
Even if we find a way to emit a warning for everything allowed by the tolerant 
mode that fails on strict, it won't still cover all the possible errors, that's 
why I think tools like validators and conformance checkers (or even the 
warning/error logs) should be used instead.

--

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



[issue7983] The encoding map from Unicode to CP932 is different from that of Windows'

2011-11-16 Thread cedre.m

Changes by cedre.m cedr...@gmail.com:


--
nosy: +cedrem

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



[issue7983] The encoding map from Unicode to CP932 is different from that of Windows'

2011-11-16 Thread cedre.m

cedre.m cedr...@gmail.com added the comment:

http://support.microsoft.com/kb/170559/EN-US
http://msdn.microsoft.com/en-us/goglobal/cc305152.aspx

--

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



[issue13414] test_strftime failed on OpenBSD

2011-11-16 Thread Remi Pointel

New submission from Remi Pointel pyt...@xiri.fr:

Hello,

I was running test_datetime.py and it failed on OpenBSD.
I have tested with Python 2.7, Python 3.2 and Python 3.3.

Python 2.7:
test_datetime.py: ok
test_srtftime.py: failed (see attached file: test_strftime_python27.log)

Have a lot of:
Conflict for nonstandard '%3y' format (year without century rendered using 
fieldwidth):
  Expected 011, but got 3y
Strftime test, platform: openbsd5, Python version: 2.7.1
strftime test for Sat Jul 24 21:56:24 2010
Supports nonstandard '%c' format (near-asctime() format)
Supports nonstandard '%x' format (%m/%d/%y %H:%M:%S)
Supports nonstandard '%Z' format (time zone name)
Supports nonstandard '%D' format (mm/dd/yy)
Supports nonstandard '%e' format (day of month as number, blank padded ( 0-31))
Supports nonstandard '%h' format (abbreviated month name)
Supports nonstandard '%k' format (hour, blank padded ( 0-23))
Supports nonstandard '%n' format (newline character)
Supports nonstandard '%r' format (%I:%M:%S %p)
Supports nonstandard '%R' format (%H:%M)
Supports nonstandard '%s' format (seconds since the Epoch in UCT)
Supports nonstandard '%t' format (tab character)
Supports nonstandard '%T' format (%H:%M:%S)


Python 3.2:
test_datetime.py: failed (see attached file: test_datetime_python32.log)
==
FAIL: test_zones (test.datetimetester.TestTimeTZ_Fast)
--
Traceback (most recent call last):
  File /usr/ports/pobj/Python-3.2.2/Python-3.2.2/Lib/test/datetimetester.py, 
line 2506, in test_zones
07:47:00 %Z=EST %z=-0500)
AssertionError: '07:47:00 Z=EST z=-0500' != '07:47:00 %Z=EST %z=-0500'
- 07:47:00 Z=EST z=-0500
+ 07:47:00 %Z=EST %z=-0500
?  +  +


==
FAIL: test_zones (test.datetimetester.TestTimeTZ_Pure)
--
Traceback (most recent call last):
  File /usr/ports/pobj/Python-3.2.2/Python-3.2.2/Lib/test/datetimetester.py, 
line 2506, in test_zones
07:47:00 %Z=EST %z=-0500)
AssertionError: '07:47:00 Z=EST z=-0500' != '07:47:00 %Z=EST %z=-0500'
- 07:47:00 Z=EST z=-0500
+ 07:47:00 %Z=EST %z=-0500
?  +  +

test_strftime.py: failed (see attached file: test_strftime_python32.log)

==
FAIL: test_strftime (__main__.StrftimeTest)
--
Traceback (most recent call last):
  File Lib/test/test_strftime.py, line 67, in test_strftime
self.strftest1(now)
  File Lib/test/test_strftime.py, line 124, in strftest1
% (e[0], e[2]))
AssertionError: strftime does not support standard '%%' format (single percent 
sign)

--


Python 3.3:
test_datetime.py: failed (see attached file: test_datetime_python33.log)
Same output than Python 3.2.

test_strftime.py: failed (see attached file: test_strftime_python33.log)
Same output than Python 3.2.


I write a small program in C to verify strftime, and it seems to correcly works:
source:
(void)strftime(buf, sizeof(buf) - 1, %H:%M:%S %%Z=%Z %%z=%z, 
localtime(startt));
printf(%s\n, buf);
buf[0] = '\0';
(void)strftime(buf, sizeof(buf) - 1, 07:47:00 %Z=EST %z=-0500, 
localtime(startt));
printf(%s\n, buf);

run:
01:00:00 %Z=CET %z=+0100
07:47:00 CET=EST +0100=-0500



Is my test correct ? Don't hesitate if you need more informations.

Thanks for your help, 

Remi.

--
files: test_datetime_python32.log
messages: 147758
nosy: rpointel
priority: normal
severity: normal
status: open
title: test_strftime failed on OpenBSD
versions: Python 2.7, Python 3.2, Python 3.3
Added file: http://bugs.python.org/file23705/test_datetime_python32.log

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



[issue13414] test_strftime failed on OpenBSD

2011-11-16 Thread Remi Pointel

Changes by Remi Pointel pyt...@xiri.fr:


Added file: http://bugs.python.org/file23706/test_datetime_python33.log

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



[issue13414] test_strftime failed on OpenBSD

2011-11-16 Thread Remi Pointel

Changes by Remi Pointel pyt...@xiri.fr:


Added file: http://bugs.python.org/file23707/test_strftime_python27.log

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



[issue13414] test_strftime failed on OpenBSD

2011-11-16 Thread Remi Pointel

Changes by Remi Pointel pyt...@xiri.fr:


Added file: http://bugs.python.org/file23708/test_strftime_python32.log

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



[issue13414] test_strftime failed on OpenBSD

2011-11-16 Thread Remi Pointel

Changes by Remi Pointel pyt...@xiri.fr:


Added file: http://bugs.python.org/file23709/test_strftime_python33.log

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



[issue13410] String formatting bug in interactive mode

2011-11-16 Thread Eric V. Smith

Eric V. Smith e...@trueblade.com added the comment:

Interesting! Same here.

Using eval() fails with or without -v:

--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -289,6 +289,18 @@
 else:
 raise TestFailed, '%*d%(maxsize, -127) should fail'
 
+def test_issue13410(self):
+class Foo(object):
+def __init__(self, x):
+self.x = x
+def __long__(self):
+return long(self.x)
+def __float__(self):
+return float(self.x)
+eval(u'%d' % Foo(22))
+eval('%d' % Foo(22))
+
+
 def test_main():
 test_support.run_unittest(FormatTest)
 
I've put both '%d' and u'%d' here, but it also fails with just one of them.

--

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



[issue13414] test_strftime failed on OpenBSD

2011-11-16 Thread STINNER Victor

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

Can you also please attach your C test program?

--
nosy: +belopolsky, haypo

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



[issue13414] test_strftime failed on OpenBSD

2011-11-16 Thread Remi Pointel

Remi Pointel pyt...@xiri.fr added the comment:

Sure.

--
Added file: http://bugs.python.org/file23710/strftime.c

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



[issue13398] _cursesmodule does not build, doesn't find Python.h on Solaris

2011-11-16 Thread Maciej Bliziński

Maciej Bliziński maciej.blizin...@gmail.com added the comment:

It's not only the curses module, other two modules are failing as well, the 
same way - not finding Python.h.

maciej@unstable9s :~/src/opencsw/pkg/lang-python/python/branches/python-3.2  
grep ^PY_CPPFLAGS work/solaris9-sparc/build-isa-sparcv8/Python-3.2.2/Makefile
PY_CPPFLAGS=-I. -IInclude -I$(srcdir)/Include $(CONFIGURE_CPPFLAGS) 
$(CPPFLAGS)

Perhaps PY_CPPFLAGS does not get included in the compiler invocation? Poking 
around the Makefile, I find:

Modules/_cursesmodule.o: $(srcdir)/Modules/_cursesmodule.c; $(CC)  $(CCSHARED) 
$(CFLAGS) $(CPPFLAGS)  -c $(srcdir)/Modules/_cursesmodule.c -o 
Modules/_cursesmodule.o

This line doesn't contain a reference to PY_CPPFLAGS.

Perhaps the answer is around line 220 in Modules/makesetup?

--

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



[issue1486713] HTMLParser : A auto-tolerant parsing mode

2011-11-16 Thread kxroberto

kxroberto kxrobe...@users.sourceforge.net added the comment:

The old patch warned already the majority of real cases  - except the missing 
white space between attributes.

The tolerant regex will match both: 
locatestarttagend_tolerant: The main and frequent issue on the web here is the 
missing white space between attributes (with enclosed values). And there is the 
new tolerant comma between attributes, which however I have not seen so far 
anywhere (the old warning machanism and attrfind.match would have already 
raised it at junk chars ... event.
Both issues can be easily warned (also/already) at quite no cost by the 
slightly extended regex below (when the 2 new non-pseudo regex groups are check 
against None in check_for_whole_start_tag). 
Or missing whitespace could be warned (multiple times) at attrfind time.

attrfind_tolerant : I see no point in the old/strict attrfind. (and the 
difference is guessed 0.000% of real cases). attrfind_tolerant  could become 
the only attrfind.


--

locatestarttagend_tolerant = re.compile(r
  [a-zA-Z][-.a-zA-Z0-9:_]*  # tag name
  (?:(?:\s+|(\s*))   # optional whitespace before attribute name
(?:[a-zA-Z_][-.:a-zA-Z0-9_]* # attribute name
  (?:\s*=\s* # value indicator
(?:'[^']*'   # LITA-enclosed value
  |\[^\]*\# LIT-enclosed value
  |[^'\\s]+# bare value
 )
 (?:\s*(,))*   # possibly followed by a comma
   )?
 )
   )*
  \s*# trailing whitespace
, re.VERBOSE)
attrfind_tolerant = re.compile(
r'\s*([a-zA-Z_][-.:a-zA-Z_0-9]*)(\s*=\s*'
r'(\'[^\']*\'|[^]*|[^\s]*))?')


#s='abc a=b,+c=de=ftext'
#s='abc a=b,+ c=de=ftext'
s='abc a=b,+,c=d e=ftext'

m = locatestarttagend_tolerant.search(s)
print m.group()
print m.groups()
#if m.group(1) is not None: self.warning('space missing ...
#if m.group(2) is not None: self.warning('comma between attr...

m = attrfind_tolerant.search(s, 5)
print m.group()
print m.groups()

--

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



[issue13294] http.server: HEAD request should not return a body

2011-11-16 Thread Michele Orrù

Michele Orrù maker...@gmail.com added the comment:

Well, actually SimpleHTTPRequesthandler extends BaseHTTPHandler with basic 
do_GET and do_HEAD methods.

Unittests for http.server shows that this behavior is intended, since: 
Traceback (most recent call last):
  File Lib/test/test_httpservers.py, line 639, in module
test_main()
  File Lib/test/test_httpservers.py, line 633, in test_main
SimpleHTTPRequestHandlerTestCase,
  File /Users/maker/dev/cpython/Lib/test/support.py, line 1274, in 
run_unittest
_run_suite(suite)
  File /Users/maker/dev/cpython/Lib/test/support.py, line 1249, in _run_suite
raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
  File Lib/test/test_httpservers.py, line 273, in test_head
self.check_status_and_reason(response, 200)
  File Lib/test/test_httpservers.py, line 242, in check_status_and_reason
self.assertEqual(response.status, status)
AssertionError: 501 != 200

So, imho this is not a bug. Anyway, I would propose a trivial patch to make 
http.server a little more elegant.

--
keywords: +patch
nosy: +maker
Added file: http://bugs.python.org/file23711/issue13294.patch

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



[issue1486713] HTMLParser : A auto-tolerant parsing mode

2011-11-16 Thread Ezio Melotti

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

Note that the regex and the way the parser considers the commas changed in 
16ed15ff0d7c (it now considers them as the name of a value-less attribute), so 
adding a group for the comma is no longer doable.

In theory, the approach you suggest might work, but if we want some warning 
mechanism it should be generic enough to work with all kind of invalid markup.  
In addition this adds complexity to already complex regular expressions, so 
there should be a valid use case for this.
Also keep in mind that HTMLParser won't do any check about the validity of the 
elements' names or attributes' names/values, or even if they are nested/closed 
correctly, so even with a comprehensive set of warnings, you won't still be 
able to use HTMLParser to validate your pages.

--
nosy: +eric.araujo

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



[issue9102] pybench: Cannot compare 2.x and 3.x benchmarks

2011-11-16 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti
versions: +Python 3.3

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



[issue3693] Obscure array.array error message

2011-11-16 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti
versions: +Python 3.3 -Python 3.1

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



[issue13413] time.daylight incorrect behavior in linux glibc

2011-11-16 Thread Antoine Pitrou

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


--
nosy: +belopolsky, lemburg

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



[issue4246] execution model - clear and complete example in documentation

2011-11-16 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti
stage:  - needs patch
versions: +Python 2.7, Python 3.3

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



[issue6304] Confusing error message when passing bytes to print with file pointing to a binary file

2011-11-16 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +pitrou
versions: +Python 3.3 -Python 3.1

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



[issue1486713] HTMLParser : A auto-tolerant parsing mode

2011-11-16 Thread kxroberto

kxroberto kxrobe...@users.sourceforge.net added the comment:

16ed15ff0d7c was not in current stable py3.2 so I missed it..

When the comma is now raised as attribute name, then the problem is anyway 
moved to the higher level anyway - and is/can be handled easily there by usual 
methods.
(still I guess locatestarttagend_tolerant matches a free standing comma extra 
after an attribute)

should be generic enough to work with all kind of invalid markup: I think we 
would be rather complete then (-missing space issue)- at least regarding %age 
of real cases. And it could be improved with few touches over time if something 
missing. 100% is not the point unless it shall drive the official W3C checker. 
The call of self.warning, as in old patch, doesn't cost otherwise and I see no 
real increase of complexity/cpu-time.

HTMLParser won't do any check about the validity of the elements' names or 
attributes' names/values: yes thats of course up to the next level handler 
(BTDT)- thus the possibilty of error handling is not killed. Its about what 
HTMLParser _hides_ irrecoverably.

there should be a valid use case for this: Almost any app which parses HTML 
(self authored or remote) can have (should have?) a no-fuzz/collateral warn log 
option. (-no need to make a expensive W3C checker session). I mostly have this 
in use as said, as it was anyway there.

Well, as for me, I use anyway a private backport to Python2 of this. I try to 
avoid Python3 as far as possible. (No real plus, too much problems) So for me 
its just about joining Python4 in the future perhaps - which can do true 
CPython multithreading, stackless, psyco/static typing ... and print statement 
again without typing so many extra braces ;-)
I considered extra libs like the HTML tidy binding, but this is all too much 
fuzz for most cases. And HTMLParser has already quite everything, with the few 
calls inserted ..

--

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



[issue1486713] HTMLParser : A auto-tolerant parsing mode

2011-11-16 Thread Ezio Melotti

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

 16ed15ff0d7c was not in current stable py3.2 so I missed it..

It's also in 3.2 and 2.7 (but it's quite recent, so if you didn't pull recently 
you might have missed it).

 When the comma is now raised as attribute name, then the problem is 
 anyway moved to the higher level anyway - and is/can be handled easily 
 there by usual methods.

The next level could/should validate the name of the attribute and determine 
that ',' is not a valid attribute name, so in this case there's no warning to 
raise here (actually you could detect that it's not a-zA-Z (or whatever the 
specs say) and raise a more general warning even at this level, but no 
information is lost here about this).

 100% is not the point unless it shall drive the official W3C checker.

I'm still not sure that having 70-80% is useful (unless we can achieve 100% on 
this level and leave the rest to an upper layer).  If you think this is doable 
you could try to first identify what errors should be detected by this layer, 
see if they are all detectable and then propose a patch.

 The call of self.warning, as in old patch, doesn't cost otherwise and
 I see no real increase of complexity/cpu-time.

The extra complexity is mainly in the already complex regular expressions, and 
also in the list of 'if' that will have to check the content of the groups to 
report the warnings.  These changes are indeed not too invasive, but they still 
make the code more complicated.

 Almost any app which parses HTML (self authored or remote) can have 
 (should have?) a no-fuzz/collateral warn log option. (-no need to 
 make a expensive W3C checker session).

I think the original goal of HTMLParser was parsing mostly-valid HTML.  People 
started reporting issues with less-valid HTML, and these issues got fixed to 
make it able to parse non-valid HTML.  AFAIK it never followed strictly any 
HTML standard, and it just provided a best-effort way to get data out of an 
HTML page.  So, I would consider doing validation or even being a building 
block for a conforming parser out of the scope of the module.

 I mostly have this in use as said, as it was anyway there.

If 'this' refers to some kind of warning system, what do you do with these 
warnings?   Do you fix them, avoid using the w3c validator (or any other 
conforming validator) and consider a mostly-valid page good enough?  Or do you 
fix them, and then you also check with the w3c validator?

--

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



[issue1481032] patch smtplib:when SMTPDataError, rset crashes with sslerror

2011-11-16 Thread Antoine Pitrou

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


--
nosy: +barry, r.david.murray -BreamoreBoy

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



[issue4508] distutils compiler not handling spaces in path to output/src files

2011-11-16 Thread ipatrol

ipatrol ipatrol6...@yahoo.com added the comment:

Ok, I found a similar problem with MMTK. I am currently altering my distutils 
package to add a function called nt_quote_dir that adds quotes to paths with 
spaces and then applies it to each path if the platform is win32. When I'm done 
I will submit a diff after confirming that it works.

--
components: +Extension Modules, Windows
nosy: +ipatrol

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



[issue9102] pybench: Cannot compare 2.x and 3.x benchmarks

2011-11-16 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
nosy: +flox

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



[issue13309] test_time fails: time data 'LMT' does not match format '%Z'

2011-11-16 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
status: pending - closed

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



[issue13126] find() slower than rfind()

2011-11-16 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
priority: low - normal
stage:  - patch review

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



[issue8913] Document that datetime.__format__ is datetime.strftime

2011-11-16 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
type:  - behavior
versions: +Python 3.3 -Python 2.6, Python 3.1

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



[issue6715] xz compressor support

2011-11-16 Thread Antoine Pitrou

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

What is the status on this, Nadeem? It would be lovely to get the feature in 
the stdlib.

--

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



[issue6715] xz compressor support

2011-11-16 Thread Amaury Forgeot d'Arc

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

I just added the missing files liblzma.a to the externals repository.
If someone can quickly check that it works on win32, I don't have anything else 
to add to this change.

--

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



[issue6715] xz compressor support

2011-11-16 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

Everything is ready to go, as far as I'm concerned. Once I've tested the
Windows build using the binary from the externals repository, I'll be ready
to commit it to the main repository.

--

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



[issue6715] xz compressor support

2011-11-16 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

I've tested the Windows build, and it works fine. If there are no objections,
I'll commit on Saturday.

Btw, what is the preferred channel for communicating with buildbot owners?
I'll want to send out an email asking that all the *nix bots have
liblzma-dev installed, so that they can actually run the tests...

--

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



[issue13415] os.unsetenv() on Windows should not use UTF-8

2011-11-16 Thread STINNER Victor

New submission from STINNER Victor victor.stin...@haypocalc.com:

os.unsetenv(name) encodes name to UTF-8. I think that the ANSI code page (or 
another code page?) should be used.

--
components: Unicode, Windows
messages: 147773
nosy: ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: os.unsetenv() on Windows should not use UTF-8
versions: Python 3.2, Python 3.3

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



[issue13064] Port codecs and error handlers to the new Unicode API

2011-11-16 Thread STINNER Victor

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

Martin von Loewis implemented this issue, thanks Martin!

--

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



[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py

2011-11-16 Thread STINNER Victor

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


--
resolution:  - fixed
status: open - closed

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



[issue13374] Deprecate usage of the Windows ANSI API in the nt module

2011-11-16 Thread Roundup Robot

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

New changeset 5f239b0ba819 by Victor Stinner in branch 'default':
Issue #13374: Deprecate os.getcwdb() on Windows
http://hg.python.org/cpython/rev/5f239b0ba819

--

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



[issue12729] Python lib re cannot handle Unicode properly due to narrow/wide bug

2011-11-16 Thread Antoine Pitrou

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

Closing this bug as PEP 393 is now implemented and makes so-called narrow 
builds obsolete. Python now has an adaptative internal representation that is 
able to fit all unicode characters.

--
resolution:  - out of date
stage:  - committed/rejected
status: open - closed

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



[issue13374] Deprecate usage of the Windows ANSI API in the nt module

2011-11-16 Thread STINNER Victor

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


--
resolution:  - fixed
status: open - closed

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



[issue13416] Python Tutorial, Section 3, Minor PEP 8 adjustment

2011-11-16 Thread Nebelhom

New submission from Nebelhom nebel...@googlemail.com:

Python Tutorial 3.3a

3. An informal introduction to python

example:

-
# this is the first comment
SPAM = 1 # and this is the second comment
 # ... and now a third!
STRING = # This is not a comment.
-

Comment: It is probably best to use PEP 8 straight from the start.
Therefore variable names should be all lowercase with connecting underscores 
(if necessary)

i.e. spam = 1 and string = #This is not a comment. instead of all uppercase.

--
assignee: docs@python
components: Documentation
messages: 14
nosy: Nebelhom, docs@python, ncoghlan
priority: normal
severity: normal
status: open
title: Python Tutorial, Section 3, Minor PEP 8 adjustment
versions: Python 3.3

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



[issue13417] faster utf-8 decoding

2011-11-16 Thread Antoine Pitrou

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

PEP 393 and the need for a two-pass decoding process has made utf-8 decoding 
much slower, especially with the current generic implementation. Attached patch 
makes utf-8 more than twice faster, which means we're around 10-20% slower than 
3.2 on non-trivial cases.

--
components: Interpreter Core
files: utf8lib2.patch
keywords: patch
messages: 147778
nosy: haypo, pitrou
priority: normal
severity: normal
stage: patch review
status: open
title: faster utf-8 decoding
type: performance
versions: Python 3.3
Added file: http://bugs.python.org/file23712/utf8lib2.patch

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



[issue13416] Python Tutorial, Section 3, Minor PEP 8 adjustment

2011-11-16 Thread Benjamin Peterson

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

It's fine as it is; constants are often denoted with capital letters.

--
nosy: +benjamin.peterson
resolution:  - rejected
status: open - closed

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



[issue10772] Several actions for argparse arguments missing from docs

2011-11-16 Thread Marc Sibson

Marc Sibson sib...@gmail.com added the comment:

changes as per the review,

--
Added file: http://bugs.python.org/file23713/issue10772.patch3

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



[issue13415] os.unsetenv() on Windows should not use UTF-8

2011-11-16 Thread Amaury Forgeot d'Arc

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

But... there is no os.unsetenv on Windows!
2.7 used to have one, which called os.putenv(key, )
3.2 has a os._unsetenv, which is a lambda key: _putenv(key, )

--
nosy: +amaury.forgeotdarc

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



[issue13215] multiprocessing Manager.connect() aggressively retries refused connections

2011-11-16 Thread Antoine Pitrou

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

Apparently you forgot to upload the patch...

--

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



[issue13415] del os.environ[key] ignores errors

2011-11-16 Thread STINNER Victor

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

 But... there is no os.unsetenv on Windows!

Correct, even unsetenv() doesn't exist on Windows: putenv() can be used to 
unset a variable using an empty value. And it's exactly what Python does.

It is confusing because posix_unsetenv() is not build on Windows, but it 
contains code specific for Windows.

While testing del os.environ[key], I found another bug: del 
os.environ['x'*5] does crash Python on Windows.

Attached patch (for Python 3.3) does:

 - Remove the Windows specific code from posix_unsetenv()
 - Check if unsetenv() failed on UNIX
 - Check environment variable length on Windows

The Windows bug does affect Python 2.7 too. Check if unsetenv() failed on 
UNIX change may be skipped on Python 2.7 and 3.2.

--
keywords: +patch
title: os.unsetenv() on Windows should not use UTF-8 - del os.environ[key] 
ignores errors
versions: +Python 2.7
Added file: http://bugs.python.org/file23714/unsetenv.patch

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



[issue6715] xz compressor support

2011-11-16 Thread Antoine Pitrou

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

I've tested under 64-bit Windows and it worked fine.

--

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



  1   2   >