[issue22904] make profile-opt includes -fprofile* flags in _sysconfigdata CFLAGS
Gregory P. Smith added the comment: see also issue23390 -- superseder: - make profile-opt: test_distutils failure ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22904 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22904] make profile-opt includes -fprofile* flags in _sysconfigdata CFLAGS
Changes by Gregory P. Smith g...@krypto.org: -- resolution: - duplicate status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22904 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23390] make profile-opt: test_distutils failure
Gregory P. Smith added the comment: Likely a dupe of http://bugs.python.org/issue22904 which is why i set the buildbot up. :) I like your patch here better than my non-fixing poor hack in the other issue. I hadn't noticed CFLAGS_NODIST before. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23390 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: dunder-docs (was Python is DOOMED! Again!)
Gregory Ewing wrote: Marko Rauhamaa wrote: For (almost) all practical purposes, that is the Python way as well. If object instantiation (conceptually) copied the class's methods into the object's dict, you'd get the semantics I'm looking for. If things worked the way you want, it would be impossible to store a function in an instance attribute and get it out again *without* it being treated as a method and getting 'self' added to its arguments. That would be a considerable nuisance when dealing with callbacks and the like. Not impossible, just inconvenient. Assuming that the descriptor protocol runs on access to instance attributes as well as class attribute, the solution is to use a custom descriptor to return the bare function. class function(object): def __init__(self, func): self.func = func def __get__(self, obj, cls=None): return self.func instance.callback = function(mycallback) Or you can possibly use staticmethod. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
Gregory Ewing wrote: Marko Rauhamaa wrote: Right now Python generates the trampoline from the class prototype every time you call a method. If the semantics allowed, you could create the trampoline at instantiation time (for better or worse). That way, the problem you seem to be referring to wouldn't materialize. Sorry, I misinterpreted what you were suggesting. You seem to be suggesting an optimisation that pre-creates bound methods when the instance is created. Keeping a cache of bound methods would achieve the same thing without changing the semantics. I think CPython might already be doing that, but I'm not sure. It's not. py class K(object): ... def f(self): pass ... py k = K() py k.f is k.f False -- Steve -- https://mail.python.org/mailman/listinfo/python-list
[issue23391] Documentation of EnvironmentError (OSError) arguments disappeared
New submission from Martin Panter: Seems to have been removed in revision 097f4fda61a4, for PEP 3151. The older EnvironmentError documentation talks about creating the exception with two and three constructor arguments, however I don’t see this in the new documentation. Is this usage meant to be deprecated, or still allowed? Either way, I think the documentation should mention it. -- assignee: docs@python components: Documentation messages: 235372 nosy: docs@python, vadmium priority: normal severity: normal status: open title: Documentation of EnvironmentError (OSError) arguments disappeared versions: Python 3.3, Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23391 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23365] integer overflow in itertools.combinations_with_replacement
Roundup Robot added the comment: New changeset 887526ebb013 by Serhiy Storchaka in branch '2.7': Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests. https://hg.python.org/cpython/rev/887526ebb013 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23365 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23366] integer overflow in itertools.combinations
Roundup Robot added the comment: New changeset 887526ebb013 by Serhiy Storchaka in branch '2.7': Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests. https://hg.python.org/cpython/rev/887526ebb013 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23366 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23363] integer overflow in itertools.permutations
Roundup Robot added the comment: New changeset 887526ebb013 by Serhiy Storchaka in branch '2.7': Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests. https://hg.python.org/cpython/rev/887526ebb013 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23363 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23364] integer overflow in itertools.product
Roundup Robot added the comment: New changeset 887526ebb013 by Serhiy Storchaka in branch '2.7': Issues #23363, #23364, #23365, #23366: Fixed itertools overflow tests. https://hg.python.org/cpython/rev/887526ebb013 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23364 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23363] integer overflow in itertools.permutations
Serhiy Storchaka added the comment: Thanks Arfrever. -- resolution: - fixed stage: - resolved status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23363 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
re.findall help
I am trying to extract the following from a data stream using find all what would be the best way to capture the ip address only from the following text ip=192.168.1.36 port=4992 I also want to make sure the program can handle the ip that is as high as 255.255.255.255 Thanks for any help you can provide -- https://mail.python.org/mailman/listinfo/python-list
Re: re.findall help
On 03Feb2015 18:52, w3t...@gmail.com w3t...@gmail.com wrote: I am trying to extract the following from a data stream using find all what would be the best way to capture the ip address only from the following text ip=192.168.1.36 port=4992 I also want to make sure the program can handle the ip that is as high as 255.255.255.255 I would not be using re.findall. If you have strings such as the one you describe I would: - call .split() on the string to break it up on whitespace - select the strings starting with ip= - split those strings on = and grab the stuff after the = - if you want to validate the address: split it on '.', check that there are 4 components, call int() on each component to check that is an int, and then check the value of the int as being in the range 0..255 inclusive Write some code doing the above, test it, and if stuck, return with: - the code - example input for which it does not work - an explaination of what it does do (including an output transcript showing the badness if possible) - an explaination of how the output is wrong, and what it should look like Cheers, Cameron Simpson c...@zip.com.au -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
Steven D'Aprano wrote: Gregory Ewing wrote: If things worked the way you want, it would be impossible to store a function in an instance attribute and get it out again *without* it being treated as a method Not impossible, just inconvenient... the solution is to use a custom descriptor But then it's not a plain function any more. Obviously you can wrap your function in something else, but that's the nuisance I was talking about. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Ghost vulnerability
Anssi Saari wrote: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Here's the one-liner: python -c 'import socket;y=0*5000;socket.gethostbyname(y)' I think it is likely that y=0*5000 would segfault due to lack of memory on many machines. I wouldn't trust this as a test. Hmm, how much RAM does that one-liner actually need? My router has 128 MB total RAM with about 90 MB free. So it can store the string once but if it's copied with the gethostbyname call then it'll run out... In Python 2, 0 is a byte (plus object header), so about 50MB give or take. In Python 3, 0 is a unicode string, so depending on whether you have a narrow or wide build, or version 3.3+, that could take 1, 2 or 4 bytes per character. So potentially 50, 100 or 200MB (plus a few extra bytes for the object header). Anyways, here's an example calling gethostbyname directly in python: from ctypes import CDLL o = CDLL('libc.so.6') for i in range(0, 2500): o.gethostbyname('0'*i) I don't have a vulnerable system to test on any more though. I stuck a print i just before the call to gethostbyname, and it got to i = 1004 and then crashed: *** glibc detected *** python2.7: realloc(): invalid next size: 0x08b9a7c0 *** with a page or three of diagnostics. -- Steve -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
On Tuesday, February 3, 2015 at 4:05:57 PM UTC-6, Ian wrote: On Tue, Feb 3, 2015 at 10:40 AM, Steven D'Aprano wrote: AT LONG LAST THE LIGHT DAWNS! THE PENNY DROPS! Careful there, you're starting to sound like Ranting Rick. ;-) Ha! My meme's are far more catchy and intellectual. But as they say, intimation *IS* the ultimate form of flattery! -- https://mail.python.org/mailman/listinfo/python-list
[issue22963] broken link in PEP 102
Ezio Melotti added the comment: The link in PEP 102 is still wrong, even though the pydotorg issue has been closed. The problem seems to affect txt PEPs (not rst ones), and it can be fixed by simply doing: diff --git a/pep2html.py b/pep2html.py --- a/pep2html.py +++ b/pep2html.py @@ -48,11 +48,11 @@ 'docutils': '0.2.7'} PROGRAM = sys.argv[0] RFCURL = 'http://www.faqs.org/rfcs/rfc%d.html' -PEPURL = 'pep-%04d.html' +PEPURL = '../pep-%04d.html' PEPCVSURL = ('https://hg.python.org/peps/file/tip/pep-%04d.txt') PEPDIRRUL = 'http://www.python.org/peps/' However this breaks the URLs while building/looking at the PEPs locally. (Note: I don't have a github account so I can't reopen the linked issue -- feel free to close this again once the issue has been reported to pydotorg.) -- nosy: +benjamin.peterson, ncoghlan status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22963 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22963] broken link in PEP 102
Berker Peksag added the comment: I've opened https://github.com/python/pythondotorg/issues/561 to track the same issue. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22963 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23389] pkgutil.find_loader raises an ImportError on PEP 420 implicit namespace packages
Eric Snow added the comment: Hmm. If I recall correctly, we set __spec__ for namespace packages... What's a quick way to consistently reproduce the ImportError? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23389 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23389] pkgutil.find_loader raises an ImportError on PEP 420 implicit namespace packages
Changes by Eric Snow ericsnowcurren...@gmail.com: -- nosy: +eric.snow ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23389 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: dunder-docs (was Python is DOOMED! Again!)
Steven D'Aprano wrote: Er, perhaps code injection is not the best name for this, on account of it also being the name for a security vulnerability anti-pattern: I'm talking about a variety of dependency injection where you either add an entirely new method to an instance, or give the instance it's own custom method overriding the one declared in the class. I think the term you're after is monkeypatching. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
Steven D'Aprano wrote: I'm arguing with those who insist that objects of type MethodType aren't methods, and objects of type FunctionType aren't functions but methods, except when they are, based on that simplified, incomplete glossary entry. I'm not arguing that based on the glossary entry. I'm arguing it based on my experience of how the term 'method' is used in the Python community. I can inject methods into a class or even an instance. If you think that methods *must* be defined in the class body, you're missing out on a very powerful technique. I'm willing to accept 'method' as a legitimate term for a function injected into a class body, *if it's used as a method* once it gets there. This is what you don't seem to understand. It's not about the type of the object. You can't write a piece of code to test whether a given object is a method or not, because it's not an intrinsic property of the object. It's a matter of how it's *used*. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
[issue23392] Add tests for marshal FILE* API
New submission from Serhiy Storchaka: Marshal C API functions that works with FILE* (PyMarshal_WriteLongToFile, PyMarshal_WriteObjectToFile, PyMarshal_ReadLongFromFile, PyMarshal_ReadShortFromFile, PyMarshal_ReadObjectFromFile, PyMarshal_ReadLastObjectFromFile) are not used now in CPython and are not tested. Proposed patch adds tests for them. -- assignee: serhiy.storchaka components: Tests files: test_marshal_file_api.patch keywords: patch messages: 235381 nosy: kristjan.jonsson, serhiy.storchaka priority: normal severity: normal stage: patch review status: open title: Add tests for marshal FILE* API type: enhancement versions: Python 2.7, Python 3.4, Python 3.5 Added file: http://bugs.python.org/file38010/test_marshal_file_api.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23392 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23344] Faster marshalling
Changes by Serhiy Storchaka storch...@gmail.com: -- assignee: - serhiy.storchaka dependencies: +Add tests for marshal FILE* API ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23344 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: How to write a non blocking SimpleHTTPRequestHandler ?
On 03/02/2015 11:04, Yassine Chaouche wrote: Thanks Marko. It's a lost cause then. You trimmed out the part where he mentioned asyncio. :) ChrisA IIRC asyncio is python 3 only and I'm not ready yet to make the leap. The leap from Python 2 to Python 3 is about as high as the second obstacle is this soon to be Olympic sport https://www.youtube.com/watch?v=TSqkdcT25ss -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: Is there a cairo like surface for the screen without the window hassle
On Mon, 02 Feb 2015 14:20:56 +0100, Antoon Pardon wrote: I need to have a program construct a number of designs. Of course I can directly use a pfd surface and later use a pdf viewer to check. But that becomes rather cumbersome fast. But if I use a cairo-surface for on the screen I suddenly have to cope with expose events and all such things I am not really interested in. If you're writing a GUI application, something has to deal with those events regardless of which rendering API you use. So does someone know of a package that provides a cairo like surface but that would take care of the events in a rather straight forward matter, so that my program could make it's design in a window on the screen just as if it is designing it in a pdf file. What exactly is the issue here? That you want to be able to construct a graphical representation then discard the data used to construct it, rather than having to keep it around in order to handle subsequent expose events? If that's the case, the simplest solution is probably to render to an image surface then handle expose events by drawing the image onto the screen (or handing the image to some kind of widget which does this for you). Or, if you want to support dynamic scaling, you can render to an SVG surface instead, but widgets which can display SVG aren't as common as those which deal with raster formats. Another solution is to render to a recording surface. This can then be used as a source surface, so handling expose events boils down to a single cairo_paint() operation with the recording surface as the source surface and the window as the destination surface. Maybe there's even a widget somewhere which does this, but I don't know of one. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to write a non blocking SimpleHTTPRequestHandler ?
The standard library and nonblocking can't be used in the same sentence. python 2.x stdlib has no high level support of *async* code. There is trollius library that ports asyncio to py2 though. I was a bit quick in my first anwser. What you want is to prevent the socket to wait indefinetly for data (based on strace output) which is done with socket.setblocking/settimeout [1]. asynchronous (asyncio) is something else, and you would still need to handle blocking I think. There is contentbrowser [2] which is somekind of web proxy. IMO, python 2 - python 3 is not a big leap. Some things are better in python 3. [1] https://docs.python.org/2/library/socket.html#socket.socket.setblocking [2] https://bitbucket.org/david/contentbrowser/src On Tue Feb 03 2015 at 2:00:27 PM Yassine Chaouche yacinechaou...@yahoo.com.dmarc.invalid wrote: On Tuesday, February 3, 2015 at 12:35:32 PM UTC+1, Marko Rauhamaa wrote: So far I've been happy with select.epoll(), socket.socket() and ten fingers. Marko There's already software written to take care of much of the HTTP stuff protocol stuff, the headers etc. I wouldn't rewrite it. I prefer to monkey patch parts of existing code rather then rewrite all of it. But your comment is interesting because, as I understand it, a non-blocking web server is simply a matter of setting timeouts on sockets, catch the exceptions and move on. I don't know why wouldn't that be possible with python stdlib ? The standard library and nonblocking can't be used in the same sentence. ? -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
[issue23388] datetime.strftime('%s') does not take timezone into account
Changes by Han Choongwoo cwhan.t...@gmail.com: -- nosy: +tunz ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23388 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: __pycache__
On Wed, Feb 4, 2015 at 1:34 AM, Emile van Sebille em...@fenx.com wrote: On 2/3/2015 6:21 AM, Dennis Lee Bieber wrote: The second is to use Google... https://www.google.com/?gws_rd=ssl#q=python+idle+can%27t+make+connection but the first page of results isn't helping -- lots of reports of the problem, but no firm remedy listed. it was suggested to me recently that i include 'solved' in google searches. doesn't always work, but helps when i don't find a result quickly. I'd not do that initially, as it'll cause a lot of false negatives; but if you're finding a bunch of problems and no solutions, then yes, that could help. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[issue23388] datetime.strftime('%s') does not take timezone into account
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +belopolsky ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23388 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: How to write a non blocking SimpleHTTPRequestHandler ?
I think You can try the asyncore lib: https://docs.python.org/2/library/asyncore.html 2015-02-03 15:50 GMT+01:00 Yassine Chaouche yacinechaou...@yahoo.com.dmarc.invalid: On Tuesday, February 3, 2015 at 3:17:37 PM UTC+1, Amirouche Boubekki wrote: What you want is to prevent the socket to wait indefinetly for data (based on strace output) which is done with socket.setblocking/settimeout [1] Exactly ! thanks for taking time to reading my original post a second time. Maybe I didn't express my problem well enough and the discussion has maybe drifted to an XYProblem type discussion :) I was about to say that most webframeworks for python already take care of the problem I'm facing, so I certainly confused people with improper formulation. There is contentbrowser [2] which is somekind of web proxy. It's using werkzeug and it seems to be a full web application. I just want something that is right above sockets and selects. All that my script is doing is grabbing some json data from an external url provided by the browser and return a formatted page showing the json data in human-readable HTML pages. Nothing fancy. -- https://mail.python.org/mailman/listinfo/python-list -- Filadelfo Fiamma mail: philosga...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: How to write a non blocking SimpleHTTPRequestHandler ?
Chris Angelico ros...@gmail.com: Threading is not such a bugbear as a lot of people seem to think. Yes, some platforms have traditionally had poor implementations Java has excellent multithreading facilities. Still, I have seen seasoned Java developers commit atrocious crimes against thread-safety that are impossible to troubleshoot and repair afterwards. There are ways to manage the complications of multithreading, but no universal practices are agreed upon so you can't count on other/legacy software to obey your policies or your software obey theirs. And even under the best guidelines there are seemingly intractable cornercases where you feel helplessly lost. Marko -- https://mail.python.org/mailman/listinfo/python-list
[issue18932] Optimize selectors.EpollSelector.modify()
STINNER Victor added the comment: selectors.EpollSelector.modify() should use epoll.modify() instead of unregister()+register(). -- title: selectors and modify() - Optimize selectors.EpollSelector.modify() ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18932 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18932] Optimize selectors.EpollSelector.modify()
Changes by STINNER Victor victor.stin...@gmail.com: -- components: +asyncio nosy: +yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18932 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19017] selectors: towards uniform EBADF handling
Changes by STINNER Victor victor.stin...@gmail.com: -- components: +asyncio nosy: +yselivanov ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19017 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14203] bytearray_getbuffer: unnecessary code
Stefan Krah added the comment: New patch with tests. -- Added file: http://bugs.python.org/file38003/issue14203-2.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14203 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23344] Faster marshalling
Kristján Valur Jónsson added the comment: looks good to me, although it has been pointed out that marshal _write_ speed is less critical than read speed :) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23344 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: __pycache__
On 2/3/2015 6:21 AM, Dennis Lee Bieber wrote: The second is to use Google... https://www.google.com/?gws_rd=ssl#q=python+idle+can%27t+make+connection but the first page of results isn't helping -- lots of reports of the problem, but no firm remedy listed. it was suggested to me recently that i include 'solved' in google searches. doesn't always work, but helps when i don't find a result quickly. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to write a non blocking SimpleHTTPRequestHandler ?
On Tuesday, February 3, 2015 at 3:17:37 PM UTC+1, Amirouche Boubekki wrote: What you want is to prevent the socket to wait indefinetly for data (based on strace output) which is done with socket.setblocking/settimeout [1] Exactly ! thanks for taking time to reading my original post a second time. Maybe I didn't express my problem well enough and the discussion has maybe drifted to an XYProblem type discussion :) I was about to say that most webframeworks for python already take care of the problem I'm facing, so I certainly confused people with improper formulation. There is contentbrowser [2] which is somekind of web proxy. It's using werkzeug and it seems to be a full web application. I just want something that is right above sockets and selects. All that my script is doing is grabbing some json data from an external url provided by the browser and return a formatted page showing the json data in human-readable HTML pages. Nothing fancy. -- https://mail.python.org/mailman/listinfo/python-list
[issue23382] Maybe can not shutdown ThreadPoolExecutor when call the method of shutdown
New submission from miles: Maybe can not shutdown ThreadPoolExecutor when call the method shutdown. Though the variable of _shutdown is set to true in the method of shutdown, it may also reads the variable of _shutdown from cpu cache in the method of _worker, and the worst case is that it could see an out-of-date value of _shutdown forever. so need to acquire lock before reading the variable of _shutdown to make sure see an up-to-date value. the following is the new code: def _worker(executor_reference, work_queue): try: while True: work_item = work_queue.get(block=True) if work_item is not None: work_item.run() continue executor = executor_reference() shutdown = False with executor._shutdown_lock.acquire(): shutdown = executor._shutdown # Exit if: # - The interpreter is shutting down OR # - The executor that owns the worker has been collected OR # - The executor that owns the worker has been shutdown. if _shutdown or executor is None or shutdown: # Notice other workers work_queue.put(None) return del executor except BaseException: _base.LOGGER.critical('Exception in worker', exc_info=True) def shutdown(self, wait=True): with self._shutdown_lock: self._shutdown = True self._work_queue.put(None) if wait: for t in self._threads: t.join() -- components: 2to3 (2.x to 3.x conversion tool) messages: 235319 nosy: miles priority: normal severity: normal status: open title: Maybe can not shutdown ThreadPoolExecutor when call the method of shutdown versions: Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23382 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
ANN: Lea 2.0.0 released
I am pleased to announce the release of Lea 2.0.0 ! What is Lea? Lea is a Python package aiming at working with discrete probability distributions in an intuitive way. It allows you to model a broad range of random phenomenons, like dice throwing, coin tossing, gambling, weather , etc. Lea is open-source (LGPL) and runs on Python 2 or 3. What's new in Lea 2? Here are the main new features, as of Lea 1.x : - new methods: pmf, cdf, fromSeq, binom, bernoulli, interval, ... - CPT (Conditional Probability Tables) - Bayesian networks - Markov chains - *Leapp*, a small probabilistic programming language - in-depth extension of wiki tutorials Lea project page + documentation http://code.google.com/p/lea/ Download Lea (PyPI) --- http://pypi.python.org/pypi/lea http://pypi.python.org/pypi/lea/2.0.0-beta.2 With the hope that Lea can make your happiness less uncertain, Pierre Denis -- https://mail.python.org/mailman/listinfo/python-announce-list Support the Python Software Foundation: http://www.python.org/psf/donations/
[issue23384] urllib.proxy_bypass_registry slow down under Windows if website has no reverse DNS and Fiddler is runing
New submission from Valeriy Osipov: Environment: OS Windows 8, Fiddler is running To reproduce the issue launch this code snippet: import requests import datetime import urllib print datetime.datetime.now() #print requests.get('http://torgi.gov.ru/lotSearchArchive.html?bidKindId=2') #print urllib.proxy_bypass_registry('torgi.gov.ru') print datetime.datetime.now() This onу GET requests to this wesite takes 6-7 seconds. Now comment the following code from the urllib.py from the proxy_bypass_registry function: try: fqdn = socket.getfqdn(rawHost) if fqdn != rawHost: host.append(fqdn) except socket.error: pass Now the same GET request takes 2 second. It is normal because this website takes 2 seconds for response. -- components: Windows messages: 235322 nosy: aristotel, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: urllib.proxy_bypass_registry slow down under Windows if website has no reverse DNS and Fiddler is runing versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23384 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22818] Deprecate splitting on possible zero-width re patterns
Roundup Robot added the comment: New changeset 7c667d8ae10d by Serhiy Storchaka in branch 'default': Issue #22818: Splitting on a pattern that could match an empty string now https://hg.python.org/cpython/rev/7c667d8ae10d -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue22818 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
__pycache__
I am in school and there is a problem with my code: When I try to run my code in the python code in the python shell it waits about 10 seconds then shows an error that says “IDLE’s subprocess didn’t make connection. Either IDLE can’t start a subprocess or personal firewall software is blocking the connection.” Then when I press OK it just closes. P.S: My code is encrypting and decrypting using an offset factor. -- https://mail.python.org/mailman/listinfo/python-list
[issue23383] Clean up bytes formatting
New submission from Serhiy Storchaka: Proposed patch makes following changes to bytes formatting code: 1) Fixes a bug when PyUnicode_AsEncodedObject() returns non-bytes byte-like object. 2) Avoid few non-neccessary memory allocations and copyings (converting bytearray or ASCII string to bytes). 3) Clean up the code. -- components: Interpreter Core files: bytes_format.patch keywords: patch messages: 235320 nosy: Arfrever, eric.smith, ethan.furman, haypo, nascheme, ncoghlan, python-dev, serhiy.storchaka, vadmium priority: normal severity: normal stage: patch review status: open title: Clean up bytes formatting type: enhancement versions: Python 3.5 Added file: http://bugs.python.org/file37996/bytes_format.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23383 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Ghost vulnerability
Anssi Saari wrote: Rustom Mody rustompm...@gmail.com writes: How many people (actually machines) out here are vulnerable? http://security.stackexchange.com/questions/80210/ghost-bug-is-there-a-simple-way-to-test-if-my-system-is-secure shows a python 1-liner to check Does that check actually work for anyone? That code didn't segfalt on my vulnerable Debian system but it did on my router which isn't (since the router doesn't use glibc). Oh and of course I can't comment on stinkexchange since I don't have whatever mana points they require... Here's the one-liner: python -c 'import socket;y=0*5000;socket.gethostbyname(y)' I think it is likely that y=0*5000 would segfault due to lack of memory on many machines. I wouldn't trust this as a test. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
[issue23388] datetime.strftime('%s') does not take timezone into account
New submission from cameris: The following occured on linux with python 3.4.2, the machines local timezone is tz2: import datetime tz1 = datetime.timezone.utc; tz2 = datetime.timezone(datetime.timedelta(seconds=3600)); tz3 = datetime.timezone(datetime.timedelta(seconds=18000)) d1 = datetime.datetime.now(tz=tz1); d2 = datetime.datetime.now(tz=tz2); d3 = datetime.datetime.now(tz=tz3) d1.timestamp(), d2.timestamp(), d3.timestamp() (1422962091.603168, 1422962091.603181, 1422962091.603185) d1.strftime('%s'), d2.strftime('%s'), d3.strftime('%s') ('1422958491', '1422962091', '1422976491') Or in other words: d1.strftime('%s') == str(int(d1.timestamp())), d2.strftime('%s') == str(int(d2.timestamp())), d3.strftime('%s') == str(int(d3.timestamp())) (False, True, False) Expected result of the last line would be (True, True, True). -- components: Library (Lib) messages: 235338 nosy: cameris priority: normal severity: normal status: open title: datetime.strftime('%s') does not take timezone into account type: behavior versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23388 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: How to write a non blocking SimpleHTTPRequestHandler ?
Thanks Chris, it's only a matter of time, I'll eventually make the transition to python3 when I'll learn it well enough. -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
Chris Angelico ros...@gmail.com: On Tue, Feb 3, 2015 at 9:38 PM, Marko Rauhamaa ma...@pacujo.net wrote: It's slightly sad that Python exposes the two-level attribute lookup. It would be more elegant if, conceptually, all methods were retrieved from the object's attribute dict. That way, the class would be simply a mundane optimization trick instead of a metaphysical entity. That's the ECMAScript model of classes - prototype-based. It's not Python's. There are many different ways to do things. For (almost) all practical purposes, that is the Python way as well. If object instantiation (conceptually) copied the class's methods into the object's dict, you'd get the semantics I'm looking for. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
Steven D'Aprano wrote: Both K.f and K.g are methods, even though only one meets the definition given in the glossary. The glossary is wrong. Or rather, it is not so much that it is *wrong*, but that it is incomplete and over-simplified. I agree with that; a more complete definition would be a function that is found in a class as a result of an attribute lookup on an instance of that class. I defined a method: py from types import MethodType py type(instance.f) is MethodType True Being of type MethodType is not the defining characterisic of a method. MethodType is actually misnamed; an instance of MethodType is *not* a method, in the same way that an eggcup is not an egg. A better name would be MethodWrapper, but that still doesn't mean that anything you wrap with it is a method. An eggcup *usually* contains an egg, but it could contain something else. instance.f is a method by the glossary definition. Not by the glossary definition as written, since the function you wrapped in a MethodType was not defined inside a class body. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: How to write a non blocking SimpleHTTPRequestHandler ?
Chris Angelico ros...@gmail.com: On Tue, Feb 3, 2015 at 10:04 PM, Yassine Chaouche IIRC asyncio is python 3 only and I'm not ready yet to make the leap. Then you're stuck with whatever you have, because the Py2 standard library isn't being expanded any. Why not make the leap? Py3 has a lot of advantages over Py2. I'm all for Py3, but I'm not ready to conclude asyncio is the way to go. The coroutines haven't won me over. The programming model is quite messy and simply weird. So far I've been happy with select.epoll(), socket.socket() and ten fingers. Marko -- https://mail.python.org/mailman/listinfo/python-list
[issue15381] Optimize BytesIO to do less reallocations when written, similarly to StringIO
Serhiy Storchaka added the comment: Some buildbots crash: http://buildbot.python.org/all/builders/x86%20Ubuntu%20Shared%203.x/builds/11152/steps/test/logs/stdio http://buildbot.python.org/all/builders/AMD64%20Debian%20PGO%203.x/builds/4/steps/test/logs/stdio http://buildbot.python.org/all/builders/AMD64%20Debian%20root%203.x/builds/1715/steps/test/logs/stdio http://buildbot.python.org/all/builders/AMD64%20Solaris%2011%20%5BSB%5D%203.x/builds/3836/steps/test/logs/stdio E.g.: Fatal Python error: Objects/frameobject.c:429 object at 0x406dd878 has negative ref count -5 Current thread 0x40525ce0 (most recent call first): File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/case.py, line 605 in run File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/case.py, line 625 in __call__ File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, line 122 in run File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, line 84 in __call__ File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, line 122 in run File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, line 84 in __call__ File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, line 122 in run File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/suite.py, line 84 in __call__ File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/unittest/runner.py, line 168 in run File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/support/__init__.py, line 1770 in _run_suite File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/support/__init__.py, line 1804 in run_unittest File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, line 1283 in test_runner File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, line 1284 in runtest_inner File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, line 967 in runtest File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, line 763 in main File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/regrtest.py, line 1568 in main_in_temp_cwd File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/test/__main__.py, line 3 in module File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/runpy.py, line 85 in _run_code File /srv/buildbot/buildarea/3.x.bolen-ubuntu/build/Lib/runpy.py, line 170 in _run_module_as_main Aborted make: *** [buildbottest] Error 134 Trying to reproduce locally and investigate. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15381 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6634] sys.exit() called from threads other than the main one: undocumented behaviour
Jan-Philip Gehrcke added the comment: Thanks for your feedback Antoine. I'm not sure what the doc patch achieves. Let me try to bring things in order. It should achieve two things: 1. Properly describe the stderr-writing behavior of sys.exit(). === Current 2.7 docs: ..., and any other object is printed to stderr. This is wrong in its generality and requires clarification. Agreed? How would you improve the docs in this regard? This is the reasoning I had in mind: We could change the original sentence, but IMO it then contains too many pieces of important information and becomes difficult to digest, e.g.: If another type of object is passed, None is equivalent to passing zero, and any other object is printed to stderr (only when called in the main thread) and results in an exit code of 1.. Difficult, right? I thought about removing the stderr part from this sentence and discussing this topic separately, in simpler sentences. But: I think the stderr part needs to stay in the original sentence, because it clarifies how different argument types are dealt with. Then I took another point of view: we have acknowledged that the behavior is problematic, we just cannot change it anymore for 2.7. The direct consequence from this point of view is to warn about current behavior. 6 years ago, I took the docs literally and relied on getting proper error messages printed to stderr. And I didn't get those. I would have appreciated a warning, I guess. With this being said, I'd love to look at an alternative proposal of how we could change the docs in this regard. 2. Clarify that when called from a thread, the thread exits silently Current 2.7 docs: Since exit ultimately only raises an exception, it will only exit the process when called from the main thread. This sentence is problematic. It relates a cause to an effect, and this relation is wrong or at least incomplete. The only valuable information left in the sentence is the *effect*, without providing an explanation. I would rather want to take the inverse approach, and explain the *cause* as correct as possible. In other words: the above sentence misses to explain what actually happens when sys.exit() is called in a non-primary thread. The actual behavior and cause for mentioned effect is, as far as I am aware: If raised in a non-primary thread, SystemExit is caught automatically and causes the calling thread to exit silently. This is what I added as a note. And I think that we agree that this cause may have many effects, whereas only one of them is that sys.exit() called from a non-primary thread can not terminate the process. It only states more verbosely what is already said in the current version. I hope to have convinced you that this is not true. Also, warnings are really for important issues (such as security issues); using them too liberally is a disservice to the reader. I agree. I really think that both points need to be addressed in the docs, and I have now clarified my reasoning, but am very open to further suggestions. And I really do not want to make a strong point about whether things should end up in red or blue boxes :-). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6634 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: __pycache__
On 2/2/2015 6:26 PM, Luke Lloyd wrote: I am in school and there is a problem with my code: When I try to run my code in the python code in the python shell it waits about 10 seconds then shows an error that says “IDLE’s subprocess didn’t make connection. Either IDLE can’t start a subprocess or personal firewall software is blocking the connection.” Then when I press OK it just closes. Idle is intended for developing code, not running code that you have already developed. (Though there are cases, at least on Windows, where it is better for running programs than python in a console.) In any case, a solution, given is the Idle doc section, is to start Idle with the -n option. python -m idlelib -n add '-r x.y' to run an existing python file (this is missing from the doc section and needs to be added). -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
On Tue, Feb 3, 2015 at 10:40 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: AT LONG LAST THE LIGHT DAWNS! THE PENNY DROPS! Careful there, you're starting to sound like Ranting Rick. ;-) -- https://mail.python.org/mailman/listinfo/python-list
Re: Ghost vulnerability
On Wed, Feb 4, 2015 at 6:38 AM, Anssi Saari a...@sci.fi wrote: Anyways, here's an example calling gethostbyname directly in python: from ctypes import CDLL o = CDLL('libc.so.6') for i in range(0, 2500): o.gethostbyname('0'*i) I don't have a vulnerable system to test on any more though. That bombs on my internal disk server, which is said to be vulnerable using the C implementation. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Cairo module
On Feb 3, 2015, at 1:00 PM, Poul Riis prii...@gmail.com wrote: I just tried the Cairo Python module. I ran the test file below. It works perfectly but instead of saving the resulting image as a file I want to see it displayed directly on the screen. How can I do that? I have quiet a bit of experience with Cairo (I wrote language bindings for it in Smalltalk and had the time of my life with it there); I have no experience with the pycairo bindings. import math import cairo WIDTH, HEIGHT = 256, 256 surface = cairo.ImageSurface (cairo.FORMAT_ARGB32, WIDTH, HEIGHT) This is your basic problem right here. And ImageSurface is for creating an Image (sometimes called a raster graphic or bitmap). If you want to display directly to your screen, you need to create a surface that binds to your screen’s display functionality. There is one for each main operating system: Win32Surface XLibSurface QuartzSurface (I see that this is missing from the pycairo documentation, but it is in the cairo documentation, and the pycairo.c file at least has some reference to it) Allocating one of these involves getting handles (and other information) for a given window on screen of your host OS and creating the surface from it. ctx = cairo.Context (surface) ctx.scale (WIDTH, HEIGHT) # Normalizing the canvas pat = cairo.LinearGradient (0.0, 0.0, 0.0, 1.0) pat.add_color_stop_rgba (1, 0.7, 0, 0, 0.5) # First stop, 50% opacity pat.add_color_stop_rgba (0, 0.9, 0.7, 0.2, 1) # Last stop, 100% opacity ctx.rectangle (0, 0, 1, 1) # Rectangle(x0, y0, x1, y1) ctx.set_source (pat) ctx.fill () ctx.translate (0.1, 0.1) # Changing the current transformation matrix ctx.move_to (0, 0) ctx.arc (0.2, 0.1, 0.1, -math.pi/2, 0) # Arc(cx, cy, radius, start_angle, stop_angle) ctx.line_to (0.5, 0.1) # Line to (x,y) ctx.curve_to (0.5, 0.2, 0.5, 0.4, 0.2, 0.8) # Curve(x1, y1, x2, y2, x3, y3) ctx.close_path () ctx.set_source_rgb (0.3, 0.2, 0.5) # Solid color ctx.set_line_width (0.02) ctx.stroke () surface.write_to_png (example.png) # Output to PNG -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
On Wed, Feb 4, 2015 at 4:40 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: given that the glossary need not be 100% complete and definitive, function defined inside a class body is close enough to the truth. * This * We are arguing, not about an element in a formal grammar, but about a glossary entry. If one of my Python students asks me, What's a method?, I'm not going to go into a technical explanation like this; I want to answer with a single sentence that covers the bit that matters. (Though I'd probably define it from the other perspective - it's an object attribute that you can call, perhaps - but if the question came from a class definition, a function defined inside a class would be fine.) ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Idiomatic backtracking in Python
On Wed, Feb 4, 2015 at 8:16 AM, Dave Angel da...@davea.name wrote: Obviously you have to define the branch somehow, but there are plenty of times when you might want to break out of everything up to here. How do you define that? How do you return lots of levels all at once? I remember facing this exact problem in trying to solve a particular piece-layout puzzle; if I discovered an impossible situation, I could actually discard at least two or three levels of recursion all at once, because there's no way that the situation could become un-impossible within those levels. Can't remember how I ended up dealing with that... I think I got naughty and used a global variable. When I've done things like that, there was no need to do a return multiple. You just return, and your caller happens to be a the end of his loop, so he returns also. Classic example of this is the 8 queens puzzle. Each level is going to examine one row, and once there are no places that aren't yet attacked, it simply returns. That's true of most problems. I may have to go dig up the code I had, but I believe the basic structure was something along the lines of place piece in available space, recurse to place piece in each remaining available space. Sometimes, attempting to fill one space would prove that the piece that _created_ that space couldn't possibly go there, so it would do a jump back up a few levels of recursion. Definitely an unusual situation, but not impossible. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: __pycache__
On Tue, Feb 3, 2015 at 10:31 AM, Mark Lawrence breamore...@yahoo.co.uk wrote: I know that you can target sites, but can you exclude them, e.g. -site:stackoverflow.com ? Yes, you can. Compare the results of these two searches, for example: git initial push git initial push -site:stackoverflow.com Skip -- https://mail.python.org/mailman/listinfo/python-list
[issue15381] Optimize BytesIO to do less reallocations when written, similarly to StringIO
Roundup Robot added the comment: New changeset ea33b61cac74 by Serhiy Storchaka in branch 'default': Issue #15381: Fixed a bug in BytesIO.write(). https://hg.python.org/cpython/rev/ea33b61cac74 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15381 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14203] PEP-3118: remove obsolete write-locks
Serhiy Storchaka added the comment: E.g. the buffer should be unshared before incrementing b-exports, but if an exception is raised instead, there is no need to unshare the buffer before raising. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14203 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23388] datetime.strftime('%s') does not take timezone into account
Alexander Belopolsky added the comment: This looks like a duplicate of #12750. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23388 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Is there a cairo like surface for the screen without the window hassle
Op 03-02-15 om 13:17 schreef Nobody: On Mon, 02 Feb 2015 14:20:56 +0100, Antoon Pardon wrote: I need to have a program construct a number of designs. Of course I can directly use a pfd surface and later use a pdf viewer to check. But that becomes rather cumbersome fast. But if I use a cairo-surface for on the screen I suddenly have to cope with expose events and all such things I am not really interested in. If you're writing a GUI application, something has to deal with those events regardless of which rendering API you use. Sure but from my point of view I am not writing a GUI. I just have a function that takes a cairo context and draws an image on it. That works all very fine if it is a postscript of pdf or an image but gives trouble when the context is associated with a window on the screen. So does someone know of a package that provides a cairo like surface but that would take care of the events in a rather straight forward matter, so that my program could make it's design in a window on the screen just as if it is designing it in a pdf file. What exactly is the issue here? That you want to be able to construct a graphical representation then discard the data used to construct it, rather than having to keep it around in order to handle subsequent expose events? I want those expose events handled for me, so I don't have to care for them, so that I can just use a context that will render the drawing in a window on the screen without me having to wonder about any event. If that's the case, the simplest solution is probably to render to an image surface then handle expose events by drawing the image onto the screen (or handing the image to some kind of widget which does this for you). Another solution is to render to a recording surface. This can then be used as a source surface, so handling expose events boils down to a single cairo_paint() operation with the recording surface as the source surface and the window as the destination surface. Maybe there's even a widget somewhere which does this, but I don't know of one. Yes I had written something like this for pygtk. The module provided an initiator which you called with a function. This would then start the gtk.main loop and start the function in a thread. The module provided also a class similar to a cairo context, which would create a windon and draw into it, it was implemented more or less as you describe above. The main advantage was that the function that made the design didn't need to care about being used in a GUI. Problem is I don't succeed in getting it to work with the new introspective gtk framework. But since this seems something usefull I thought I ask about maybe someone else already having written something similar before I sink more of my own time into it. -- https://mail.python.org/mailman/listinfo/python-list
[issue14203] bytearray_getbuffer: unnecessary code
Roundup Robot added the comment: New changeset e8fe32d43c96 by Stefan Krah in branch 'default': Issue #14203: Remove obsolete support for view==NULL in PyBuffer_FillInfo() https://hg.python.org/cpython/rev/e8fe32d43c96 -- nosy: +python-dev ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14203 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14203] PEP-3118: remove obsolete write-locks
Stefan Krah added the comment: bytesiobuf_getbuffer() also still has this obsolete feature, so BufferError should be raised if view==NULL. I'm unsure if this plays well with the new SHARED_BUF(b) thing. Should the exception be raised before or after? -- nosy: +serhiy.storchaka title: bytearray_getbuffer: unnecessary code - PEP-3118: remove obsolete write-locks ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14203 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14203] PEP-3118: remove obsolete write-locks
Serhiy Storchaka added the comment: I think before. It doesn't harm, but it doesn't make much sense to unshare the buffer if its address is not used. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14203 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23359] Speed-up set_lookkey()
Roundup Robot added the comment: New changeset 17cda5a92b6a by Raymond Hettinger in branch 'default': Issue 23359: Reduce size of code in set_lookkey. Only do linear probes when there is no wrap-around. https://hg.python.org/cpython/rev/17cda5a92b6a -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23359 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23359] Speed-up set_lookkey()
Raymond Hettinger added the comment: Thanks Serhiy, that was brilliant. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23359 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: __pycache__
On 03/02/2015 14:34, Emile van Sebille wrote: On 2/3/2015 6:21 AM, Dennis Lee Bieber wrote: The second is to use Google... https://www.google.com/?gws_rd=ssl#q=python+idle+can%27t+make+connection but the first page of results isn't helping -- lots of reports of the problem, but no firm remedy listed. it was suggested to me recently that i include 'solved' in google searches. doesn't always work, but helps when i don't find a result quickly. I know that you can target sites, but can you exclude them, e.g. -site:stackoverflow.com ? -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: How to write a non blocking SimpleHTTPRequestHandler ?
On 03/02/2015 15:03, Filadelfo Fiamma wrote: I think You can try the asyncore lib: https://docs.python.org/2/library/asyncore.html People can try it but it's effectively deprecated, with its partner asynchat, in favour of asyncio. Also please don't top post here, thank you. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: __pycache__
On 2/3/2015 8:31 AM, Mark Lawrence wrote: On 03/02/2015 14:34, Emile van Sebille wrote: On 2/3/2015 6:21 AM, Dennis Lee Bieber wrote: The second is to use Google... https://www.google.com/?gws_rd=ssl#q=python+idle+can%27t+make+connection but the first page of results isn't helping -- lots of reports of the problem, but no firm remedy listed. it was suggested to me recently that i include 'solved' in google searches. doesn't always work, but helps when i don't find a result quickly. I know that you can target sites, but can you exclude them, e.g. -site:stackoverflow.com ? yep -- https://support.google.com/websearch/answer/2466433?hl=en - Remove words When you use a dash before a word or site, it excludes results that include that word or site. This is useful for words with multiple meanings, like Jaguar the car brand and jaguar the animal. Examples: jaguar speed -car and pandas -site:wikipedia.org -- https://mail.python.org/mailman/listinfo/python-list
Re: Downloading videos (in flash applications) using python
On Mon, 02 Feb 2015 15:21:07 -0800, Gabriel Ferreira wrote: Mark Lawrence wrote: I don't actually know, but could you please provide some context and write in plain English, those damn ... things are extremely annoying. Hi, Mark. I am developing a research project, which includes video analysis (computer vision, big data, data mining, etc). The first part of the project is about building a database containing a big amount of video of urban zones. I live in Brazil, so the plan is collecting videos from urban areas of Brazilian big cities, like Sao Paulo. I have to make this task automatic. in other words, I don't want to manually download hundreds or thousands hours of videos. So I have to develop a robot to do that assingment for me. (I wish I could do that using Python). I have found a good website that provides me live images from several cities in Brazil. So that's it! That's what I need. I was expecting to develop a program to record download those videos, that are being broadcasted live on that website. So I would be able to form my database and continue my research. The problem is that this particular website uses a flash player application do broadcast the live images of the urban areas. I'm not too familiar with Flash Applications. I don't know how to deal with them using Python. I was wondering if someone could help me solve this problem. The goal is recording downloading those videos, from the mentioned website. And, yes, it has to be an automated program (no manual work). I wish I had been clear with you guys! THX! So why not speak to the owners of the web site see if thay can provide you with easier access to their video streams if this is a genuine research project I am sure they would like to help -- If God had a beard, he'd be a UNIX programmer. -- https://mail.python.org/mailman/listinfo/python-list
[issue23386] snmp - mib error
Eric V. Smith added the comment: pysnmp is not part of the Python standard library. It looks like you should report issues or search for help at at pysnmp.sourceforge.net. -- components: -Build nosy: +eric.smith resolution: - third party stage: - resolved status: open - closed type: compile error - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23386 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23386] snmp - mib error
nivin added the comment: I have fixed the issue that i reported by creating my mib file into py by the command 'build-pysnmp-mib -o MY-MIB.py MY-MIB' and copy it into the path '/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs' But my doubts are : Is there any other option to send snmp trap using python with OID and host id only and without mib file in trap sender. -- status: closed - open ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23386 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: How to write a non blocking SimpleHTTPRequestHandler ?
On Tue, Feb 3, 2015 at 11:56 PM, Yassine Chaouche yacinechaou...@yahoo.com.dmarc.invalid wrote: But your comment is interesting because, as I understand it, a non-blocking web server is simply a matter of setting timeouts on sockets, catch the exceptions and move on. I don't know why wouldn't that be possible with python stdlib ? Not really. You could, in theory, set very low timeouts and then poll everything, but it's not efficient. What you want to do is say to the system Hey, see all these sockets? Let me know when *any one of them* has stuff for me, where stuff would be a new connected client if it's a listening socket, or some data written if it's a connected socket; and you might need to check if there's room to write more data, too, which you can do with the same syscall. The key here is that you have a long timeout on the meta-event any one of these being ready. That's not simply a matter of setting socket timeouts; you need a way to handle the meta-event, and that's something along the lines of select(): http://linux.die.net/man/2/select Other languages have inbuilt asynchronous I/O handlers; eg Pike handles this fairly well, and I've made some use of it with a generic networking system: https://github.com/Rosuav/Hogan Basically, you spin up a server with any number of listening sockets, each of which can talk to any number of connected clients, and all of those sockets get smoothly multiplexed on a single thread. Lots of other languages have similar facilities. Python 2.x doesn't have anything of that nature; Python 3's asyncio is exactly that. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[issue23386] snmp - mib error
Eric V. Smith added the comment: Your question is not appropriate here, and you're unlikely to get an answer. This tracker is for bugs in python and its standard library. It is not for asking for help with third party packages. See my other comment for a pointer to an appropriate venue for pysnmp questions. -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23386 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue15381] Optimize BytesIO to do less reallocations when written, similarly to StringIO
Roundup Robot added the comment: New changeset 3fdbdf4d2ac7 by Serhiy Storchaka in branch 'default': Issue #15381: Try to fix refcount bug. Empty and 1-byte buffers are always shared. https://hg.python.org/cpython/rev/3fdbdf4d2ac7 -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15381 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: How to write a non blocking SimpleHTTPRequestHandler ?
Yassine Chaouche yacinechaou...@yahoo.com: On Tuesday, February 3, 2015 at 12:35:32 PM UTC+1, Marko Rauhamaa wrote: So far I've been happy with select.epoll(), socket.socket() and ten fingers. [...] But your comment is interesting because, as I understand it, a non-blocking web server is simply a matter of setting timeouts on sockets, catch the exceptions and move on. Now I think you might have some misconceptions about nonblocking networking I/O. Nonblocking I/O is done using asynchronous, or event-driven, programming. Your code reacts to external stimuli, never blocking, mostly just sleeping. The reactions are defined in callback routings, aka listeners, aka event handlers. I don't know why wouldn't that be possible with python stdlib ? It is possible using the low-level facilities. However, the traditional high-level facilities are built on multithreading, which (as a rule) is based on blocking I/O. Marko -- https://mail.python.org/mailman/listinfo/python-list
Re: How to write a non blocking SimpleHTTPRequestHandler ?
On Tuesday, February 3, 2015 at 12:35:32 PM UTC+1, Marko Rauhamaa wrote: So far I've been happy with select.epoll(), socket.socket() and ten fingers. Marko There's already software written to take care of much of the HTTP stuff protocol stuff, the headers etc. I wouldn't rewrite it. I prefer to monkey patch parts of existing code rather then rewrite all of it. But your comment is interesting because, as I understand it, a non-blocking web server is simply a matter of setting timeouts on sockets, catch the exceptions and move on. I don't know why wouldn't that be possible with python stdlib ? The standard library and nonblocking can't be used in the same sentence. ? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to write a non blocking SimpleHTTPRequestHandler ?
On Wed, Feb 4, 2015 at 12:45 AM, Marko Rauhamaa ma...@pacujo.net wrote: But your comment is interesting because, as I understand it, a non-blocking web server is simply a matter of setting timeouts on sockets, catch the exceptions and move on. Now I think you might have some misconceptions about nonblocking networking I/O. Nonblocking I/O is done using asynchronous, or event-driven, programming. Your code reacts to external stimuli, never blocking, mostly just sleeping. The reactions are defined in callback routings, aka listeners, aka event handlers. Not strictly true - that's just one convenient way of doing things. A callback/event-handler structure lets you write a bunch of listeners that coexist effortlessly, but it's not the only way to do non-blocking I/O, and it's certainly not an intrinsic part of the concept. That said, though, it is a VERY convenient way to lay things out in the code. The Pike system I offered, and most of the older multiplexed-I/O systems I've used, did work that way. It just isn't something that non-blocking necessarily implies. I don't know why wouldn't that be possible with python stdlib ? It is possible using the low-level facilities. However, the traditional high-level facilities are built on multithreading, which (as a rule) is based on blocking I/O. Multithreading is another way to cope with the same problem of wanting to deal with different sockets on a single CPU, but I don't think it's inherently a part of any of Python's own high-level facilities - not that I can think of, at least? However, in terms of common programming models, yes, multithreading+blocking I/O is an effective way to write code, and will therefore be commonly used. I wish more people had grown up on OS/2 instead of (or as well as) Windows or Unix. Threading is not such a bugbear as a lot of people seem to think. Yes, some platforms have traditionally had poor implementations, and to be sure, you don't want to mix threading and forking without a *lot* of care, but threads aren't inherently bad. They're a useful tool in the toolbox. Sometimes non-blocking I/O is the right thing to do; sometimes threads suit the problem better; other times, something else again. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: __pycache__
On Mon, Feb 2, 2015 at 4:26 PM, Luke Lloyd nieko...@gmail.com wrote: I am in school and there is a problem with my code: When I try to run my code in the python code in the python shell it waits about 10 seconds then shows an error that says “IDLE’s subprocess didn’t make connection. Either IDLE can’t start a subprocess or personal firewall software is blocking the connection.” Then when I press OK it just closes. IDLE runs code by starting a Python interpreter in a subprocess and connecting to it. If this is a school computer then I would guess it probably has a very aggressive firewall as the message suggests. What happens if you try running the script directly from the OS command line instead of through IDLE? -- https://mail.python.org/mailman/listinfo/python-list
Re: __pycache__
On Mon, Feb 2, 2015 at 4:26 PM, Luke Lloyd nieko...@gmail.com wrote: I am in school and there is a problem with my code: When I try to run my code in the python code in the python shell it waits about 10 seconds then shows an error that says “IDLE’s subprocess didn’t make connection. Either IDLE can’t start a subprocess or personal firewall software is blocking the connection.” Then when I press OK it just closes. P.S: My code is encrypting and decrypting using an offset factor. By the way, your subject line doesn't seem to have anything to do with your question. -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
Steven D'Aprano wrote: In Python 2, they are methods. In Python 3, they are functions, and aren't converted into methods until you access them via the instance: They're methods in both cases. They don't have to be converted into methods; they already are, by virtue of their location and intended usage. The wrapper that gets created on attribute access isn't the method (despite being called MethodType!) -- the method is the function that it wraps. The wrapper is just part of the machinery that passes the self argument to the method. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Ghost vulnerability
On Tue, Feb 3, 2015 at 4:53 AM, Rustom Mody rustompm...@gmail.com wrote: How many people (actually machines) out here are vulnerable? http://security.stackexchange.com/questions/80210/ghost-bug-is-there-a-simple-way-to-test-if-my-system-is-secure shows a python 1-liner to check -- https://mail.python.org/mailman/listinfo/python-list Not very reliable in my experience, this python test does segfault on my *patched* Debian machine root@web:~# python -c 'import socket;y=0*5000;socket.gethostbyname(y)' Segmentation fault However, the other test proposed on stackechange correctly reports that I'm not vulnerable ;) root@web:/tmp# wget https://webshare.uchicago.edu/orgs/ITServices/itsec/Downloads/GHOST.c root@web:/tmp# gcc GHOST.c -o GHOST root@web:/tmp# ./GHOST not vulnerable -- Marc -- https://mail.python.org/mailman/listinfo/python-list
[issue23389] pkgutil.find_loader raises an ImportError on PEP 420 implicit namespace packages
New submission from Alistair Lynn: The documentation states that __spec__ is None in–and only in–__main__. That this happens also for PEP 420 implicit namespace packages appears to be the cause of the error. -- components: Interpreter Core messages: 235357 nosy: alynn priority: normal severity: normal status: open title: pkgutil.find_loader raises an ImportError on PEP 420 implicit namespace packages type: crash versions: Python 3.4 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23389 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Is there a cairo like surface for the screen without the window hassle
On Feb 2, 2015, at 5:20 AM, Antoon Pardon antoon.par...@rece.vub.ac.be wrote: I need to have a program construct a number of designs. Of course I can directly use a pfd surface and later use a pdf viewer to check. But that becomes rather cumbersome fast. But if I use a cairo-surface for on the screen I suddenly have to cope with expose events and all such things I am not really interested in. So does someone know of a package that provides a cairo like surface but that would take care of the events in a rather straight forward matter, so that my program could make it's design in a window on the screen just as if it is designing it in a pdf file. For the most part, you cannot draw directly to the screen with Cairo. Some OSes kind of allow out, but they won’t repaint it for you. Any viewing software that will auto detect file updates and reload would do the trick. For example, I know that preview on OS X will automatically reload a png file that I write. Cairo can generate png output. Just open preview on the file, and then have the program rewrite the same file. -- https://mail.python.org/mailman/listinfo/python-list
Re: Ghost vulnerability
On 02/03/2015 04:19 AM, Steven D'Aprano wrote: Anssi Saari wrote: Rustom Mody rustompm...@gmail.com writes: How many people (actually machines) out here are vulnerable? http://security.stackexchange.com/questions/80210/ghost-bug-is-there-a-simple-way-to-test-if-my-system-is-secure shows a python 1-liner to check Does that check actually work for anyone? That code didn't segfalt on my vulnerable Debian system but it did on my router which isn't (since the router doesn't use glibc). Oh and of course I can't comment on stinkexchange since I don't have whatever mana points they require... Here's the one-liner: python -c 'import socket;y=0*5000;socket.gethostbyname(y)' I think it is likely that y=0*5000 would segfault due to lack of memory on many machines. I wouldn't trust this as a test. I ran it on both my servers (each running a different version of the OS) which were recently updated to Red Hat's latest version of glibc that fixes the problem, and both of them segfault with this one liner. -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
Devin Jeanpierre wrote: On Mon, Feb 2, 2015 at 6:07 AM, Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote: Run this code: # === cut === class K(object): def f(self): pass def f(self): pass instance = K() things = [instance.f, f.__get__(instance, K)] from random import shuffle shuffle(things) print(things) # === cut === You allege that one of these things is a method, and the other is not. I challenge you to find any behavioural or functional difference between the two. (Object IDs don't count.) If you can find any meaningful difference between the two, I will accept that methods have to be created as functions inside a class body. In this particular case, there is none. What if the body of the method was super().f() ? What of it? The zero-argument form of super() is a compiler hack documented as only working inside classes. Most methods don't even use super *at all*, let alone the Python3-only zero argument form. Surely you cannot be serious that the defining characteristic of what is or is not a method is whether or not an explicit hack works? But you know, I can duplicate the compiler hack and still use the zero-argument form of super in a method defined on the outside of the class. py class A(object): ... pass ... py def magic(): # Don't do this at home! ... __class__ = A ... def f(self): ... __class__ ... return super() # Magic zero-argument form. ... return f ... py A.f = magic() py a = A() py a.f() super: class 'A', A object So to answer your question: What if the body of the method was super().f() ? It would still work correctly. Because Python is just that awesome. Some methods can be defined outside of the body and still work exactly the same, but others won't. Some methods can be defined outside of the body. AT LONG LAST THE LIGHT DAWNS! THE PENNY DROPS! If some methods can be defined outside of the body of a class, then being defined inside the body of a class does not define a method. You say some methods, but the reality is that *all methods* can do so. Even if they use super. Even if they use the zero-argument form of super (although that one is rather inconvenient). The class statement is syntactic sugar for calling type(name, bases, ns): class A(bases): x = 100 f = lambda self: self.x + 1 is equivalent to: A = type(A, bases, {'x': 100, 'f': lambda self: self.x + 1}) *ANY* class you create with the class statement can be created (less conveniently) with type (or the appropriate metaclass). Obviously the class statement form is convenient because it allows you to define the items of the namespace in place, which you can't always do using type itself. With type, you may have to prepare the items first, insert them into a dict, and pass it as the namespace argument. It also offers convenient syntax for changing the metaclass. Most importantly, it is simply more readable and nicer to be able to define the methods indented inside the class statement. This is the natural way to define classes, and given that the glossary need not be 100% complete and definitive, function defined inside a class body is close enough to the truth. But it is not *the whole truth*. Not only can methods be defined outside of a class, but with a little preparation functions defined inside of classes can remain functions. py class function(object): ... def __init__(self, func): ... self.func = func ... def __get__(self, obj, cls=None): ... return self.func ... py class B(object): ... @function ... def f(x, y): # No self. ... return x + y ... py B.f(23, 42) 65 py b = B() py b.f(23, 42) 65 py type(b.f) class 'function' (Alternatively, I could change the metaclass, although that's trickier. Using a custom descriptor is just too easy.) Otherwise you are reduced to claiming that there is some sort of mystical, undetectable essence or spirit that makes one of those two objects a real method and the other one a fake method, even though they have the same type, the same behaviour, and there is no test that can tell you which is which. It isn't mystical. There are differences in semantics of defining methods inside or outside of a class that apply in certain situations (e.g. super(), metaclasses). You have cherrypicked an example that avoids them. Out of the millions, billions of methods people write, how many do you think use super? 1% 0.1%? 10%? And you accuse *me* of cherrypicking. Not that it matters. As I have shown, even the zero argument form of super can be used. -- Steven -- https://mail.python.org/mailman/listinfo/python-list
[issue23389] pkgutil.find_loader raises an ImportError on PEP 420 implicit namespace packages
Changes by Eric V. Smith e...@trueblade.com: -- nosy: +eric.smith ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23389 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23388] datetime.strftime('%s') does not take timezone into account
cameris added the comment: Yes, this seems to be exactly the same. Searching with All text*: '%s' didn't return anything, therefore I thought it is an unknown bug/behaviour. Well, sorry for the duplicate. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23388 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7434] general pprint rewrite
Changes by Fred L. Drake, Jr. fdr...@gmail.com: -- nosy: -fdrake ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7434 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Ghost vulnerability
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes: Here's the one-liner: python -c 'import socket;y=0*5000;socket.gethostbyname(y)' I think it is likely that y=0*5000 would segfault due to lack of memory on many machines. I wouldn't trust this as a test. Hmm, how much RAM does that one-liner actually need? My router has 128 MB total RAM with about 90 MB free. So it can store the string once but if it's copied with the gethostbyname call then it'll run out... According to a Reddit thread (http://www.reddit.com/r/Python/comments/2u7ghu/python_socketgethostbyname_is_not_affected_by/) Python's socket.gethostbyname() doesn't actually even call the gethostbyname function in glibc, it uses the newer getaddrinfo instead. So it's a little unlikely to cause a segfault because of the Ghost vuln :) Anyways, here's an example calling gethostbyname directly in python: from ctypes import CDLL o = CDLL('libc.so.6') for i in range(0, 2500): o.gethostbyname('0'*i) I don't have a vulnerable system to test on any more though. -- https://mail.python.org/mailman/listinfo/python-list
[issue18454] distutils crashes when uploading to PyPI having only the username (no pw) defined
Changes by Jan-Philip Gehrcke jgehr...@gmail.com: Added file: http://bugs.python.org/file38006/issue18454_py27_prompt_test.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18454 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18454] distutils crashes when uploading to PyPI having only the username (no pw) defined
Jan-Philip Gehrcke added the comment: First, I want to address the situation in 2.7. Please have a look at my patch and my reasoning. This is my setup.py test file content: from distutils.core import setup setup(name='foo', version='1.0', packages=['testpackage']) This is the current situation for 2.7 head, in summary: 1) Without a proper .pypirc file in place, uploading fails with Upload failed (401): You must be identified to edit package information 2) With a valid .pypirc in place which does not define a password this exception is raised: TypeError: cannot concatenate 'str' and 'NoneType' objects (1) happens due to the fact that the default username/password strings are empty, but the request is still fired against PyPI. This obviously fails. This could be fixed by prompting for both, username and password or by aborting before sending the request. However, this would be quite a significant change in behavior. I think we should not do this, because AFAIK the 2.7 documentation does not specify what the behavior should be *without* existing .pypirc file. So, I think there might not be enough reason to consider such a change a bug fix. What do you think? (2) violates the docs and I guess this is what Nick meant when he said that the stdlib should be updated. I propose a patch so that what the docs say (If omitted, the user will be prompt to type it when needed) is what actually happens. The patch consists of two parts: Part A: issue18454_py27_prompt.patch This uses getpass/sys.stdin.readline() for retrieving the password, depending on whether the process is attached to a tty or not, respectively. The config parsing and value propagation is a little messy in the command/upload.py module, so I have also added comments for clarity and simplified the logic a little. Part B: issue18454_py27_prompt_test.patch - Here it gets messy. Normally, we want to have a new test case that fails before applying patch A, and succeeds after applying it. However, here we actually have to deal with an already existing bogus test case which succeeds before and fails after A gets applied. A very bad sign, usually. But in this case I am of the strong opinion that we can and have to change the test implementation, because: - the test actually makes sure that `cmd.password` is set to None when `cmd.finalize_options()` has done its work. However,`cmd.password` being None leads to the TypeError exception described above. That is, this test case basically ensures the very existance of the bug that we want to fix. - it has a suspiciously useless name. It is called `test_saved_password`, but actually tests the case when no password is saved in .pypirc. - this test actually has quite low code coverage. AFAIK it *only* tests the behavior of `cmd.finalize_options()`. We want to change this behavior, so we have to consider changing the test. My patch modifies this test case so that it has a proper name and makes sure that `cmd.finalize_options()` obtains a password from stdin. The involvement of stdin makes testing a little complicated. In a proper testing environment, we'd probably spawn a subprocess and provide it with some real stdin data. The distutils upload command test structure seems not to be prepared for this endeavor, so I have decided to temporarily/locally patch sys.stdin, and ensure restoration with a try/finally clause. With A and B in place, all distutils unit tests validate. I used two methods of invocation, for covering the two cases (with and without attached tty): $ nohup python test_distutils.py 21 out.log $ python test_distutils.py -- keywords: +patch Added file: http://bugs.python.org/file38005/issue18454_py27_prompt.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18454 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: dunder-docs (was Python is DOOMED! Again!)
On Wed, Feb 4, 2015 at 10:32 AM, Marko Rauhamaa ma...@pacujo.net wrote: No, I'm saying Python should behave differently. Python: class A: ...def f(self): ... print(f) ...def g(self): ... print(g) ... a = A() a.__class__.f = a.__class__.g a.f() g In my preferred semantics, a.f() would print a.f() f Yeeeouch. So either it has to actually copy everything in on instantiation (stupid cost for the tiny chance that it'll actually ever matter), or else have some kind of versioning that means that it knows that 'a' was created from the pre-changed class. What's the advantage?!? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: dunder-docs (was Python is DOOMED! Again!)
On 03/02/2015 23:32, Marko Rauhamaa wrote: Gregory Ewing greg.ew...@canterbury.ac.nz: You seem to be suggesting an optimisation that pre-creates bound methods when the instance is created. Keeping a cache of bound methods would achieve the same thing without changing the semantics. I think CPython might already be doing that, but I'm not sure. No, I'm saying Python should behave differently. Python: class A: ...def f(self): ... print(f) ...def g(self): ... print(g) ... a = A() a.__class__.f = a.__class__.g a.f() g In my preferred semantics, a.f() would print a.f() f IMHO as clear as mud. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
[issue23390] make profile-opt: test_distutils failure
Changes by Stefan Krah ste...@bytereef.org: -- nosy: skrah priority: normal severity: normal status: open title: make profile-opt: test_distutils failure type: behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue23390 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: dunder-docs (was Python is DOOMED! Again!)
Marko Rauhamaa wrote: Right now Python generates the trampoline from the class prototype every time you call a method. If the semantics allowed, you could create the trampoline at instantiation time (for better or worse). That way, the problem you seem to be referring to wouldn't materialize. Sorry, I misinterpreted what you were suggesting. You seem to be suggesting an optimisation that pre-creates bound methods when the instance is created. Keeping a cache of bound methods would achieve the same thing without changing the semantics. I think CPython might already be doing that, but I'm not sure. -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Problem while reading files from hdfs using python
On 01/25/2015 03:23 PM, Shalini Ravishankar wrote: Hello Everyone, I am trying to read(open) and write files in hdfs inside a python script. But having error. Please copy/paste the full error traceback. Can someone tell me what is wrong here. Code (full): sample.py #!/usr/bin/python from subprocess import Popen, PIPE print Before Loop cat = Popen([hadoop, fs, -cat, ./sample.txt], stdout=PIPE) I don't know anything about hadoop, and when you run it separately, you used different parameters. So you can do a lot towards testing it yourself. Start by running hadoop fs -cat ... from shell to see whether it displays anything. You should be able to use exactly the same arguments as you use in the Popen call. Then if that seems to work as you expect, comment out your 'put' code below, and add some prints to the loop. Does that look reasonable? At that point, if both look reasonable, then try the inverse. Write some known data to the 'put' command, and see if it makes it into the appropriate file. Once again, you should be able to also test the program parameters and behavior from the shell, typing manually into stdin. put = Popen([hadoop, fs, -put, -, ./modifiedfile.txt], stdin=PIPE) for line in cat.stdout: line += Blah print line put.stdin.write(line) cat.stdout.close() cat.wait() put.stdin.close() put.wait() When I execute : hadoop jar /usr/local/hadoop/share/hadoop/tools/lib/hadoop-streaming-2.5.1.jar -file ./sample.py -mapper './sample.py' -input sample.txt -output fileRead It executes properly I couldn't find the file which supposed to create in hdfs modifiedfile And When I execute : hadoop fs -getmerge ./fileRead/ file.txt Inside the file.txt, I got : Before Loop Before Loop Can someone please tell me what I am doing wrong here ?? I dont think it reads from the sample.txt I would really appreciate the help. -- Thanks Regards, Shalini Ravishankar. -- DaveA -- https://mail.python.org/mailman/listinfo/python-list