ANN: SciPy 0.9.0
I'm pleased to announce the release of SciPy 0.9.0. SciPy is a package of tools for science and engineering for Python. It includes modules for statistics, optimization, integration, linear algebra, Fourier transforms, signal and image processing, ODE solvers, and more. This release comes seven months after the 0.8.0 release and contains several new features, numerous bug-fixes, improved test coverage, and better documentation. This is the first release that supports Python 3 (with the exception of the scipy.weave module). Sources, binaries, documentation and release notes can be found at http://sourceforge.net/projects/scipy/files/scipy/0.9.0/ Thank you to everybody who contributed to this release. Enjoy, The SciPy developers = SciPy 0.9.0 Release Notes = .. contents:: SciPy 0.9.0 is the culmination of 6 months of hard work. It contains many new features, numerous bug-fixes, improved test coverage and better documentation. There have been a number of deprecations and API changes in this release, which are documented below. All users are encouraged to upgrade to this release, as there are a large number of bug-fixes and optimizations. Moreover, our development attention will now shift to bug-fix releases on the 0.9.x branch, and on adding new features on the development trunk. This release requires Python 2.4 - 2.7 or 3.1 - and NumPy 1.5 or greater. Please note that SciPy is still considered to have Beta status, as we work toward a SciPy 1.0.0 release. The 1.0.0 release will mark a major milestone in the development of SciPy, after which changing the package structure or API will be much more difficult. Whilst these pre-1.0 releases are considered to have Beta status, we are committed to making them as bug-free as possible. However, until the 1.0 release, we are aggressively reviewing and refining the functionality, organization, and interface. This is being done in an effort to make the package as coherent, intuitive, and useful as possible. To achieve this, we need help from the community of users. Specifically, we need feedback regarding all aspects of the project - everything - from which algorithms we implement, to details about our function's call signatures. Python 3 Scipy 0.9.0 is the first SciPy release to support Python 3. The only module that is not yet ported is ``scipy.weave``. Scipy source code location to be changed Soon after this release, Scipy will stop using SVN as the version control system, and move to Git. The development source code for Scipy can from then on be found at http://github.com/scipy/scipy New features Delaunay tesselations (``scipy.spatial``) - Scipy now includes routines for computing Delaunay tesselations in N dimensions, powered by the Qhull_ computational geometry library. Such calculations can now make use of the new ``scipy.spatial.Delaunay`` interface. .. _Qhull: http://www.qhull.org/ N-dimensional interpolation (``scipy.interpolate``) --- Support for scattered data interpolation is now significantly improved. This version includes a ``scipy.interpolate.griddata`` function that can perform linear and nearest-neighbour interpolation for N-dimensional scattered data, in addition to cubic spline (C1-smooth) interpolation in 2D and 1D. An object-oriented interface to each interpolator type is also available. Nonlinear equation solvers (``scipy.optimize``) --- Scipy includes new routines for large-scale nonlinear equation solving in ``scipy.optimize``. The following methods are implemented: * Newton-Krylov (``scipy.optimize.newton_krylov``) * (Generalized) secant methods: - Limited-memory Broyden methods (``scipy.optimize.broyden1``, ``scipy.optimize.broyden2``) - Anderson method (``scipy.optimize.anderson``) * Simple iterations (``scipy.optimize.diagbroyden``, ``scipy.optimize.excitingmixing``, ``scipy.optimize.linearmixing``) The ``scipy.optimize.nonlin`` module was completely rewritten, and some of the functions were deprecated (see above). New linear algebra routines (``scipy.linalg``) -- Scipy now contains routines for effectively solving triangular equation systems (``scipy.linalg.solve_triangular``). Improved FIR filter design functions (``scipy.signal``) --- The function ``scipy.signal.firwin`` was enhanced to allow the design of highpass, bandpass, bandstop and multi-band FIR filters. The function ``scipy.signal.firwin2`` was added. This function uses the window method to create a linear phase FIR filter with an arbitrary frequency response. The functions ``scipy.signal.kaiser_atten`` and ``scipy.signal.kaiser_beta`` were added. Improved statistical tests
Re: [ANN]VTD-XML 2.10
pyt...@bdurham.com, 27.02.2011 13:52: How does VTD-XML compare to XML tools in the stdlib or to 3rd party alternatives like lxml? For one, I'm not aware of any Python wrappers for vtd-xml, despite having seen lots of announcements by Jimmy on this list already (not the python-announce list, *this* list). So, IMHO, these announcements are to be considered spam, or at least vapourware. Also, Jimmy commonly does not respond to questions regarding his announcements, so I assume he doesn't actually read c.l.py but uses it solely to post his announcements. That being said, vtd-xml is supposed to be fast, and there are benchmarks on the web that seem to suggest that this may be true. For example, http://xmlbench.sourceforge.net/results/benchmark200910/index.html lists its parser as being about twice as fast as libxml2, which is used by lxml. I say may be true, because benchmarks rarely indicate the performance behaviour in real world code. It does not seem completely unreasonable to me that vtd-xml is interesting for Java developers, where XML performance isn't really whopping cool and simple-to-use XML tools are rare anyway (I never tried it, but vtd-xml also has an aura of a not-so-easy-to-use tool). It does not seem unreasonable that there are use cases for a very fast parser that justify the time it may take to get used to the tool. But its 'different' nature also makes it clearly lack a lot of tooling around the actual parser, which prevents it from positioning itself as a general purpose XML tool. I'm yet to be convinced that vtd-xml is an interesting tool for a Python developer. Stefan -- http://mail.python.org/mailman/listinfo/python-list
Lumberjack Song
We all like computers here. No doubt many of us like computer games. And most of us will be at least somewhat familiar with Monty Python. Therefore, I present (drum roll)... http://www.youtube.com/watch?v=Zh-zL-rhUuU (For the Runescape fans out there, this should be quite hilarious. Possibly not as much for those unfamiliar with Runescape...) -- Tom Zych / freethin...@pobox.com Quidquid latine dictum sit, altum viditur. -- http://mail.python.org/mailman/listinfo/python-list
Re: urlopen returns forbidden
On Sun, 27 Feb 2011 22:19:18 -0800, Chris Rebert wrote: On Sun, Feb 27, 2011 at 9:38 PM, monkeys paw mon...@joemoney.net wrote: I have a working urlopen routine which opens a url, parses it for a tags and prints out the links in the page. On some sites, wikipedia for instance, i get a HTTP error 403, forbidden. What is the difference in accessing the site through a web browser and opening/reading the URL with python urllib2.urlopen? [...] Sidenote: Wikipedia has a proper API for programmatic browsing, likely hence why it's blocking your program. What he said. Please don't abuse Wikipedia by screen-scraping it. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
SocketServer problem: client hangs trying to reconnect after server restart
Hi everyone! in my script (Python 2.6 on windows 7) I have to set up a SocketServer server and use it to handle external connections. During the execution It can happen that this server should be closed and restarted (for example with different port or host). The following piece of code simulates the situation I have to deal with: import SocketServer, socket, threading from time import sleep BUF_LENGTH = 1024 class MyHandler(SocketServer.BaseRequestHandler) : def handle(self): while 1: data = self.request.recv(1024) self.request.send(data) if data.strip() == 'bye': return class MyServer(SocketServer.ThreadingTCPServer) : def __init__(self, host, port, handler) : self.allow_reuse_address = True self.__handler = handler self.__serving = True SocketServer.ThreadingTCPServer.__init__ (self, (host, port), handler) def StartServer(self) : self.serve_forever() def StopServer(self) : self.shutdown() def Init() : server = MyServer(localhost, 5000, MyHandler) threading.Thread(target=server.StartServer).start() sleep(0.5) sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.connect((localhost, 5000)) sock.send(hi) sock.recv(BUF_LENGTH) sock.send(bye) return server def CleanUp(server) : server.StopServer() for i in range(3) : print -- Connection: +str(i)+ -- server = Init() CleanUp(server) print Finished If you ran the code you'll see that the client hangs after the first connection. Can anyone point me out where I'm doing wrong? Thanks in advance! -- http://mail.python.org/mailman/listinfo/python-list
Re: Various behaviors of doctest
Gnarlodious wrote: Yeah, I just spent about 2 hours trying everything I could think of... without success. Including your suggestions. Guess I'll have to skip it. But thanks for the ideas. -- Gnarlie Are you using Python 2.x? Then you cannot redefine print. Instead you have to redirect stdout. The following example should run as a cgi script: #!/usr/bin/env python import cgi import sys from cStringIO import StringIO def f(): 1 + 1 2 2 + 2 22 '' if __name__ == __main__: print (Content-type: text/html\r\n\r\n htmlbody style='background-color:#f0f0f0' h1 style='color: navy;'There goes:/h1) outstream = StringIO() import doctest, sys from doctest import DocTestRunner class DTR(DocTestRunner): def run(self, test, compileflags=None, out=None, clear_globs=True): DocTestRunner.run(self, test, compileflags, outstream.write, clear_globs) def summarize(self): saved = sys.stdout sys.stdout = outstream DocTestRunner.summarize(self) sys.stdout = saved doctest.DocTestRunner = DTR doctest.testmod(verbose=True) text = outstream.getvalue() for line in text.splitlines(): spaces = len(line) - len(line.lstrip()) line = line.strip() if * in line: print hr/ else: print div style='color: %s; margin-left:%sem;'%s/div % ( blue if spaces else black, spaces, cgi.escape(line)) print /body/html -- http://mail.python.org/mailman/listinfo/python-list
Embedding python : can't find encoding error
Hi, I'm trying to embed python in a c++ program. I have compiled python32.lib with msvc 2010 targetting 32bits, i link it with my program wich is also 32bit. I get an error when calling Py_Initialize() : no codec search functions registered: can't find encoding Py_FileSystemDefaultEncoding value is mbcs. _PyCodec_Lookup raise an eror because len = PyList_Size(interp- codec_search_path); returns 0 in codecs.c Does someone already had this problem ? I have no idea how to solve that. Sorry for my bad english. -- http://mail.python.org/mailman/listinfo/python-list
Re: Embedding python : can't find encoding error
Precisions : I'm trying to embed python 3.2 release. -- http://mail.python.org/mailman/listinfo/python-list
Re: SocketServer problem: client hangs trying to reconnect after server restart
In method StopServer() of class MyServer try calling self.server_close() after the self.shutdown() call. I believe this will actually close the server's socket and allow its reuse. -- http://mail.python.org/mailman/listinfo/python-list
Re: SocketServer problem: client hangs trying to reconnect after server restart
On 28 Feb, 13:34, cmcp mcphail_co...@hotmail.com wrote: In method StopServer() of class MyServer try calling self.server_close() after the self.shutdown() call. I believe this will actually close the server's socket and allow its reuse. It works! Thank you!! -- http://mail.python.org/mailman/listinfo/python-list
a chance from you.
You'll like the way I was convinced a girl for winning the new Volvo S60: http://www.unlimitednaughty.ro/camera/video/concurent/Marian-Briceag Give me a chance by sharing this video to everyone on the group. Please, please SHARE it :) . p.s.: for English turn on the captions (the cc, under arrow from the right-bottom side of video). This is not a spam, it's my dream. Thanks! -- http://mail.python.org/mailman/listinfo/python-list
Re: urlopen returns forbidden
On 2011-02-28, Chris Rebert c...@rebertia.com wrote: On Sun, Feb 27, 2011 at 9:38 PM, monkeys paw mon...@joemoney.net wrote: I have a working urlopen routine which opens a url, parses it for a tags and prints out the links in the page. On some sites, wikipedia for instance, i get a HTTP error 403, forbidden. What is the difference in accessing the site through a web browser and opening/reading the URL with python urllib2.urlopen? The User-Agent header (http://en.wikipedia.org/wiki/User_agent ). Sometimes you also need to set the Referrer header for pages that don't allow direct-linking from outside. As somebody else has already said, if the site provides an API that they want you to use you should do so rather than hammering their web server with a screen-scraper. Not only is is a lot less load on the site, it's usually a lot easier. -- Grant Edwards grant.b.edwardsYow! Look DEEP into the at OPENINGS!! Do you see any gmail.comELVES or EDSELS ... or a HIGHBALL?? ... -- http://mail.python.org/mailman/listinfo/python-list
question about numpy.polyval
Hi, I have some simulated data of stellar absorption lines. What I am trying to is the following: I divide my data into chunks (each of the same size). Then I let the code find the max y value in one of those chunks. I got this working. Then I put those value in a two column array (first column has the position of the max value in the original data; second column the y value at this position). Then I use polyfit to fit the data. At last I use polyval to get the fit. The problem is now since I got about 70 chunks I am not sure how to use polyfit to get the fit for the original data. My simulated data is a one column array of 30 data points. I am only interested in a fit of values above 16. The data is data_mean. My code: import numpy as np import matplotlib.pyplot as mpl import scipy, pyfits chunk = 2000 data_len = len(data_mean) num_chunk = data_len/chunk start_chunk = 16 num_chunk = num_chunk - start_chunk/chunk # I defined num_chunk this way so I can change the startvalue data_chunk = np.zeros( (num_chunk, chunk)) data_mean_b = data_mean[start_chunk:len(data_mean)] # for fitting purpose later in the code for i in range(num_chunk): data_chunk[i] = data_mean[start_chunk+i*2000:start_chunk +2000+i*2000] data_max = np.zeros(num_chunk) for i in range(num_chunk): data_max[i] = max(data_chunk[i]) # finding the max values inside a chunk data_max_pos = np.zeros(num_chunk) # the position of the max values for i in range(num_chunk): for position, item in enumerate(data_mean): if item == data_max[i]: data_max_pos[i] = position data_fin = np.zeros((num_chunk,2)) for i in range(num_chunk): # final data two columns data_fin[i,0] = data_max_pos[i] data_fin[i,1] = data_max[i] order = 2 x = np.arange(num_chunk) y = data_fin[::,1] coeff = np.polyfit(x, y, order) fit = np.polyval(coeff,x) xa = np.arange(len(data_mean_b)) fitb = np.zeros((num_chunk,2)) #end of code Now fit does work fine but as len(num_chunk) = 70 it is no use for the simulated data. So I tried with xa and fitb. But this just gives me somethin like this (plot of fita): http://img40.imageshack.us/i/web01.png/ Plot of fit: http://img196.imageshack.us/i/web02j.png/ Thanks -- http://mail.python.org/mailman/listinfo/python-list
Problems with read_eager and Telnet
Hi everybody, I'm totally new to Python but well motivated :-) I'm fooling around with Python in order to interface with FlightGear using a telnet connection. I can do what I had in mind (send some commands and read output from Flightgear using the telnetlib) with a read_until() object to catch every output line I need, but it proved to be very slow (it takes 1/10 of a sec for every read_until(). I tried using the read_eager() object and it's w faster (it does the job in 1/100 of a sec, maybe more, I didn't tested) but it gives me problems, it gets back strange strings, repeated ones, partially broken ones, well ... I don't know what's going on with it. You see, I don't know telnet (the protocol) very good, I'm very new to Python and Python's docs are not very specific about that read_eager(9 stuff. Could someone point me to some more documentation about that? or at least help me in getting a correct idea of what's going on with read_eager()? I'm going on investigating but a help from here would be very appreciated :-) Thanks in advance, Roberto -- http://mail.python.org/mailman/listinfo/python-list
OT: Code Examples
I'm interested in developing Python-based programs, including an engineering app. ... re-writing from Fortran and C versions. One of the objectives would to be make reasonable use of the available structure (objects, etc.). So, I'd like to read a couple of good, simple scientific-oriented programs that do that kind of thing. Looking for links, etc. Fred -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
On Mon, Feb 28, 2011 at 10:54 AM, Robi roberto.inzeri...@gmail.com wrote: Hi everybody, I'm totally new to Python but well motivated :-) I'm fooling around with Python in order to interface with FlightGear using a telnet connection. I can do what I had in mind (send some commands and read output from Flightgear using the telnetlib) with a read_until() object to catch every output line I need, but it proved to be very slow (it takes 1/10 of a sec for every read_until(). I tried using the read_eager() object and it's w faster (it does the job in 1/100 of a sec, maybe more, I didn't tested) but it gives me problems, it gets back strange strings, repeated ones, partially broken ones, well ... I don't know what's going on with it. You see, I don't know telnet (the protocol) very good, I'm very new to Python and Python's docs are not very specific about that read_eager(9 stuff. Could someone point me to some more documentation about that? or at least help me in getting a correct idea of what's going on with read_eager()? Telnet sends two kinds of data over the same channel (a simple TCP stream). It sends the bytes you actually see in your terminal and it sends control commands that do things like turn echo on/off and negotiate what terminal type to use. Each time telnetlib reads from the socket it puts the control stuff in one bucket and stores the plain text in a buffer to return from all the read_* commands. read_eager() returns the plain text that has already been read from the socket. That might be a partial line. It won't try to read from the socket to get a full line. That's why it is fast, because it never does I/O. -Jack -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Code Examples
On Feb 28, 6:03 pm, Fred Marshall fmarshallxremove_th...@acm.org wrote: I'm interested in developing Python-based programs, including an engineering app. ... re-writing from Fortran and C versions. One of the objectives would to be make reasonable use of the available structure (objects, etc.). So, I'd like to read a couple of good, simple scientific-oriented programs that do that kind of thing. Looking for links, etc. Fred The best place for you to start: http://numpy.scipy.org/ Numpy manual: http://www.tramy.us/numpybook.pdf -- http://mail.python.org/mailman/listinfo/python-list
Re: question about numpy.polyval
On 2/28/11 9:34 AM, sirvival wrote: Hi, I have some simulated data of stellar absorption lines. You will want to ask numpy questions on the numpy mailing list: http://www.scipy.org/Mailing_Lists It would be best if you could make a minimal, self-contained, runnable script that demonstrates your problem. I.e. provide x and y arrays that show the problem; all the details about chunking and such are just getting in the way. Please state what results you expect in addition to the results you got; you show plots but don't show exactly what you plotted. I have no idea what you were expecting to get. Make sure you use variable names consistently. For example, you refer to a plot of fita, but nothing in your code assigns to fita. Thanks. -- Robert Kern I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth. -- Umberto Eco -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
Telnet sends two kinds of data over the same channel (a simple TCP stream). It sends the bytes you actually see in your terminal and it sends control commands that do things like turn echo on/off and negotiate what terminal type to use. Each time telnetlib reads from the socket it puts the control stuff in one bucket and stores the plain text in a buffer to return from all the read_* commands. read_eager() returns the plain text that has already been read from the socket. That might be a partial line. It won't try to read from the socket to get a full line. That's why it is fast, because it never does I/O. -Jack Ok, that's a start (I'm reading RFC 854 in the meanwhile). Still that doesn't help me much (sorry, I know it's me, not you). You mean read_eager() doesn't wait until it gets a complete reading of a line, instead it reads what's on the socket (even if it's to quick and there's till nothing) and let's the python script running anyway, right? Then with the subsequent read_eager() it will read (if there's something more on the socket in the meanwhile) the previous data bits and maybe the new ones too (a new line of data) into a single data chunk. Is that why I get sometimes repeated empty lines followed by many consequent lines all together out of a single read_eager() call? -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
On Mon, Feb 28, 2011 at 11:50 AM, Robi roberto.inzeri...@gmail.com wrote: Telnet sends two kinds of data over the same channel (a simple TCP stream). It sends the bytes you actually see in your terminal and it sends control commands that do things like turn echo on/off and negotiate what terminal type to use. Each time telnetlib reads from the socket it puts the control stuff in one bucket and stores the plain text in a buffer to return from all the read_* commands. read_eager() returns the plain text that has already been read from the socket. That might be a partial line. It won't try to read from the socket to get a full line. That's why it is fast, because it never does I/O. Ok, that's a start (I'm reading RFC 854 in the meanwhile). Still that doesn't help me much (sorry, I know it's me, not you). You mean read_eager() doesn't wait until it gets a complete reading of a line, instead it reads what's on the socket (even if it's to quick and there's till nothing) and let's the python script running anyway, right? Then with the subsequent read_eager() it will read (if there's something more on the socket in the meanwhile) the previous data bits and maybe the new ones too (a new line of data) into a single data chunk. Is that why I get sometimes repeated empty lines followed by many consequent lines all together out of a single read_eager() call? Yes. read_eager() will never actually read from the socket, if it has any data it has already read processed it will return those. If you call it enough times it will just start returning empty strings because it never asks the socket to read wait for new data. -Jack -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
Can you point me to a pratical usage example of read_eager()? Maybe that will help me in making all this clear. I'm still very fuzzy about the socket and the processing stuff. I'm still convinced I cannot use read_until() in my project and I'm determined in looking into the read_eager(), maybe that will be of any help if carefully used. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
On Mon, Feb 28, 2011 at 12:13 PM, Roberto Inzerillo roberto.inzeri...@gmail.com wrote: Yes. read_eager() will never actually read from the socket, if it has any data it has already read processed it will return those. If you call it enough times it will just start returning empty strings because it never asks the socket to read wait for new data. Can you point me to a pratical usage example of read_eager()? Maybe that will help me in making all this clear. I'm still very fuzzy about the socket and the processing stuff. I'm still convinced I cannot use read_until() in my project and I'm determined in looking into the read_eager(), maybe that will be of any help if carefully used. If you always want to see the response you have to use read_until(). All the other read_* methods don't guarantee you will get the text you want because they don't wait for the other end of the connection to have actually sent the data. It's a bummer, but if the server hasn't returned the data there is nothing magic that telnetlib can do to make it true. -- http://mail.python.org/mailman/listinfo/python-list
Re: urlopen returns forbidden
On 2/28/2011 10:21 AM, Grant Edwards wrote: As somebody else has already said, if the site provides an API that they want you to use you should do so rather than hammering their web server with a screen-scraper. If there any generic method for finding out 'if the site provides an API and specifically, how to find Wikipedia's? I looked as the Wikipedia articles on API and web services and did not find any mention of thiers (though there is one for Amazon). -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: nntplib encoding problem
Hi, Thanks it's working! But is it normal for a string coming out of a module (nntplib) to crash when passed to print or write? I'm just asking to know if I should open a bug report or not :) I'm also wondering which strings should be re-encoded using the surrogateescape parameter and which should not.. I guess I could reencode them all and it wouldn't cause any problems? Laurent On Mon, 28 Feb 2011 02:12:20 +, MRAB wrote: On 28/02/2011 01:31, Laurent Duchesne wrote: Hi, I'm using python 3.2 and got the following error: nntpClient = nntplib.NNTP_SSL(...) nntpClient.group(alt.binaries.cd.lossless) nntpClient.over((534157,534157)) ... 'subject': 'Myl\udce8ne Farmer - Anamorphosee (Japan Edition) 1995 [02/41] Back.jpg yEnc (1/3)' ... overview = nntpClient.over((534157,534157)) print(overview[1][0][1]['subject']) Traceback (most recent call last): File stdin, line 1, in module UnicodeEncodeError: 'utf-8' codec can't encode character '\udce8' in position 3: surrogates not allowed I'm not sure if I should report this as a bug in nntplib or if I'm doing something wrong. Note that I get the same error if I try to write this data to a file: h = open(output.txt, a) h.write(overview[1][0][1]['subject']) Traceback (most recent call last): File stdin, line 1, in module UnicodeEncodeError: 'utf-8' codec can't encode character '\udce8' in position 3: surrogates not allowed It's looks like the subject was originally encoded as Latin-1 (or similar) (b'Myl\xe8ne Farmer - Anamorphosee (Japan Edition) 1995 [02/41] Back.jpg yEnc (1/3)') but has been decoded as UTF-8 with surrogateescape passed as the errors parameter. You can get the correct Unicode by encoding as UTF-8 with surrogateescape and then decoding as Latin-1: overview[1][0][1]['subject'].encode(utf-8, surrogateescape).decode(latin-1) -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
On 28 Feb, 18:35, Jack Diederich jackd...@gmail.com wrote: On Mon, Feb 28, 2011 at 12:13 PM, Roberto Inzerillo roberto.inzeri...@gmail.com wrote: Yes. read_eager() will never actually read from the socket, if it has any data it has already read processed it will return those. If you call it enough times it will just start returning empty strings because it never asks the socket to read wait for new data. Can you point me to a pratical usage example of read_eager()? Maybe that will help me in making all this clear. I'm still very fuzzy about the socket and the processing stuff. I'm still convinced I cannot use read_until() in my project and I'm determined in looking into the read_eager(), maybe that will be of any help if carefully used. If you always want to see the response you have to use read_until(). All the other read_* methods don't guarantee you will get the text you want because they don't wait for the other end of the connection to have actually sent the data. It's a bummer, but if the server hasn't returned the data there is nothing magic that telnetlib can do to make it true. Well, you see, I could prefetch some usefull data in a spare cycle, maybe this way I could fake almost-realtime ... I don't know, I'm just guessing here. Fact is, in my case, when I do a 100 write/read cycles in a second with telnet.write() followed by telnet.read-eager(), I see I get all those 100 things done properly, that means, both client and server are doing it right, there's no lag on the processing and network sides. But when I use telnet.read_until() I get those feedbacks in the right order (good) but it's way too slow (it's at least 10 times slower, t bad!!! and, in my case, unusable). I'm trying to find a way out, and I know in these cases knowledge is the only way out. I've seen a huge speed improvement using telnet.read_eager(), I want to investigate more. Who knows, maybe I can stitch my code around it's appearant unusability. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems of Symbol Congestion in Computer Languages
On Feb 17, 3:07 am, Xah Lee xah...@gmail.com wrote: might be interesting. 〈Problems of Symbol Congestion in Computer Languages (ASCII Jam; Unicode; Fortress)〉http://xahlee.org/comp/comp_lang_unicode.html Haskell is slowly moving this way see for example http://www.haskell.org/ghc/docs/latest/html/users_guide/syntax-extns.html#unicode-syntax But its not so easy the lambda does not work straight off -- see http://hackage.haskell.org/trac/ghc/ticket/1102 -- http://mail.python.org/mailman/listinfo/python-list
Re: Lumberjack Song
On 28/02/2011 10:26, Tom Zych wrote: We all like computers here. No doubt many of us like computer games. And most of us will be at least somewhat familiar with Monty Python. Therefore, I present (drum roll)... http://www.youtube.com/watch?v=Zh-zL-rhUuU (For the Runescape fans out there, this should be quite hilarious. Possibly not as much for those unfamiliar with Runescape...) BTW, the lumberjack is called Kevin. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
On 2/28/2011 10:54 AM, Robi wrote: Hi everybody, I'm totally new to Python but well motivated :-) I'm fooling around with Python in order to interface with FlightGear using a telnet connection. Given that FlightGear is a graphical flight simulator http://www.flightgear.org/ https://secure.wikimedia.org/wikipedia/en/wiki/FlightGear using a text terminal connection seems a bit odd, unless using it just to get/set configuration, in which case, speed should hardly seem an issue. I can do what I had in mind (send some commands and read output from Flightgear using the telnetlib) with a read_until() object to catch every output line I need, but it proved to be very slow (it takes 1/10 of a sec for every read_until(). I presume you are using read_until(b'\n'). read_until cannot return any faster than the server sends complete lines I tried using the read_eager() object and it's w faster (it does the job in 1/100 of a sec, maybe more, I didn't tested) but it gives me problems, it gets back strange strings, repeated ones, partially broken ones, well ... I don't know what's going on with it. read_eager is for when you want to parse the bytes yourself, such as when they come in a continuous stream without newline or other obvious separators. It will not return b'\n' any faster than read_until. It will simply give you your output lines in little bits that you would have to reassemble yourself. You see, I don't know telnet (the protocol) very good, I'm very new to Python and Python's docs are not very specific about that read_eager(9 stuff. Could someone point me to some more documentation about that? or at least help me in getting a correct idea of what's going on with read_eager()? Read the source Lib/telnetlib.py (as I just did). It is pretty straightforwad code. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems of Symbol Congestion in Computer Languages
You miss the canonical bad character reuse case: = vs ==. Had there been more meta keys, it might be nice to have a symbol for each key on the keyboard. I personally have experimented with putting the symbols as regular keys and the numbers as the Shifted versions. It's great for programming. -- Dotan Cohen http://gibberish.co.il http://what-is-what.com -- http://mail.python.org/mailman/listinfo/python-list
subclass urllib2
I'm trying to subclass urllib2 in order to mask the version attribute. Here's what i'm using: import urllib2 class myURL(urllib2): def __init__(self): urllib2.__init__(self) self.version = 'firefox' I get this Traceback (most recent call last): File interactive input, line 1, in module TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) I don't see where i am supplying 3 arguments. What am i missing? -- http://mail.python.org/mailman/listinfo/python-list
how to properly pass literal strings python code to be executed using python -c
I need some help figuring out how to execute this python code from python -c I am have trouble formatting python so that it will execute for another app in cmd I understand there maybe other ways to do what I am doing but I am limited by the final execution using cmd python -c so please keep this in mind. I'm limited by the final delivery of code. The python is being called by a server that does not have access to any python script file So I have some python code ie, import os import shutil myPath =rC:\dingdongz for root, dirs, files in os.walk(myPath): for file in files: os.remove(os.path(root, file)) for dir in dirs: shutil.rmtree(os.path.join(root,dir)) But I am trying to excute it using the following method, python -c print 'hotdogs' So this what i have but no worky cmdline = \ import os, shutil \n for root, dirs, files in os.walk(+myPath+):\n \t for file in files: \n \t \t os.remove(os.path.join(root, file)) \n \t for dir in dirs: \n \t\t shutil.rmtree(os.path.join(root, dir)) I have also tried the following python -c import os; import shutil; for root, dirs, files in os.walk('+myPath+'): for file in files: os.remove(os.path.join(root, file)); for dir in dirs: shutil.rmtree(os.path.join(root, dir)) I am still getting error tree(os.path.join(root, dir)) ^ SyntaxError: invalid syntax -- http://mail.python.org/mailman/listinfo/python-list
Re: subclass urllib2
1. Why are you subclassing a module? 2. If you want to mask a module's version attribute, just do this: import urllib2 urllib2.__version__ = 'foo' print urllib2.__version__ foo ~/santa On Mon, Feb 28, 2011 at 10:53 AM, monkeys paw mon...@joemoney.net wrote: I'm trying to subclass urllib2 in order to mask the version attribute. Here's what i'm using: import urllib2 class myURL(urllib2): def __init__(self): urllib2.__init__(self) self.version = 'firefox' I get this Traceback (most recent call last): File interactive input, line 1, in module TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) I don't see where i am supplying 3 arguments. What am i missing? -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
Re: Problem with python 3.2 and circular imports
I'm stil totally stuck with relative imports, i' ve tried the example tree from PEP 328 without any result: package/ __init__.py subpackage1/ __init__.py moduleX.py moduleY.py subpackage2/ __init__.py moduleZ.py moduleA.py Assuming that the current file is either moduleX.py or subpackage1/__init__.py, following are correct usages of the new syntax: from .moduleY import spam from .moduleY import spam as ham from . import moduleY from ..subpackage1 import moduleY from ..subpackage2.moduleZ import eggs from ..moduleA import foo from ...package import bar from ...sys import path I always get: Traceback (most recent call last): File moduleY.py, line 1, in module from ..moduleA import a ValueError: Attempted relative import in non-package 2011/2/27 Frank Millman fr...@chagford.com Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote in message news:4d6a56aa$0$29972$c3e8da3$54964...@news.astraweb.com... On Sun, 27 Feb 2011 12:08:12 +0200, Frank Millman wrote: Assume the following structure - main.py /pkg __init__.py mod1.py mod2.py main.py from pkg import mod1 mod1.py import mod2 mod2.py import mod1 If you change the import mod* lines to import pkg.mod* it works for me in Python 3.1 and 3.2. According to my understand of PEP 328, from . import mod* should work, but I agree with you that it doesn't. If you get rid of the circular import, it does work. So I suspect a bug. Thanks, Steven. I confirm that 'import pkg.mod* works. Unfortunately I am using sub-packages as well, which means that to refer to an object in the sub-package I need to use w.x.y.z every time, which gets to be a lot of typing! I will stick to my hack of putting the package name in sys.path for now, unless someone comes up with a better idea. Frank -- http://mail.python.org/mailman/listinfo/python-list -- http://mail.python.org/mailman/listinfo/python-list
3.1 - 3.2: base64 lost deprecation warning
Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. -- import base64 -- base64.encodestring(b'this is a test') __main__:1: DeprecationWarning: encodestring() is a deprecated alias, use encodebytes() b'dGhpcyBpcyBhIHRlc3Q=\n' Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. -- import base64 -- base64.encodestring(b'another test') b'dGhpcyBpcyBhIHRlc3Q=\n' The deprecation warning has gone away in 3.2, but the function remains... does anyone know if this was intentional? ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: urlopen returns forbidden
On Mon, Feb 28, 2011 at 9:44 AM, Terry Reedy tjre...@udel.edu wrote: On 2/28/2011 10:21 AM, Grant Edwards wrote: As somebody else has already said, if the site provides an API that they want you to use you should do so rather than hammering their web server with a screen-scraper. If there any generic method for finding out 'if the site provides an API and specifically, how to find Wikipedia's? I looked as the Wikipedia articles on API and web services and did not find any mention of thiers (though there is one for Amazon). Technically it's Wikipedia's underlying wiki software (MediaWiki)'s API: http://www.mediawiki.org/wiki/API Cheers, Chris -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
Given that FlightGear is a graphical flight simulatorhttp://www.flightgear.org/https://secure.wikimedia.org/wikipedia/en/wiki/FlightGear using a text terminal connection seems a bit odd, unless using it just to get/set configuration, in which case, speed should hardly seem an issue. Right, I'm using it that way, I get/set properties changing them in real time (I whish!). I presume you are using read_until(b'\n'). read_until cannot return any faster than the server sends complete lines Actually it's read_until('\n') (because it's python 2.6, anyway I know what you meant with b'\n'). And yes, after today I've come to the conclusion that even read_eager is of no use to me. I have to settle down for that poor telnet speed, I can't get more than that :-( In fact, the telnet connection speed is not the issue, it's the time FGFS spends in reading its internals and answearing back to the telnet client. I've made some tests, it looks like it doesn't matter how many fgfs's properties I try and read with telnet at the same time with python, I always have the same lag, I can even run multiple python instances of the same script, in order to get/set those same amount of properties in parallel, well ... result is I always get the same lag, it doesn't even become slower. In my test I run a simple loop, in each loop I do a telnet.write() and a telnet.read_until('\n'). I get back results at 20Hz (that means I get 120 write/read cycles in 6 seconds). I repeated the same test doing three telnet.write() followed by three telnet.read_until('\n') in each loop. Result is always 20Hz (but now that means I get 120 loop cycles in 6 seconds, which is now 120x3 write/read cycles in 6 seconds). I even run three instances of the same script at the same time (trying to saturate fgfs's capabilities and find some limits). No luck (or yes?!?), I always get a 20hz frequency. My conclusion being, fgfs cannot answer back quicker than this: 20Hz. This is quite poor for a quasi-realtime hardware interface (which is in my intention). Maybe it's enough for something ... I'll give it a try anyway and find out what can be a usable scenario for such values. I guees even telnet is not the best apporach to use for my project, I'll keep experiencing. Thank you all anyway, it's always a pleasure to share some considerations and get back usefull hints. -- http://mail.python.org/mailman/listinfo/python-list
Re: SoC project: Python-Haskell bridge - request for feedback
There is your bridge: http://kks.cabal.fi/HaskellAndPython It's not polished and one might shoot his/her legs off while using that -so be careful. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems with read_eager and Telnet
On 2/28/2011 3:46 PM, Robi wrote: unless using it just to get/set configuration, in which case, speed should hardly seem an issue. Right, I'm using it that way, I get/set properties changing them in real time (I whish!). ... My conclusion being, fgfs cannot answer back quicker than this: 20Hz. I suspect that is by design, so as to not interfere with the simulation itself. This is quite poor for a quasi-realtime hardware interface (which is in my intention). I suggest you discuss your use case on a FlightGear mailing list (mirrored on gmane as newsgroups) or forum. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: 3.1 - 3.2: base64 lost deprecation warning
On 2011-02-28 15:51:32 -0500, Ethan Furman said: Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. -- import base64 -- base64.encodestring(b'this is a test') __main__:1: DeprecationWarning: encodestring() is a deprecated alias, use encodebytes() b'dGhpcyBpcyBhIHRlc3Q=\n' Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. -- import base64 -- base64.encodestring(b'another test') b'dGhpcyBpcyBhIHRlc3Q=\n' The deprecation warning has gone away in 3.2, but the function remains... does anyone know if this was intentional? ~Ethan~ I only found this: Issue #3613: base64.{encode,decode}string are now called base64.{encode,decode}bytes which reflects what type they accept and return. The old names are still there as deprecated aliases. Doesn't exlain the no warning though. -- Robert -- http://mail.python.org/mailman/listinfo/python-list
Re: 3.1 - 3.2: base64 lost deprecation warning
On 2/28/2011 3:51 PM, Ethan Furman wrote: Python 3.1.2 (r312:79149, Mar 21 2010, 00:41:52) [MSC v.1500 32 bit (Intel)] on win32 Type help, copyright, credits or license for more information. -- import base64 -- base64.encodestring(b'this is a test') __main__:1: DeprecationWarning: encodestring() is a deprecated alias, use encodebytes() b'dGhpcyBpcyBhIHRlc3Q=\n' Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win 32 Type help, copyright, credits or license for more information. -- import base64 -- base64.encodestring(b'another test') b'dGhpcyBpcyBhIHRlc3Q=\n' The deprecation warning has gone away in 3.2, No, still there: def encodestring(s): Legacy alias of encodebytes(). import warnings warnings.warn(encodestring() is a deprecated alias, use encodebytes(), DeprecationWarning, 2) return encodebytes(s) but the function remains... does anyone know if this was intentional? In 3.2, DeprecationWarnings are turned off by default so as to not annoy users who can do nothing about them and developers who do not want to do anything at the moment. I presume the doc for warnings says how to turn them back on. -- Terry Jan Reedy -- http://mail.python.org/mailman/listinfo/python-list
Re: 3.1 - 3.2: base64 lost deprecation warning
Terry Reedy wrote: On 2/28/2011 3:51 PM, Ethan Furman wrote: The deprecation warning has gone away in 3.2, No, still there: def encodestring(s): Legacy alias of encodebytes(). import warnings warnings.warn(encodestring() is a deprecated alias, use encodebytes(), DeprecationWarning, 2) return encodebytes(s) In 3.2, DeprecationWarnings are turned off by default so as to not annoy users who can do nothing about them and developers who do not want to do anything at the moment. I presume the doc for warnings says how to turn them back on. Ah, thank you! ~Ethan~ -- http://mail.python.org/mailman/listinfo/python-list
Re: subclass urllib2
On Feb 28, 6:53 pm, monkeys paw mon...@joemoney.net wrote: I'm trying to subclass urllib2 in order to mask the version attribute. Here's what i'm using: import urllib2 class myURL(urllib2): def __init__(self): urllib2.__init__(self) self.version = 'firefox' I get this Traceback (most recent call last): File interactive input, line 1, in module TypeError: Error when calling the metaclass bases module.__init__() takes at most 2 arguments (3 given) I don't see where i am supplying 3 arguments. What am i missing? urllib2 is a module, not a class, so you can't subclass it. You could subclass one of the classes inside urllib2, such as urllib2.BaseHandler. Whether you want to depends on what your want to achieve. -- http://mail.python.org/mailman/listinfo/python-list
Re: how to properly pass literal strings python code to be executed using python -c
On Mon, 28 Feb 2011 10:59:01 -0800, jmoons wrote: I need some help figuring out how to execute this python code from python -c I am have trouble formatting python so that it will execute for another app in cmd I understand there maybe other ways to do what I am doing but I am limited by the final execution using cmd python -c so please keep this in mind. I'm limited by the final delivery of code. The python is being called by a server that does not have access to any python script file Let me translate that... I'm having trouble hammering this nail with a screwdriver. Keep in mind that I am limited by the requirement that I use a screwdriver, not a hammer, to hammer the nail. The nail is being hammered by somebody who doesn't have a hammer. So give them a hammer. Put the code in a text file, call it main.py or something, and execute python -m main, or python -c 'import main' if you prefer. I don't understand the requirement to avoid storing your code in a file -- surely you won't be typing the script into cmd every single time you want to run it, so surely it will be stored in a batch file or similar? As far as I can tell, the *only* legitimate reason for the requirement is to win a bet :) Otherwise, you're just making your life much much harder than it needs to be. [...] So this what i have but no worky cmdline = \ import os, shutil \n for root, dirs, files in os.walk(+myPath+):\n \t for file in files: \n \t \t os.remove(os.path.join(root, file)) \n \t for dir in dirs: \n \t\t shutil.rmtree(os.path.join(root, dir)) I have no idea what the string handling rules for cmd are, and I'm not going to try to guess. This doesn't appear to be a Python problem, it's a cmd problem. You need to work out how to correctly quote your string. Perhaps try on some Windows forums. I have also tried the following python -c import os; import shutil; for root, dirs, files in os.walk('+myPath+'): for file in files: os.remove(os.path.join(root, file)); for dir in dirs: shutil.rmtree(os.path.join(root, dir)) I am still getting error tree(os.path.join(root, dir)) ^ SyntaxError: invalid syntax No you don't. You don't call a function tree, so you can't be getting that error. The actual function you call is shutil.rmtree. Please don't retype, summarize, simplify or paraphrase error messages. Copy and paste them *exactly* as they are shown, complete with any traceback which is printed. -- Steven -- http://mail.python.org/mailman/listinfo/python-list
Re: move to end, in Python 3.2 Really?
Raymond Hettinger wrote: The existing list.pop() API is similar (though it takes an index value instead of a boolean): mylist.pop() # default case: pop from last mylist.pop(0) # other case:pop from first pop() is somewhat different, because there is an infinite range of possible values for the index parameter. Here there are only two possibilites, though, and it's unlikely that code will want to dynamically select between them -- so the no constant parameters guideline would seem to apply. -- Greg -- http://mail.python.org/mailman/listinfo/python-list
Re: OT: Code Examples
On 2/28/2011 8:14 AM, n00m wrote: On Feb 28, 6:03 pm, Fred Marshallfmarshallxremove_th...@acm.org wrote: The best place for you to start: http://numpy.scipy.org/ Numpy manual: http://www.tramy.us/numpybook.pdf OK Thanks! Fred -- http://mail.python.org/mailman/listinfo/python-list
Re: Plumber, an alternative to mixin-based subclassing
[posted e-mailed] In article mailman.1666.1296864671.6505.python-l...@python.org, Florian Friesdorf f...@chaoflow.net wrote: An alternative to mixin-based subclassing: http://pypi.python.org/pypi/plumber You'll probably get more interest if you provide a summary. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong. --GvR, python-ideas, 2009-03-01 -- http://mail.python.org/mailman/listinfo/python-list
Re: Idea for removing the GIL...
In article b8112a95-0c8d-41b7-9e42-805e63a78...@o32g2000prb.googlegroups.com, Carl Banks pavlovevide...@gmail.com wrote: The real reason they never replaced the GIL is that fine-grained locking is expensive with reference counting. The only way the cost of finer-grained locking would be acceptable, then, is if they got rid of the reference counting altogether, and that was considered too drastic a change. ...especially given CPython's goal of easy integration with C libraries. -- Aahz (a...@pythoncraft.com) * http://www.pythoncraft.com/ Programming language design is not a rational science. Most reasoning about it is at best rationalization of gut feelings, and at worst plain wrong. --GvR, python-ideas, 2009-03-01 -- http://mail.python.org/mailman/listinfo/python-list
Re: Executing js/ajax in a sandboxed environment
I was wondering if there is a way to execute js associated in page in sandbox environment before I start parsing it. You can use http://code.google.com/p/python-spidermonkey/ or http://code.google.com/p/pyv8/ to evaluate JavaScript. You can use any browser (including embedded htmlunit) using Selenium. HTH -- Miki Tebeka miki.teb...@gmail.com http://pythonwise.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems of Symbol Congestion in Computer Languages
On Feb 28, 11:39 pm, Dotan Cohen dotanco...@gmail.com wrote: You miss the canonical bad character reuse case: = vs ==. Had there been more meta keys, it might be nice to have a symbol for each key on the keyboard. I personally have experimented with putting the symbols as regular keys and the numbers as the Shifted versions. It's great for programming. Hmmm... Clever! Is it X or Windows? Can I have your setup? One problem we programmers face is that keyboards were made for typists not programmers. Another is that when we move from 'hi-level' questions eg code reuse -- to lower and lower -- eg ergonomics of reading and writing code -- the focus goes from the center of consciousness to the periphery and we miss how many inefficiencies there are in our semi-automatic actions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Problems of Symbol Congestion in Computer Languages
On Feb 28, 7:30 pm, rusi rustompm...@gmail.com wrote: On Feb 28, 11:39 pm, Dotan Cohen dotanco...@gmail.com wrote: You miss the canonical bad character reuse case: = vs ==. Had there been more meta keys, it might be nice to have a symbol for each key on the keyboard. I personally have experimented with putting the symbols as regular keys and the numbers as the Shifted versions. It's great for programming. Hmmm... Clever! Is it X or Windows? Can I have your setup? hi Russ, there's a programer's dvorak layout i think is bundled with linux. or you can do it with xmodmap on X-11 or AutoHotKey on Windows, or within emacs... On the mac, you can use keyboardMaestro, Quickeys, or just write a os wide config file yourself. You can see tutorials and sample files for all these here http://xahlee.org/Periodic_dosage_dir/keyboarding.html i'd be interested to know what Dotan Cohen use too. i tried the swapping number row with symbols a few years back. didn't like it so much because numbers are frequently used as well, especially when you need to enter a series of numbers. e.g. heavy math, or dates 2010-02-28. One can use the number pad but i use that as extra programable buttons. Xah One problem we programmers face is that keyboards were made for typists not programmers. Another is that when we move from 'hi-level' questions eg code reuse -- to lower and lower -- eg ergonomics of reading and writing code -- the focus goes from the center of consciousness to the periphery and we miss how many inefficiencies there are in our semi-automatic actions. -- http://mail.python.org/mailman/listinfo/python-list
Re: Idea for removing the GIL...
Aahz, 01.03.2011 03:02: Carl Banks wrote: The real reason they never replaced the GIL is that fine-grained locking is expensive with reference counting. The only way the cost of finer-grained locking would be acceptable, then, is if they got rid of the reference counting altogether, and that was considered too drastic a change. ...especially given CPython's goal of easy integration with C libraries. +1, the GIL is much more rarely a problem than some people want to make it appear. Especially those who don't understand why it's there, or who fail to notice that threading is not the only way to do parallel processing (and certainly not the easiest either). Stefan -- http://mail.python.org/mailman/listinfo/python-list
[issue8271] str.decode('utf8', 'replace') -- conformance with Unicode 5.2.0
Marc-Andre Lemburg m...@egenix.com added the comment: Ezio Melotti wrote: Ezio Melotti ezio.melo...@gmail.com added the comment: The patch turned out to be less trivial than I initially thought. The current algorithm checks for invalid continuation bytes in 4 places: 1) before the switch/case statement in Objects/unicodeobject.c when it checks if there are enough bytes in the string (e.g. if the current byte is a start byte of a 4-bytes sequence and there are only 2 more bytes in the string, the sequence is invalid); 2) in the case 2 of the switch, where it's checked if the second byte is a valid continuation byte; 3) in the case 3 of the switch, where it's checked if the second and third bytes are valid continuation bytes, including additional invalid cases for the second bytes; 3) in the case 4 of the switch, where it's checked if the second, third, and fourth bytes are valid continuation bytes, including additional invalid cases for the second bytes; The correct algorithm should determine the maximum valid subpart of the sequence determining the position of the first invalid continuation byte. Continuation bytes are all in range 80..BF except for the second byte of 3-bytes sequences that start with E0 or ED and second byte of 4-bytes sequences that start with F0 or F4 (3rd and 4th continuation bytes are always in range 80..BF). This means that the above 4 cases should be changed in this way: 1) if there aren't enough bytes left to complete the sequence check for valid continuation bytes considering the special cases for the second bytes (E0, ED, F0, F4) instead of using the naive algorithm that checks only for continuation bytes in range 80..BF; 2) the case 2 is fine as is, because the second byte is always in range 80..BF; 3) the case 3 should check (pseudocode): if (second_byte_is_not_valid) max_subpart_len = 1 else if (third_byte not in 80..BF) max_subpart_len = 2 else # the sequence is valid the second_byte_is_not_valid part should consider the two special cases for E0 and ED. 4) the case 4 should check (pseudocode): if (second_byte_is_not_valid) max_subpart_len = 1 else if (third_byte not in 80..BF) max_subpart_len = 2 else if (fourth_byte not in 80..BF) max_subpart_len = 3 else # the sequence is valid here the second_byte_is_not_valid part should consider the two special cases for F0 and E4. In order to avoid duplication of code I was thinking to add 2 macros (something like IS_VALID_3_SEQ_2ND_BYTE, IS_VALID_4_SEQ_2ND_BYTE) that will be used in the cases 1) and 3), and 1) and 4) respectively. The change shouldn't affect the decoding speed, but it will increase the lines of code and complexity of the function. Is this OK? Sure. It would be great if you could time the difference in performance. In tight loops like the codec ones, small changes in the way you write things can often make a big difference. Please also include a Misc/NEWS entry to point to the change and possibly consequences for existing code relying on the previous behavior. Thanks, -- Marc-Andre Lemburg eGenix.com ::: Try our new mxODBC.Connect Python Database Interface for free ! eGenix.com Software, Skills and Services GmbH Pastor-Loeh-Str.48 D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg Registered at Amtsgericht Duesseldorf: HRB 46611 http://www.egenix.com/company/contact/ -- title: str.decode('utf8', 'replace') -- conformance with Unicode 5.2.0 - str.decode('utf8','replace') -- conformance with Unicode 5.2.0 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8271 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11283] incorrect pattern in the re module docs for conditional regex
Senthil Kumaran orsent...@gmail.com added the comment: Thinking about the regex pattern again. The example given is not really wrong. It does what it claims to match, that is 'u...@example.com' and 'u...@example.com' and reject u...@example.com' kind of string. Nothing is said about 'u...@example.com' kind of string. Also, this is not an example of validating an email address or finding an email address pattern in text data. A good regex for that purposes would be more complex[1][2]. Having said that, if example of conditional regex has been given - the current one is sufficient (in which case no change is required) or a simpler one can be presented, which may not like matching a email address and thus devoid of any expectations of valid patterns. Also, if we 'really' think that rejecting 'user@example' is good idea in the example documentation, then having '$' in no-pattern of regex is good enough. No need to think for regex search cases for the explanation given about. 1: http://www.regular-expressions.info/email.html 2: http://ex-parrot.com/~pdw/Mail-RFC822-Address.html -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11283 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10524] Patch to add Pardus to supported dists in platform
Onur Küçük o...@pardus.org.tr added the comment: Is this patch going to be applied ? platform.dist() is a function which detects and returns the distribution name and version, and it fails to detect Pardus distribution name and version. Since the attached patch fixes this, this should be considered as a bugfix. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11350] __setitem__()'s problem of dbm.dumb object pointed out by comments
New submission from Ray.Allen ysj@gmail.com: By reading the Lib/dbm/dumb.py source, there seems to be an distinct problem which is pointed out in comments: the __setitem__() should call self._commit() in order to keep .dat file and .dir file consist. Here is a piece of comment found at the end of __setitem__(): # Note that _index may be out of synch with the directory # file now: _setval() and _addval() don't update the directory # file. This also means that the on-disk directory and data # files are in a mutually inconsistent state, and they'll # remain that way until _commit() is called. Note that this # is a disaster (for the database) if the program crashes # (so that _commit() never gets called). And another piece found in __delitem__(): # XXX It's unclear why we do a _commit() here (the code always # XXX has, so I'm not changing it). __setitem__ doesn't try to # XXX keep the directory file in synch. Why should we? Or # XXX why shouldn't __setitem__? One probable reason I guess is that the self._commit() method which writes the keys information to .dir file is regarded as a slow process, and the __setitem__() is called frequently at most cases while __deltiem__ is not, so calling self._commit() at each __setitem__ could make the program very slow. But based on the fact that The dbm.dumb module is not written for speed and is not nearly as heavily used as the other database modules.(found on dbm's library document), maybe correctness is more important than speed. So I think it should be fixed: Index: Lib/dbm/dumb.py === --- Lib/dbm/dumb.py (revision 88674) +++ Lib/dbm/dumb.py (working copy) @@ -196,6 +196,7 @@ # remain that way until _commit() is called. Note that this # is a disaster (for the database) if the program crashes # (so that _commit() never gets called). +self._commit() def __delitem__(self, key): if isinstance(key, str): And the remaining comments can be deleted. -- components: Library (Lib) messages: 129688 nosy: ysj.ray priority: normal severity: normal status: open title: __setitem__()'s problem of dbm.dumb object pointed out by comments versions: Python 3.1, Python 3.2, Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11350 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] (test_os) os.sendfile() error
New submission from Steffen Daode Nurpmeso sdao...@googlemail.com: Antoine, i made you noisy because you took care about Issue11323. I'm at r88671 (271057c7c6f3). I'm opening this because the buildbot URL (thanks) doesn't show anything about sendfile(2). 12:47 ~/arena/code.extern.repos/py3k.hg $ ./python.exe -Wd -m test.test_os -r -w -v ... test_headers (__main__.TestSendfile) ... FAIL test_invalid_offset (__main__.TestSendfile) ... ok test_offset_overflow (__main__.TestSendfile) ... ok test_send_at_certain_offset (__main__.TestSendfile) ... ok test_send_whole_file (__main__.TestSendfile) ... ok test_trailers (__main__.TestSendfile) ... /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/unittest/case.py:387: ResourceWarning: unclosed file _io.BufferedReader name='@test_28253_tmp2' function() ok test_set_get_priority (__main__.ProgramPriorityTests) ... ok == FAIL: test_headers (__main__.TestSendfile) -- Traceback (most recent call last): File /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/test/test_os.py, line 1517, in test_headers self.assertEqual(total_sent, len(expected_data)) AssertionError: 163840 != 164352 -- Ran 92 tests in 0.447s FAILED (failures=1, skipped=10) Traceback (most recent call last): File /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/runpy.py, line 160, in _run_module_as_main __main__, fname, loader, pkg_name) File /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/runpy.py, line 73, in _run_code exec(code, run_globals) File /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/test/test_os.py, line 1573, in module test_main() File /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/test/test_os.py, line 1569, in test_main ProgramPriorityTests, File /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/test/support.py, line 1187, in run_unittest _run_suite(suite) File /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/test/support.py, line 1170, in _run_suite raise TestFailed(err) test.support.TestFailed: Traceback (most recent call last): File /Users/steffen/arena/code.extern.repos/py3k.hg/Lib/test/test_os.py, line 1517, in test_headers self.assertEqual(total_send, len(expected_data)) AssertionError: 163840 != 164352 -- components: Library (Lib) messages: 129689 nosy: pitrou, sdaoden priority: normal severity: normal status: open title: (test_os) os.sendfile() error type: behavior versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] (test_os) os.sendfile() error
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: It's about the headers[]: def test_headers(self): total_sent = 0 sent = os.sendfile(self.sockno, self.fileno, 0, 4096, headers=[bx * 512]) total_sent += sent print(HEADER SENT:, sent) prints test_headers (__main__.TestSendfile) ... HEADER SENT: 4096 Well. 'man 2 sendfile' tells me it is supporting headers and trailers since Darwin 9.0 aka Mac OS X 10.5. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11352] Buf in cgi module doc
New submission from Pierre Quentel pierre.quen...@gmail.com: Hi, I wrote a patch for the cgi module in version 3.2rc1 (#4953). Small changes should be done to the documentation of this module to reflect the changes in the module API : - in section 20.2.2. Using the cgi module original text : If a field represents an uploaded file, accessing the value via the value attribute or the getvalue() method reads the entire file in memory as a string. This may not be what you want. You can test for an uploaded file by testing either the filename attribute or the file attribute. You can then read the data at leisure from the file attribute: proposed new text (for files, value is bytes, not string, and the read() method on file also returns bytes) : If a field represents an uploaded file, accessing the value via the value attribute or the getvalue() method reads the entire file in memory as bytes. This may not be what you want. You can test for an uploaded file by testing either the filename attribute or the file attribute. You can then read the data at leisure from the file attribute (the read() and readline() methods will return bytes) : - version 3.2 introduced a parameter encoding for the FieldStorage constructor, used to decode the bytes received on the HTTP connection for fields other than files. This encoding must the one defined in the HTML document holding the form submitted to the CGI script ; it is usually defined by a meta tag : meta http-equiv=Content-type content=text/html;charset=latin-1 or by the Content-Type header for this document I'm not sure where this should be mentioned in the module documentation. Maybe in 20.2.9. Common problems and solutions for the moment. But there are plans (#11066) to introduce another interface to change the encoding of sys.stdout in the CGI script itself, so another option would be to open a specific section about encodings Hope it's clear enough Pierre -- assignee: docs@python components: Documentation messages: 129691 nosy: docs@python, quentel priority: normal severity: normal status: open title: Buf in cgi module doc type: behavior versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11352 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11352] Bug in cgi module doc
Pierre Quentel pierre.quen...@gmail.com added the comment: bug, not buf... -- title: Buf in cgi module doc - Bug in cgi module doc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11352 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5542] Socket is closed prematurely in httplib, if server sends response before request body has been sent
Senthil Kumaran orsent...@gmail.com added the comment: Guy, if the issue you describe in relevant to py3.x or 2.7, can you open a new issue? -- nosy: +orsenthil ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5542 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] (test_os) os.sendfile() error
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: posixmodule.c: iov_setup(): IOV[i]: buffer:0x10152b8f0, len:512 iov_setup() leave ok before sendfile: sf=0x7fff5fbfb410, sf.headers=0x10036c780 sf.headers[0].iov_base=0x10152d950, .iov_len=512 after sendfile: sbytes=4096 Maybe Mac OS X does not support headers (i'm on Mac OS X 10.6)? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1720250] PyGILState_Ensure does not acquires GIL
Nick Coghlan ncogh...@gmail.com added the comment: Given the deprecation of PyEval_ReleaseLock in issue10913, should this be closed as out of date? -- nosy: +ncoghlan ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1720250 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11350] __setitem__()'s problem of dbm.dumb object pointed out by comments
R. David Murray rdmur...@bitdance.com added the comment: Can you construct a test case that demonstrates the corruption? -- nosy: +r.david.murray stage: - test needed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11350 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11342] ResourceWarning: unclosed file _io.TextIOWrapper
Éric Araujo mer...@netwok.org added the comment: So the patch fixes the resource warnings? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11342 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] (test_os) os.sendfile() error
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: Did you know that 'sbytes' is not adjusted to match possibly existent headers and trailers in posixmodule.c? This however is required according to Mac OS X 'man 2 sendfile'. I'll attach a simple, naive patch for a very intelligent and outstanding operating system. -- Added file: http://bugs.python.org/file20943/posixmodule.naive-apple-patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5867,9 +5867,10 @@ #ifdef HAVE_SENDFILE #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__) -static int +static off_t iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, int cnt, int type) { +off_t ret = 0; int i, j; *iov = PyMem_New(struct iovec, cnt); if (*iov == NULL) { @@ -5880,7 +5881,7 @@ if (*buf == NULL) { PyMem_Del(*iov); PyErr_NoMemory(); -return 0; +return ret; } for (i = 0; i cnt; i++) { @@ -5889,14 +5890,18 @@ PyMem_Del(*iov); for (j = 0; j i; j++) { PyBuffer_Release((*buf)[j]); - } +} PyMem_Del(*buf); -return 0; +ret ^= ret; +return ret; } (*iov)[i].iov_base = (*buf)[i].buf; -(*iov)[i].iov_len = (*buf)[i].len; -} -return 1; +do {off_t x = (*buf)[i].len; +(*iov)[i].iov_len = x; +ret += x; +} while (0); +} +return ret; } static void @@ -5954,10 +5959,15 @@ sendfile() headers must be a sequence or None); return NULL; } else { +off_t i = 0; /* Uninitialized warning */ sf.hdr_cnt = PySequence_Size(headers); -if (sf.hdr_cnt 0 !iov_setup((sf.headers), hbuf, -headers, sf.hdr_cnt, PyBUF_SIMPLE)) +if (sf.hdr_cnt 0 +!(i = iov_setup((sf.headers), hbuf, +headers, sf.hdr_cnt, PyBUF_SIMPLE))) return NULL; +#ifdef __APPLE__ +sbytes += i; +#endif } } if (trailers != NULL) { @@ -5966,10 +5976,15 @@ sendfile() trailers must be a sequence or None); return NULL; } else { +off_t i = 0; /* Uninitialized warning */ sf.trl_cnt = PySequence_Size(trailers); -if (sf.trl_cnt 0 !iov_setup((sf.trailers), tbuf, -trailers, sf.trl_cnt, PyBUF_SIMPLE)) +if (sf.trl_cnt 0 +!(i = iov_setup((sf.trailers), tbuf, +trailers, sf.trl_cnt, PyBUF_SIMPLE))) return NULL; +#ifdef __APPLE__ +sbytes += i; +#endif } } ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] Mac OS X os.sendfile()
Changes by Steffen Daode Nurpmeso sdao...@googlemail.com: -- title: (test_os) os.sendfile() error - Mac OS X os.sendfile() ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11281] smtplib: add ability to bind to specific source IP address/port
Paulo Scardine pa...@scardine.com.br added the comment: Patch attached. -- Added file: http://bugs.python.org/file20944/smtp_lib_source_address.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11281 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10524] Patch to add Pardus to supported dists in platform
Éric Araujo mer...@netwok.org added the comment: Marc-André already approved it; he must just have lacked time. We’re all volunteers with a lot of bugs on our radar, so thanks for the reminder. Marc-André: I can commit this if you want. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue10524 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11281] smtplib: add ability to bind to specific source IP address/port
Paulo Scardine pa...@scardine.com.br added the comment: oops... -- Added file: http://bugs.python.org/file20945/smtp_lib_source_address.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11281 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11348] test_os: test_set_get_priority() fails when high niceness is set
R. David Murray rdmur...@bitdance.com added the comment: We could, however, raise SkipTest if getpriority returns 19 or higher with a message like unable to reliably test setpriority at current nice level of NN. My guess is that no system we support has a lower upper limit on nice. If someone wants to customize the test/message per OS, that would probably be even better; but not, I think, required. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11348 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11281] smtplib: add ability to bind to specific source IP address/port
Paulo Scardine pa...@scardine.com.br added the comment: Sorry for the last post, I had the impression that I forgot to attach the patch. I'm slow this Monday. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11281 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11348] test_os: test_set_get_priority() fails when high niceness is set
R. David Murray rdmur...@bitdance.com added the comment: To be clear: raise SkipTest if prio is 19 or above *and* the increment fails. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11348 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] Mac OS X os.sendfile()
Antoine Pitrou pit...@free.fr added the comment: Likely explanation is http://bugs.python.org/issue10882#msg129555. -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11301] cookielib.LWPCookieJar.save() doesn't save cookies
Changes by Senthil Kumaran orsent...@gmail.com: -- resolution: - invalid stage: - committed/rejected ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11301 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] (test_os) os.sendfile() error
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: Before i'm going down, here is the paragraph from 'man 2 sendfile': When a header or trailer is specified the value of len returned will include the size of header or trailer sent. The user should provide suf- ficiently large value of len as argument including the size of header or trailer, otherwise only part of file data will be sent following the header. -- title: Mac OS X os.sendfile() - (test_os) os.sendfile() error ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] Mac OS X os.sendfile()
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: (But see msg12970. And the test runs fine with my patch applied.) On Mon, Feb 28, 2011 at 02:17:46PM +, Antoine Pitrou wrote: Antoine Pitrou pit...@free.fr added the comment: Likely explanation is http://bugs.python.org/issue10882#msg129555. -- nosy: +giampaolo.rodola ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ -- title: (test_os) os.sendfile() error - Mac OS X os.sendfile() ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] Mac OS X os.sendfile()
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: (Should have been msg129706, sorry.) P.S.: yes, you're right. But now: issue 10882 is on adding os.sendfile(), not on fixing errors on os.sendfile(). ;-) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] Mac OS X os.sendfile()
Antoine Pitrou pit...@free.fr added the comment: Your patch is not cleaned up. There are strange things like: +ret ^= ret; (while would you xor an off_t?) and +do {off_t x = (*buf)[i].len; +(*iov)[i].iov_len = x; +ret += x; +} while (0); -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1720250] PyGILState_Ensure does not acquires GIL
Antoine Pitrou pit...@free.fr added the comment: Given the deprecation of PyEval_ReleaseLock in issue10913, should this be closed as out of date? Indeed :) -- resolution: - out of date stage: test needed - status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1720250 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] Mac OS X os.sendfile()
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: Will this do? Otherwise feel free to adjust the patch the way Python needs it, i'll learn from that, then, for possible future things. (I need to go down now.) On Mon, Feb 28, 2011 at 02:37:16PM +, Antoine Pitrou wrote: Antoine Pitrou pit...@free.fr added the comment: Your patch is not cleaned up. There are strange things like: +ret ^= ret; (while would you xor an off_t?) and +do {off_t x = (*buf)[i].len; +(*iov)[i].iov_len = x; +ret += x; +} while (0); -- keywords: +patch Added file: http://bugs.python.org/file20946/issue11351.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5867,10 +5867,11 @@ #ifdef HAVE_SENDFILE #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__) -static int +static off_t iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, int cnt, int type) { int i, j; +off_t len, ret = 0; *iov = PyMem_New(struct iovec, cnt); if (*iov == NULL) { PyErr_NoMemory(); @@ -5880,7 +5881,7 @@ if (*buf == NULL) { PyMem_Del(*iov); PyErr_NoMemory(); -return 0; +return ret; } for (i = 0; i cnt; i++) { @@ -5889,14 +5890,17 @@ PyMem_Del(*iov); for (j = 0; j i; j++) { PyBuffer_Release((*buf)[j]); - } +} PyMem_Del(*buf); -return 0; +ret = 0; +return ret; } (*iov)[i].iov_base = (*buf)[i].buf; -(*iov)[i].iov_len = (*buf)[i].len; -} -return 1; +len = (*buf)[i].len; +(*iov)[i].iov_len = len; +ret += len; +} +return ret; } static void @@ -5954,10 +5958,15 @@ sendfile() headers must be a sequence or None); return NULL; } else { +off_t i = 0; /* Uninitialized warning */ sf.hdr_cnt = PySequence_Size(headers); -if (sf.hdr_cnt 0 !iov_setup((sf.headers), hbuf, -headers, sf.hdr_cnt, PyBUF_SIMPLE)) +if (sf.hdr_cnt 0 +!(i = iov_setup((sf.headers), hbuf, +headers, sf.hdr_cnt, PyBUF_SIMPLE))) return NULL; +#ifdef __APPLE__ +sbytes += i; +#endif } } if (trailers != NULL) { @@ -5966,10 +5975,15 @@ sendfile() trailers must be a sequence or None); return NULL; } else { +off_t i = 0; /* Uninitialized warning */ sf.trl_cnt = PySequence_Size(trailers); -if (sf.trl_cnt 0 !iov_setup((sf.trailers), tbuf, -trailers, sf.trl_cnt, PyBUF_SIMPLE)) +if (sf.trl_cnt 0 +!(i = iov_setup((sf.trailers), tbuf, +trailers, sf.trl_cnt, PyBUF_SIMPLE))) return NULL; +#ifdef __APPLE__ +sbytes += i; +#endif } } ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] Mac OS X os.sendfile()
Changes by Antoine Pitrou pit...@free.fr: -- assignee: - giampaolo.rodola nosy: +rosslagerwall stage: - patch review ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11353] Python 2.7.1 cannot be built by 2.x baselines of Python
New submission from David w004...@xsmail.com: I tried to download and install the latest Python tarball (2.7.1) and use Python 2.6 to execute setup.py. I got the error No module named sysconfig when running setup.py. sysconfig was introduced with Python 3.2 (per http://docs.python.org/dev/library/sysconfig.html). I am running Ubuntu 10.04.2 LTS and Python 2.6 trying to update to 2.7.x since Django does not support Python 3.x. It seems like a lot of trouble to install Python 3.x to downgrade to the Python version I need. Recommend providing deb source packages that can be built on Ubuntu 10.04 and 10.10, or fixing this bug. -- components: Build messages: 129712 nosy: w004dal priority: normal severity: normal status: open title: Python 2.7.1 cannot be built by 2.x baselines of Python type: compile error versions: Python 2.5, Python 2.6, Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11353 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11353] Python 2.7.1 cannot be built by 2.x baselines of Python
Antoine Pitrou pit...@free.fr added the comment: The way to build Python is to run ./configure followed by make. This is explained in the README. -- nosy: +barry, pitrou resolution: - invalid status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11353 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11354] argparse: nargs could accept range of options count
New submission from Wojciech Muła wojciech_m...@poczta.onet.pl: Hi, sometimes it is needed to grab variable, but limited, number of options. For example --point could accept 2, 3 or 4 values: (x,y) or (x,y,z) or (x,y,z,w). Current version of argparse requires postprocessing: parser.add_argument('--point', action='append', default=[]) nmps = parser.parse_args() if not (2 = len(nmsp.point) = 4): raise argparse.ArgumentTypeError(--point expects 2, 3 or 4 values) I propose to allow pass range of options count to nargs, including lower/upper bound. For example: parser.add_argument('--point', nargs=(2,4) )# from 2 to 4 parser.add_argument('--foo', nargs=(9, None) ) # at least 9 parser.add_argument('--bar', nargs=(None, 7) ) # at most 7 nmsp = parser.parse_args() I've attached tests and patch made against Python3.2 lib from Debian. w. -- components: Library (Lib) files: argparse-nargs.patch keywords: patch messages: 129714 nosy: wm priority: normal severity: normal status: open title: argparse: nargs could accept range of options count type: feature request versions: Python 3.2, Python 3.3 Added file: http://bugs.python.org/file20947/argparse-nargs.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11354 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11354] argparse: nargs could accept range of options count
Wojciech Muła wojciech_m...@poczta.onet.pl added the comment: tests -- Added file: http://bugs.python.org/file20948/test.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11354 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11342] ResourceWarning: unclosed file _io.TextIOWrapper
LW cjejuni2...@yahoo.com added the comment: only the sysconfig.py was patched, the rest were reject'ed. no compilation yet at this time. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11342 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8728] 2.7 regression in httplib.py: AttributeError: 'NoneType' object has no attribute 'makefile'
Changes by Ryan Coyner rcoy...@gmail.com: -- nosy: +rcoyner ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8728 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8594] Add a source_address option to ftplib
Giampaolo Rodola' g.rod...@gmail.com added the comment: Committed in r88679. -- versions: +Python 3.3 -Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8594 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11351] Mac OS X os.sendfile()
Steffen Daode Nurpmeso sdao...@googlemail.com added the comment: This version uses Py_ssize_t for the lengths and seems to be more Python-style beside that, too. It compiles clean and the test is ok. -- Added file: http://bugs.python.org/file20949/issue11351-2.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11351 ___diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -5867,36 +5867,42 @@ #ifdef HAVE_SENDFILE #if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__APPLE__) -static int +static Py_ssize_t iov_setup(struct iovec **iov, Py_buffer **buf, PyObject *seq, int cnt, int type) { int i, j; +Py_ssize_t blen, total = 0; + *iov = PyMem_New(struct iovec, cnt); if (*iov == NULL) { PyErr_NoMemory(); -return 0; -} +return total; +} + *buf = PyMem_New(Py_buffer, cnt); if (*buf == NULL) { PyMem_Del(*iov); PyErr_NoMemory(); -return 0; +return total; } for (i = 0; i cnt; i++) { -if (PyObject_GetBuffer(PySequence_GetItem(seq, i), (*buf)[i], -type) == -1) { +if (PyObject_GetBuffer(PySequence_GetItem(seq, i), + (*buf)[i], type) == -1) { PyMem_Del(*iov); for (j = 0; j i; j++) { PyBuffer_Release((*buf)[j]); - } +} PyMem_Del(*buf); -return 0; +total = 0; +return total; } (*iov)[i].iov_base = (*buf)[i].buf; -(*iov)[i].iov_len = (*buf)[i].len; -} -return 1; +blen = (*buf)[i].len; +(*iov)[i].iov_len = blen; +total += len; +} +return total; } static void @@ -5954,10 +5960,15 @@ sendfile() headers must be a sequence or None); return NULL; } else { +Py_ssize_t i = 0; /* Avoid uninitialized warning */ sf.hdr_cnt = PySequence_Size(headers); -if (sf.hdr_cnt 0 !iov_setup((sf.headers), hbuf, -headers, sf.hdr_cnt, PyBUF_SIMPLE)) +if (sf.hdr_cnt 0 +!(i = iov_setup((sf.headers), hbuf, +headers, sf.hdr_cnt, PyBUF_SIMPLE))) return NULL; +#ifdef __APPLE__ +sbytes += i; +#endif } } if (trailers != NULL) { @@ -5966,10 +5977,15 @@ sendfile() trailers must be a sequence or None); return NULL; } else { +Py_ssize_t i = 0; /* Avoid uninitialized warning */ sf.trl_cnt = PySequence_Size(trailers); -if (sf.trl_cnt 0 !iov_setup((sf.trailers), tbuf, -trailers, sf.trl_cnt, PyBUF_SIMPLE)) +if (sf.trl_cnt 0 +!(i = iov_setup((sf.trailers), tbuf, +trailers, sf.trl_cnt, PyBUF_SIMPLE))) return NULL; +#ifdef __APPLE__ +sbytes += i; +#endif } } ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11348] test_os: test_set_get_priority() fails when high niceness is set
Giampaolo Rodola' g.rod...@gmail.com added the comment: Committed in r88680. -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11348 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8594] Add a source_address option to ftplib
Changes by Giampaolo Rodola' g.rod...@gmail.com: -- resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue8594 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11355] os.mkdir() and os.mkdirat() don't apply SUID/SGID permissions
New submission from Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: os.mkdir() and os.mkdirat() use libc's mkdir() and mkdirat(), which can ignore SUID/SGID permissions. This problem occurs at least on systems using glibc. The solution is to call chmod() / fchmodat() to ensure that given directory has been created with requested permissions. I'm attaching the patch. -- files: python-mkdir.patch keywords: patch messages: 129720 nosy: Arfrever priority: normal severity: normal status: open title: os.mkdir() and os.mkdirat() don't apply SUID/SGID permissions versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file20950/python-mkdir.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11355 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11355] os.mkdir() and os.mkdirat() don't apply SUID/SGID permissions
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +r.david.murray ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11355 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11355] os.mkdir() and os.mkdirat() don't apply SUID/SGID permissions
Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com added the comment: The new patch restores respecting of umask. -- Added file: http://bugs.python.org/file20951/python-mkdir.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11355 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11355] os.mkdir() and os.mkdirat() don't apply SUID/SGID permissions
Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com: Removed file: http://bugs.python.org/file20950/python-mkdir.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11355 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11355] os.mkdir() and os.mkdirat() don't apply SUID/SGID permissions
Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com added the comment: A side effect of this patch is that it fixes failure of test_exist_ok_existing_directory() from test_os.py in situation when top-level directory of Python sources has SGID bit set. (test_exist_ok_existing_directory() exists only in Python =3.2.) $ chmod g+s . $ LD_LIBRARY_PATH=$(pwd) ./python Lib/test/test_os.py ... == ERROR: test_exist_ok_existing_directory (__main__.MakedirTests) -- Traceback (most recent call last): File Lib/test/test_os.py, line 653, in test_exist_ok_existing_directory os.makedirs(path, mode=mode, exist_ok=True) File /var/tmp/portage/dev-lang/python-3.3_pre20110227/work/python-3.3_pre20110227/Lib/os.py, line 152, in makedirs mkdir(name, mode) OSError: [Errno 17] File exists: '@test_32218_tmp/dir1' -- -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11355 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11347] libpython3.so: Broken soname and linking
Martin v. Löwis mar...@v.loewis.de added the comment: The -hl - -h part seems correct though. Indeed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11347 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11347] libpython3.so: Broken soname and linking
Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com added the comment: Having the soname be libpython3 is the whole point of the library: I think that the point of this library is libpython3.so filename, not soname. Everything should still work if libpython3.so had no soname at all. (If somebody has installed unpatched Python 3.2, then ldconfig will create llibpython3.so symlink (e.g. /usr/lib/llibpython3.so) and linker will hardcode dependency on llibpython3.so in generated libraries/executables during linking against libpython3.so (e.g. when -lpython3 has been specified).) (I will work on improved patch for -Wl,--no-as-needed.) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11347 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11347] libpython3.so: Broken soname and linking
Martin v. Löwis mar...@v.loewis.de added the comment: Having the soname be libpython3 is the whole point of the library: I think that the point of this library is libpython3.so filename, not soname. Everything should still work if libpython3.so had no soname at all. IIUC, the linker will hard-code the full path name (include directory name) into DT_NEEDED if the shared library has no soname. That would be undesirable - the DT_NEEDED reference must be just the file name, not the full path. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11347 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11140] threading.Lock().release() raises _thread.error, not RuntimeError
Antoine Pitrou pit...@free.fr added the comment: Patch committed in r88682, thank you! -- resolution: - fixed stage: needs patch - committed/rejected status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11140 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com