DEAP 0.8 released - Distributed Evolutionary Algorithms in Python
Hi everyone, We are proud to annouce the release of DEAP 0.8, a library for doing Distributed Evolutionary Algorithms in Python. You can download a copy of this release at the following web page. http://deap.googlecode.com This release includes : - compatibility with Python 3; - a new algorithm : generate-update - a lot of new examples; - a lot of new benchmarks; - History can now return the genealogy of a single individual; - C++ version of the NSGA-2 algorithm - more detailed documentation with new tutorials and examples; - new theme for the documentation; - and many more. Users of DEAP 0.7 should be aware that some of the modifications included with 0.8 will break your code. Be sure to check the this page : http://code.google.com/p/deap/wiki/Break to find out the minor modifications that are needed to get your code fully functionnal with 0.8. We are also proud to announce the creation of the DEAP speed project which aims at benchmarking on a daily basis the execution time of every examples provided with DEAP. Details of the project and the results are available at the following web page. http://deap.gel.ulaval.ca/speed Your feedback and comments are welcome at http://goo.gl/2HiO1 or deap-users at googlegroups dot com. You can also follow us on Twitter @deapdev, and on our blog http://deapdev.wordpress.com/. Best, François-Michel De Rainville Félix-Antoine Fortin Marc-André Gardner Christian Gagné Marc Parizeau Laboratoire de vision et systèmes numériques Département de génie électrique et génie informatique Université Laval Quebec City (Quebec), Canada -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Python Gotcha's?
On Apr 5, 10:36 pm, rusi rustompm...@gmail.com wrote: On Apr 6, 9:54 am, Steve Howell showel...@yahoo.com wrote: JS, YAML, and HTML are pretty similar to Python with respect to single vs. double, as far as I know/remember/care. [Complete ignoramus here -- writing after a few minutes of googling] YAML:http://yaml.org/spec/current.html#single%20quoted%20style/syntax seems to indicate that the double-quote is multi-lineable the single not. [So YAML double-quote is like python triple-quote] JS:http://stackoverflow.com/questions/242813/when-to-use-double-or-singl... seems to have some arcane argument about whether there is a difference or not I like the fact that even this seemingly harmless statement on the stackoverflow thread invites (light-hearted) controversy: Double quotes will wear your shift key out faster :) The response is this: Not on Azerty, buddy. And, yes, I am quoting via indentation here. But quoting is not a gotcha. Not in the least bit. Anybody who says quoting is a gotcha just doesn't understand how simple this whole quoting business is. Quoting is completely straightforward. Just read the specs, I think some wise person said earlier in this thread. They're completely correct, of course. No gotchas here. Move along... -- http://mail.python.org/mailman/listinfo/python-list
Reading Live Output from a Subprocess
Okay, I've been trying for days to figure this out, posting on forums, Googling, whatever. I have yet to find a solution that has worked for me. (I'm using Python 3.2.2, Ubuntu 11.04.) Everything I've tried has led to buffered output being spat back all at once after the subprocess terminates. I need this functionality because the script I am currently writing is only glue, and most of the work is done by a subprocess (which could potentially run for a long time). Here are some StackOverflow questions about this topic: http://stackoverflow.com/questions/2525263/capture-subprocess-output http://stackoverflow.com/questions/2996887/how-to-replicate-tee-behavior-in-python-when-using-subprocess http://stackoverflow.com/questions/803265/getting-realtime-output-using-subprocess http://stackoverflow.com/questions/1183643/unbuffered-read-from-process-using-subprocess-in-python http://stackoverflow.com/questions/527197/intercepting-stdout-of-a-subprocess-while-it-is-running And a few others for good measure: http://www.linuxquestions.org/questions/programming-9/python-how-do-you-capture-stdout-stream-from-external-program-612998/ http://devlishgenius.blogspot.com/2008/10/logging-in-real-time-in-python.html Not a single one of the solutions above has worked for me. I've tried ## import subprocess as sub out = sub.Popen([pypy, 5], universal_newlines=True, stdout=sub.PIPE, stderr=sub.STDOUT, bufsize=1) line = out.stdout.readline() out.stdout.flush() while line: print(line) line = out.stdout.readline() out.stdout.flush() ## I've tried ## line = out.stdout.readline() while line: print(line) line = out.stdout.readline() ## I've tried ## for line in out.readline(): print(line) ## I've tried ## for line in out.communicate(): print(line) ## etc... None have worked, and it seems that the while loops worked in Python 2.x (according to those links), but not in Python 3. (I am a two week old Python coder, and it's already tied for my strongest language, which is why I decided to start with Python 3.) I've heard that the Pexpect module works wonders, but the problem is that relies on pty which is available in Unix only. Additionally, because I want this script to be usable by others, any solution should be in the standard library, which means I'd have to copy the Pexpect code into my script to use it. Is there any such solution in the Python 3 Standard Library, and if not, how much of a thorn is this? There should be one-- and preferably only one --obvious way to do it. Unfortunately, this is one case where the above is true for Perl but not Python. Such an example in Perl is open(PROG, command |) or die Couldn't start prog!; while (PROG) { print $_; } (Note that I do not know Perl and do not have any intentions to learn it; the above comes from the script I was previously copying and extending, but I imagine (due to its simplicity) that it's a common Perl idiom. Note however, that the above does fail if the program re-prints output to the same line, as many long-running C programs do. Preferably this would also be caught in a Python solution.) If there is a general consensus that this is a problem for lots of people, I might consider writing a PEP. Of course, my highest priority is solving the blasted problem, which is holding up my script at the moment. (I can work around this by redirecting the program to a tmp file and reading that, but that would be such a perilous and ugly kludge that I would like to avoid it if at all possible.) Thanks, Bill -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading Live Output from a Subprocess
On Thu, Apr 5, 2012 at 11:57 PM, buns...@gmail.com wrote: Okay, I've been trying for days to figure this out, posting on forums, Googling, whatever. I have yet to find a solution that has worked for me. (I'm using Python 3.2.2, Ubuntu 11.04.) Everything I've tried has led to buffered output being spat back all at once after the subprocess terminates. I need this functionality because the script I am currently writing is only glue, and most of the work is done by a subprocess (which could potentially run for a long time). snip Not a single one of the solutions above has worked for me. I've tried ## import subprocess as sub out = sub.Popen([pypy, 5], universal_newlines=True, stdout=sub.PIPE, stderr=sub.STDOUT, bufsize=1) line = out.stdout.readline() out.stdout.flush() while line: print(line) line = out.stdout.readline() out.stdout.flush() You're flush()-ing the wrong stream here. The process's stdout is an incoming stream from Python's perspective, which makes flushing it pointless AFAIK. You want to flush *Python*'s stdout (that you're print()-ing to). Which would be: import sys for line in out.stdout: print(line) sys.stdout.flush() ## I've tried ## line = out.stdout.readline() while line: print(line) line = out.stdout.readline() Less repetitively written: while True: line = out.stdout.readline() if not line: break print(line) Or more idiomatically written: # I hope this was the first thing you tried? for line in out.stdout: print(line) ## I've tried ## for line in out.readline(): print(line) (I assume you meant out.stdout? out is a bad name anyway; it's a process, not an output stream.) This iterates over individual characters in the first line of the output. In for X in Y, Y only gets evaluated once. ## I've tried ## for line in out.communicate(): print(line) That's the explicitly-documented-as-blocking method, the exact opposite of what you want. Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
numpy.genfromtxt with Python3 - howto
Hi I have a machine with a non-UTF8 local. I can't figure out how to make numpy.genfromtxt work I pipe some ascii data into the following script but get this bytes to str hell. Many thanks for a hint, Helmut. #!/usr/bin/python3 import numpy as np import io import sys inpstream = io.open(sys.stdin.fileno(), r, encoding='latin1') data = np.genfromtxt(inpstream) ''' Traceback (most recent call last): File SimpleMatInp.py, line 8, in module data = np.genfromtxt(inpstream) File /usr/lib64/python3.2/site-packages/numpy/lib/npyio.py, line 1274, in genfromtxt first_values = split_line(first_line) File /usr/lib64/python3.2/site-packages/numpy/lib/_iotools.py, line 206, in _delimited_splitter line = line.split(self.comments)[0].strip(asbytes( \r\n)) TypeError: Can't convert 'bytes' object to str implicitly ''' print(data) print(data.dtype) print(data.shape) -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading Live Output from a Subprocess
On Thu, 05 Apr 2012 23:57:49 -0700, bunslow wrote: Okay, I've been trying for days to figure this out, posting on forums, Googling, whatever. I have yet to find a solution that has worked for me. (I'm using Python 3.2.2, Ubuntu 11.04.) Everything I've tried has led to buffered output being spat back all at once after the subprocess terminates. In all probability, this is because the child process (pypy) is buffering its stdout, meaning that the data doesn't get passed to the OS until either the buffer is full or the process terminates. If it doesn't get passed to the OS, then the OS can't pass it on to whatever is on the read end of the pipe. In that situation, there is nothing that the parent process can do about it. I've heard that the Pexpect module works wonders, If it does, that would confirm the buffering hypothesis. Pexpect causes the child process' stdout to be associated with a pty. The stdout stream created by the C library (libc) is initially line-buffered if it is associated with a tty (according to the isatty() function) and fully-buffered otherwise. The program can change the buffering with e.g. setvbuf(), or it can explicitly fflush(stdout) after each line, but this is up to the program, and is not something which can be controlled externally (short of hacking the child process with techniques such as ptrace() or LD_PRELOAD). While the libc behaviour is occasionally inconvenient, it is mandated by the C standard (7.19.3p7): As initially opened, the standard error stream is not fully buffered; the standard input and standard output streams are fully buffered if and only if the stream can be determined not to refer to an interactive device. It's up to individual programs to force line-buffered output where appropriate (e.g. GNU grep has the --line-buffered switch, GNU sed has the -u switch, etc). -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Kernighan and Plauger's RATFOR (a pre-processor that added some C-like syntax to FORTRAN) did that. Published in their book _Software Tools_. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: escaping/encoding/formatting in python
On Thu, 05 Apr 2012 22:28:19 -0700, rusi wrote: All this mess would vanish if the string-literal-starter and ender were different. You still need an escape character in order to be able to embed an unbalanced end character. Tcl and PostScript use mirrored string delimiters (braces for Tcl, parentheses for PostScript), which results in the worst of both worlds: they still need an escape character (backslash, in both cases) but now you can't match tokens with a regexp/DFA. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
In article jlmaid$hum$1...@dont-email.me, mwil...@the-wire.com wrote: rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Kernighan and Plauger's RATFOR (a pre-processor that added some C-like syntax to FORTRAN) did that. Published in their book _Software Tools_. I used to write a lot of code in RATFOR. It was really a pretty good tool. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
Roy Smith wrote: In article jlmaid$hum$1...@dont-email.me, mwil...@the-wire.com wrote: rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Kernighan and Plauger's RATFOR (a pre-processor that added some C-like syntax to FORTRAN) did that. Published in their book _Software Tools_. I used to write a lot of code in RATFOR. It was really a pretty good tool. ISTR that RATFOR also concatenated adjacent quoted strings to build up long strings. That sort of puts the capstone on the two-quote-characters scheme. I can't lay my hands on the book to prove it. GE/Honeywell FORTRAN stole the single quote to delimit seek addresses in I/O statements, so my RATFOR implementations had to lose the two-quote feature and use a two-for-one scheme, like backslash-escaping and % inclusion in moduloed strings do in Python. Mel. -- http://mail.python.org/mailman/listinfo/python-list
Re: escaping/encoding/formatting in python
On Apr 6, 1:52 pm, Nobody nob...@nowhere.com wrote: On Thu, 05 Apr 2012 22:28:19 -0700, rusi wrote: All this mess would vanish if the string-literal-starter and ender were different. You still need an escape character in order to be able to embed an unbalanced end character. Tcl and PostScript use mirrored string delimiters (braces for Tcl, parentheses for PostScript), which results in the worst of both worlds: they still need an escape character (backslash, in both cases) but now you can't match tokens with a regexp/DFA. Yes. I hand it to you that I missed the case of explicitly unbalanced strings. But are not such cases rare? For example code such as: print '' print str(something) print '' could better be written as print '%s' % str(something) -- http://mail.python.org/mailman/listinfo/python-list
Re: escaping/encoding/formatting in python
06.04.12 08:28, rusi написав(ла): All this mess would vanish if the string-literal-starter and ender were different. [You dont need to escape a open-paren in a lisp sexp] But you need to escape an escape symbol. -- http://mail.python.org/mailman/listinfo/python-list
Re: escaping/encoding/formatting in python
06.04.12 16:22, rusi написав(ла): Yes. I hand it to you that I missed the case of explicitly unbalanced strings. But are not such cases rare? No, unfortunately. }:-( For example code such as: print '' print str(something) print '' could better be written as print '%s' % str(something) Don't forget to escape %. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
On Thu, 05 Apr 2012 21:28:01 -0700, rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML, Modula-2, HTML, and (of course) English. There may be others. Other languages like Perl, PHP and Ruby support alternate delimiters with slightly different semantics. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
On 06.04.2012, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wroted: Are there languages (other than python) in which single and double quotes are equivalent? Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML, Modula-2, HTML, and (of course) English. There may be others. Other languages like Perl, PHP and Ruby support alternate delimiters with slightly different semantics. Perl, first of all, has the 'q' and 'qq' operators. As much as I'd come to dislike Perl after I discovered Python, I miss those two. Every time I have to quote a string full of single/double quotes, this comes to my mind: q{'this' is not this, but 'that' is 'that' like 'this'} q|'this' is not this, but 'that' is 'that' like 'this'| q'this' is not this, but 'that' is 'that' like 'this' ... with 'qq' providing the version with inerpolation. I could always find an arbitrary character for quoting that was _not_ present in the string, and so, most of the time, avoid quoting altogether. It was perhaps a bit too magical, but pruced very readable strings. GS -- Grzegorz Staniak gstaniak _at_ gmail [dot] com -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating custom Windows installers
I'm still getting my feet wet on the Windows side of things with Python, so I apologize for the noobish question. If i am reading the create_link.py example correctly, that is created when the application itself is invoked, not during installation. Is that correct? If it is, how would I be able to invoke that when generating the MSI so that the installer creates the shortcut? Cesar On Thu, Apr 5, 2012 at 8:42 PM, Mark Hammond skippy.hamm...@gmail.comwrote: Seeing you are relying on win32com, you might as well add the links directly rather than via the intermediate WScript.shell object. Look in win32comext\shell\demos\**create_link.py for an example of how to create shortcuts directly. HTH, Mark On 6/04/2012 5:23 AM, cesar.covarrub...@gmail.com wrote: Hello, I am working on creating an installer of a Python 3.2 application that we programmed. The end goal is to create an installer in which we can specify the install path, and create shortcuts in the Start Menu and Desktop. Ideally, we would like to give the users the option to create the Desktop or Start Menu shortcuts. I was able to create a .msi file with the setup.py and install.py files below. This allowed me to specify the custom default path but not create the shortcut in the Start Menu. Can anyone help me figure out what I'm missing? setup.py from cx_Freeze import setup, Executable import sys productName = ProductName if 'bdist_msi' in sys.argv: sys.argv += ['--initial-target-dir', 'C:\InstallDir\\' + productName] sys.argv += ['--install-script', 'install.py'] exe = Executable( script=main.py, base=Win32GUI, targetName=Product.exe ) setup( name=Product.exe, version=1.0, author=Me, description=Copyright 2012, executables=[exe], scripts=[ 'install.py' ] ) --**--- install.py -- import os import sys import win32com.client as w32client shortcut_group_name = Start Menu Dir shortcut_name = Product Name shortcut_target = http://www.microsoft.com; sh = w32client.Dispatch(WScript.**Shell) p = sh.SpecialFolders(**AllUsersPrograms) assert(os.path.isdir(p)) p = os.path.join(p, shortcut_group_name) if (not os.path.isdir(p)): os.makedirs(p) lnk = sh.CreateShortcut(os.path.**join(p, shortcut_name + .lnk)) lnk.TargetPath = shortcut_target lnk.Save() -- Very Respectfully, Cesar Covarrubias -- http://mail.python.org/mailman/listinfo/python-list
Re: [Savoynet] list settings
On Sat, Apr 7, 2012 at 12:50 AM, Freed freeda...@aol.com wrote: New here. The list is set so that ‘reply’ goes only to the sender, not the list. Is that intentional? Most lists are set so that ‘reply’ goes to the list by default. Doesn’t look like I can change that for emails that come to me, can I? I don't think you can change that, it's part of the list configuration. But here's the rationale as given for another list that has the same setup: If the default reply-to is the list, then private replies risk being sent to the list; but if default reply is to the single sender, the only risk is that you then have to re-send to the list. You can't un-send something once hundreds of people have seen it; you CAN re-send so that the correct people get to see it. Also, you can always use Reply-All to send to the list. I don't like this, though, as it ends up sending to the original poster and also to the list, and if multiple people start doing this, the To line starts to get unnecessarily long. However, it does work; and it's something that has no equivalent in the alternative arrangement - you can't use any default form of sending to choose to make your message more private. My personal habit is to write up my reply, then choose one of three ways to send: 1) Hit Send, and communicate only with one person 2) Replace the To: address with the list's and hit Send 3) Hit Discard because the post isn't worth sending after all. Option 2 does have some risk, of course. I've sometimes replied to a completely wrong list (mainly between the two most active lists I'm a member of, they being python-list and one about Gilbert and Sullivan operas called Savoynet), which is embarrassing but not a breach of privacy (both lists are archived publicly); it would be far worse to snap off a quick reply to someone that includes private details like user names and passwords, and then to find you sent it to every subscriber on the list... All in all, I prefer the current situation. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
[ANN]: asyncoro: Framework for asynchronous programming with coroutines
I posted this message earlier to the list, but realized that URLs appear broken with '.' at the end of URL. Sorry for that mistake and this duplicate! asyncoro is a framework for developing concurrent programs with asynchronous event completions and coroutines. Asynchronous completions currently implemented in asyncoro are socket I/O operations, sleep timers, (conditional) event notification and semaphores. Programs developed with asyncoro will have same logic as Python programs with synchronous sockets and threads, except for a few syntactic changes. asyncoro supports polling mechanisms epoll, kqueue, /dev/poll (and poll and select if necessary), and Windows I/O Completion Ports (IOCP) for high performance and scalability, and SSL for security. More details about asyncoro are at http://dispy.sourceforge.net/asyncoro.html and can be downloaded from https://sourceforge.net/projects/dispy/files asyncoro is used in development of dispy (http://dispy.sourceforge.net), which is a framework for parallel execution of computations by distributing them across multiple processors on a single machine (SMP), multiple nodes in a cluster, or large clusters of nodes. The computations can be standalone programs or Python functions. Both asyncoro and dispy have been tested with Python versions 2.7 and 3.2 under Linux, OS X and Windows. Cheers, Giri-- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
On Apr 6, 6:55 pm, Steven D'Aprano steve +comp.lang.pyt...@pearwood.info wrote: On Thu, 05 Apr 2012 21:28:01 -0700, rusi wrote: Are there languages (other than python) in which single and double quotes are equivalent? Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML, Modula-2, HTML, and (of course) English. There may be others. Other languages like Perl, PHP and Ruby support alternate delimiters with slightly different semantics. -- Steven Prolog: seems to be different, see http://stackoverflow.com/questions/4391435/how-to-manipulate-strings-in-prolog yaml: double seems to be like python triple, ie multi-line allowed whereas single does not allow multi-line http://yaml.org/spec/current.html#single%20quoted%20style/syntax -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
* Steven D'Aprano wrote: On Thu, 05 Apr 2012 23:08:11 +0200, André Malo wrote: * Steven D'Aprano wrote: For a 21st century programming language or data format to accept only one type of quotation mark as string delimiter is rather like having a 21st century automobile with a hand crank to start the engine instead of an ignition. Even if there's a good reason for it (which I doubt), it's still surprising. Here's a reason: KISS. KISS is a reason *for* allowing multiple string delimiters, not against it. The simplicity which matters here are: * the user doesn't need to memorise which delimiter is allowed, and which is forbidden, which will be different from probably 50% of the other languages he knows; * the user can avoid the plague of escaping quotes inside strings whenever he needs to embed the delimiter inside a string literal. This is the 21st century, not 1960, and if the language designer is worried about the trivially small extra effort of parsing ' as well as then he's almost certainly putting his efforts in the wrong place. Yes, that's what you said already. My reasoning was in the part you stripped from my quote. *shrug* nd -- Treat your password like your toothbrush. Don't let anybody else use it, and get a new one every six months. -- Clifford Stoll (found in ssl_engine_pphrase.c) -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
On Apr 6, 7:18 pm, Grzegorz Staniak gstan...@gmail.com wrote: On 06.04.2012, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wroted: Are there languages (other than python) in which single and double quotes are equivalent? Classic REXX, CSS, JavaScript, Lua, Prolog, XPath, YAML, Modula-2, HTML, and (of course) English. There may be others. Other languages like Perl, PHP and Ruby support alternate delimiters with slightly different semantics. Perl, first of all, has the 'q' and 'qq' operators. As much as I'd come to dislike Perl after I discovered Python, I miss those two. Every time I have to quote a string full of single/double quotes, this comes to my mind: q{'this' is not this, but 'that' is 'that' like 'this'} q|'this' is not this, but 'that' is 'that' like 'this'| q'this' is not this, but 'that' is 'that' like 'this' ... with 'qq' providing the version with inerpolation. I could always find an arbitrary character for quoting that was _not_ present in the string, and so, most of the time, avoid quoting altogether. It was perhaps a bit too magical, but pruced very readable strings. Yes the q of perl is qute and qlever. Come to think of it its very sensible because it factors delimition from quoting just as the () and ' do for lisp. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
On Apr 6, 8:40 pm, André Malo ndpar...@gmail.com wrote: * Steven D'Aprano wrote: On Thu, 05 Apr 2012 23:08:11 +0200, André Malo wrote: * Steven D'Aprano wrote: For a 21st century programming language or data format to accept only one type of quotation mark as string delimiter is rather like having a 21st century automobile with a hand crank to start the engine instead of an ignition. Even if there's a good reason for it (which I doubt), it's still surprising. Here's a reason: KISS. KISS is a reason *for* allowing multiple string delimiters, not against it. The simplicity which matters here are: * the user doesn't need to memorise which delimiter is allowed, and which is forbidden, which will be different from probably 50% of the other languages he knows; * the user can avoid the plague of escaping quotes inside strings whenever he needs to embed the delimiter inside a string literal. This is the 21st century, not 1960, and if the language designer is worried about the trivially small extra effort of parsing ' as well as then he's almost certainly putting his efforts in the wrong place. Yes, that's what you said already. My reasoning was in the part you stripped from my quote. *shrug* Multiple symmetric quote characters breaks one of python's own zen rules: There should be one-- and preferably only one --obvious way to do it. -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
On 06.04.2012, rusi rustompm...@gmail.com wroted: This is the 21st century, not 1960, and if the language designer is worried about the trivially small extra effort of parsing ' as well as then he's almost certainly putting his efforts in the wrong place. Yes, that's what you said already. My reasoning was in the part you stripped from my quote. *shrug* Multiple symmetric quote characters breaks one of python's own zen rules: There should be one-- and preferably only one --obvious way to do it. Then again, practicality beats purity. GS -- Grzegorz Staniak gstaniak _at_ gmail [dot] com -- http://mail.python.org/mailman/listinfo/python-list
Re: Async IO Server with Blocking DB
We are thinking about building a webservice server and considering python event-driven servers i.e. Gevent/Tornado/ Twisted or some combination thereof etc. We are having doubts about the db io part. Even with connection pooling and cache, there is a strong chance that server will block on db. Blocking for even few ms is bad. Libraries that support the event loop of your framework, be it Gevent, Tornado or Twisted, should yield to other work when the database connection (its socket) blocks. Now, database drivers that use C libraries are ussually a problem, unless designed to cooperate with event loops. One of those is psycopg2 which at least cooperates with Gevent. CouchDBkit (using restkit ie http) also cooperates with Gevent fine. MySQLdb does not cooperate with Gevent as far as I know, so one sollution would be to run queries through a Thread Pool (built-in in Gevent 1.0dev). Another is to use the pure python mysqlconn (mysql-connector-repackaged on pypi) with gevents monkey patching. Sqlite should be probably run in a ThreadPool too, since it depends on disk I/O which is not async in Gevent. You can readup on Gevent integration of Couchdbkit and Psycopg2 in their documentation. can someone suggest some solutions or is async-io is not at the prime- time yet. -- damjan -- http://mail.python.org/mailman/listinfo/python-list
Re: Async IO Server with Blocking DB
There is asyncmongo! http://pypi.python.org/pypi/asyncmongo/0.1.3 Although I have never tried it. It has support for async I/O for mongodb and tornadoweb. Here is a bit old article about it: http://www.dunnington.net/entry/asynchronous-mongodb-in-tornado-with-asyncmongo I have a related question. I just ran into this post, when I was wondering how to implement sessions with tornado. It is also a blocking db access, right? Say, what if I run four instances of tornado on a computer (one instance per CPU core) and load-balance requests between these instances with ngnix. It cannot be guaranteed that requests from the same user will always go to the same web server process. So the same session must somehow be accessed from multiple processes. But tornado does not have built-in session support. I have read this article about the issue: http://milancermak.posterous.com/benchmarking-tornados-sessions-0 but I found no actual code for session managers. Does anyone know a good, tested implementation of sessions for tornado? Or should I just create my own? I'm thinking about running mongodb and using it for storing sessions (plus also using it for storing application data...) Thanks Laszlo -- http://mail.python.org/mailman/listinfo/python-list
'string_escape' in python 3
In Python 2 given the following raw string: s = rHello\x3a this is a test the escaping could be removed by use of the following: s.decode('string_escape') In Python 3, however, the only way I can see to achieve the same result is to convert into a byte stream and then back: bytes(s, 'utf-8').decode('unicode_escape') This seems very ugly (and slightly 'wrong'). Is there no way to do this without using bytes? Have I missed something? Best wishes, N. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading Live Output from a Subprocess
Maybe this can help you? http://technogems.blogspot.com/2012/01/capture-colored-console-output-in.html -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading Live Output from a Subprocess
On Friday, April 6, 2012 3:37:10 AM UTC-5, Nobody wrote: In all probability, this is because the child process (pypy) is buffering its stdout, meaning that the data doesn't get passed to the OS until either the buffer is full or the process terminates. If it doesn't get passed to the OS, then the OS can't pass it on to whatever is on the read end of the pipe. In that situation, there is nothing that the parent process can do about it. It's just a short test script written in python, so I have no idea how to even control the buffering (and even if I did, I still can't modify the subprocess I need to use in my script). What confuses me then is why Perl is able to get around this just fine without faking a terminal or similar stuff. (And also, this needs to work in Windows as well.) For the record, here's the test script: ## #!/usr/bin/python import time, sys try: total = int(sys.argv[1]) except IndexError: total = 10 for i in range(total): print('This is iteration', i) time.sleep(1) print('Done. Exiting!') sys.exit(0) ## If it does, that would confirm the buffering hypothesis. Pexpect causes the child process' stdout to be associated with a pty. The stdout stream created by the C library (libc) is initially line-buffered if it is associated with a tty (according to the isatty() function) and fully-buffered otherwise. The program can change the buffering with e.g. setvbuf(), or it can explicitly fflush(stdout) after each line, but this is up to the program, and is not something which can be controlled externally (short of hacking the child process with techniques such as ptrace() or LD_PRELOAD). While the libc behaviour is occasionally inconvenient, it is mandated by the C standard (7.19.3p7): As initially opened, the standard error stream is not fully buffered; the standard input and standard output streams are fully buffered if and only if the stream can be determined not to refer to an interactive device. It's up to individual programs to force line-buffered output where appropriate (e.g. GNU grep has the --line-buffered switch, GNU sed has the -u switch, etc). Well, they shouldn't assume they can determine what's interactive or not *grumble*. I take it then that setting Shell=True will not be fake enough for catching output live? On Friday, April 6, 2012 1:43:35 PM UTC-5, shi wrote: Maybe this can help you? http://technogems.blogspot.com/2012/01/capture-colored-console-output-in.html Maybe, but even if it does work as expected, it's a _lot_ of pain to go through, with separate threads, etc.. just to get something so blasted simple to work. It certainly isn't obvious. Thanks for the link though. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading Live Output from a Subprocess
On Apr 6, 7:57 am, buns...@gmail.com wrote: I've heard that the Pexpect module works wonders, but the problem is that relies on pty which is available in Unix only. Additionally, because I want this script to be usable by others, any solution should be in the standard library, which means I'd have to copy the Pexpect code into my script to use it. Is there any such solution in the Python 3 Standard Library, and if not, how much of a thorn is this? There should be one-- and preferably only one --obvious way to do it. Unfortunately, this is one case where the above is true for Perl but not Python. Such an example in Perl is open(PROG, command |) or die Couldn't start prog!; while (PROG) { print $_; } (Note that I do not know Perl and do not have any intentions to learn it; the above comes from the script I was previously copying and extending, but I imagine (due to its simplicity) that it's a common Perl idiom. Note however, that the above does fail if the program re-prints output to the same line, as many long-running C programs do. Preferably this would also be caught in a Python solution.) If there is a general consensus that this is a problem for lots of people, I might consider writing a PEP. Of course, my highest priority is solving the blasted problem, which is holding up my script at the moment. (I can work around this by redirecting the program to a tmp file and reading that, but that would be such a perilous and ugly kludge that I would like to avoid it if at all possible.) Try the sarge package [1], with documentation at [2] and source code at [3]. It's intended for your use case, works with both Python 2.x and 3.x, and is tested on Linux, OS X and Windows. Disclosure: I'm the maintainer. Regards, Vinay Sajip [1] http://pypi.python.org/pypi/sarge/0.1 [2] http://sarge.readthedocs.org/en/latest/ [3] https://bitbucket.org/vinay.sajip/sarge/ -- http://mail.python.org/mailman/listinfo/python-list
Possible change to logging.handlers.SysLogHandler
There is a problem with the way logging.handlers.SysLogHandler works when presented with Unicode messages. According to RFC 5424, Unicode is supposed to be sent encoded as UTF-8 and preceded by a BOM. However, the current handler implementation puts the BOM at the start of the formatted message, and this is wrong in scenarios where you want to put some additional structured data in front of the unstructured message part; the BOM is supposed to go after the structured part (which, therefore, has to be ASCII) and before the unstructured part. In that scenario, the handler's current behaviour does not strictly conform to RFC 5424. The issue is described in [1]. The BOM was originally added / position changed in response to [2] and [3]. It is not possible to achieve conformance with the current implementation of the handler, unless you subclass the handler and override the whole emit() method. This is not ideal. For 3.3, I will refactor the implementation to expose a method which creates the byte string which is sent over the wire to the syslog daemon. This method can then be overridden for specific use cases where needed. However, for 2.7 and 3.2, removing the BOM insertion would bring the implementation into conformance to the RFC, though the entire message would have to be regarded as just a set of octets. A Unicode message would still be encoded using UTF-8, but the BOM would be left out. I am thinking of removing the BOM insertion in 2.7 and 3.2 - although it is a change in behaviour, the current behaviour does seem broken with regard to RFC 5424 conformance. However, as some might disagree with that assessment and view it as a backwards-incompatible behaviour change, I thought I should post this to get some opinions about whether this change is viewed as objectionable. Regards, Vinay Sajip [1] http://bugs.python.org/issue14452 [2] http://bugs.python.org/issue7077 [3] http://bugs.python.org/issue8795 -- http://mail.python.org/mailman/listinfo/python-list
Re: 'string_escape' in python 3
On 4/6/2012 1:52 PM, Nicholas Cole wrote: In Python 2 given the following raw string: s = rHello\x3a this is a test the escaping could be removed by use of the following: s.decode('string_escape') In Python 3, however, the only way I can see to achieve the same result is to convert into a byte stream and then back: bytes(s, 'utf-8').decode('unicode_escape') This seems very ugly (and slightly 'wrong'). Is there no way to do this without using bytes? Have I missed something? eval('+s+') 'Hello: this is a test' -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Learning new APIs/classes (beginner question)
In a nutshell: My question is: how do experienced coders learn about external/third-party classes/APIs? I'm teaching myself Python through a combination of Hetland's 'Beginning Python', various online tutorials and some past experience coding ASP/VBScript. To start to learn Python I've set myself the task of coding a viewer/editor for Google Contacts and Google Calendar, mainly because I've been experiencing some synchronisation anomalies lately. This has so far entailed getting into Google's Contacts API. Although they give some examples, my searches haven't been able to pull up anything approaching comprehensive documentation on each class/method. Can anyone experienced advise on how they would usually go about learning to use third party APIs/classes like these? With thanks, Martin -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning new APIs/classes (beginner question)
On 4/6/2012 1:41 PM Martin Jones said... In a nutshell: My question is: how do experienced coders learn about external/third-party classes/APIs? I'm teaching myself Python through a combination of Hetland's 'Beginning Python', various online tutorials and some past experience coding ASP/VBScript. One resource for learning at least the bulk of python's interal library is http://effbot/librarybook -- of course, not much help for third party libraries... Emile -- http://mail.python.org/mailman/listinfo/python-list
Re: 'string_escape' in python 3
On 06Apr2012 16:57, Terry Reedy tjre...@udel.edu wrote: | On 4/6/2012 1:52 PM, Nicholas Cole wrote: | In Python 2 given the following raw string: | | s = rHello\x3a this is a test | | the escaping could be removed by use of the following: | | s.decode('string_escape') | | In Python 3, however, the only way I can see to achieve the same | result is to convert into a byte stream and then back: | | bytes(s, 'utf-8').decode('unicode_escape') | | This seems very ugly (and slightly 'wrong'). Is there no way to do | this without using bytes? Have I missed something? | | eval('+s+') | 'Hello: this is a test' https://xkcd.com/327/ -- Cameron Simpson c...@zip.com.au DoD#743 http://www.cskk.ezoshosting.com/cs/ Every \item command in item_list must have an optional argument. - Leslie Lamport, LaTeX -- http://mail.python.org/mailman/listinfo/python-list
Re: 'string_escape' in python 3
On 4/6/2012 6:05 PM, Cameron Simpson wrote: On 06Apr2012 16:57, Terry Reedytjre...@udel.edu wrote: | On 4/6/2012 1:52 PM, Nicholas Cole wrote: | bytes(s, 'utf-8').decode('unicode_escape') | | This seems very ugly (and slightly 'wrong'). Is there no way to do | this without using bytes? Have I missed something? | | eval('+s+') | 'Hello: this is a test' https://xkcd.com/327/ I actually thought of that, but assumed that adding enclosing quotes would be safe (or that the OP trusted the string). After sending, I realized that if Nasty Hacker guessed that the string would be so augmented, then it would not be safe. This or above with literal_eval is. ast.literal_eval('{}'.format('\x3a')) ':' --- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: numpy.genfromtxt with Python3 - howto
Helmut Jarausch jarau...@skynet.be wrote: I have a machine with a non-UTF8 local. I can't figure out how to make numpy.genfromtxt work [...] #!/usr/bin/python3 import numpy as np import io import sys inpstream = io.open(sys.stdin.fileno(), r, encoding='latin1') data = np.genfromtxt(inpstream) Hi Helmut, numpy.genfromtxt wants bytes, not str. Use inpstream = io.open(sys.stdin.fileno(), rb) or simply inpstream = sys.stdin.buffer Ciao Marc -- http://mail.python.org/mailman/listinfo/python-list
Re: 'string_escape' in python 3
On Fri, Apr 6, 2012 at 4:19 PM, Terry Reedy tjre...@udel.edu wrote: I actually thought of that, but assumed that adding enclosing quotes would be safe (or that the OP trusted the string). After sending, I realized that if Nasty Hacker guessed that the string would be so augmented, then it would not be safe. This or above with literal_eval is. ast.literal_eval('{}'.format('\x3a')) ':' That version is safe from injection, but it will still choke on things that string_escape can process successfully: s = Isn't it wonderful? s.decode('string_escape') Isn't it wonderful? ast.literal_eval(' + s + ') Traceback (most recent call last): File stdin, line 1, in module File c:\python27\lib\ast.py, line 49, in literal_eval node_or_string = parse(node_or_string, mode='eval') File c:\python27\lib\ast.py, line 37, in parse return compile(expr, filename, mode, PyCF_ONLY_AST) File unknown, line 1 'Isn't it wonderful?' ^ SyntaxError: invalid syntax Of course you could use different string delimiters, but then you just fail on different strings. -- http://mail.python.org/mailman/listinfo/python-list
Re: 'string_escape' in python 3
On Fri, Apr 6, 2012 at 11:52 AM, Nicholas Cole nicholas.c...@gmail.com wrote: In Python 2 given the following raw string: s = rHello\x3a this is a test the escaping could be removed by use of the following: s.decode('string_escape') In Python 3, however, the only way I can see to achieve the same result is to convert into a byte stream and then back: bytes(s, 'utf-8').decode('unicode_escape') This seems very ugly (and slightly 'wrong'). Is there no way to do this without using bytes? Have I missed something? import codecs codecs.getdecoder('unicode_escape')(s)[0] 'Hello: this is a test' Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
Re: Learning new APIs/classes (beginner question)
On Fri, 06 Apr 2012 13:41:23 -0700, Martin Jones wrote: In a nutshell: My question is: how do experienced coders learn about external/third-party classes/APIs? Does it have a tutorial? Do it. Does it have a manual, a wiki, FAQs, or other documentation? Read them. If all else fails, what does help(external_library) say? Are there examples you can follow? Do so. Does it have a mailing list to ask for help? Subscribe to it. Google for examples and sample code. If all else fails, read the source code if it is available. Otherwise find another library. If you can't do that, then you're stuck with learning by trial and error. Which is to say, mostly by error, which is a trial. I'm teaching myself Python through a combination of Hetland's 'Beginning Python', various online tutorials and some past experience coding ASP/VBScript. To start to learn Python I've set myself the task of coding a viewer/editor for Google Contacts and Google Calendar, mainly because I've been experiencing some synchronisation anomalies lately. This has so far entailed getting into Google's Contacts API. Although they give some examples, my searches haven't been able to pull up anything approaching comprehensive documentation on each class/method. Sounds like this library is documented the same way most third party libraries are: as an afterthought, by somebody who is so familiar with the software that he cannot imagine why anyone might actually need documentation. I feel your pain. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Gotcha's?
On Thursday, April 5, 2012 11:28:01 PM UTC-5, rusi wrote: On Apr 5, 4:06 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: JSON expects double-quote marks, not single: v = json.loads({'test':'test'}) fails v = json.loads('{test:test}') succeeds You mean JSON expects a string with valid JSON? Quelle surprise. Are there languages (other than python) in which single and double quotes are equivalent? Fortran 90 and more recent versions. [No I dont claim to know all the languages out there, just that I dont know any other language which allows single and double quotes to be interconvertible like python does] On Thursday, April 5, 2012 11:28:01 PM UTC-5, rusi wrote: On Apr 5, 4:06 pm, Duncan Booth duncan.bo...@invalid.invalid wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: JSON expects double-quote marks, not single: v = json.loads({'test':'test'}) fails v = json.loads('{test:test}') succeeds You mean JSON expects a string with valid JSON? Quelle surprise. Are there languages (other than python) in which single and double quotes are equivalent? [No I dont claim to know all the languages out there, just that I dont know any other language which allows single and double quotes to be interconvertible like python does] -- http://mail.python.org/mailman/listinfo/python-list
Re: xlrd 0.7.6 released!
Karim kliat...@gmail.com wrote in news:mailman.1309.1333529851.3037.python-l...@python.org: This release manage the '.xlsx' format? http://packages.python.org/openpyxl/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Generating custom Windows installers
On 7/04/2012 12:57 AM, Cesar Covarrubias wrote: I'm still getting my feet wet on the Windows side of things with Python, so I apologize for the noobish question. If i am reading the create_link.py example correctly, that is created when the application itself is invoked, not during installation. Is that correct? If it is, how would I be able to invoke that when generating the MSI so that the installer creates the shortcut? Right - I think I misunderstood your question. If you can't arrange for install.py to run then what I suggested isn't going to help that. Note however that bdist_msi really isn't targeted at creating stand-alone installations, but instead at installing Python extension modules. I'd recommend using cx_Freeze to create the app, but looking further afield to create the installer for the app (eg, Inno, NSIS, WiX, etc) Mark Cesar On Thu, Apr 5, 2012 at 8:42 PM, Mark Hammond skippy.hamm...@gmail.com mailto:skippy.hamm...@gmail.com wrote: Seeing you are relying on win32com, you might as well add the links directly rather than via the intermediate WScript.shell object. Look in win32comext\shell\demos\__create_link.py for an example of how to create shortcuts directly. HTH, Mark On 6/04/2012 5:23 AM, cesar.covarrub...@gmail.com mailto:cesar.covarrub...@gmail.com wrote: Hello, I am working on creating an installer of a Python 3.2 application that we programmed. The end goal is to create an installer in which we can specify the install path, and create shortcuts in the Start Menu and Desktop. Ideally, we would like to give the users the option to create the Desktop or Start Menu shortcuts. I was able to create a .msi file with the setup.py and install.py files below. This allowed me to specify the custom default path but not create the shortcut in the Start Menu. Can anyone help me figure out what I'm missing? setup.py from cx_Freeze import setup, Executable import sys productName = ProductName if 'bdist_msi' in sys.argv: sys.argv += ['--initial-target-dir', 'C:\InstallDir\\' + productName] sys.argv += ['--install-script', 'install.py'] exe = Executable( script=main.py, base=Win32GUI, targetName=Product.exe ) setup( name=Product.exe, version=1.0, author=Me, description=Copyright 2012, executables=[exe], scripts=[ 'install.py' ] ) --__--- install.py -- import os import sys import win32com.client as w32client shortcut_group_name = Start Menu Dir shortcut_name = Product Name shortcut_target = http://www.microsoft.com; sh = w32client.Dispatch(WScript.__Shell) p = sh.SpecialFolders(__AllUsersPrograms) assert(os.path.isdir(p)) p = os.path.join(p, shortcut_group_name) if (not os.path.isdir(p)): os.makedirs(p) lnk = sh.CreateShortcut(os.path.__join(p, shortcut_name + .lnk)) lnk.TargetPath = shortcut_target lnk.Save() -- Very Respectfully, Cesar Covarrubias -- http://mail.python.org/mailman/listinfo/python-list
Re: xlrd 0.7.6 released!
Le 07/04/2012 04:07, Keith Medcalf a écrit : Karimkliat...@gmail.com wrote in news:mailman.1309.1333529851.3037.python-l...@python.org: This release manage the '.xlsx' format? http://packages.python.org/openpyxl/ Ah Keith, I just check this is only for xlsx format so I will make 2 code branches so I don't have to modify the xlrd one for xls binary file. I will use both in the same program. Many thanks Cheers Karim -- http://mail.python.org/mailman/listinfo/python-list
Re: Cannot connect to IMAP server in Python 3.2
Steve Howell showel...@yahoo.com wrote in news:ae774035-9db0-469d-aa2a- 02f2d25ff...@qg3g2000pbc.googlegroups.com: Once you are able to import ssl, you should be able to use IMAP4_SSL, but that still doesn't entirely explain to me why you got a timeout error with plain IMAP4 and the proper port. (I would have expected a failure, but of a different kind.) Connecting to the SSL socket requires that one initiate the TLS handshake forthwith. Establishing a connection to an I expect SSL from the get- go using a protocol that speaks I am a normal unencrypted socket but you can initiate TLS using the starttls command is not the same thing. In other words, you are violating the requirements of the protocol, and you are timing out. This is because the first protocol step in a standard connection is to wait for the plain-text greeting, where the first step in connecting to the SSL socket is to do a TLS dance, then initiate the IMAP protocol by sending the greeting. If you connect with a non-SSL initiator to an SSL endpoint, you will get a timeout. If you connect with an SSL initiator to a non-SSL endpoint, you will timeout. It is not the connection that is timing out, it is the protocol. I'd still be curious to see what happens when you try this: import socket, imaplib your_host_name = # ... socket.create_connection((your_host_name, imaplib.IMAP4_SSL_PORT)) This will, of course, work just fine. You will not see a +Hello however until you have completed the TLS negotiation. -- http://mail.python.org/mailman/listinfo/python-list
Re: Reading Live Output from a Subprocess
On Fri, 6 Apr 2012 12:21:51 -0700 (PDT) Dubslow buns...@gmail.com wrote: On Friday, April 6, 2012 3:37:10 AM UTC-5, Nobody wrote: In all probability, this is because the child process (pypy) is buffering its stdout, meaning that the data doesn't get passed to the OS until either the buffer is full or the process terminates. If it doesn't get passed to the OS, then the OS can't pass it on to whatever is on the read end of the pipe. In that situation, there is nothing that the parent process can do about it. It's just a short test script written in python, so I have no idea how to even control the buffering (and even if I did, I still can't modify the subprocess I need to use in my script). What confuses me then is why Perl is able to get around this just fine without faking a terminal or similar stuff. (And also, this needs to work in Windows as well.) For the record, here's the test script: ## #!/usr/bin/python import time, sys try: total = int(sys.argv[1]) except IndexError: total = 10 for i in range(total): print('This is iteration', i) time.sleep(1) print('Done. Exiting!') sys.exit(0) ## I agree that this kind of thing (IO) can seem unduly difficult to find out how to do at first. To get your test script working, you just need to flush stdout from there; add: sys.stdout.flush() to your for loop above. However, if there is a real process you need to use which you can't modify, then it seems you'll have to use one of the more complex solutions offered here. Regards, John -- http://mail.python.org/mailman/listinfo/python-list
Re: escaping/encoding/formatting in python
On Fri, 06 Apr 2012 06:22:13 -0700, rusi wrote: But are not such cases rare? They exist, therefore they have to be supported somehow. For example code such as: print '' print str(something) print '' could better be written as print '%s' % str(something) Not if the text between the delimiters is large. Consider: print 'static const char * const data[] = {' for line in infile: print '\t%s,' % line.rstrip() print '};' Versus: text = '\n'.join('\t%s,' % line.rstrip() for line in infile) print 'static const char * const data[] = {\n%s\n};' % text C++11 solves the problem to an extent by providing raw strings with user-defined delimiters (up to 16 printable characters excluding parentheses and backslash), e.g.: Rdelim(quote: backslash: \ rparen: ))delim evaluates to the string: quote: backslash: \ rparen: ) The only sequence which cannot appear in such a string is )delim (i.e. a right parenthesis followed by the chosen delimiter string followed by a double quote). The delimiter can be chosen either by analysing the string or by choosing something a string at random and relying upon a collision being statistically improbable. -- http://mail.python.org/mailman/listinfo/python-list
[issue14508] gprof2html is broken
Éric Araujo mer...@netwok.org added the comment: Should also use with statements IMO. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14508 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14465] xml.etree.ElementTree: add feature to prettify XML output
Éric Araujo mer...@netwok.org added the comment: You may be able to code it entirely in the Python part of the module (adding a new parameter to Element.write and tostring). -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14465 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14488] Can't install Python2.7.2
Éric Araujo mer...@netwok.org added the comment: Can you try with 2.7.3? -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14488 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13903] New shared-keys dictionary implementation
Mark Shannon m...@hotpy.org added the comment: How about changing the method-cache size in a separate patch? On my machine, reducing the method-cache size from 2**10 to 2**9 results in a very small improvement in performance (with the original dict). That way we don't get a performance regression with the new dict and the patch is better focussed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13903 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8555] tkinter doesn't see _tkinter
py.user bugzilla-mail-...@yandex.ru added the comment: testing new e-mail -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8555 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14508] gprof2html is broken
Popa Claudiu pcmantic...@gmail.com added the comment: Hello. I've attached the new version of the patch. I used with statement in add_escapes and the test was rewritten according to David's suggestion. -- Added file: http://bugs.python.org/file25139/gprof.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14508 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14236] re: Docstring for \s and \S doesn’t mention Unicode
Changes by py.user bugzilla-mail-...@yandex.ru: -- title: re: Docstring for \s and \S don’t mention Unicode - re: Docstring for \s and \S doesn’t mention Unicode ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14236 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14502] Document better what happens on releasing an unacquired lock
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 068a614e9d97 by Sandro Tosi in branch 'default': Issue #14502: it's RuntimeError on 3.3 http://hg.python.org/cpython/rev/068a614e9d97 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14502 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14082] shutil doesn't copy extended attributes
Hynek Schlawack h...@ox.cx added the comment: This ticket has a small catch: There are several namespaces. According to http://en.wikipedia.org/wiki/Xattr#Linux : - user: can be set by anyone - trusted: root only - security: root only - system: even root can’t do that, at least not in my vm I’m writing a shutil.copyxattr() first which could simple get another argument for the namespaces that should be copied. However what to do inside copy2()? I’m tending to either: 1. copy only user.* 2. ignore errors in any namespace != user Personally, I find the second approach rather non-deterministic. So I’d suggest: - copyxattr has an extra argument called namespaces with default being ['user'], so that in theory someone who wants to do something more sophisticated can do it. - copy2 copies only user.* though because that’s what you usually want. Please let me know what you think about it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14082 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14502] Document better what happens on releasing an unacquired lock
Antoine Pitrou pit...@free.fr added the comment: On Thu, Apr 5, 2012 at 5:38 PM, Antoine Pitrou rep...@bugs.python.org wrote: Antoine Pitrou pit...@free.fr added the comment: Not sure what you're talking about. The doc patch is about unacquired locks, not locks that someone else (another thread) holds. Isn't one common reason for not being able to acquire a lock that someone else was already holding it? We're talking about *releasing* an (un)acquired lock, not acquiring it again... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14502 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14516] test_tools assumes BUILDDIR=SRCDIR
New submission from Ronald Oussoren ronaldousso...@mac.com: When I run make tests I get (amongst others) the following test failure: == FAIL: test_noargs (test.test_tools.ReindentTests) -- Traceback (most recent call last): File /Users/ronald/Projects/python/rw/default/Lib/test/test_tools.py, line 30, in test_noargs assert_python_ok(self.script) File /Users/ronald/Projects/python/rw/default/Lib/test/script_helper.py, line 53, in assert_python_ok return _assert_python(True, *args, **env_vars) File /Users/ronald/Projects/python/rw/default/Lib/test/script_helper.py, line 45, in _assert_python stderr follows:\n%s % (rc, err.decode('ascii', 'ignore'))) AssertionError: Process return code is 2, stderr follows: /Users/ronald/Projects/python/rw/default/build/python.exe: can't open file '/Users/ronald/Projects/python/rw/default/build/Tools/scripts/reindent.py': [Errno 2] No such file or directory This is because the script is actually /Users/ronald/Projects/python/rw/default/Tools/scripts/reindent.py. The attached patch fixes the issue. (assigned to eric because he introduced these tests, unless there are objections I'll commit during the weekend) -- assignee: eric.araujo components: Tests files: test_tools.patch keywords: easy, needs review, patch messages: 157655 nosy: eric.araujo, ronaldoussoren priority: normal severity: normal stage: needs patch status: open title: test_tools assumes BUILDDIR=SRCDIR type: behavior versions: Python 3.3 Added file: http://bugs.python.org/file25140/test_tools.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11060] distutils2 sdist does not complain about version that is not PEP 386 compliant
Rik Poggi poggi.ri...@gmail.com added the comment: Thanks, I'll wait! In the meanwhile I couldn't help to dig a little deeper and found that the Metadata class is currently logging a warning. Should the commands raise something when there's a warning in strict mode? I was playing with the check command about this when I stumbled in an odd looking piece of code in metadata.py with a FIXME note: # FIXME this rejects UNKNOWN, is that right? (see attached file). I'm not sure how, but it seems related to a random (I couldn't find any pattern) log message that sometimes give: 'UNKNOWN': '0.4.5dev' is not a valid version (field 'Version') and others: 'Name': '0.4.5dev' is not a valid version (field 'Version') (I had this with consecutive execution from a simple test that I wrote in test_command_check, with metadata['name'] == 'Name'). I hoped to not have wasted your time, but I thought that it could may be related to this bug since it seems that the version gets rightfully (but strangefully) warned as not valid from this middle-layer check point. -- Added file: http://bugs.python.org/file25141/metadata_set_extract.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11060 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9141] Allow objects to decide if they can be collected by GC
Kristján Valur Jónsson krist...@ccpgames.com added the comment: New patch with explicit mutually exclusive flags and better comments. -- Added file: http://bugs.python.org/file25142/ob_is_gc.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9141] Allow objects to decide if they can be collected by GC
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Thanks for your comments Jim. They made me realize that the patch was incomplete. What is needed are two mutually exclusive flags that override the presence of the tp_del slot. This addresses your 1) point and is the case for Generators. I don't think 2 is important. Does the context of the call matter? It is merely a question of whether a finalizer will or will not do something trivial. Finalizers implemented in python can never run from garbage collection. the potential to do harm is simply too great. Which is why these extensions are purely the domain of specialized C extensions. Hence I don't think adding another slot, or allowing self-declared idempotent python finalizers to run during cleanup is a good idea. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14517] Recompilation of sources with Distutils
New submission from Christophe Benoit cca.ben...@gmail.com: When using distutils to build a C-extension, I have noticed that my C-sources were recompiled as soon as one source file has been touched; from python 2.6. This was not the case with previous python versions. -- assignee: eric.araujo components: Distutils messages: 157659 nosy: cbenoit, eric.araujo, tarek priority: normal severity: normal status: open title: Recompilation of sources with Distutils type: behavior versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14517 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10576] Add a progress callback to gcmodule
Kristján Valur Jónsson krist...@ccpgames.com added the comment: You are right, I was thinking more of pyobject attributes. I'll fix this then. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10576 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14310] Socket duplication for windows
Changes by Kristján Valur Jónsson krist...@ccpgames.com: -- Removed message: http://bugs.python.org/msg157189 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14310 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14310] Socket duplication for windows
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Not much happening on python-dev. Perhaps this is not so controversial. http://www.mail-archive.com/python-dev@python.org/msg66206.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14310 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14310] Socket duplication for windows
Antoine Pitrou pit...@free.fr added the comment: I have one question: you're simply doing a binary copy of the WSAPROTOCOL_INFO structure. Does it mean sharing wouldn't work between e.g. different MSVC builds of Python (if the structure is different), or between a 32-bit and a 64-bit Python? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14310 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14310] Socket duplication for windows
Antoine Pitrou pit...@free.fr added the comment: Comments about the patch: - versionadded should be 3.3, not 3.4 - MultiprocessingFunc would deserve a meaningful, PEP8 name; it should also probably be a classmethod on TestSocketSharing - please use PEP8 for comments (a space after the #) - it would be nice to have a test for the ValueError when passing a bytes object of the wrong size - also, there should be a test that the family, type and proto attributes are correctly set on the fromshare() result (perhaps timeout too) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14310 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14510] Regular Expression + perform wrong repeat
YunJian tld...@yahoo.com.cn added the comment: Well, maybe I had never understood this though I use RE oftenly, this is the first time I met this and in my mind capture should not perform like this, thank you very much! 发件人: Matthew Barnett rep...@bugs.python.org 收件人: tld...@yahoo.com.cn 发送日期: 2012年4月6日, 星期五, 上午 12:08 主题: [issue14510] Regular Expression + perform wrong repeat Matthew Barnett pyt...@mrabarnett.plus.com added the comment: If a capture group is repeated, as in r'(\$.)+', only its last match is returned. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14510 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14510 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14510] Regular Expression + perform wrong repeat
YunJian tld...@yahoo.com.cn added the comment: If that was caused by capture, I think I should learn and use it from start because it gave a result I didn't want but in the way I want, thank you very much, I will be more careful next time, thank you! 发件人: Ezio Melotti rep...@bugs.python.org 收件人: tld...@yahoo.com.cn 发送日期: 2012年4月6日, 星期五, 上午 9:41 主题: [issue14510] Regular Expression + perform wrong repeat Ezio Melotti ezio.melo...@gmail.com added the comment: ['$b$B', '$B$b'] -- assignee: - ezio.melotti resolution: - invalid stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14510 ___ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14510 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14310] Socket duplication for windows
Kristján Valur Jónsson krist...@ccpgames.com added the comment: The binary copy: This is a winsock2 feature. There is no difference in layout between 32 bits and 64 bits. I also don't think there is a difference between SDK versions. However, strangely, there is a difference between unicode and non-unicode builds. But since we are using this in python3, which always uses the same unicode setting, this shouldn't be an issue. I'll take your other comments into account and produce a new patch. Similar to socket.dup(), the socket shared is assumed to be in blockin mode (this his how its timeout is initialized). We can test for that too. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14310 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14516] test_tools assumes BUILDDIR=SRCDIR
Éric Araujo mer...@netwok.org added the comment: Thanks for catching this. The definition of projectbase and srcdir is not clear to me, I always have to use trial and error to find the right one in my tests. The patch must be applied to all three branches; let me know if I should do it. -- versions: +Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14516 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14455] plistlib unable to read json and binary plist files
Éric Araujo mer...@netwok.org added the comment: Keep it simple: if a few functions work, there is no need at all to add classes. Before doing more work though I suggest you wait for the feedback of the Mac maintainers. -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14455 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14455] plistlib unable to read json and binary plist files
Ronald Oussoren ronaldousso...@mac.com added the comment: I (as one of the Mac maintainers) like the new functionality, but would like to see some changes: 1) as others have noted it is odd that binary and json plists can be read but not written 2) there need to be tests, and I'd add two or even three set of tests: a. tests that read pre-generated files in the various formats (tests that we're compatible with the format generated by Apple) b. tests that use Apple tools to generated plists in various formats, and check that the library can read them (these tests would be skipped on platforms other than OSX) c. if there are read and write functions: check that the writer generates files that can be read back in. 3) there is a new public function for reading binary plist files, I'd keep that private and add a format argument to readPlist when there is a need for forcing the usage of a specific format (and to mirror the (currently hypothetical) format argument for writePlist). Don't worry about rearchitecturing plistlib, it might need work in that regard but that need not be part of this issue and makes it harder to review the changes. I'm also far from convinced that a redesign of the code is needed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14455 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10197] subprocess.getoutput fails on win32
Éric Araujo mer...@netwok.org added the comment: I think that adding safer wrappers and deprecating things are valuable but different bugs. In the short term, we could apply the proposed small patch to just fix the issue at hand. Can one of the Windows experts weigh in? The patch does this: if mswindows: pipe = os.popen('( ' + cmd + ' ) 21', 'r') else: pipe = os.popen('{ ' + cmd + '; } 21', 'r') It was tested manually; a test should be simple to write. -- keywords: +needs review nosy: +tim.golden stage: - test needed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10197 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14412] Sqlite Integer Fields
Benjamin Peterson benja...@python.org added the comment: What steps can we take to further debug/address this? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14412 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14477] Rietveld test issue
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14477 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6225] Fixing several minor bugs in Tkinter.Canvas and one in Misc._configure
Changes by Éric Araujo mer...@netwok.org: -- versions: +Python 3.3 -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6225 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14469] Python 3 documentation links
Changes by Éric Araujo mer...@netwok.org: -- nosy: +eric.araujo versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14469 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14500] test_importlib fails in refleak mode
Roundup Robot devn...@psf.upfronthosting.co.za added the comment: New changeset 1c3bd0cc3eca by Brett Cannon in branch 'default': Issue #14500: Fix importlib.test.import_.test_packages to clean up http://hg.python.org/cpython/rev/1c3bd0cc3eca -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14500] test_importlib fails in refleak mode
Changes by Brett Cannon br...@python.org: -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14500 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14341] sporadic (?) test_urllib2 failures
R. David Murray rdmur...@bitdance.com added the comment: If one changes the stacklevel in the DeprecationWarnings in the library to '2' instead of '1' (I believe it should be '2'), then an interesting array of deprecation warnings are issued...including from cookiejar code. Most of them are in the urllib2 tests, though, and obviously they aren't being correctly protected. I'm not sure what is causing the deprecation test to sometimes succeed and sometimes fail, though. Running python -m unittest.test_urllib2 consistently fails for me without the 1-2 change, and consistently passes (but with more warnings) with it. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14341 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13749] socketserver can't stop
Daniel Swanson popcorn.tomato.d...@gmail.com added the comment: what about this? def __init__(...): ... self.stop = False while True: (do stuff) if self.stop: break def quit(or whatever it's called): self.stop = True That would work without the backwards copatability issue right? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13749 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2377] Replace __import__ w/ importlib.__import__
Brett Cannon br...@python.org added the comment: OK, -v/PYTHONVERBOSE is as done as it is going to be by me. Next up is (attempting) Windows registry stuff. After that I will push to default with test_trace and test_pydoc skipped so others can help me with those. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14341] sporadic (?) test_urllib2 failures
Stefan Krah stefan-use...@bytereef.org added the comment: Running test_http_cookiejar and test_urllib2 in succession always fails here. The same thing occurs when running test_urllib2 twice: $ ./python -m test test_http_cookiejar test_urllib2 [1/2] test_http_cookiejar [2/2] test_urllib2 test test_urllib2 failed -- Traceback (most recent call last): File /home/stefan/pydev/cpython/Lib/test/test_urllib2.py, line 628, in test_method_deprecations req.get_host() File /home/stefan/pydev/cpython/Lib/contextlib.py, line 54, in __exit__ next(self.gen) File /home/stefan/pydev/cpython/Lib/test/support.py, line 766, in _filterwarnings missing[0]) AssertionError: filter ('', DeprecationWarning) did not catch any warning 1 test OK. 1 test failed: test_urllib2 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14341 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13749] socketserver can't stop
Daniel Swanson popcorn.tomato.d...@gmail.com added the comment: Or even better: def __init__(...): ... self.stop = False while not self.stop: (do stuff) def quit(or whatever it's called): self.stop = True -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13749 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14502] Document better what happens on releasing an unacquired lock
Jim Jewett jimjjew...@gmail.com added the comment: On Fri, Apr 6, 2012 at 5:57 AM, Antoine Pitrou rep...@bugs.python.org wrote: Antoine Pitrou pit...@free.fr added the comment: Not sure what you're talking about. The doc patch is about unacquired locks, not locks that someone else (another thread) holds. Isn't one common reason for not being able to acquire a lock that someone else was already holding it? We're talking about *releasing* an (un)acquired lock, not acquiring it again... Right, but I thought the original motivation was concern over a race condition in the lock acquisition. lock.acquire() try:# What if something happens here, during try setup? Leak? foo() finally: lock.release() vs try: lock.acquire() foo() finally: lock.release() # But what if the acquire failed? -jJ -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14502 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14518] Add bcrypt $2a$ to crypt.py
New submission from Daniel Holth dho...@fastmail.fm: The prefix for bcrypt '$2a$' is supported on many systems and could be added to crypt.py Could the documentation mention the available rounds parameter for most of these newer hashes? And that Unicode strings are automatically converted to utf-8 before being passed into the OS crypt() function, or is that just assumed to be common knowledge? -- messages: 157679 nosy: dholth priority: normal severity: normal status: open title: Add bcrypt $2a$ to crypt.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14518 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14518] Add bcrypt $2a$ to crypt.py
Changes by Daniel Holth dho...@fastmail.fm: -- components: +Library (Lib) versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14518 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14502] Document better what happens on releasing an unacquired lock
R. David Murray rdmur...@bitdance.com added the comment: It doesn't matter *how* you get to the situation where you are releasing a lock that hasn't been acquired, the point is to document what actually happens when you do the release. And just yesterday I needed to know this, since I have a lock that may or may not be currently held when I release it, and now I know I can just catch RuntimeError in that case. -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14502 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9141] Allow objects to decide if they can be collected by GC
Jim Jewett jimjjew...@gmail.com added the comment: I don't think 2 is important. Does the context of the call matter? It is merely a question of whether a finalizer will or will not do something trivial. It would affect how I would write such functions. If I knew that it wouldn't be called until the object was already garbage, then I be inclined to move parts of tp_del there, and break the cycle. Finalizers implemented in python can never run from garbage collection. the potential to do harm is simply too great. __del__ methods do run, even if an object was collected by the cycle detector. And they can't do any harm that couldn't also be done by a C finalizer. The only change from today's situation with __del__ is that once an object is known to be cyclic garbage, it would get a chance to break the cycles itself (or, admittedly, to rescue itself) before the cycle-breaker began making arbitrary decisions or gave up and stuffed it in the uncollectable list. Even in your case, instead of setting a timer to clean out garbage, you could have the garbage itself notify your cleaner that it needed attention. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9141] Allow objects to decide if they can be collected by GC
Daniel Stutzbach stutzb...@google.com added the comment: On Fri, Apr 6, 2012 at 12:51 PM, Jim Jewett rep...@bugs.python.org wrote: __del__ methods do run, even if an object was collected by the cycle detector. And they can't do any harm that couldn't also be done by a C finalizer. No, if an object with a __del__ method is part of a cycle, it is not collected. The objects get appended to gc.garbage instead. See: http://docs.python.org/py3k/library/gc.html#gc.garbage -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2377] Replace __import__ w/ importlib.__import__
Antoine Pitrou pit...@free.fr added the comment: OK, -v/PYTHONVERBOSE is as done as it is going to be by me. Next up is (attempting) Windows registry stuff. After that I will push to default with test_trace and test_pydoc skipped so others can help me with those. Skipped? How so? I think it would be better if you tried to debug them. I don't think we have anyone active knowledgeable on either trace or pydoc. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2377 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14478] Decimal hashing very slow, could be cached
Jim Jewett jimjjew...@gmail.com added the comment: @Jimbofbx: You are correct that a value has to be reserved to indicate that the hash hasn't been (or can't be) computed, but python uses -1 instead of zero. An integer can't return itself because a hash is an unboxed integer; that said, there is a fast path for small enough integers. You can see the actual code at http://hg.python.org/cpython/file/388016438a50/Objects/longobject.c#l2581 Since it is too late for 3.2, I suggest closing this and opening a separate 3.3 issue if the existing improvements are not sufficient. -- nosy: +Jim.Jewett ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14478 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9141] Allow objects to decide if they can be collected by GC
Kristján Valur Jónsson krist...@ccpgames.com added the comment: Right Daniel, but currently an exception is made for Generator objects. The generator can tell that the finalizer won't do anything and then allow collection regardless. It knows the finalizer and that in its state it will at most do some Py_DECREF operations. This patch aims to generalize this exception mechanism, and also its opposite, so that we don´t need to rely on the presence of the finalizer slot to decide. We can then remove a silly function from the public (but undocumented) API. Of course, you can only allow collectino of an object with a finalizer if you know for sure that it will not do anything but Py_DECREF. This is possible for generators because they are not an inheritable class. But we could never do this in general for a python class. Even running .py code from the GC collector cycle would crash everything instantly. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14511] _static/opensearch.xml for Python 3.2 docs directs searches to 3.3 docs
Éric Araujo mer...@netwok.org added the comment: Will fix, thanks for the report. -- assignee: docs@python - eric.araujo versions: +Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14511 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14455] plistlib unable to read json and binary plist files
d9pouces pyt...@19pouces.net added the comment: I'm working on a class, BinaryPlistParser, which allow to both read and write binary files. I've also added a parameter fmt to writePlist and readPlist, to specify the format ('json', 'xml1' or 'binary1', using XML by default). These constants are used by Apple for its plutil program. I'm now working on integrating these three formats to the test_plistlib.py. However, the json is less expressive than the other two, since it cannot handle dates. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14455 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9141] Allow objects to decide if they can be collected by GC
Daniel Stutzbach stutzb...@google.com added the comment: Are __del__ and tp_del getting conflated in this conversation? I don't see a __del__ method on generator objects: filfre:$ python3.1 Python 3.1.2 (r312:79147, Dec 9 2011, 20:47:34) [GCC 4.4.3] on linux2 (i for i in range(5)).__del__ Traceback (most recent call last): File stdin, line 1, in module AttributeError: 'generator' object has no attribute '__del__' but I may be missing something. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9141] Allow objects to decide if they can be collected by GC
Kristján Valur Jónsson krist...@ccpgames.com added the comment: typeobject.c: TPSLOT(__del__, tp_del, slot_tp_del, NULL, ), I'm not super-familiar with how typeobjects and slots work, but I imagine that if a type is defined with a __del__ member, then the tp_del slot is automatically filled out. The converse need not be true. At any rate, the non-zero-ness of tp_del is what gcmodule.c uses to find out if an object has a finaliser. There is a code rudiment present in gcmodule.c, that hints at an earlier time when '__del__' was looked up but that string is not actually used. That can be removed to, eiter as part of this patch or separately since it should be quite uncontroversial. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9141 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14518] Add bcrypt $2a$ to crypt.py
Antoine Pitrou pit...@free.fr added the comment: This requires someone to propose a patch. If you are interested, you can read the Developer's Guide - http://docs.python.org/devguide/ - for more information on how to contribute. -- nosy: +jafo, pitrou stage: - needs patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14518 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14468] Update cloning guidelines in devguide
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14468 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14468] Update cloning guidelines in devguide
Terry J. Reedy tjre...@udel.edu added the comment: I agree, for reasons stated. Having to skip over the wrong instructions made getting started a bit harder for me. I also think TortoiseHG should get more than just a mention. The initial re-creation of the recent DAG for each branch when starting up Workbench takes some time, but having the graph makes it immediately obvious whether the repository is in a proper state -- two heads for default and 2.7, three for 3.2 -- both before starting work after pulling from py.org and again when ready to push changes back. -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14468 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com