Strange pexpect behaviour: just duplicates stdin

2009-03-30 Thread Nikolaus Rath
Hello, I have a strange problem with pexpect: $ cat test.py #!/usr/bin/python import pexpect child = pexpect.spawn(./test.pl) while True: try: line = raw_input() except EOFError: break child.sendline(line) print child.readline().rstrip(\r\n) child.close() $

Protecting instance variables

2008-07-18 Thread Nikolaus Rath
Hello, I am really surprised that I am asking this question on the mailing list, but I really couldn't find it on python.org/doc. Why is there no proper way to protect an instance variable from access in derived classes? I can perfectly understand the philosophy behind not protecting them from

Re: Attack a sacred Python Cow

2008-07-25 Thread Nikolaus Rath
Terry Reedy [EMAIL PROTECTED] writes: Torsten Bronger wrote: Hallöchen! And why does this make the implicit insertion of self difficult? I could easily write a preprocessor which does it after all. class C(): def f(): a = 3 Inserting self into the arg list is trivial. Mindlessly

Re: Attack a sacred Python Cow

2008-07-26 Thread Nikolaus Rath
Terry Reedy [EMAIL PROTECTED] writes: Nikolaus Rath wrote: Terry Reedy [EMAIL PROTECTED] writes: Torsten Bronger wrote: Hallöchen! And why does this make the implicit insertion of self difficult? I could easily write a preprocessor which does it after all. class C(): def f

Re: Attack a sacred Python Cow

2008-07-27 Thread Nikolaus Rath
Terry Reedy [EMAIL PROTECTED] writes: What he wants is to write class foo: def bar(arg): self.whatever = arg + 1 instead of class foo: def bar(self, arg) self.whatever = arg + 1 so 'self' should *automatically* only be inserted in the function declaration, and

Re: Attack a sacred Python Cow

2008-07-28 Thread Nikolaus Rath
castironpi [EMAIL PROTECTED] writes: I think you misunderstood him. What he wants is to write class foo:    def bar(arg):        self.whatever = arg + 1 instead of class foo:    def bar(self, arg)        self.whatever = arg + 1 so 'self' should *automatically* only be inserted in the

Re: Attack a sacred Python Cow

2008-07-28 Thread Nikolaus Rath
Michael Torrie [EMAIL PROTECTED] writes: Colin J. Williams wrote: def fun( ., cat): I don't see the need for the comma in fun. It (the entire first variable!) is needed because a method object is constructed from a normal function object: def method(self,a,b): pass class

Re: Attack a sacred Python Cow

2008-07-28 Thread Nikolaus Rath
Bruno Desthuilliers [EMAIL PROTECTED] writes: The fact that a function is defined within a class statement doesn't imply any magic, it just creates a function object, bind it to a name, and make that object an attribute of the class. You have the very same result by defining the function

Re: Attack a sacred Python Cow

2008-07-28 Thread Nikolaus Rath
Russ P. [EMAIL PROTECTED] writes: The issue here has nothing to do with the inner workings of the Python interpreter. The issue is whether an arbitrary name such as self needs to be supplied by the programmer. All I am suggesting is that the programmer have the option of replacing

Re: Attack a sacred Python Cow

