Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 268737 - dev-python/twisted-8.2.0 with python-2.6 gives 'DeprecationWarning' for modules 'md5' and 'sha'
Summary: dev-python/twisted-8.2.0 with python-2.6 gives 'DeprecationWarning' for modul...
Status: RESOLVED UPSTREAM
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
: 270400 (view as bug list)
Depends on:
Blocks: python-2.6
  Show dependency tree
 
Reported: 2009-05-05 17:08 UTC by rinus
Modified: 2009-08-28 17:35 UTC (History)
3 users (show)

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


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rinus 2009-05-05 17:08:32 UTC
When starting net-nntp/hellanzb, witch uses twisted, there are a couple of DeprecationWarning's.

I posted a patch for the hallanzb part in bug 262881.

It looks like upstream already fixed this.
http://twistedmatrix.com/trac/changeset/25457?format=diff&new=25457

Reproducible: Always

Steps to Reproduce:
1. /etc/init.d/hellanzb restart
Actual Results:  
* Starting hellanzb... [ ok ]
/usr/lib64/python2.6/site-packages/twisted/internet/_sslverify.py:5: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import itertools, md5
/usr/lib64/python2.6/site-packages/twisted/python/filepath.py:12: DeprecationWarning: the sha module is deprecated; use the hashlib module instead
  import sha

Expected Results:  
No warnings.

Portage 2.2_rc33 (default/linux/amd64/2008.0, gcc-4.3.3, glibc-2.9_p20081201-r2, 2.6.29-gentoo-r1 x86_64)
=================================================================
System uname: Linux-2.6.29-gentoo-r1-x86_64-Intel-R-_Pentium-R-_D_CPU_3.00GHz-with-gentoo-2.0.0
Timestamp of tree: Tue, 05 May 2009 14:30:02 +0000
distcc 3.1 x86_64-pc-linux-gnu [disabled]
ccache version 2.4 [disabled]
app-shells/bash:     4.0_p17-r1
dev-java/java-config: 2.1.7
dev-lang/python:     2.6.2
dev-python/pycrypto: 2.0.1-r8
dev-util/ccache:     2.4-r8
dev-util/cmake:      2.6.4
sys-apps/baselayout: 2.0.0
sys-apps/openrc:     0.4.3-r2
sys-apps/sandbox:    1.9
sys-devel/autoconf:  2.13, 2.63-r1
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10.2
sys-devel/binutils:  2.19.1-r1
sys-devel/gcc-config: 1.4.1
sys-devel/libtool:   2.2.6a
virtual/os-headers:  2.6.28-r1
ACCEPT_KEYWORDS="amd64 ~amd64"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-O2 -march=nocona -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/config /var/bind"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/env.d/java/ /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo /etc/udev/rules.d"
CXXFLAGS="-O2 -march=nocona -pipe"
DISTDIR="/usr/portage/distfiles"
EMERGE_DEFAULT_OPTS="--with-bdeps y"
FEATURES="collision-protect distlocks fixpackages parallel-fetch preserve-libs preserved-rebuild protect-owned sandbox sfperms strict unemerge-orphans unmerge-orphans userfetch"
GENTOO_MIRRORS="ftp://ftp.snt.utwente.nl/pub/os/linux/gentoo"
LANG="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
LDFLAGS="-Wl,-O1"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage/layman/vlegel /usr/local/portage/layman/trauma /usr/local/portage/layman/desktop-effects /usr/local/portage/layman/nouveau /usr/local/portage/layman/secondlife /usr/local/portage/layman/vmware /usr/local/portage/layman/sunrise /usr/local/portage"
SYNC="rsync://192.168.161.1/gentoo-portage"
USE="3dnow 3dnowext X X10 X509 Xaw3d a52 aac accessibility acl acpi additions ads aim alsa amd64 amr amrnb amrwb apache2 ares artworkextra asf async audiofile autoipd avahi ax25 bash-completion berkdb bluetooth bonjour bzip2 cairo calendar caps cddb cdparanoia cdr cgi clamav cli console consolekit cracklib crypt css cups curl curlwrappers dba dbus dga dirac directfb divx divx4linux dri dts dv dvb dvd dvdr dvdread eds emerald encode epiphany esd ethereal evo exif expat extrafilters fam fame fat fbcon ffmpeg fftw firefox flac flash foomaticdb freeimage freetts ftdi ftp fuse gadu garmin gb gcrypt gd gdbm ggi gif gimp git glib glitz glut gmp gnome gnome-keyring gnutls gpac gpg gphoto2 gpm gps groupwise gsm gstreamer gtk gtkhtml h323 hal hfs hpn ical iconv icq id3tag idn ieee1394 imagemagick imap imlib insecure-drivers ipv6 irrlicht iscsi isdnlog jabber jack java java6 javascript jce jfs joystick jpeg jpeg2k kde4 kerberos kodak krb4 kvm ladcca ladspa lame lcd lcms ldap libcaca libffi libnotify libsamplerate libssh2 lirc live lm_sensors logrotate logwatch lua lvm lzo mad matroska mbox mbrola mdnsresponder-compat meanwhile midi mikmod milter mime ming mjpeg mmap mmx mmxext mng modplug mono moonlight mozdevelop mp2 mp3 mp4 mp4live mpeg mplayer msn mudflap multilib musepack musicbrainz mysql mythtv nas ncurses nemesi netcdf network networkmanager nls nptl nptlonly nsplugin ntfs nuv nvidia offensive ogg openal openexr opengl openmp openssh openssl osc oscar oss pam parted pcap pcmcia pcntl pcre pda pdf pdo perl php pic pkcs11 png pnm portaudio posix postgres ppds pppd pulseaudio pvr python qemu qq qt3support qt4 quicktime radio radius rar rdesktop readline realmedia reflection reiser4 reiserfs rfkill rle rrdtool rt2400pci rt2500pci rt2500usb rt61pci rt73usb rtc rtsp samba sasl scanner schroedinger sdl serial server session sharedext sharedmem shorten shout silc skey slang slp smartcard smi sms sndfile snmp sockets sox speechd speex spell spl sqlite sqlite3 sse sse2 ssl stream streamzap subversion svg swat sysfs syslog tcltk tcpd teletext theora tidy tiff timidity tokenizer tordns transcode truetype udev unicode upnp usb userlocales v4l v4l2 vboxbfe vcd vdr vfat vhosts videos visualization vorbis wavpack wddx webkit wifi winbind wma wmf wmp wxwindows x264 xattr xcb xcomposite xerces-c xext xface xfs xine xml xml2 xorg xosd xpm xrandr xscreensaver xsl xulrunner xv xvid xvmc yahoo yv12 zephyr zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mmap_emul mulaw multi null plug rate route share shm softvol" APACHE2_MODULES="actions alias auth_basic auth_digest authn_anon authn_dbd authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache dav dav_fs dav_lock dbd deflate dir disk_cache env expires ext_filter file_cache filter headers ident imagemap include info log_config logio mem_cache mime mime_magic negotiation proxy proxy_ajp proxy_balancer proxy_connect proxy_http rewrite setenvif so speling status unique_id userdir usertrack vhost_alias" DVB_CARDS="bcm3510 dibusb-usb1 dibusb-usb2 nxt2002 nxt200x or51132 or51211 sp8870 sp887x ttpci ttusb-dec usb-a800 usb-bluebird usb-dib0700 usb-dtt200u usb-umt usb-vp702x usb-vp7045 usb-wt220u tda10045 tda10046" ELIBC="glibc" FOO2ZJS_DEVICES="hp1018" INPUT_DEVICES="keyboard mouse evdev joystick wacom" KERNEL="linux" LCD_DEVICES="ncurses hd44780 md8800 text xosd" LIRC_DEVICES="devinput" MYTHTV_OPTS="sasc budgetcard" USERLAND="GNU" VIDEO_CARDS="nv nvidia vesa fbdev v4l"
Unset:  CPPFLAGS, CTARGET, FFLAGS, INSTALL_MASK, LINGUAS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS
Comment 1 Mike Auty (RETIRED) gentoo-dev 2009-05-25 13:44:19 UTC
*** Bug 270400 has been marked as a duplicate of this bug. ***
Comment 2 Dirkjan Ochtman (RETIRED) gentoo-dev 2009-07-30 12:43:29 UTC
Looks like this should be fixed in twisted-8.2.0-r1. Can you verify?
Comment 3 Tom Flair 2009-07-30 23:39:47 UTC
(In reply to comment #2)
> Looks like this should be fixed in twisted-8.2.0-r1. Can you verify?
> 

I emerged twisted-8.2.0-r1, twisted-web-8.2.0 and hellanzb-0.13-r7 and still get the deprecated messages.

/usr/lib/python2.6/site-packages/twisted/internet/_sslverify.py:5: DeprecationWarning: the md5 module is deprecated; use hashlib instead
  import itertools, md5
Comment 4 TheUni 2009-08-02 00:09:40 UTC
Confirmed all around here. The hellanzb patch led me here.

Still get the md5 deprecation warning on:
/usr/lib64/python2.6/site-packages/twisted/internet/_sslverify.py

with twisted-8.2.0-r1
Comment 5 m_zwart 2009-08-26 15:28:54 UTC
While fixing this would be nice, the patch that was committed is terrible and really needs to be either fixed or removed. Here's what's wrong with it:

- As mentioned on this bug it does not actually fix the problem. It removes one import of the "md5" module and one import of the "sha" module, but leaves many more of them in place, including one in the _sslverify module which is almost always hit (t.i.ssl imports it, t.i.posixbase imports that, and most reactors are built on top of posixbase). And there are probably others that are frequently hit, I did not do a thorough search. Although I wonder why you picked these two imports to "fix"...

- The second of the two hunks introduces a bug. There are many ways to find out: 

  - You could read the patch, and if you understand basic python syntax you would understand replacing "import sha" with "from hashlib import sha1" can never be correct: either the new import must also be called "sha", or the original import was unused and should have been removed. No knowledge of the python stdlib or twisted's code is necessary.

  - You could test the affected code by hand: calling twisted.python.filepath._secureEnoughString directly now unsurprisingly raises a NameError. Testing it using public methods is slightly more work but not rocket science either: "filepath.FilePath('/tmp').temporarySibling()" suffices. Or use moveTo across partitions if you prefer.

  - You could test the code by running the test suite. Obviously the test suite was run before committing, since the commit message was "Fixed test failures wrt bug #190433. Changed to EAPI 2. Added patches for py26 deprecations". But apparently not *immediately* before committing, since four or so tests in twisted.test.test_paths.FilePathTestCase now fail.

- The first of the two hunks also introduces a bug. This is a more subtle one: you cannot find out by just reading the patch itself, unless you happen to know something about the stdlib modules involved (md5 and hashlib). Of course both testing the affected code by hand and running twisted's test suite still catch it: "AttributeError: 'builtin_function_or_method' object has no attribute 'new'".

The bug is that while the hashlib module replaces the md5 and sha modules the hashlib.md5 *function* does not replace the md5 *module*. Skimming the documentation for both modules or reading http://docs.python.org/whatsnew/2.5.html#the-hashlib-package would have told you that hashlib.md5 replaces md5.new.

Notice the same thing is true for sha: hashlib.sha replaces sha1.new, not the sha module.

Please revert this patch, since both hunks introduce errors while only fixing warnings, and the warnings are still triggered elsewhere. Please at least skim the hashlib, md5 and sha module documentation before attempting to get rid of the DeprecationWarnings again (getting rid of them is still a good idea! There are some cases where getting them is annoying, like when twisted is used through a cron script, with any stderr output mailed). Just picking likely looking names in the hashlib module when you're told "use hashlib instead" in the DeprecationWarning does not suffice, unfortunately.

Also note that while I keep mentioning tests above this does break "real" code too: dev-python/axiom uses temporarySibling when creating a new store. Axiom can only run on existing stores unless this patch is removed or fixed.
Comment 6 Arfrever Frehtes Taifersar Arahesis (RETIRED) gentoo-dev 2009-08-28 17:35:56 UTC
(In reply to comment #5)
> While fixing this would be nice, the patch that was committed is terrible and
> really needs to be either fixed or removed.

I agree :) . I removed this patch. Deprecation warnings are harmless, so we will wait for next release.