Author LambertDW
Recipients LambertDW, georg.brandl
Date 2008-11-12.20:53:11
SpamBayes Score 0.000132049
Marked as misclassified No
Message-id <1226523194.83.0.190505447778.issue4309@psf.upfronthosting.co.za>
In-reply-to
Content
'''
    http://docs.python.org/dev/3.0/library/ctypes.html

    Where web page says

    >>> printf("An int %d, a double %f\n", 1234, c_double(3.14))
    Integer 1234, double 3.1400001049
    31
    >>>

    should instead read
 
    >>> printf(c_char_p("An int %d, a double %f\n"), 1234, c_double(3.14))
    An int 1234, a double 3.140000
    31

    Although the intent of the message is clear, it is inexact with
    regard to "An int" and "a double".  Core dump is bigger problem:


    Processor: Dual-Core AMD Opteron(tm) Processor 2218
    Python: Python 3.0rc1+ (py3k, Nov  5 2008, 14:44:46) 
            [GCC 3.4.6 20060404 (Red Hat 3.4.6-3)] on linux2

    core dumps by segmentation fault for all the printf examples without
    specifying c_char_p("string").
'''

# this program succeeds

from ctypes import *
libc = CDLL("libc.so.6")
print(libc.printf(c_char_p("An int %d, a double %f\n"), 1234,
c_double(3.14)))
History
Date User Action Args
2008-11-12 20:53:15LambertDWsetrecipients: + LambertDW, georg.brandl
2008-11-12 20:53:14LambertDWsetmessageid: <1226523194.83.0.190505447778.issue4309@psf.upfronthosting.co.za>
2008-11-12 20:53:12LambertDWlinkissue4309 messages
2008-11-12 20:53:11LambertDWcreate