2008-07-28 Thread Nikolaus Rath
Michael Torrie [EMAIL PROTECTED] writes: I think the biggest reason why an implicit self is bad is because it prevents monkey-patching of existing class objects. Right now I can add a new method to any existing class just with a simple attribute like so (adding a new function to an existing

os.symlink()

2008-07-28 Thread Nikolaus Rath
Hello, From `pydoc os`: symlink(...) symlink(src, dst) Create a symbolic link pointing to src named dst. Is there any reason why this is so deliberately confusing? Why is the target of the symlink, the think where it points *to*, called the `src`? It seems to me

Re: Protecting instance variables

2008-07-28 Thread Nikolaus Rath
Hi, Sorry for replying so late. Your MUA apparently messes up the References:, so I saw you reply only now and by coincidence. Diez B. Roggisch [EMAIL PROTECTED] writes: Nikolaus Rath schrieb: Hello, I am really surprised that I am asking this question on the mailing list, but I really

Re: Attack a sacred Python Cow

2008-07-29 Thread Nikolaus Rath
Bruno Desthuilliers [EMAIL PROTECTED] writes: Nikolaus Rath a écrit : Michael Torrie [EMAIL PROTECTED] writes: (snip) In short, unlike what most of the implicit self advocates are saying, it's not just a simple change to the python parser to do this. It would require a change

[unittest] Run setUp only once

2008-07-29 Thread Nikolaus Rath
Hello, I have a number of conceptually separate tests that nevertheless need a common, complicated and expensive setup. Unfortunately, unittest runs the setUp method once for each defined test, even if they're part of the same class as in class TwoTests(unittest.TestCase): def setUp(self):

Re: [unittest] Run setUp only once

2008-07-29 Thread Nikolaus Rath
Jean-Paul Calderone [EMAIL PROTECTED] writes: On Tue, 29 Jul 2008 16:35:55 +0200, Nikolaus Rath [EMAIL PROTECTED] wrote: Hello, I have a number of conceptually separate tests that nevertheless need a common, complicated and expensive setup. Unfortunately, unittest runs the setUp method once

Re: [unittest] Run setUp only once

2008-07-29 Thread Nikolaus Rath
Jean-Paul Calderone [EMAIL PROTECTED] writes: On Tue, 29 Jul 2008 19:26:09 +0200, Nikolaus Rath [EMAIL PROTECTED] wrote: Jean-Paul Calderone [EMAIL PROTECTED] writes: On Tue, 29 Jul 2008 16:35:55 +0200, Nikolaus Rath [EMAIL PROTECTED] wrote: Hello, I have a number of conceptually separate tests

Difference between type and class

2008-07-31 Thread Nikolaus Rath
Hello, Can someone explain to me the difference between a type and a class? After reading http://www.cafepy.com/article/python_types_and_objects/ it seems to me that classes and types are actually the same thing: - both are instances of a metaclass, and the same metaclass ('type') can

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Thomas Troeger [EMAIL PROTECTED] writes: Can someone explain to me the difference between a type and a class? If your confusion is of a more general nature I suggest reading the introduction of `Design Patterns' (ISBN-10: 0201633612), under Specifying Object Interfaces'. In short: A type

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
oj [EMAIL PROTECTED] writes: On Jul 31, 11:37 am, Nikolaus Rath [EMAIL PROTECTED] wrote: So why does Python distinguish between e.g. the type 'int' and the class 'myclass'? Why can't I say that 'int' is a class and 'myclass' is a type? I might be wrong here, but I think the point

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Maric Michaud [EMAIL PROTECTED] writes: Can someone explain to me the difference between a type and a class? If your confusion is of a more general nature I suggest reading the introduction of `Design Patterns' (ISBN-10: 0201633612), under `Specifying Object Interfaces'. In short: A type

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Maric Michaud [EMAIL PROTECTED] writes: Le Thursday 31 July 2008 14:30:19 Nikolaus Rath, vous avez écrit : oj [EMAIL PROTECTED] writes: On Jul 31, 11:37 am, Nikolaus Rath [EMAIL PROTECTED] wrote: So why does Python distinguish between e.g. the type 'int' and the class 'myclass'? Why can't

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Maric Michaud [EMAIL PROTECTED] writes: Le Thursday 31 July 2008 16:46:28 Nikolaus Rath, vous avez écrit : Maric Michaud [EMAIL PROTECTED] writes: Can someone explain to me the difference between a type and a class? If your confusion is of a more general nature I suggest reading

Re: Difference between type and class

2008-07-31 Thread Nikolaus Rath
Maric Michaud [EMAIL PROTECTED] writes: What the type int means is that int is not a user type but a builtin type, instances of int are not types (or classes) but common objects, so its nature is the same as any classes. The way it prints doesn't matter, it's just the __repr__ of any

Re: Difference between type and class

2008-08-01 Thread Nikolaus Rath
Miles [EMAIL PROTECTED] writes: On Thu, Jul 31, 2008 at 1:59 PM, Nikolaus Rath wrote: If it is just a matter of different rendering, what's the reason for doing it like that? Wouldn't it be more consistent and straightforward to denote builtin types as classes as well? Yes, and in Python 3

Re: Difference between type and class

2008-08-01 Thread Nikolaus Rath
Steven D'Aprano [EMAIL PROTECTED] writes: So, to the Original Poster: In Python, new-style classes and types are the same, but it is traditional to refer to customer objects as class and built-in objects as types. Old-style classes are different, but you are discouraged from using old-style

Locking around

2008-08-04 Thread Nikolaus Rath
Hello, I need to synchronize the access to a couple of hundred-thousand files[1]. It seems to me that creating one lock object for each of the files is a waste of resources, but I cannot use a global lock for all of them either (since the locked operations go over the network, this would make the

Re: Locking around

2008-08-06 Thread Nikolaus Rath
Ulrich Eckhardt [EMAIL PROTECTED] writes: Nikolaus Rath wrote: I need to synchronize the access to a couple of hundred-thousand files[1]. It seems to me that creating one lock object for each of the files is a waste of resources, but I cannot use a global lock for all of them either (since

Re: Locking around

2008-08-06 Thread Nikolaus Rath
Nikolaus Rath [EMAIL PROTECTED] writes: This should work, at least the idea is not flawed. However, I'd say there are too many locks involved. Rather, you just need a simple flag and the global lock. Further, you need a condition/event that tells waiting threads that you released some

Re: Locking around

2008-08-06 Thread Nikolaus Rath
Carl Banks [EMAIL PROTECTED] writes: Freaky... I just posted nearly this exact solution. I have a couple comments. First, the call to acquire should come before the try block. If the acquire were to fail, you wouldn't want to release the lock on cleanup. Second, you need to change

Re: Locking around

2008-08-06 Thread Nikolaus Rath
Tobiah [EMAIL PROTECTED] writes: On Mon, 04 Aug 2008 15:30:51 +0200, Nikolaus Rath wrote: Hello, I need to synchronize the access to a couple of hundred-thousand files[1]. It seems to me that creating one lock object for each of the files is a waste of resources, but I cannot use a global

Re: Find class of an instance?

2008-08-06 Thread Nikolaus Rath
Neal Becker [EMAIL PROTECTED] writes: Sounds simple, but how, given an instance, do I find the class? It does not only sound simple. When 'inst' is your instance, then inst.__class__ or type(inst) is the class. Best, -Nikolaus -- »It is not worth an intelligent man's time to

Re: Calculate sha1 hash of a binary file

2008-08-07 Thread Nikolaus Rath
LaundroMat [EMAIL PROTECTED] writes: Hi - I'm trying to calculate unique hash values for binary files, independent of their location and filename, and I was wondering whether I'm going in the right direction. Basically, the hash values are calculated thusly: f = open('binaryfile.bin')

[distutils] Install script under a different name

2009-12-04 Thread Nikolaus Rath
Hello, All my Python files have extension .py. However, I would like to install scripts that are meant to be called by the user without the suffix, i.e. the file scripts/doit.py should end up as /usr/bin/doit. Apparently the scripts= option of the setup() function does not support this directly.

Re: [distutils] Install script under a different name

2009-12-05 Thread Nikolaus Rath
Lie Ryan lie.1...@gmail.com writes: On 12/5/2009 11:34 AM, Nikolaus Rath wrote: Hello, All my Python files have extension .py. However, I would like to install scripts that are meant to be called by the user without the suffix, i.e. the file scripts/doit.py should end up as /usr/bin/doit

Re: [distutils] Install script under a different name

2009-12-05 Thread Nikolaus Rath
Wolodja Wentland wentl...@cl.uni-heidelberg.de writes: On Fri, Dec 04, 2009 at 19:34 -0500, Nikolaus Rath wrote: All my Python files have extension .py. However, I would like to install scripts that are meant to be called by the user without the suffix, i.e. the file scripts/doit.py should end

Determine PyArg_ParseTuple parameters at runtime?

2009-12-08 Thread Nikolaus Rath
Hello, I want to create an extension module that provides an interface to a couple of C functions that take arguments of type struct iovec, struct stat, struct flock, etc (the FUSE library, in case it matters). Now the problem is that these structures contain attributes of type fsid_t, off_t,

Implementing a cache

2009-07-10 Thread Nikolaus Rath
Hello, I want to implement a caching data structure in Python that allows me to: 1. Quickly look up objects using a key 2. Keep track of the order in which the objects are accessed (most recently and least recently accessed one, not a complete history) 3. Quickly retrieve and remove the

Re: Python docs disappointing

2009-07-31 Thread Nikolaus Rath
Carl Banks pavlovevide...@gmail.com writes: This is one area in which Perl still whips Python... No way. Perl's man pages are organized so poorly there is no ergonomic pit deep enough to offset them. Quick, what man page is the do statement documented in? Of course there is: $ perldoc -f

Monkeypatching an object to become callable

2009-08-09 Thread Nikolaus Rath
Hi, I want to monkeypatch an object so that it becomes callable, although originally it is not meant to be. (Yes, I think I do have a good reason to do so). But simply adding a __call__ attribute to the object apparently isn't enough, and I do not want to touch the class object (since it would

Profiling a Callback Function

2009-08-11 Thread Nikolaus Rath
Hello, I am trying to profile a Python program that primarily calls a C extension. From within the C extension, a callback Python function is then called concurrently in several threads. When I tried to profile this application with import c_extension def callback_fn(args): # Do all

Re: Monkeypatching an object to become callable

2009-08-11 Thread Nikolaus Rath
Bruno Desthuilliers bruno.42.desthuilli...@websiteburo.invalid writes: 7stud a écrit : (snip) class Wrapper(object): def __init__(self, obj, func): self.obj = obj self.func = func def __call__(self, *args): return self.func(*args) def

Profiling: Interpreting tottime

2010-04-07 Thread Nikolaus Rath
Hello, Consider the following function: def check_s3_refcounts(): Check s3 object reference counts global found_errors log.info('Checking S3 object reference counts...') for (key, refcount) in conn.query(SELECT id, refcount FROM s3_objects): refcount2 =

Re: Profiling: Interpreting tottime

2010-04-08 Thread Nikolaus Rath
Gabriel Genellina gagsl-...@yahoo.com.ar writes: En Wed, 07 Apr 2010 18:44:39 -0300, Nikolaus Rath nikol...@rath.org escribió: def check_s3_refcounts(): Check s3 object reference counts global found_errors log.info('Checking S3 object reference counts...') for (key

Dynamically change __del__

2010-04-30 Thread Nikolaus Rath
Hi, I'm trying to be very clever: class tst(object): def destroy(self): print 'Cleaning up.' self.__del__ = lambda: None def __del__(self): raise RuntimeError('Instance destroyed without running destroy! Hell may break loose!') However, it doesn't work:

[pyunit] Only run one specific test

2009-05-28 Thread Nikolaus Rath
Hi, Consider these two files: , mytest.py - | #!/usr/bin/env python | import unittest | | class myTestCase(unittest.TestCase): | def test_foo(self): | pass | | # Somehow important according to pyunit documentation | def suite(): | return unittest.makeSuite(myTestCase)

Re: [pyunit] Only run one specific test

2009-05-28 Thread Nikolaus Rath
Dave Angel da...@ieee.org writes: Nikolaus Rath wrote: Hi, Consider these two files: , mytest.py - | #!/usr/bin/env python | import unittest | | class myTestCase(unittest.TestCase): | def test_foo(self): |pass | | # Somehow important according to pyunit documentation

Problem with apsw and garbage collection

2009-06-11 Thread Nikolaus Rath
Hi, Please consider this example: #!/usr/bin/env python import apsw import tempfile fh = tempfile.NamedTemporaryFile() conn = apsw.Connection(fh.name) # Fill the db with some data cur = conn.cursor() datafh = open(/dev/urandom, rb) cur.execute(CREATE TABLE foo (no INT, data BLOB)) for i in

Exceptions and Object Destruction (was: Problem with apsw and garbage collection)

2009-06-12 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org writes: Hi, Please consider this example: [] I think I managed to narrow down the problem a bit. It seems that when a function returns normally, its local variables are immediately destroyed. However, if the function is left due to an exception, the local

Logging multiple lines

2009-06-16 Thread Nikolaus Rath
Hi, Are there any best practices for handling multi-line log messages? For example, the program, main = logging.getLogger() handler = logging.StreamHandler() handler.setFormatter(logging.Formatter('%(asctime)s %(levelname)s %(message)s')) main.addHandler(handler)

select(sock) indicates not-ready, but sock.recv does not block

2014-02-16 Thread Nikolaus Rath
Hello, I have a problem with using select. I can reliably reproduce a situation where select.select((sock.fileno(),), (), (), 0) returns ((),(),()) (i.e., no data ready for reading), but an immediately following sock.recv() returns data without blocking. I am pretty sure that this is not a race

Re: select(sock) indicates not-ready, but sock.recv does not block

2014-02-17 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org writes: Hello, I have a problem with using select. I can reliably reproduce a situation where select.select((sock.fileno(),), (), (), 0) returns ((),(),()) (i.e., no data ready for reading), but an immediately following sock.recv() returns data without

Corrputed stacktrace?

2014-06-03 Thread Nikolaus Rath
Hello, I'm trying to debug a problem. As far as I can tell, one of my methods is called at a point where it really should not be called. When setting a breakpoint in the function, I'm getting this: /home/nikratio/in-progress/s3ql/src/s3ql/backends/s3c.py(693)close() - if not self.md5_checked:

Missing stack frames?

2014-06-03 Thread Nikolaus Rath
Hello, (This may or may not be related to my mail about a corrupted stack trace). I've instrumented one of my unit tests with a conditional 'pdb.set_trace' in some circumstances (specifically, when a function is called by a thread other than MainThread). However, when trying to print a back

Re: Missing stack frames?

2014-06-04 Thread Nikolaus Rath
Chris Angelico ros...@gmail.com writes: On Wed, Jun 4, 2014 at 12:30 PM, Nikolaus Rath nikol...@rath.org wrote: I've instrumented one of my unit tests with a conditional 'pdb.set_trace' in some circumstances (specifically, when a function is called by a thread other than MainThread). I think

Re: Corrputed stacktrace?

2014-06-04 Thread Nikolaus Rath
Chris Angelico ros...@gmail.com writes: On Wed, Jun 4, 2014 at 12:20 PM, Nikolaus Rath nikol...@rath.org wrote: File /usr/lib/python3.3/threading.py, line 878 in _bootstrap Can you replicate the problem in a non-threaded environment? Threads make interactive debugging very hairy. Hmm. I

Re: Missing stack frames?

2014-06-04 Thread Nikolaus Rath
Chris Angelico ros...@gmail.com writes: On Wed, Jun 4, 2014 at 12:30 PM, Nikolaus Rath nikol...@rath.org wrote: I've instrumented one of my unit tests with a conditional 'pdb.set_trace' in some circumstances (specifically, when a function is called by a thread other than MainThread). I think

Re: Missing stack frames?

2014-06-05 Thread Nikolaus Rath
Paul Rubin no.email@nospam.invalid writes: Nikolaus Rath nikol...@rath.org writes: Still no context before the ominous close() call. I'm very confused. close() could be getting called from a destructor as the top level function of a thread exits, or something like that. Shouldn't

Re: Missing stack frames?

2014-06-05 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org writes: Chris Angelico ros...@gmail.com writes: On Wed, Jun 4, 2014 at 12:30 PM, Nikolaus Rath nikol...@rath.org wrote: I've instrumented one of my unit tests with a conditional 'pdb.set_trace' in some circumstances (specifically, when a function is called

Re: Missing stack frames?

2014-06-05 Thread Nikolaus Rath
dieter die...@handshake.de writes: [...] Someone else already mentioned that the close call can come from a destructor. Destructors can easily be called at not obvious places (e.g. s = C(); ... x = [s for s in ...]; in this example the list comprehension calls the C destructor which is not

Re: Missing stack frames?

2014-06-06 Thread Nikolaus Rath
Chris Angelico ros...@gmail.com writes: On Fri, Jun 6, 2014 at 12:16 PM, Nikolaus Rath nikol...@rath.org wrote: - Is there some way to make the call stack for destructors less confusing? First off, either don't have refloops, or explicitly break them. The actual code isn't as simple

ssl.SSLError: [SSL: BAD_WRITE_RETRY] bad write retry (_ssl.c:1636)

2014-09-21 Thread Nikolaus Rath
Hello, Can someone explain help me understand what this exception means? [...] File /usr/local/lib/python3.4/dist-packages/dugong-3.2-py3.4.egg/dugong/__init__.py, line 584, in _co_send len_ = self._sock.send(buf) File /usr/lib/python3.4/ssl.py, line 679, in send v =

[issue9400] multiprocessing.pool.AsyncResult.get() messes up exceptions

2010-07-28 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: The attached test program calls apply_async with a function that will raise CalledProcessError. However, when result.get() is called, it raises a TypeError and the program hangs: $ ./bug.py ERROR:root:ops Traceback (most recent call last

[issue9400] multiprocessing.pool.AsyncResult.get() messes up exceptions

2010-07-31 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: @ray: Try it with the following dummy dcon program: $ cat dcon #!/bin/sh exit 127 (and change the path to dcon in bug.py accordingly). -- ___ Python tracker rep...@bugs.python.org http

[issue9449] glibc detected *** /usr/bin/python: corrupted double-linked list

2010-08-01 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: $ python --version Python 2.6.5 $ pylint --version pylint 0.21.1, astng 0.20.1, common 0.50.3 Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56) [GCC 4.4.3] $ pylint pylint_crasher.py * Module pylint_crasher R0903: 62:Config

[issue9449] glibc detected *** /usr/bin/python: corrupted double-linked list

2010-08-01 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: Duplicate of http://projects.scipy.org/numpy/ticket/1462 -- status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9449

[issue9606] logging filter is ignored when added to root handler

2010-08-14 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: I believe the following should print only one log message, not two: import logging class Filter(object): def filter(self, record): return record.name == 'foo' logger = logging.getLogger() formatter = logging.Formatter('%(message

[issue9606] logging filter is not applied to messages from descendant loggers

2010-08-14 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: -- title: logging filter is ignored when added to root handler - logging filter is not applied to messages from descendant loggers ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9606

[issue6627] threading.local() does not work with C-created threads

2010-09-17 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: @Swapnil: the rules you quote are correct for the C extension, but do not apply when using ctypes, because ctypes is doing the required initializations automatically. However, if Amaury is correct, ctypes performs the initializations in a way

[issue6627] threading.local() does not work with C-created threads

2010-09-17 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: -- resolution: invalid - ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6627 ___ ___ Python-bugs-list

[issue6627] threading.local() does not work with C-created threads

2010-09-17 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: No, I am not saying that the behaviour of ctypes is wrong. It just happens to have some effects on threading.local that I think should be documented. That's why I reassigned this as a documentation bug. Please reconsider closing this bug

[issue6627] threading.local() does not work with C-created threads

2010-09-17 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: To be a bit more constructive, why not add something like this in paragraph to http://docs.python.org/library/ctypes.html#callback-functions: Note that if the callback function is called in a new thread that has been created outside

[issue6627] threading.local() does not work with C-created threads

2010-09-17 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: One point of ctypes is to save the user the trouble of having to create a full blown C extension, so I don't think it's reasonable to expect a ctypes user to have read the full C API documentation as well. Only a very small subset of the page

[issue10058] Unclear PyString_AsStringAndSize return value

2010-10-09 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: http://docs.python.org/c-api/string.html says about the return value of AsStringAndSize: If length is NULL, the resulting buffer may not contain NUL characters; if it does, the function returns -1 and a TypeError is raised. If string

[issue10058] C-API Intro should be more explicit about error return codes

2010-10-15 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: Georg, this is an important piece of information, but I think it is not yet clearly stated in the documentation. Here is what http://docs.python.org/c-api/intro.html says about return codes: In general, when a function encounters an error

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: The following is a very subtle bug and it took me a couple of days to reduce it to a manageable test case. So please bear with me even if it's tedious. The problem is that in some cases the use of ctypes for a callback function freezes

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: Added file: http://bugs.python.org/file15943/call_hello.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: Added file: http://bugs.python.org/file15944/hello_ll.c ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: Added file: http://bugs.python.org/file15945/libfuse26.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: Added file: http://bugs.python.org/file15946/libfuse28.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: Added file: http://bugs.python.org/file15947/call_hello.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: Removed file: http://bugs.python.org/file15943/call_hello.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: Reproduced with Python 3.1 -- versions: +Python 3.1 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: Removed file: http://bugs.python.org/file15947/call_hello.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-18 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: Added file: http://bugs.python.org/file15948/call_hello.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] ctypes freezes/deadlocks process

2010-01-19 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: Wow, great! Thanks for looking into this. How did you manage to get the backtrace? As I said, on my system gdb -p just hangs with when attaching. I'm changing the component, since it seems that it's the os module that's at fault

[issue7736] os.listdir hangs since opendir() and closedir() do not release GIL

2010-01-19 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: -- title: ctypes freezes/deadlocks process - os.listdir hangs since opendir() and closedir() do not release GIL ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7736

[issue7736] os.listdir hangs since opendir() and closedir() do not release GIL

2010-01-20 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: In this simple example, FUSE does not fork and does not start any threads. Note that PyGILState_Ensure() cannot do anything here. What happens is this: - call_hello.py calls FUSE in a new thread, releasing the GIL. - FUSE mounts the file

[issue7736] os.listdir hangs since opendir() and closedir() do not release GIL

2010-01-20 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: I have used both of them in the past, but in the end I wrote my own bindings (currently only available as part of the http://code.google.com/p/s3ql source code, but I intend to factor it out at some point), since neither fuse.py (http

[issue7736] os.listdir hangs since opendir() and closedir() do not release GIL

2010-01-20 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: On 01/20/2010 07:19 AM, Antoine Pitrou wrote: Ah, thanks for the explanation. Yes indeed the patch looks ok for the job. You should just be aware that similar problems may appear with other system calls. I don't think we have ever considered

[issue7736] os.listdir hangs since opendir() and closedir() do not release GIL

2010-01-22 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: The patch works fine for me too. Also, I did not discover any other such problems for other syscalls (but I did not systematically try all os.* functions). -- ___ Python tracker rep

[issue7760] use_errno=True does not work

2010-01-22 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: On my system (Ubuntu Karmic, Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15), Kernel 2.6.31-17-generic, libc6 2.10.1-0ubuntu16) the attached test script produces the following output: Traceback (most recent call last): File test1.py

[issue7760] use_errno=True does not work

2010-01-23 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: I can confirm that without the path it works for me too. But I have to admit that I don't really understand your explanation. Should I generally not use full paths with CDLL? Or just in the case of libc? In either case, I think the ctypes

[issue7931] Python hangs after last thread has exited

2010-02-15 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: Here is a short testcase that reproduces the problem. If you run the script it daemonizes correctly, but then the daemon does not terminate but hangs forever. The crucial part seems to be to daemonize the program while there is more than one

[issue7931] Interpreter does not terminate if daemonized while running multithreaded

2010-02-15 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: -- title: Python hangs after last thread has exited - Interpreter does not terminate if daemonized while running multithreaded ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue7931

[issue7736] os.listdir hangs since opendir() and closedir() do not release GIL

2010-02-16 Thread Nikolaus Rath
Nikolaus Rath nikol...@rath.org added the comment: Does this patch still need review? Both Martin and Antoine already commented that the patch is ok, so it'd be great if someone could actually apply it... -- ___ Python tracker rep...@bugs.python.org

[issue6715] xz compressor support

2010-04-09 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: -- nosy: +Nikratio ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6715 ___ ___ Python-bugs-list mailing

[issue8487] os.mknod() fails on NFS mounted directories

2010-04-21 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: $ cat test.py #!/usr/bin/env python import os import stat dbfile = './testfile.test' with open(dbfile, 'w') as fh: print('Opened file for writing') os.unlink(dbfile) os.mknod(dbfile, stat.S_IRUSR | stat.S_IWUSR | stat.S_IFREG) print('Mknod

[issue6627] threading.local() does not work with C-created threads

2009-08-02 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: When threads are created by a C extension loaded with ctypes, threading.local() objects are always empty. If one uses _threading_local.local() instead of threading.local(), the problem does not occur. More information and example program

[issue6648] codecs documentation does not mention surrogateescape

2009-08-05 Thread Nikolaus Rath
New submission from Nikolaus Rath nikol...@rath.org: On http://docs.python.org/3.1/library/codecs.html it says that Possible values for errors are 'strict' (raise an exception in case of an encoding error), 'replace' (replace malformed data with a suitable replacement marker

[issue5689] please support lzma compression as an extension and in the tarfile module

2009-08-13 Thread Nikolaus Rath
Changes by Nikolaus Rath nikol...@rath.org: -- nosy: +Nikratio ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5689 ___ ___ Python-bugs-list mailing

  1   2   3   4   >