Marc-Andre Lemburg <m...@egenix.com> added the comment:

Raymond Hettinger wrote:
> Raymond Hettinger <rhettin...@users.sourceforge.net> added the comment:
> 
> In Py3.x, this fails:
>     "%s.%s.%s-%s-%s" % sys.version_info
> 
> The reason is that PyUnicode_Format() expects a real tuple, not a tuple
> lookalike.  The fix is to either have structseq inherit from tuple or to
> modify PyUnicode_Format() to handle structseq:
> 
>    if (PyCheck_StructSeq(args)) {
>       newargs = PyTuple_FromSequence(args);
>       if (newargs == NULL)
>           return NULL;
>       result = PyUncode_Format(format, newargs);
>       Py_DECREF(newargs);
>       return result;
>    }

-1

The special-casing of tuples vs. non-tuples for % is already
bad enough. Adding structseq as another special case doesn't
make that any better.

What's so hard about writing

"%s.%s.%s-%s-%s" % tuple(sys.version_info)

anyway ?

----------
nosy: +lemburg
title: Enhance Object/structseq.c to match namedtuple and tuple api -> Enhance 
Object/structseq.c to match namedtuple and tuple api

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue1820>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to