From: Jonathan Wakely <jwakely@redhat.com>
To: Tom Tromey <tromey@adacore.com>
Cc: Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org>,
libstdc++@gcc.gnu.org
Subject: Re: [committed] libstdc++: Add GDB printers for <chrono> types
Date: Wed, 27 Sep 2023 17:15:07 +0100 [thread overview]
Message-ID: <CACb0b4kf33Y518=X6LFTi=i29dp2FvQT1JjPh+8j39Wn9iK3zw@mail.gmail.com> (raw)
In-Reply-To: <878r8r4og4.fsf@tromey.com>
[-- Attachment #1: Type: text/plain, Size: 1581 bytes --]
On Wed, 27 Sept 2023 at 16:37, Tom Tromey <tromey@adacore.com> wrote:
>
> >>>>> Jonathan Wakely via Gcc-patches <gcc-patches@gcc.gnu.org> writes:
>
> Replying to a quite old email...
>
> I ran a Python linter on the libstdc++ pretty-printers.
>
> I have fixes for most of the issues that are worth fixing (I didn't
> bother with line lengths -- FWIW in gdb we just run 'black' and don't
> worry about these details),
I used autopep8 and committed the result as
e08559271b2d797f658579ac8610dbf5e58bcfd8 so the line lengths should be
OK now.
> but the patch I'm replying to had a problem
> that I didn't know how to fix:
>
> > +class StdChronoTimeZoneRulePrinter:
> [...]
> > + if kind == 0: # DayOfMonth
> > + start = '{} {}{}'.format(month, ordinal_day)
>
> flake8 points out that this call to format has three placeholders but
> only two arguments.
Oops, I think it was originally written like this:
'{} {}{}'.format(month, day, suffixes.get(day, 'th'))
but then I refactored it to:
ordinal_day = '{}{}'.format(day, suffixes.get(day, 'th'))
if kind == 0: # DayOfMonth
start = '{} {}{}'.format(month, ordinal_day)
So the fix is to just change the string to '{} {}' which I've pushed
as 1fab05a885a308c19cf42b72fd36805ddf27fdc8 now (also attached).
These printers are for implementation details internal to the library,
which are never exposed to users. I added them because they made it
much easier to debug the implementation when stepping through library
functions, but that means there are no tests for them.
Thanks for finding this!
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 1028 bytes --]
commit 1fab05a885a308c19cf42b72fd36805ddf27fdc8
Author: Jonathan Wakely <jwakely@redhat.com>
Date: Wed Sep 27 17:03:51 2023
libstdc++: Fix format string in StdChronoTimeZoneRulePrinter
libstdc++-v3/ChangeLog:
* python/libstdcxx/v6/printers.py (StdChronoTimeZoneRulePrinter):
Fix incorrect number of replacement fields.
diff --git a/libstdc++-v3/python/libstdcxx/v6/printers.py b/libstdc++-v3/python/libstdcxx/v6/printers.py
index c0056de2565..d60c8003a63 100644
--- a/libstdc++-v3/python/libstdcxx/v6/printers.py
+++ b/libstdc++-v3/python/libstdcxx/v6/printers.py
@@ -2215,7 +2215,7 @@ class StdChronoTimeZoneRulePrinter:
day = on['day_of_month']
ordinal_day = '{}{}'.format(day, suffixes.get(day, 'th'))
if kind == 0: # DayOfMonth
- start = '{} {}{}'.format(month, ordinal_day)
+ start = '{} {}'.format(month, ordinal_day)
else:
weekday = weekdays[on['day_of_week']]
if kind == 1: # LastWeekDay
next prev parent reply other threads:[~2023-09-27 16:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-22 23:38 Jonathan Wakely
2023-09-27 15:37 ` Tom Tromey
2023-09-27 16:15 ` Jonathan Wakely [this message]
2023-09-27 17:24 ` Tom Tromey
2023-09-27 19:57 ` Jonathan Wakely
2023-09-28 7:23 ` Jonathan Wakely
2023-09-28 17:37 ` Tom Tromey
2023-09-28 18:47 ` Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CACb0b4kf33Y518=X6LFTi=i29dp2FvQT1JjPh+8j39Wn9iK3zw@mail.gmail.com' \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).