🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: pl.comp.lang.python
Article #27663

Re: [C] PyUnicode_FromFormat(%U) -crash

#27663
From: Artur M. Piwko
Date: Thu, 16 Sep 2010 06:35
36 lines
2147 bytes
In the darkest hour on Wed, 15 Sep 2010 16:58:49 +0200,
kenubi <nono@no.pl> screamed:
> Mam dziwny objaw (python 3.1.2 / gcc 4.5.0).
>
> w module pomocniczym w C używam ~takiej konstrukcji:
>
> static PyObject *w_cudzyslowy (PyObject *self,PyObject *uo)
> {
> PyObject *tmp;
> tmp = PyUnicode_FromFormat("'%U'", uo);
> return tmp;
> }
>
> uo - jest oczywiście obiektem Unicode.
>

Z tego co widzę...

PyObject* PyUnicode_FromFormat(const char *format, ...) ¶

Take a C printf()-style format string and a variable number of
arguments, calculate the size of the resulting Python unicode string and
return a string with the values formatted into it. The variable
                                                   ^^^^^^^^^^^^
arguments must be C types and must correspond exactly to the format
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
characters in the format ASCII-encoded string. [...]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

http://docs.python.org/dev/py3k/c-api/unicode.html?highlight=pyunicode_fromformat#PyUnicode_FromFormat

-- 
[ Artur M. Piwko : Pipen : AMP29-RIPE : RLU:100918 : From == Trap! : SIG:239B ]
[ 08:33:17 user up 12562 days, 20:28,  1 user, load average: 0.94, 0.10, 0.06 ]

 Women are nothing but machines for producing children.  -- Napolean Bonaparte
Technical Details
Message-ID: <slrni93em7.6qg.milusi.pysiaczek@buziaczek.pl>
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
References: <4c90de51$0$22813$65785112@news.neostrada.pl>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!not-for-mail
From: "Artur M. Piwko" <milusi.pysiaczek@buziaczek.pl>
Newsgroups: pl.comp.lang.python
Subject: Re: [C] PyUnicode_FromFormat(%U) -crash
Date: Thu, 16 Sep 2010 08:35:51 +0200
Organization: Petroleum Drinkers (;
Lines: 36
Message-ID: <slrni93em7.6qg.milusi.pysiaczek@buziaczek.pl>
References: <4c90de51$0$22813$65785112@news.neostrada.pl>
Reply-To: milusi.pysiaczek@buziaczek.pl
NNTP-Posting-Host: 81.26.8.20
Mime-Version: 1.0
X-Trace: inews.gazeta.pl 1284620881 11478 81.26.8.20 (16 Sep 2010 07:08:01 GMT)
X-Complaints-To: usenet@agora.pl
NNTP-Posting-Date: Thu, 16 Sep 2010 07:08:01 +0000 (UTC)
X-User: pipene
User-Agent: slrn/pre1.0.0-18 (Linux)
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit