Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 520752 - sys-apps portage-2.2.12 date header in elog mail is localized
Summary: sys-apps portage-2.2.12 date header in elog mail is localized
Alias: None
Product: Portage Development
Classification: Unclassified
Component: Unclassified (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Portage team
Keywords: InVCS
Depends on:
Blocks: 484436
  Show dependency tree
Reported: 2014-08-24 09:40 UTC by Florent Bondoux
Modified: 2017-08-11 21:30 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---

Use email.utils.formatdate instead of time.strftime (portage-2.2.12-mail-date.diff,902 bytes, patch)
2014-08-24 09:40 UTC, Florent Bondoux
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Florent Bondoux 2014-08-24 09:40:23 UTC
Created attachment 383504 [details, diff]
Use email.utils.formatdate instead of time.strftime

Since portage-2.2.11, the date header in build summary emails is formatted with the system's locale.

Using email.utils.formatdate instead of strftime would produce a RFC-compliant date timestamp.

|[florent] ~ $ emerge --info portage
Portage 2.2.12 (python 3.3.5-final-0, default/linux/amd64/13.0/desktop/kde, gcc-4.7.3, glibc-2.19-r1, 3.12.21-gentoo-r1 x86_64)
                         System Settings
System uname: Linux-3.12.21-gentoo-r1-x86_64-Intel-R-_Core-TM-_i5_CPU_M_460_@_2.53GHz-with-gentoo-2.2
KiB Mem:     3911396 total,    865268 free
KiB Swap:    2047996 total,   1988240 free
Timestamp of tree: Sun, 24 Aug 2014 07:15:01 +0000
ld GNU ld (GNU Binutils) 2.23.2
distcc 3.1 x86_64-pc-linux-gnu [disabled]
app-shells/bash:          4.2_p45
dev-java/java-config:     2.2.0
dev-lang/python:          2.7.7, 3.3.5-r1
dev-util/pkgconfig:       0.28-r1
sys-apps/baselayout:      2.2
sys-apps/openrc:          0.12.4
sys-apps/sandbox:         2.6-r1
sys-devel/autoconf:       2.69
sys-devel/automake:       1.11.6, 1.12.6, 1.13.4
sys-devel/binutils:       2.23.2
sys-devel/gcc:            4.7.3-r1
sys-devel/gcc-config:     1.7.3
sys-devel/libtool:        2.4.2-r1
sys-devel/make:           3.82-r4
sys-kernel/linux-headers: 3.13 (virtual/os-headers)
sys-libs/glibc:           2.19-r1
Repositories: gentoo sunrise steam-overlay mrueg local myspell
CFLAGS="-march=native -O3 -pipe"
CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/themes/oxygen-gtk/gtk-2.0 /usr/share/themes/oxygen-gtk/gtk-3.0"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5.5/ext-active/ /etc/php/cgi-php5.5/ext-active/ /etc/php/cli-php5.5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/texmf/language.dat.d /etc/texmf/language.def.d /etc/texmf/updmap.d /etc/texmf/web2c"
CXXFLAGS="-march=native -O3 -pipe"
FCFLAGS="-O2 -pipe"
FEATURES="assume-digests binpkg-logs config-protect-if-modified distlocks ebuild-locks fixlafiles merge-sync news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg"                                                                                                    
FFLAGS="-march=native -O3 -pipe"                                                                                                                                                                
LDFLAGS="-Wl,-O1 -Wl,--as-needed"                                                                                                                                                               
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTDIR_OVERLAY="/var/lib/layman/sunrise /var/lib/layman/steam /var/lib/layman/mrueg /usr/local/portage /usr/local/myspell-overlay"
USE="X a52 aac acl acpi alsa amd64 apache2 bash-completion berkdb branding bzip2 cairo cdda cddb cdr cli consolekit cracklib crypt cryptsetup cups cxx dbus declarative djvu dri dts dvd dvdr emboss encode exif fam flac fortran gdbm gif git gpm gtk handbook iconv imlib ipv6 java java6 jpeg jpeg2k kde kipi lcms ldap libnotify mad matroska mmx mng modules mp3 mp4 mpeg multilib ncurses nls nptl ogg opengl openmp pam pango pcre pdf phonon plasma png policykit ppds qt3support qt4 raw readline samba sasl sdl semantic-desktop session spell sse sse2 ssl startup-notification subversion svg tcpd theora threads tiff truetype udev udisks unicode upower usb v4l vorbis wxwidgets x264 xcb xcomposite xinerama xml xscreensaver xv xvid zlib" ABI_X86="64" ALSA_CARDS="hda-intel" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias" CALLIGRA_FEATURES="kexi words flow plan sheets stage tables krita karbon braindump author" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev synaptics" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="fr" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3" QEMU_SOFTMMU_TARGETS="x86_64 i386 arm" QEMU_USER_TARGETS="x86_64 arm" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="vesa radeon r600" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account"

                        Package Settings

sys-apps/portage-2.2.12 was built with the following:
USE="(ipc) (policykit) -build -doc -epydoc (-pypy) -python2 -python3 (-selinux) -xattr" ABI_X86="64" LINGUAS="-ru" PYTHON_TARGETS="python2_7 python3_3 (-pypy) -python3_2 -python3_4"
Comment 1 Brian Dolbec gentoo-dev 2014-08-24 16:29:59 UTC
Yes, there was a change to make portage more localized for formatting.

Thank you for the patch.  We will look it over for inclusion in the next release.
Comment 2 tereutes 2014-08-29 22:38:43 UTC
This bug is very annoying.
I confirm the patch works
Comment 3 Brian Dolbec gentoo-dev 2014-09-11 23:08:33 UTC
A modified commit has been applied in 

Commit: 7204b87040edfcf0924f2d3647d5a00e1de7a170
Subject: portage/ Make email date, timestamp RFC-compliant Bug 520752

I also remved the no longer used time import, and wrapped the formatdate call with  a _unicode_encode()
Comment 4 Florent Bondoux 2014-09-12 19:57:31 UTC
(In reply to Brian Dolbec from comment #3)
> A modified commit has been applied in 
> Commit: 7204b87040edfcf0924f2d3647d5a00e1de7a170
> Subject: portage/ Make email date, timestamp RFC-compliant Bug 520752
> I also remved the no longer used time import, and wrapped the formatdate
> call with  a _unicode_encode()


I'm trying this version with _unicode_encode and I'm getting an error.

Error in portage.process.run_exitfuncs

  File "/usr/lib64/portage/pym/portage/", line 164, in run_exitfuncs
    func(*targs, **kargs)
  File "/usr/lib64/portage/pym/portage/elog/", line 47, in finalize
    _finalize(mysettings, items)
  File "/usr/lib64/portage/pym/portage/elog/", line 80, in _finalize
    portage.mail.send_mail(mysettings, mymessage)
  File "/usr/lib64/portage/pym/portage/", line 170, in send_mail
    message_str = _force_ascii_if_necessary(message.as_string())
  File "/usr/lib64/python3.3/email/", line 151, in as_string
    g.flatten(self, unixfrom=unixfrom)
  File "/usr/lib64/python3.3/email/", line 113, in flatten
  File "/usr/lib64/python3.3/email/", line 193, in _write
  File "/usr/lib64/python3.3/email/", line 220, in _write_headers
    self.write(self.policy.fold(h, v))
  File "/usr/lib64/python3.3/email/", line 314, in fold
    return self._fold(name, value, sanitize=True)
  File "/usr/lib64/python3.3/email/", line 352, in _fold
'bytes' object has no attribute 'encode'

$ emerge --version
Portage 2.2.12 (python 3.3.5-final-0, default/linux/amd64/13.0/desktop/kde, gcc-4.7.3, glibc-2.19-r1, 3.14.14-gentoo x86_64)
Comment 5 Zac Medico gentoo-dev 2014-09-12 21:04:50 UTC
It seems that the _unicode_encode call is unwanted here. All the other _unicode_encode calls in this function are conditional on sys.hexversion < 0x3000000, so that explains why it fails for you with python3.

So, I conclude that the attached patch does the job perfectly.
Comment 6 Zac Medico gentoo-dev 2014-09-12 21:28:01 UTC
It's fixed in git now:
Comment 7 Zac Medico gentoo-dev 2017-08-11 21:30:08 UTC
Fixed in 2.2.13.