Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

Oct 27, 2009, 11:49 PM

Post #1 of 15 (649 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c)

New submission from Hirokazu Yamamoto <ocean-city [at] m2>:

Hello. There is following sentence in Modules/_io/bufferedio.c,

PyErr_Format(PyExc_IOError,
"Raw stream returned invalid position %" PY_PRIdOFF,
(PY_OFF_T_COMPAT)n);

and PY_PRIdOFF == "lld" when sizeof(off_t) == sizeof(long long).

But it seems that PyErr_Format doesn't support lld as specifier.

I noticed this because
# define PY_OFF_T_COMPAT long long
caused compile error on my good old VC6. ;-) (VC6 doesn't have it)

----------
messages: 94601
nosy: mark.dickinson, ocean-city
severity: normal
status: open
title: %lld for PyErr_Format (Modules/_io/bufferedio.c)
versions: Python 2.7

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 27, 2009, 11:51 PM

Post #2 of 15 (635 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Hirokazu Yamamoto <ocean-city [at] m2> added the comment:

I believe r75728 and r75879 are related.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:12 AM

Post #3 of 15 (626 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

Thanks for reporting this.

Do you know what the right conversion specifier is for print(f)ing
something of long long type in MSVC?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:20 AM

Post #4 of 15 (626 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

The 'long long' define should have been PY_LONG_LONG. I don't know what
the appropriate substitute for "%lld" is, though.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:21 AM

Post #5 of 15 (625 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Hirokazu Yamamoto <ocean-city [at] m2> added the comment:

MSVC6 uses __int64 as 64bit integer, and printf uses "I64" as its specifier.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:31 AM

Post #6 of 15 (621 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

So PY_PRIdOFF should be "I64d"? Or just "I64"?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:37 AM

Post #7 of 15 (625 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Hirokazu Yamamoto <ocean-city [at] m2> added the comment:

Oh, I was late. I agree with msg94605.

printf("%I64d\n", 1I64 << 40); /* 1099511627776 */

So if PyErr_Format (actually, PyString_FromFormatV) will support
PY_LONG_LONG, I think we can use same technique as PY_FORMAT_SIZE_T like

#define PY_FORMAT_LONG_LONG "I64" /* On Windows */
#define PY_FORMAT_LONG_LONG "ll" /* On Unix */

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:43 AM

Post #8 of 15 (622 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Hirokazu Yamamoto <ocean-city [at] m2> added the comment:

I was late again...? Hmm, I thought Python tracker told me that somebody
else modified this issue. Anyway, printf can use both "%I64" and "%I64d"
for signed 64bit integer, but should use "%I64u" for unsigned 64bit
integer AFAIK.

But PyErr_Format actually calls PyString_FromFormatV, and it's not
treating %lld. So probably we should modify PyString_FromFormatV.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:48 AM

Post #9 of 15 (633 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

Thanks. I'm just going to fix Modules/io/_iomodule.h for now. But I
agree that it might make sense to have a PY_FORMAT_OFF_T or
PY_FORMAT_LONG_LONG in pyport.h, especially if uses of off_t become more
widespread in the codebase.

I also notice there are some uses of "%zd" in Modules/io that should be
replaced with PY_FORMAT_SIZE_T.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:54 AM

Post #10 of 15 (632 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

Aargh. You're right, of course. PyString_FromFormatV needs to be
updated, or avoided in this case.

I'll look at this later today.

----------
assignee: -> mark.dickinson

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 28, 2009, 12:59 AM

Post #11 of 15 (624 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Hirokazu Yamamoto <ocean-city [at] m2> added the comment:

Sorry for confusion. I shouldn't have said last 3 lines in msg94601. :-(

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 29, 2009, 3:01 AM

Post #12 of 15 (614 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

I've rolled back all the changes I made trying to fix these format
arguments; the rollback is in r75939 (trunk), r75941 (py3k) and r75942
(release31-maint). Next time I'll think a bit harder, get a code
review, and make sure that the code gets tested on Windows before it
goes in.

I agree that what's needed here is %lld and %llu support in PyErr_Format
and PyString_FromFormat(V); this seems like a useful thing to add in
any case.

ocean-city: you don't happen to have a patch available, do you?

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 30, 2009, 7:33 AM

Post #13 of 15 (611 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Hirokazu Yamamoto <ocean-city [at] m2> added the comment:

No, I don't have it.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 31, 2009, 7:08 AM

Post #14 of 15 (594 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Mark Dickinson <dickinsm [at] gmail> added the comment:

Patch to add %lld support to PyString_FromFormat(V). (Against the trunk.)

----------
keywords: +patch
stage: -> patch review
type: -> feature request
Added file: http://bugs.python.org/file15240/add_lld_format.patch

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

Oct 31, 2009, 9:35 AM

Post #15 of 15 (591 views)
Permalink
[issue7228] %lld for PyErr_Format (Modules/_io/bufferedio.c) [In reply to]

Hirokazu Yamamoto <ocean-city [at] m2> added the comment:

I tried your patch on windows, your patch worked great. One little
thing: I think line 346 of patch can be wrapped with "#ifdef
HAVE_LONG_LONG".

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue7228>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.