Python Tools for Visual Studio 1.5 RC Released
We're pleased to announce the release of Python Tools for Visual Studio 1.5 RChttp://pytools.codeplex.com/releases/view/82130. Python Tools for Visual Studio (PTVS) is an open-source plug-in for Visual Studio which supports programming with the Python language. PTVS supports a broad range of features including CPython/IronPython, Edit/Intellisense/Debug/Profile, Cloud, HPC, IPython, etc. support. The primary new feature for the 1.5 release is Django including Azure support! The http://www.djangoproject.comhttp://www.djangoproject.com/ is a popular Python webframework/CMS which is used by many reputable companies and high-traffic websites. For Python on Azure support see: https://www.windowsazure.com/en-us/develop/python. In this RC release, the following improvements have been made based on your requests feedback: * VS2012 support! * A Live Debug REPL - YT: http://www.youtube.com/watch?v=erNx2NLu-t4hd=1 * Project load time improvements * Kinect 1.5 support * New New Project from Existing Code! * Improved intellisense (iterator, PyQt, ...) * Python 3.3 language support * Azure Python Client Lib improvements for Windows, Linux MacOS There were over 80 fixes/improvements in this release. Unfortunately because of Codeplex's Release Notes character limit (sad), we can't list the summary of bug fixes, so here's a link to the data: http://bit.ly/Ptvs15RcBugs We'd like to thank the following people who took the time to report the issues and feedback for this release (in reverse chronological order): Tmaslach, odwalla, jrade, michiya, timeisparallax, tachiorz, sourbox, tramsay, bahrep, lqbest127, hyh, mrpy, boomer_74, BigFreakinGobot, AngeloBast, ajp, mahpour, cecilphillip, dhabersat. We'd also like to thank Weidong for his wonderful test support during the past few months welcome Hugues aboard the project! -- http://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine
On Thursday, September 20, 2012 10:39:28 AM UTC+5:30, Chris Angelico wrote: On Thu, Sep 20, 2012 at 2:27 PM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: On Wed, 19 Sep 2012 12:46:33 -0700, ashish wrote: 2. I have a python script, local.py, running on local which needs to pass arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to a python script, remote.py running on remote (the remote machine). If 3/4 of the arguments are strings, what sort of objects are the other 1/4? Sorry for the confusion Steven. There are 3 or 4 arguments, all of which are strings. I understand the OP as meaning three or four string arguments. Yup, that's what i meant. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: How to send email programmatically from a gmail email a/c when port 587(smtp) is blocked
On 19/09/2012 20:12, ashish wrote: Folks, I asked the same query on the python tutor mailing list. The responses i received are here : http://thread.gmane.org/gmane.comp.python.tutor/77601 Mark, There is nothing wrong in asking a query on multiple forums. Poeple on the tutor list, may not be part of comp.lang.python subscribers to comp.lang.python And you've done exactly the same thing with another question. So there are two sets of answers on two mls/ngs that are completely unconnected except that I amongst others know that they exist. If you had to ask on both, why not post to both in one hit? -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing Pip onto a mac os x system
On 20/09/12 03:32:40, John Mordecai Dildy wrote: Does anyone know how to install Pip onto a mac os x ver 10.7.4? Ive tried easy_instal pip but it brings up this message (but it doesn't help with my problem): error: can't create or remove files in install directory The following error occurred while trying to add or remove files in the installation directory: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/test-easy-install-1820.write-test' The installation directory you specified (via --install-dir, --prefix, or the distutils default setting) was: /Library/Python/2.7/site-packages/ Perhaps your account does not have write access to this directory? If the installation directory is a system-owned directory, you may need to sign in as the administrator or root account. If you do not have administrative access to this machine, you may wish to choose a different installation directory, preferably one that is listed in your PYTHONPATH environment variable. For information on other options, you may wish to consult the documentation at: http://peak.telecommunity.com/EasyInstall.html Please make the appropriate changes for your system and try again. Thing is I am the Administrator of the computer In that case, you should be able to do sudo easy_instal pip This will ask your login password, and then run easy_instal pip with so-called root privileges. and can use all of the folders on the mac computer. You may be able to view them, but I doubt that you can add new files to folders like, say, /Library/Python . Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
Re: How to get the list of all my open file(descriptor)s and locks?
On 20/09/12 05:11:11, Chris Angelico wrote: On Thu, Sep 20, 2012 at 7:09 AM, Ian Kelly ian.g.ke...@gmail.com wrote: You could do: os.listdir(/proc/%d/fd % os.getpid()) This should work on Linux, AIX, and Solaris, but obviously not on Windows. On MacOS X, you can use os.listdir(/dev/fd) This might work on other OSes. I'm not sure how cross-platform it is, but at least on Linux, you can use /proc/self as an alias for /proc/+os.getpid() - worth a try, might make your code a bit easier to read. It's documented as useful when you don't know the PID yet (eg telling a process to read the file /proc/self/fd/0 to force it to use stdin). At least on Linux, Solaris and MacOS X, you shouldd use /dev/stdin, which is a symlink to whatever the official name is. /dev/stdin is more readable and more portable than the official name. So I'm confident enough to recommend testing it. :) Testing such things is the best way to learn. Hope this helps, -- HansM -- http://mail.python.org/mailman/listinfo/python-list
[Q] How to exec code object with local variables specified?
Hi, Is it possible to run code object with local variables specified? I'm trying the following code but not work: def fn(): x = 1 y = 2 localvars = {'x': 0} exec(fn.func_code, globals(), localvars) print(localvars) ## what I expected is: {'x': 1, 'y': 2} ## but actual is: {'x': 0} Python: 2.7.3 OS: MacOS X -- regards, makoto kuwata -- http://mail.python.org/mailman/listinfo/python-list
Re: Programming Issues
On 09/19/2012 07:01 PM, Nathan Spicer wrote: Dave, You sent this response privately, which isn't the way the mailing list works. Private responses are good for thank-yous and for personal remarks of no interest to others. But you're short-circuiting the helping process if you don't let everyone else see what you're saying here. I'll forward my response to the list, so others can jump in. You also top-posted, rather than putting your remarks after what you're quoting. I'm running Python 3.2. I think doing raw input is what the instructor is looking for. What version of Python does the instructor think you're using? raw_input is not in Python 3.2, being renamed to input(). The 2.x logic of input() is fortunately gone, as it was quite unsafe. I know a need to do a loop, but the problem is i don't know ho to do this. An open-ended loop can be done with the while statement. What I mean by open-ended is that you have no way of predicting how many times it will loop, because it depends on data you don't have ahead of time. The other type of loop is the for loop, where the loop will normally progress till it processes all items in a sequence. A while loop might look something like: def ask_user(): amount = get_amount() while amount != 0: do_some_stuff(amount) amount = get_amount() print done with program # And your top-level code might look something like: if __name__ == __main__: ask_user() If that makes sense to you, then write the functions that this one calls. If you don't understand this loop, then ask us to elaborate. And if you don't understand what this while statement itself does, ask your professor. There is no code, because i'm not sure how or what to write. So far we've done simple inputs. Are you aware of any examples similar to my problem, that i could look at and possibly base my program accordingly? Thanks, Nathan -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: [Q] How to exec code object with local variables specified?
Makoto Kuwata wrote: Is it possible to run code object with local variables specified? I'm trying the following code but not work: def fn(): x = 1 y = 2 localvars = {'x': 0} exec(fn.func_code, globals(), localvars) print(localvars) ## what I expected is: {'x': 1, 'y': 2} ## but actual is: {'x': 0} Python: 2.7.3 loc = {} exec(x = 1; y = 2, globals(), loc) loc {'y': 2, 'x': 1} However, this won't work with the code object taken from a function which uses a different a bytecode (STORE_FAST instead of STORE_NAME): import dis def f(): x = 1 ... dis.dis(f) 1 0 LOAD_CONST 1 (1) 3 STORE_FAST 0 (x) 6 LOAD_CONST 0 (None) 9 RETURN_VALUE dis.dis(compile(x=1, nofile, exec)) 1 0 LOAD_CONST 0 (1) 3 STORE_NAME 0 (x) 6 LOAD_CONST 1 (None) 9 RETURN_VALUE -- http://mail.python.org/mailman/listinfo/python-list
Re: 'indent'ing Python in windows bat
Jason Friedman ja...@powerpull.net wrote: I'm converting windows bat files little by little to Python 3 as I find time and learn Python. The most efficient method for some lines is to call Python like: python -c import sys; sys.exit(3) How do I indent if I have something like: if (sR=='Cope'): sys.exit(1) elif (sR=='Perform') sys.exit(2) else sys.exit(3) Some months ago I posted what I think is a similar question in the Unix world: I wanted to call a small portion of Python from within a Bash script. Someone on this list answered (for Bash): #!/bin/bash command1 command2 python -c if True: import module if condition: do_this else: do_that command4 # end code Perhaps something similar would work for a .bat file. Provided there's only one Python block in the .bat or .cmd file then there's no real problem; you just have to hide each language from the other: goto :start :start @echo off echo This is a CMD script python -x %~f0 %1 echo Back in the CMD script goto :eof import sys print(Welcome to Python) print(Arguments were {}.format(sys.argv)) print(Bye!) You can put the Python code either before or after the triple-quote string containing the CMD commands, just begin the file with a goto to skip into the batch commands and end them by jumping to eof. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Fool Python class with imaginary members (serious guru stuff inside)
I'm trying to create a class that would lie to the user that a member is in some cases a simple variable and in other cases a class. The nature of the member would depend on call syntax like so: 1. x = obj.member #x becomes the simple value contained in member 2. x = obj.member.another_member #x becomes the simple value contained in first member's another_member. So the first method detects that we only need a simple value and returns that. The second method sees that we need member as a class and returns that. Note that simple type could mean anything, from int to bitmap image. I have determined that this is possible if I sacrifice the final member reference to the __call__ override using function-call syntax: 1. x = obj.member(). The call syntax returns the simple value and the other returns the class. It is also possible if I override the __xxxitem__ methods to simulate a dictionary. However, I would like to use the true member access syntax if possible. So, is it possible? -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine (using ssh ?)
On 9/19/2012 12:50 PM ashish said... Hi c.l.p folks Here is my situation 1. I have two machines. Lets call them 'local' 'remote'. Both run ubuntu both have python installed 2. I have a python script, local.py, running on 'local' which needs to pass arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to a python script, remote.py running on 'remote' (the remote machine). I have the following questions: 1. What's the best way to accomplish my task ? Check out http://rpyc.sourceforge.net/ -- It's reasonably lightweight and has been working well for our similar situation. Emile -- http://mail.python.org/mailman/listinfo/python-list
How to limit CPU usage in Python
Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this task? I saw Resource module but I think it is not the module I am looking for. Some people recommend to use nice and cpulimit unix tools, but those are external to python and I prefer a python solution. I am working with Linux (Ubuntu 10.04). Best regards. -- http://mail.python.org/mailman/listinfo/python-list
Re: [Q] How to exec code object with local variables specified?
On Thu, Sep 20, 2012 at 10:15 PM, Peter Otten __pete...@web.de wrote: loc = {} exec(x = 1; y = 2, globals(), loc) loc {'y': 2, 'x': 1} However, this won't work with the code object taken from a function which uses a different a bytecode (STORE_FAST instead of STORE_NAME): Is there any way to use STORE_FAST instead of STORE_NAME? exec(string, ...) is not a solution for me. # What is different between fn.func_code and compile(string)? -- regards, makoto kuwata -- http://mail.python.org/mailman/listinfo/python-list
Re: [Q] How to exec code object with local variables specified?
On 9/20/2012 7:27 AM, Makoto Kuwata wrote: Is it possible to run code object with local variables specified? In the way you mean that, no. I'm trying the following code but not work: def fn(): x = 1 y = 2 localvars = {'x': 0} exec(fn.func_code, globals(), localvars) The globals and locals you pass to exec are the globals and locals for the context in which the code object runs. They have nothing to do with the code objects local namespace. Running exec with separate globals and locals is like running the code within a class definition context. If you ran def fn(): x = 1 class dummy: fn() dummy.x would not be defined and I presume you would not expect it to. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine (using ssh ?)
On Wed, Sep 19, 2012 at 12:50 PM, ashish ashish.mak...@gmail.com wrote: snip 2. I have a python script, local.py, running on 'local' which needs to pass arguments ( 3/4 string arguments, containing whitespaces like spaces, etc ) to a python script, remote.py running on 'remote' (the remote machine). snip 3. Has anybody been able to do this using os.system ? I tried this import os os.system (ssh remoteuser@remote python remote.py arg1 arg2 arg3) This worked, but if the arguments i tried to pass, had spaces, i was not able to 'escape' the spaces. Use the `subprocess` module instead (with shell=False). You then won't need to worry about escaping. http://docs.python.org/library/subprocess.html Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: A little morning puzzle
Here is my solution: ** Incredibly convoluted and maximally less concise solution than other offerings. ** Might be better ones though. Unlikely. Zing! -- http://mail.python.org/mailman/listinfo/python-list
Re: How to limit CPU usage in Python
On 9/20/2012 11:12 AM, Rolando Cañer Roblejo wrote: Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this task? I saw Resource module but I think it is not the module I am looking for. Some people recommend to use nice and cpulimit unix tools, but those are external to python and I prefer a python solution. I am working with Linux (Ubuntu 10.04). Call the external tools with subprocess.open. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How to limit CPU usage in Python
On 9/20/2012 12:46 PM, Terry Reedy wrote: On 9/20/2012 11:12 AM, Rolando Cañer Roblejo wrote: Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this task? I saw Resource module but I think it is not the module I am looking for. Some people recommend to use nice and cpulimit unix tools, but those are external to python and I prefer a python solution. I am working with Linux (Ubuntu 10.04). Call the external tools with subprocess.open. I meant to end that with ? as I don't know how easy it is to get the external id of the calling process that is to be limited. I presume that can be done by first calling ps (with subprocess) and searching the piped-back output. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Fool Python class with imaginary members (serious guru stuff inside)
On 9/20/2012 9:52 AM, Jure Erznožnik wrote: I'm trying to create a class that would lie to the user that a member is in some cases a simple variable and in other cases a class. The nature of the member would depend on call syntax like so: 1. x = obj.member #x becomes the simple value contained in member 2. x = obj.member.another_member #x becomes the simple value contained in first member's another_member. x.y.z is parsed and executed as (x.y).z, so you are asking if the attribute-getter can know what will be done with the object it returns. Assuming CPython, you would have to write something that searches the Python code before compilation, the ast during compilation, or the bytecode after compilation. Much easier would be to define a union class that is a simple type with attributes and return that in the first lookup. class AttrInt(int): def __getattr__(self, name): return 'attribute' y = AttrInt(3) print(y, y.a) ### 3 attribute If x.y returns an AttrInt, it will act like an int for most purposes, while x.y.z will return whatever AttrInt.__getattr__ does and the temporary AttrInt y disappears. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: How to limit CPU usage in Python
On Thu, Sep 20, 2012 at 11:12 AM, Rolando Cañer Roblejo rolando.ca...@cnic.edu.cu wrote: Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this task? I saw Resource module but I think it is not the module I am looking for. Some people recommend to use nice and cpulimit unix tools, but those are external to python and I prefer a python solution. I am working with Linux (Ubuntu 10.04). Maximum percentage of CPU used isn't normally something you control. The only way I know of to do it involves having another process monitor the thing you want to control and sending signals to stop and start it (e.g., http://cpulimit.sourceforge.net/). Typically, you instead want to control the priority (so that higher priority apps can easily take more CPU time). That's what nice is for (http://docs.python.org/library/os.html#os.nice). If you want to limit a process in the same way that ulimit does, then the resources module is what you want (http://docs.python.org/library/resource.html#resource.setrlimit). Is there a particular reason that you'd rather have your CPU sitting idle, rather than continuing with whatever code is waiting to be run? I'm having a hard time understanding what problem you might be having that some combination of setting the nice level and imposing resource limits won't handle. -- Jerry -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine (using ssh ?)
Ismael Farfán sulfur...@gmail.com writes: How about something like this: os.system ( 'ssh remoteuser@remote python remote.py arg 1 arg 2 arg 3' ) That won't work. You need an additional level of quoting because ssh is also a shell so it adds another level of interpretation. The following works: os.system('''ssh remoteuser@remote python remote.py 'arg 1' 'arg 2' 'arg 3) -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
Re: Passing arguments to executing, a python script on a remote machine from a python script on local machine (using ssh ?)
Chris Rebert c...@rebertia.com writes: Use the `subprocess` module instead (with shell=False). You then won't need to worry about escaping. http://docs.python.org/library/subprocess.html You will still need to worry about escaping because on the remote end you invoke ssh which is a shell. The obvious call: subprocess.call([ssh, remoteuser@remote, python, remote.py, arg 1, arg 2, arg 3]) won't work because ssh will break up the arg n strings. You need to use 'arg n' or put the whole python command in a string like: python TEST/testargs.py 'arg 1' 'arg 2' 'arg 3' -- Piet van Oostrum p...@vanoostrum.org WWW: http://pietvanoostrum.com/ PGP key: [8DAE142BE17999C4] -- http://mail.python.org/mailman/listinfo/python-list
looping in array vs looping in a dic
Hi, I have this script in python that i need to apply for very large arrays (arrays coming from satellite images). The script works grate but i would like to speed up the process. The larger computational time is in the for loop process. Is there is a way to improve that part? Should be better to use dic() instead of np.ndarray for saving the results? and if yes how i can make the sum in dic()(like in the correspondent matrix[row_c,1] = matrix[row_c,1] + valuesRaster[row,col] )? If the dic() is the solution way is faster? Thanks Giuseppe import numpy as np import sys from time import clock, time # create the arrays start = time() valuesRaster = np.random.random_integers(0, 100, 100).reshape(10, 10) valuesCategory = np.random.random_integers(1, 10, 100).reshape(10, 10) elapsed = (time() - start) print(elapsed , create the data) start = time() categories = np.unique(valuesCategory) matrix = np.c_[ categories , np.zeros(len(categories))] elapsed = (time() - start) print(elapsed , create the matrix and append a colum zero ) rows = 10 cols = 10 start = time() for col in range(0,cols): for row in range(0,rows): for row_c in range(0,len(matrix)) : if valuesCategory[row,col] == matrix[row_c,0] : matrix[row_c,1] = matrix[row_c,1] + valuesRaster[row,col] break elapsed = (time() - start) print(elapsed , loop in the data ) print (matrix) -- http://mail.python.org/mailman/listinfo/python-list
Development mode
I am new to python and I have come across the following command and its description: Now to be able to run the project you will need to install it and its dependencies. python setup.py develop I looked up what the 'develop' argument does and found: Extra commands: develop install package in 'development mode' I searched for a description of 'development mode' but could not find a good description. Can anyone (very briefly) explain to me, in a sentence or two: what 'development mode' is? how 'development mode' differs from other 'modes'? why/when I would use 'development mode'? what 'development mode' does or does not allow me to do? Many thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: looping in array vs looping in a dic
On 2012-09-20 19:31, giuseppe.amatu...@gmail.com wrote: Hi, I have this script in python that i need to apply for very large arrays (arrays coming from satellite images). The script works grate but i would like to speed up the process. The larger computational time is in the for loop process. Is there is a way to improve that part? Should be better to use dic() instead of np.ndarray for saving the results? and if yes how i can make the sum in dic()(like in the correspondent matrix[row_c,1] = matrix[row_c,1] + valuesRaster[row,col] )? If the dic() is the solution way is faster? Thanks Giuseppe import numpy as np import sys from time import clock, time # create the arrays start = time() valuesRaster = np.random.random_integers(0, 100, 100).reshape(10, 10) valuesCategory = np.random.random_integers(1, 10, 100).reshape(10, 10) elapsed = (time() - start) print(elapsed , create the data) start = time() categories = np.unique(valuesCategory) matrix = np.c_[ categories , np.zeros(len(categories))] elapsed = (time() - start) print(elapsed , create the matrix and append a colum zero ) rows = 10 cols = 10 start = time() for col in range(0,cols): for row in range(0,rows): for row_c in range(0,len(matrix)) : if valuesCategory[row,col] == matrix[row_c,0] : matrix[row_c,1] = matrix[row_c,1] + valuesRaster[row,col] break elapsed = (time() - start) print(elapsed , loop in the data ) print (matrix) If I understand the code correctly, 'matrix' contains the categories in column 0 and the totals in column 1. What you're doing is performing a linear search through the categories and then adding to the corresponding total. Linear searches are slow because on average you have to search through half of the list. Using a dict would be much faster (although you should of course measure it!). Try something like this: import numpy as np from time import time # Create the arrays. start = time() valuesRaster = np.random.random_integers(0, 100, 100).reshape(10, 10) valuesCategory = np.random.random_integers(1, 10, 100).reshape(10, 10) elapsed = time() - start print(elapsed, Create the data.) start = time() categories = np.unique(valuesCategory) totals = dict.fromkeys(categories, 0) elapsed = time() - start print(elapsed, Create the totals dict.) rows = 100 cols = 10 start = time() for col in range(cols): for row in range(rows): cat = valuesCategory[row, col] ras = valuesRaster[row, col] totals[cat] += ras elapsed = time() - start print(elapsed, Loop in the data.) print(totals) -- http://mail.python.org/mailman/listinfo/python-list
Re: Fool Python class with imaginary members (serious guru stuff inside)
On Thu, 20 Sep 2012 06:52:07 -0700, Jure Erznožnik wrote: I'm trying to create a class that would lie to the user that a member is in some cases a simple variable and in other cases a class. The nature of the member would depend on call syntax like so: 1. x = obj.member #x becomes the simple value contained in member 2. x = obj.member.another_member #x becomes the simple value contained in first member's another_member. Why do you hate your users so much that you want to cause them enormous difficulty with perfectly reasonable code like this? tmp = obj.member x = tmp.another_member So the first method detects that we only need a simple value and returns that. Fortunately that is impossible without nasty bytecode or AST hacks. Thank the stars that Python doesn't allow anything as badly designed as this! -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: How to limit CPU usage in Python
Am 20.09.2012 17:12, schrieb Rolando Cañer Roblejo: Hi all, Is it possible for me to put a limit in the amount of processor usage (% CPU) that my current python script is using? Is there any module useful for this task? I saw Resource module but I think it is not the module I am looking for. Some people recommend to use nice and cpulimit unix tools, but those are external to python and I prefer a python solution. I am working with Linux (Ubuntu 10.04). Hello, you have two options here. You can either limit the total amount of CPU seconds with the resource module or reduce the priority and scheduling priority of the process. The resource module is a wrapper around the setrlimit and getrlimit feature as described in http://linux.die.net/man/2/setrlimit . The scheduling priority can be altered with nice, get/setpriority or io priority. The psutil package http://code.google.com/p/psutil/ wraps all functions in a nice Python API. Regards Christian -- http://mail.python.org/mailman/listinfo/python-list
Re: looping in array vs looping in a dic
On Thu, Sep 20, 2012 at 1:09 PM, MRAB pyt...@mrabarnett.plus.com wrote: for col in range(cols): for row in range(rows): cat = valuesCategory[row, col] ras = valuesRaster[row, col] totals[cat] += ras Expanding on what MRAB wrote, since you probably have far fewer categories than pixels, you may be able to take better advantage of numpy's vectorized operations (which are pretty much the whole point of using numpy in the first place) by looping over the categories instead: for cat in categories: totals[cat] += np.sum(valuesCategory * (valuesRaster == cat)) -- http://mail.python.org/mailman/listinfo/python-list
Re: looping in array vs looping in a dic
On Thu, Sep 20, 2012 at 1:28 PM, Ian Kelly ian.g.ke...@gmail.com wrote: Expanding on what MRAB wrote, since you probably have far fewer categories than pixels, you may be able to take better advantage of numpy's vectorized operations (which are pretty much the whole point of using numpy in the first place) by looping over the categories instead: for cat in categories: totals[cat] += np.sum(valuesCategory * (valuesRaster == cat)) Of course, that should have read: for cat in categories: totals[cat] += np.sum(valuesRaster * (valuesCategory == cat)) -- http://mail.python.org/mailman/listinfo/python-list
When should I use development mode?
I am new to python and I have come across the following command and its description: Now to be able to run the project you will need to install it and its dependencies. python setup.py develop I looked up what the 'develop' argument does and found: Extra commands: develop install package in 'development mode' I searched for a description of 'development mode' but could not find a good description. Can anyone (very briefly) explain to me, in a sentence or two: what 'development mode' is? how 'development mode' differs from other 'modes'? why/when I would use 'development mode'? what 'development mode' does or does not allow me to do? Many thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: When should I use development mode?
On Thu, Sep 20, 2012 at 1:38 PM, py_lrnr henryalpha...@hotmail.com wrote: Can anyone (very briefly) explain to me, in a sentence or two: what 'development mode' is? how 'development mode' differs from other 'modes'? why/when I would use 'development mode'? what 'development mode' does or does not allow me to do? Instead of installing the package into your site-packages, it installs a link back to the source folder. This lets you make changes to the code in the source folder which are immediately visible to Python without having to install the package again. -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing Pip onto a mac os x system
Thank you Hans M. for some input. Now it shows the error of: sudo: easy_instal: command not found -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing Pip onto a mac os x system
In a316e0ba-8b7c-470e-b9cf-4c4647aa3...@googlegroups.com John Mordecai Dildy jdild...@gmail.com writes: Now it shows the error of: sudo: easy_instal: command not found Try 'easy_install' instead of 'easy_instal'. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies -- http://mail.python.org/mailman/listinfo/python-list
Re: Installing Pip onto a mac os x system
On Thursday, September 20, 2012 4:37:36 PM UTC-4, John Gordon wrote: In a316e0ba-8b7c-470e-b9cf-4c4647aa3...@googlegroups.com John Mordecai Dildy jdild...@gmail.com writes: Now it shows the error of: sudo: easy_instal: command not found Try 'easy_install' instead of 'easy_instal'. -- John Gordon A is for Amy, who fell down the stairs gor...@panix.com B is for Basil, assaulted by bears -- Edward Gorey, The Gashlycrumb Tinies Thanks John G. -- http://mail.python.org/mailman/listinfo/python-list
portable way of locating an executable (like which)
I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. If not, is there a portable way of splitting the environment variable PATH? Thanks for any sugestions -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On 20/09/2012 22:06, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. Searching found nothing obvious to me :( If not, is there a portable way of splitting the environment variable PATH? With os.sep ? Thanks for any sugestions -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On Thu, Sep 20, 2012 at 5:06 PM, Gelonida N gelon...@gmail.com wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. If not, is there a portable way of splitting the environment variable PATH? I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: for path in os.getenv(PATH).split(os.pathsep): exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file return None IIRC, I adapted it from StackOverflow. I know it works on Linux and Mac OS X, but not sure about windows (since I don't know if PATH works the same way there). HTH, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On Fri, Sep 21, 2012 at 7:47 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 20/09/2012 22:06, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. Searching found nothing obvious to me :( If not, is there a portable way of splitting the environment variable PATH? With os.sep ? os.sep is the directory separator, but os.pathsep may be what you want. Between that and os.getenv('path') you can at least get the directories. Then on Windows, you also need to check out os.getenv('pathext') and split _that_ on the semicolon, and try each of those as a file extension. I'm not sure whether or not Windows will add extensions from pathext if one is given on the command line - for instance, if typing foo.exe will search for foo.exe.bat - but the basics are there. Alternatively, there may be a Win32 API funct5ion that does this. Would be worth a look. ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On Thu, Sep 20, 2012 at 4:21 PM, Chris Angelico ros...@gmail.com wrote: os.sep is the directory separator, but os.pathsep may be what you want. Between that and os.getenv('path') you can at least get the directories. Then on Windows, you also need to check out os.getenv('pathext') and split _that_ on the semicolon, and try each of those as a file extension. I'm not sure whether or not Windows will add extensions from pathext if one is given on the command line - for instance, if typing foo.exe will search for foo.exe.bat - but the basics are there. Easy enough to test: C:\echo echo hello! foo.exe.bat C:\foo.exe hello! Yup, it does. It looks like it tries it without the extension first, though: C:\copy c:\windows\notepad.exe foo.exe 1 file(s) copied. C:\foo.exe [starts notepad] -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On Fri, Sep 21, 2012 at 8:32 AM, Ian Kelly ian.g.ke...@gmail.com wrote: On Thu, Sep 20, 2012 at 4:21 PM, Chris Angelico ros...@gmail.com wrote: os.sep is the directory separator, but os.pathsep may be what you want. Between that and os.getenv('path') you can at least get the directories. Then on Windows, you also need to check out os.getenv('pathext') and split _that_ on the semicolon, and try each of those as a file extension. I'm not sure whether or not Windows will add extensions from pathext if one is given on the command line - for instance, if typing foo.exe will search for foo.exe.bat - but the basics are there. Easy enough to test: C:\echo echo hello! foo.exe.bat C:\foo.exe hello! Yup, it does. It looks like it tries it without the extension first, though: C:\copy c:\windows\notepad.exe foo.exe 1 file(s) copied. C:\foo.exe [starts notepad] Well, at least it's consistent. Makes your PATH extremely sensitive, though, easy for anyone to inject executables into it. But then, you can already do that by putting them in the current directory, so that's not really any different. Jason's solution looks fine apart from the PATHEXT requirement, so if you know you have the full filename and you don't care if the actual command interpreter will do exactly the same, that'll do you fine. Is this something that might want to be a function in the os module? Particularly so if, as I suspect there might be, there's a Win32 API function that precisely replicates the behaviour of executable invocation. A while since I've done much Windows programming but I think there's a SearchPath function? ChrisA -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On 09/21/2012 12:21 AM, Chris Angelico wrote: On Fri, Sep 21, 2012 at 7:47 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: On 20/09/2012 22:06, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. Searching found nothing obvious to me :( I was afraid so, but wanted to be sure If not, is there a portable way of splitting the environment variable PATH? With os.sep ? os.sep is the directory separator, but os.pathsep may be what you want. Thanks, os.pathsep was the missing piece for portably splitting the searchpath Between that and os.getenv('path') you can at least get the directories. Then on Windows, you also need to check out os.getenv('pathext') and split _that_ on the semicolon, and try each of those as a file extension. I'm not sure whether or not Windows will add extensions from pathext if one is given on the command line - for instance, if typing foo.exe will search for foo.exe.bat - but the basics are there. For what I am doing I can even skip trying the pathexts, the ext is already given, but good to know :-) Alternatively, there may be a Win32 API funct5ion that does this. Would be worth a look. Yeah true, but ideally I'd like to avoid platform detection and just have a generic function. -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On 09/21/2012 12:04 AM, Jason Swails wrote: Thanks a lot Jason, I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: for path in os.getenv(PATH).split(os.pathsep): exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file return None IIRC, I adapted it from StackOverflow. I know it works on Linux and Mac OS X, but not sure about windows (since I don't know if PATH works the same way there). I'll try it, the script looks reasonably portable (using os.pathsep) to really replicate which I had probably to add os.getenv('pathext') as Chris mentioned. However for my current use case this is not necessarily required. HTH, Jason -- http://mail.python.org/mailman/listinfo/python-list
Re: looping in array vs looping in a dic
Hi Ian and MRAB thanks to you input i have improve the speed of my code. Definitely reading in dic() is faster. I have one more question. In the dic() I calculate the sum of the values, but i want count also the number of observation, in order to calculate the average in the end. Should i create a new dic() or is possible to do in the same dic(). Here in the final code. Thanks Giuseppe rows = dsCategory.RasterYSize cols = dsCategory.RasterXSize print(Generating output file %s %(dst_file)) start = time() unique=dict() for irows in xrange(rows): valuesRaster=dsRaster.GetRasterBand(1).ReadAsArray(0,irows,cols,1) valuesCategory=dsCategory.GetRasterBand(1).ReadAsArray(0,irows,cols,1) for icols in xrange(cols): if ( valuesRaster[0,icols] != no_data_Raster ) and ( valuesCategory[0,icols] != no_data_Category ) : row = valuesCategory[0, icols],valuesRaster[0, icols] if row[0] in unique : unique[row[0]] += row[1] else: unique[row[0]] = 0+row[1] # this 0 was add if not the first observation was considered = 0 -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On 21/09/2012 00:15, Gelonida N wrote: On 09/21/2012 12:04 AM, Jason Swails wrote: Thanks a lot Jason, I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: for path in os.getenv(PATH).split(os.pathsep): exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file return None IIRC, I adapted it from StackOverflow. I know it works on Linux and Mac OS X, but not sure about windows (since I don't know if PATH works the same way there). I'll try it, the script looks reasonably portable (using os.pathsep) to really replicate which I had probably to add os.getenv('pathext') as Chris mentioned. However for my current use case this is not necessarily required. HTH, Jason http://nedbatchelder.com/code/utilities/wh_py.html -- Cheers. Mark Lawrence. -- http://mail.python.org/mailman/listinfo/python-list
Re: looping in array vs looping in a dic
On 2012-09-21 00:35, giuseppe.amatu...@gmail.com wrote: Hi Ian and MRAB thanks to you input i have improve the speed of my code. Definitely reading in dic() is faster. I have one more question. In the dic() I calculate the sum of the values, but i want count also the number of observation, in order to calculate the average in the end. Should i create a new dic() or is possible to do in the same dic(). Here in the final code. Thanks Giuseppe Keep it simple. Use 2 dicts. rows = dsCategory.RasterYSize cols = dsCategory.RasterXSize print(Generating output file %s %(dst_file)) start = time() unique=dict() for irows in xrange(rows): valuesRaster=dsRaster.GetRasterBand(1).ReadAsArray(0,irows,cols,1) valuesCategory=dsCategory.GetRasterBand(1).ReadAsArray(0,irows,cols,1) for icols in xrange(cols): if ( valuesRaster[0,icols] != no_data_Raster ) and ( valuesCategory[0,icols] != no_data_Category ) : row = valuesCategory[0, icols],valuesRaster[0, icols] if row[0] in unique : unique[row[0]] += row[1] else: unique[row[0]] = 0+row[1] # this 0 was add if not the first observation was considered = 0 You could use defaultdict instead: from collections import defaultdict unique = defaultdict(int) ... category, raster = valuesCategory[0, icols], valuesRaster[0, icols] unique[category] += raster -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On Thu, 20 Sep 2012 23:06:46 +0200, Gelonida N wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Note that which attempts to emulate the behaviour of execvp() etc. The exec(3) manpage will explain the precise algorithm used (e.g. they skip files for which the process lacks execute permission). Also, note that the shell has built-in commands, functions, and aliases in addition to programs. The type built-in command performs a similar function to which but using the shell's semantics. On some systems, the default configuration may alias which to type. On Windows, there's a host of different execute program interface, all with subtly different semantics: which extensions they will run, which extensions can be omitted, which paths are used (e.g. %PATH%, paths from the registry, current directory). -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On 09/20/2012 06:04 PM, Jason Swails wrote: On Thu, Sep 20, 2012 at 5:06 PM, Gelonida N gelon...@gmail.com wrote: I'd like to implement the equivalent functionality of the unix command /usr/bin/which The function should work under Linux and under windows. Did anybody already implement such a function. If not, is there a portable way of splitting the environment variable PATH? I've used the following in programs I write: def which(program): def is_exe(fpath): return os.path.exists(fpath) and os.access(fpath, os.X_OK) fpath, fname = os.path.split(program) if fpath: if is_exe(program): return program else: for path in os.getenv(PATH).split(os.pathsep): exe_file = os.path.join(path, program) if is_exe(exe_file): return exe_file return None IIRC, I adapted it from StackOverflow. I know it works on Linux and Mac OS X, but not sure about windows (since I don't know if PATH works the same way there). I don't have a Windows machine set up right now, but I believe there are two more directories to search, besides the ones described in the PATH variable. One is the current directory, and the other is the Windows directory (maybe also the xxx/system32 or something). They don't have analogues in Linux or Mac, as far as I know. -- DaveA -- http://mail.python.org/mailman/listinfo/python-list
Re: portable way of locating an executable (like which)
On 2012.09.20 21:31, Dave Angel wrote: I don't have a Windows machine set up right now, but I believe there are two more directories to search, besides the ones described in the PATH variable. One is the current directory, and the other is the Windows directory (maybe also the xxx/system32 or something). Those system directories are in the path by default. -- CPython 3.3.0rc2 | Windows NT 6.1.7601.17835 -- http://mail.python.org/mailman/listinfo/python-list
Re: Obnoxious postings from Google Groups
On 9/16/2012 8:18 AM, Ben Finney wrote: Νικόλαος Κούρας nikos.gr...@gmail.com writes: Iam sorry i didnt do that on purpose and i dont know how this is done. Iam positng via google groups using chrome, thats all i know. It is becoming quite clear that some change has happened recently to Google Groups that makes posts coming from there rather more obnoxious than before. And there doesn't seem to be much its users can do except use something else. Using Google Groups for posting to Usenet has been a bad idea for a long time, but now it just seems to be a sure recipe for annoying the rest of us. Again, not something you have much control over, except to stop using Google Groups. Could this mean that Google wants all the spam posted through Google Groups to look obnoxious to the rest of Usenet that the spammers will go elsewhere? Robert Miles -- http://mail.python.org/mailman/listinfo/python-list
python idioms : some are confusing
Amongst the python idioms, how the below-mentioned make sense? ## There should be one-- and preferably only one --obvious way to do it. Although that way may not be obvious at first unless you're Dutch. --- In programming, there can be a number of ways, equally efficient, to do certain thing. ## Although never is often better than *right* now. --- How come never is better that right now ? Any thoughts?... -- http://mail.python.org/mailman/listinfo/python-list
Re: python idioms : some are confusing
On Sep 21, 3:34 pm, Vineet vineet.deod...@gmail.com wrote: Amongst the python idioms, how the below-mentioned make sense? ## There should be one-- and preferably only one --obvious way to do it. --- In programming, there can be a number of ways, equally efficient, to do certain thing. This isn't talking about your Python code as much as about Python itself. For example, in Python 2.x you can use either `open` or `file` to open a file, with `file` being a factory function for creating file objects, and `open` using it internally. In Python 3.x, `file` is no longer a built-in, as it produced a point of confusion as to which was the one obvious way to open a file. ## Although never is often better than *right* now. --- How come never is better that right now ? It's better to not add a language feature than it is to add it poorly, especially when you endeavour to provide backwards compatibility as much as possible within major versions. -- http://mail.python.org/mailman/listinfo/python-list
[issue15979] Improve timeit documentation
Ezio Melotti added the comment: The sh syntax highlight can be enabled with: .. code-block:: sh $ ... -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15979 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15977] Memory leak in _ssl.c
Daniel Sommermann added the comment: This patch looks good to me (it's exactly how I fixed it in my local build), although I'm not sure how to approve your patch so you can push it to the upstream. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15977 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15980] Non-escaped '\n' in docstrings
New submission from Serhiy Storchaka: Here are patches that escapes '\n' in docstrings of LWPCookieJar and (for 2.7 only) of email. -- assignee: docs@python components: Documentation files: escape_nl2.patch keywords: patch messages: 170794 nosy: docs@python, ezio.melotti, storchaka priority: normal severity: normal status: open title: Non-escaped '\n' in docstrings type: enhancement versions: Python 2.7, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file27229/escape_nl2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15980 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15980] Non-escaped '\n' in docstrings
Changes by Serhiy Storchaka storch...@gmail.com: Added file: http://bugs.python.org/file27230/escape_nl2-2.7.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15980 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15944] memoryviews and ctypes
Stefan Krah added the comment: As I understand it, you prefer memoryviews where the format is purely informational, whereas we now have typed memoryviews. Typed memoryviews are certainly useful, in fact they are present in Cython, see here for examples: http://docs.cython.org/src/userguide/memoryviews.html I can see only one obvious benefit of ignoring the format: All possible formats are accepted. What I don't understand is why this ... m[0] = b'\x00\x00\x00\x01' ... should be preferable to: m[0] = 1 If you think that typed memoryviews are a mistake, I suggest raising the issue on python-dev as soon as possible (3.3 is due soon). All memoryview operations are now based on values instead of bit patterns, see for example #15573. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15944 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15977] Memory leak in _ssl.c
Roundup Robot added the comment: New changeset 2bdc8c8ea42e by Christian Heimes in branch 'default': Issue #15977: Fix memory leak in Modules/_ssl.c when the function _set_npn_protocols() is called multiple times http://hg.python.org/cpython/rev/2bdc8c8ea42e -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15977 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15977] Memory leak in _ssl.c
Christian Heimes added the comment: Georg, here is another candidate for the new release candidate. Daniel, two equal patches are good enough as a patch review. The fix is simple and straight forward, too. Thanks for your report! -- assignee: - georg.brandl nosy: +georg.brandl resolution: - fixed stage: patch review - committed/rejected status: open - pending ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15977 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15981] improve documentation of __hash__
New submission from Max: In dev/reference/datamodel#object.__hash__, there are two paragraphs that seem inconsistent. The first paragraph seems to say that a class that overrides __eq__() *should* explicitly flag itself as unhashable. The next paragraph says that a class that overrides __eq__() *will be* flagged unhashable by default. Which one is it? Here are the two paragraphs: Classes which inherit a __hash__() method from a parent class but change the meaning of __eq__() such that the hash value returned is no longer appropriate (e.g. by switching to a value-based concept of equality instead of the default identity based equality) can explicitly flag themselves as being unhashable by setting __hash__ = None in the class definition. Doing so means that not only will instances of the class raise an appropriate TypeError when a program attempts to retrieve their hash value, but they will also be correctly identified as unhashable when checking isinstance(obj, collections.Hashable) (unlike classes which define their own __hash__() to explicitly raise TypeError). If a class that overrides __eq__() needs to retain the implementation of __hash__() from a parent class, the interpreter must be told this explicitly by setting __hash__ = ParentClass.__hash__. Otherwise the inheritance of __hash__() will be blocked, just as if __hash__ had been explicitly set to None. -- assignee: docs@python components: Documentation messages: 170798 nosy: docs@python, max priority: normal severity: normal status: open title: improve documentation of __hash__ type: enhancement versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15981 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15982] asyncore.dispatcher does not handle windows socket error code correctly (namely WSAEWOULDBLOCK 10035)
New submission from Nicolai Ehemann: There are some differences between win32 and other os socket implementations. One specific I found is that in windows, non-blocking socket apis will return WSAEWOULDBLOCK or 10035 instead of EWOULDBLOCK. This causes recv() in asyncore.dispatcher to raise an unhandled exception instead of continuing gracefully. The fix could maybe be as simple as replacing line 384 in asyncore.py: data = self.socket.recv(buffer_size) with try: data = self.socket.recv(buffer_size) except socket.error as e: if 10035 == e.errno: pass else: raise e The differences between windows and unix non-blocking sockets are summarized quite nice here: http://itamarst.org/writings/win32sockets.html The original documentation from microsoft can be found here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms740668(v=vs.85).aspx -- components: Library (Lib) messages: 170799 nosy: McNetic priority: normal severity: normal status: open title: asyncore.dispatcher does not handle windows socket error code correctly (namely WSAEWOULDBLOCK 10035) type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15982 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15978] asyncore: included batteries don't fit
chrysn added the comment: i'm aware this is ambitious, and hope that at least the individual sub-agendas will be manageable. as for vague, i can enhance it (i'd start refining the individual sub-agendas -- or do you think the big picture needs more details too?). integration of frameworks is hard, i know. for some libraries, it might not even be feasible, or it could be that it'd be easier to write a new server than integrating into the existing one. (eg it might be easier to refactor http servers into a generic and a blocking part first, and then offer a http.server.AsyncServer in parallel to the existing implementation). that's why i'd like to try to get a rough roadmap instead of hacking ahead :-) nevertheless, the current situation is not satisfying -- we have a versatile http client module, and yet who wants to fetch asynchronously is left with a stub implementation in the asyncore docs. that's not what one would expect from the batteries included catchphrase. we don't need all of that implemented *right now*, but maybe we can do better than implementing it never. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15978 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15276] unicode format does not really work in Python 2.x
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15276 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15276] unicode format does not really work in Python 2.x
STINNER Victor added the comment: I fixed a similar bug in Python 3.3: issue #13706. changeset: 75231:f89e2f4cda88 user:Victor Stinner victor.stin...@haypocalc.com date:Fri Feb 24 00:37:51 2012 +0100 files: Include/unicodeobject.h Lib/test/test_format.py Objects/stringlib/asciilib.h Objects/stringlib/localeutil.h Objects/stringlib/stringdefs.h Objects/stringlib/ucs1lib.h description: Issue #13706: Fix format(int, n) for locale with non-ASCII thousands separator * Decode thousands separator and decimal point using PyUnicode_DecodeLocale() (from the locale encoding), instead of decoding them implicitly from latin1 * Remove _PyUnicode_InsertThousandsGroupingLocale(), it was not used * Change _PyUnicode_InsertThousandsGrouping() API to return the maximum character if unicode is NULL * Replace MIN/MAX macros by Py_MIN/Py_MAX * stringlib/undef.h undefines STRINGLIB_IS_UNICODE * stringlib/localeutil.h only supports Unicode -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15276 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15276] unicode format does not really work in Python 2.x
STINNER Victor added the comment: I can't reproduce this with Python 2.7.3. locale.setlocale(locale.LC_NUMERIC, 'fr_FR') 'fr_FR' u'{:n}'.format(1) u'10 000' I don't understand why, but the all french locales are the same. Some french locale uses the standard ASCII space (U+0020) as thousand seperator, others use the non-breaking space (U+00A0). I suppose that some systems prefer to avoid non-ASCII characters to avoid Unicode issues. On Ubuntu 12.04, locale.localeconv()['thousands_sep'] is chr(32) for the locale fr_FR.utf8. You may need to install other locales to test this issue. For example, the ps_AF locale uses U+066b as the decimal point and the thousands separator. I chose to not fix the issue in Python 3.2 because it needs to change too much code (and I don't want to introduce a regression and 3.2 code is very different than 3.3). You should upgrade to Python 3.3, or reimplement the Unicode format() function for numbers using locale.localeconv() ('thousands_sep', 'decimal_point' and 'grouping') :-/ Or find a more motivated developer. Or I can do the job if you pay me ;-) (Read also the issue #13706 for more information.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15276 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15973] Segmentation fault on timezone comparison
Jesús Cea Avión added the comment: Alexander, did you send a contributor agreement?. I don't see it in the tracker :-?? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15973 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15972] wrong error message for os.path.getsize
STINNER Victor added the comment: It looks like os.stat() and os.path.getsize() converts the list into a byte string. It does something like: x=[]; y=bytes(x); print(y.decode(ascii)) x=[65, 66, 67]; y=bytes(x); print(y.decode(ascii)) ABC x=[None]; y=bytes(x); print(y.decode(ascii)) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'NoneType' object cannot be interpreted as an integer -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15972 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15972] wrong error message for os.path.getsize
STINNER Victor added the comment: Functions of the os module uses PyUnicode_FSConverter() function (which uses PyBytes_Check() on bytes) in Python 3.2, whereas PyBytes_FromObject() is used in Python 3.3. Related change: changeset: 77597:27f9c26fdd8b user:Larry Hastings la...@hastings.org date:Fri Jun 22 16:30:09 2012 -0700 files: Doc/library/os.rst Lib/os.py Lib/shutil.py Lib/test/support.py Lib/test/test_os.py Lib/test/test_posix.py Lib/test/test_shutil.py Misc/NEWS Modules/posixmodule.c description: Issue #14626: Large refactoring of functions / parameters in the os module. Many functions now support dir_fd and follow_symlinks parameters; some also support accepting an open file descriptor in place of of a path string. Added os.support_* collections as LBYL helpers. Removed many functions only previously seen in 3.3 alpha releases (often starting with f or l, or ending with at). Originally suggested by Serhiy Storchaka; implemented by Larry Hastings. -- nosy: +larry, storchaka ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15972 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15972] wrong error message for os.path.getsize
STINNER Victor added the comment: Set the priority to release blocker until it is decided if this issue is a regression, or a new feature :-) -- priority: normal - release blocker ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15972 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15960] logging.shutdown should cope with IO errors from handler.release methods
Nick Coghlan added the comment: Dan and Amit worked out a patch for ConcurrentLogHandler (https://bugzilla.redhat.com/show_bug.cgi?id=858912) so I'm OK with rejecting this one. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15960 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12750] datetime.strftime('%s') should respect tzinfo
Mümin Öztürk added the comment: I made a patch for datetime.strftime('%s'). it takes tzinfo into consideration. datetime.datetime(1970,1,1).strftime(%s) '-7200' datetime.datetime(1970,1,1, tzinfo=datetime.timezone.utc).strftime(%s) '0' datetime.date still behave as naive datetime.datetime datetime.date(1970,1,1).strftime(%s) '-7200' -- keywords: +patch nosy: +mumino Added file: http://bugs.python.org/file27231/strftime.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue12750 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15144] Possible integer overflow in operations with addresses and sizes.
Serhiy Storchaka added the comment: Well, here is a new patch. The five new macros moved to pymacros.h and used in more files. -- Added file: http://bugs.python.org/file27232/align_operations2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15144 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14783] Make int() and str() docstrings correct
Serhiy Storchaka added the comment: It may be worth rewrite int() and str() so that the first argument was positional-only argument? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15144] Possible integer overflow in operations with addresses and sizes.
Mark Dickinson added the comment: Apologies; I got distracted from the main point of this issue with the strict aliasing stuff, and then it fell off the to-do list. Unassigning; Antoine or Victor, do you want to take this? -- assignee: mark.dickinson - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15144 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15983] multiprocessing JoinableQueue's join function with timeout
New submission from Karl Bicker: The multiprocessing.JoinableQueue's function join() should have a timeout argument so that one can check on other things while waiting for a queue to finish. As join() uses a condition to wait anyway, a timeout is easily implemented and passed to the Condidition.wait(). Patch is attached. -- components: Library (Lib) files: JoinableQueue_with_timeout.patch keywords: patch messages: 170812 nosy: legordian priority: normal severity: normal status: open title: multiprocessing JoinableQueue's join function with timeout type: enhancement versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4 Added file: http://bugs.python.org/file27233/JoinableQueue_with_timeout.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15983 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15983] multiprocessing JoinableQueue's join function with timeout
Changes by Berker Peksag berker.pek...@gmail.com: -- versions: -Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15983 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15960] logging.shutdown should cope with IO errors from handler.release methods
Changes by Vinay Sajip vinay_sa...@yahoo.co.uk: -- assignee: - vinay.sajip resolution: - wont fix stage: - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15960 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14783] Make int() and str() docstrings correct
Ezio Melotti added the comment: That would be backward incompatible, and there might be some valid (corner) cases to pass it as a keyword. Since people are usually not supposed to use it as a keyword arg, it doesn't matter much if the name is different if that makes the docs more understandable. If someone tries to do int(number=10) and gets an error it would likely switch to the simpler int(10). If he really needs keyword args he can always check the code. That said, I don't have a strong opinion about this, so if people think that x should be used, it's fine with me. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14783 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15954] No error checking after using of the wcsxfrm()
Serhiy Storchaka added the comment: No, I think the appropriate error is ValueError, at least if errno is EINVAL. With what message? msvcrt gives EILSEQ or ERANGE, but never EINVAL. EILSEQ is returned if LCMapString failed, and ERANE if the output buffer is too small. I don't see where ERANE can be returned. If the output buffer is too small then the required buffer size (not including terminating null-char) should be returned. I see the same issue with wcscoll() in locale.strcoll(). An alternative solution is in case of an error to return the original string (in locale.strxfrm) and to compare strings without regard locale (in locale.strcoll). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15954 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15973] Segmentation fault on timezone comparison
Alexander Belopolsky added the comment: Alexander, did you send a contributor agreement? At least twice. :-) -- keywords: +patch priority: normal - high stage: needs patch - commit review Added file: http://bugs.python.org/file27234/issue15973.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15973 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15981] improve documentation of __hash__
R. David Murray added the comment: This has already been fixed, and the change is visible in the online documentation. -- nosy: +r.david.murray resolution: - duplicate stage: - committed/rejected status: open - closed superseder: - confusing docs with regard to __hash__ ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15981 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15983] multiprocessing JoinableQueue's join function with timeout
Changes by Richard Oudkerk shibt...@gmail.com: -- nosy: +sbt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15983 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15144] Possible integer overflow in operations with addresses and sizes.
Serhiy Storchaka added the comment: Mark, please open a new discussion, so we don't lose it and that was the place for discussion. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15144 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15944] memoryviews and ctypes
David Beazley added the comment: There's probably a bigger discussion about memoryviews for a rainy day. However, the number one thing that would save all of this in my book would be to make sure cast('B') is universally supported regardless of format including endianness--especially in the standard library. For example, being able to do this: a = array.array('d',[1.0, 2.0, 3.0, 4.0]) m = memoryview(a).cast('B') m[0:4] = b'\x00\x01\x02\x03' a array('d', [1.000112050316, 2.0, 3.0, 4.0]) Right now, it doesn't work for ctypes. For example: import ctypes a = (ctypes.c_double * 4)(1,2,3,4) a __main__.c_double_Array_4 object at 0x1006a7cb0 m = memoryview(a).cast('B') Traceback (most recent call last): File stdin, line 1, in module ValueError: memoryview: source format must be a native single character format prefixed with an optional '@' As some background, being able to work with a byte view of memory is important for a lot of problems involving I/O, data interchange, and related problems where being able to accurately construct/deconstruct the underlying memory buffers is more useful than actually interpreting their contents. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15944 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15944] memoryviews and ctypes
David Beazley added the comment: One followup note---I think it's fine to punt on cast('B') if the memoryview is non-contiguous. That's a rare case that's probably not as common. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15944 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15421] Calendar.itermonthdates OverflowError
Skip Montanaro added the comment: LGTM -- nosy: +skip.montanaro ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15421 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15984] Wrong documentation for PyUnicode_FromObject()
New submission from Serhiy Storchaka: In the documentation it is written that PyUnicode_FromObject() is a shortcut for PyUnicode_FromEncodedObject(). But PyUnicode_FromObject() is not call PyUnicode_FromEncodedObject() direct nor indirect. PyUnicode_FromObject() works only with unicode and unicode subclass objects, PyUnicode_FromEncodedObject() is not works with unicode objects. -- assignee: docs@python components: Documentation messages: 170821 nosy: docs@python, storchaka priority: normal severity: normal status: open title: Wrong documentation for PyUnicode_FromObject() versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15984 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15421] Calendar.itermonthdates OverflowError
Changes by STINNER Victor victor.stin...@gmail.com: -- nosy: +haypo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15421 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15985] round() has wrong argument names
Changes by Ezio Melotti ezio.melo...@gmail.com: -- nosy: +ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15985 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15985] round() has wrong argument names
New submission from Chris Jerdonek: The documentation for round() says: round(x[, n]) Return the floating point value x rounded to n digits after the decimal point. If n is omitted, it defaults to zero. Delegates to x.__round__(n). (from http://docs.python.org/dev/library/functions.html#round ) However, we have the following: Python 3.3.0rc2+ (default:1704deb7e6d7+, Sep 16 2012, 04:49:45) round(x=4.7) Traceback (most recent call last): File stdin, line 1, in module TypeError: Required argument 'number' (pos 1) not found round(number=4.7) 5 The second argument is also affected: round(5.1234, n=3) Traceback (most recent call last): File stdin, line 1, in module TypeError: 'n' is an invalid keyword argument for this function round(5.1234, ndigits=3) 5.123 -- assignee: docs@python components: Documentation keywords: easy messages: 170822 nosy: cjerdonek, docs@python priority: normal severity: normal stage: needs patch status: open title: round() has wrong argument names type: behavior versions: Python 2.7, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15985 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15985] round() has wrong argument names
Mark Dickinson added the comment: A case where fixing the names improves both accuracy *and* readability! -- nosy: +mark.dickinson ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15985 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15421] Calendar.itermonthdates OverflowError
Terry J. Reedy added the comment: Context: http://issues.roundup-tracker.org/issue2550765 -- nosy: +terry.reedy ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15421 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15421] Calendar.itermonthdates OverflowError
Changes by Ezio Melotti ezio.melo...@gmail.com: -- assignee: - ezio.melotti ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15421 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15972] wrong error message for os.path.getsize
Serhiy Storchaka added the comment: Here is a patch. Are there any tests for string and bytes arguments as filenames? I will add float and list there. -- keywords: +patch Added file: http://bugs.python.org/file27235/posix_path_converter.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15972 ___diff -r ddec854843f1 Modules/posixmodule.c --- a/Modules/posixmodule.c Thu Sep 20 09:47:41 2012 +0300 +++ b/Modules/posixmodule.c Thu Sep 20 20:50:29 2012 +0300 @@ -427,26 +427,24 @@ #endif static int -_fd_converter(PyObject *o, int *p, int default_value) { -long long_value; -if (o == Py_None) { -*p = default_value; -return 1; -} -if (PyFloat_Check(o)) { -PyErr_SetString(PyExc_TypeError, -integer argument expected, got float ); +_fd_converter(PyObject *o, int *p, const char *allowed) +{ +int overflow; +long long_value = PyLong_AsLongAndOverflow(o, overflow); +if (PyFloat_Check(o) || +(long_value == -1 !overflow PyErr_Occurred())) { +PyErr_Clear(); +PyErr_Format(PyExc_TypeError, +argument must be %s, not %.200s, +allowed, Py_TYPE(o)-tp_name); return 0; } -long_value = PyLong_AsLong(o); -if (long_value == -1 PyErr_Occurred()) -return 0; -if (long_value INT_MAX) { +if (overflow 0 || long_value INT_MAX) { PyErr_SetString(PyExc_OverflowError, signed integer is greater than maximum); return 0; } -if (long_value INT_MIN) { +if (overflow 0 || long_value INT_MIN) { PyErr_SetString(PyExc_OverflowError, signed integer is less than minimum); return 0; @@ -456,8 +454,13 @@ } static int -dir_fd_converter(PyObject *o, void *p) { -return _fd_converter(o, (int *)p, DEFAULT_DIR_FD); +dir_fd_converter(PyObject *o, void *p) +{ +if (o == Py_None) { +*(int *)p = DEFAULT_DIR_FD; +return 1; +} +return _fd_converter(o, (int *)p, integer); } @@ -634,17 +637,16 @@ } else { PyErr_Clear(); -bytes = PyBytes_FromObject(o); +if (PyObject_CheckBuffer(o)) +bytes = PyBytes_FromObject(o); +else +bytes = NULL; if (!bytes) { PyErr_Clear(); if (path-allow_fd) { int fd; -/* - * note: _fd_converter always permits None. - * but we've already done our None check. - * so o cannot be None at this point. - */ -int result = _fd_converter(o, fd, -1); +int result = _fd_converter(o, fd, + string, bytes or integer); if (result) { path-wide = NULL; path-narrow = NULL; @@ -705,15 +707,17 @@ } static int -dir_fd_unavailable(PyObject *o, void *p) { -int *dir_fd = (int *)p; -int return_value = _fd_converter(o, dir_fd, DEFAULT_DIR_FD); -if (!return_value) +dir_fd_unavailable(PyObject *o, void *p) +{ +int dir_fd; +if (!dir_fd_converter(o, dir_fd)) return 0; -if (*dir_fd == DEFAULT_DIR_FD) -return 1; -argument_unavailable_error(NULL, dir_fd); -return 0; +if (dir_fd != DEFAULT_DIR_FD) { +argument_unavailable_error(NULL, dir_fd); +return 0; +} +*(int *)p = dir_fd; +return 1; } static int ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15986] memoryview: expose 'buf' attribute
Changes by Stefan Krah stefan-use...@bytereef.org: -- components: Interpreter Core nosy: dabeaz, skrah priority: normal severity: normal stage: needs patch status: open title: memoryview: expose 'buf' attribute type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15986 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15987] Provide a way to compare AST nodes for equality recursively
New submission from Julian Berman: As is, as far as I can tell, there's no way to easily compare two AST nodes to see if they have the same children and same fields (recursively). I'm writing some unit tests for a NodeTransformers, so I've settled for comparing `ast.dump()`s of each, which is kind of dirty, but 1) works and 2) produces reasonable failure messages. (As a side note of what else I've tried, comparing, say, a list of the `iter_child_nodes` is not a good alternative, since the tests I'm writing are making assertions that a given node was not modified, which means they deepcopy the node and then want to assert that the transformed node is unchanged.) I don't know the global implications of changing ast.AST.__eq__ to know if that's feasible (hopefully someone will comment on that), but if it isn't, another provided way would be nice. -- components: Library (Lib) messages: 170826 nosy: Julian priority: normal severity: normal status: open title: Provide a way to compare AST nodes for equality recursively type: enhancement versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15987 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15144] Possible integer overflow in operations with addresses and sizes.
Antoine Pitrou added the comment: Thanks for the patch! These macros will be useful. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15144 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15988] Inconsistency in overflow error messages of integer argument
New submission from Serhiy Storchaka: PyArg_ParseTuple raises inconsistent overflow error messages for small integer formats. For example: import _testcapi _testcapi.getargs_b(100) 100 _testcapi.getargs_b(1000) Traceback (most recent call last): File stdin, line 1, in module OverflowError: unsigned byte integer is greater than maximum _testcapi.getargs_b(-1000) Traceback (most recent call last): File stdin, line 1, in module OverflowError: unsigned byte integer is less than minimum _testcapi.getargs_b(1) Traceback (most recent call last): File stdin, line 1, in module OverflowError: Python int too large to convert to C long _testcapi.getargs_b(-1) Traceback (most recent call last): File stdin, line 1, in module OverflowError: Python int too large to convert to C long On platforms with 32-bit int and 64-bit long there will be more such cases. -- components: Interpreter Core messages: 170827 nosy: storchaka priority: low severity: normal status: open title: Inconsistency in overflow error messages of integer argument type: enhancement versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15988 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15985] round() has wrong argument names
Chris Jerdonek added the comment: Here is a patch. Also, I checked, and there is already a test for the keyword arguments: http://hg.python.org/cpython/file/dcced3bd22fe/Lib/test/test_builtin.py#l1239 -- keywords: +needs review, patch stage: needs patch - patch review Added file: http://bugs.python.org/file27236/issue-15985-1-branch-default.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15985 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15144] Possible integer overflow in operations with addresses and sizes.
Roundup Robot added the comment: New changeset 99112b851b25 by Antoine Pitrou in branch 'default': Issue #15144: Fix possible integer overflow when handling pointers as integer values, by using Py_uintptr_t instead of size_t. http://hg.python.org/cpython/rev/99112b851b25 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15144 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15144] Possible integer overflow in operations with addresses and sizes.
Antoine Pitrou added the comment: Committed in 3.3(.1). -- resolution: - fixed stage: patch review - committed/rejected status: open - closed versions: +Python 3.3 -Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15144 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com