Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 577182 - dev-python/psycopg: psycopg2 aborts the Python runtime instead of raising TypeError on Python 3
Summary: dev-python/psycopg: psycopg2 aborts the Python runtime instead of raising Ty...
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal with 1 vote (vote)
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-03-12 17:24 UTC by Michal Petrucha
Modified: 2021-07-29 15:36 UTC (History)
2 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 Michal Petrucha 2016-03-12 17:24:09 UTC
The following command should raise a TypeError (assuming the current user can connect to a Postgres server with default parameters):

python3 -c 'import psycopg2; psycopg2.connect("").cursor().executemany("SELECT %s, %s", [(1, 2, 3)])'

Instead, with both dev-lang/python-3.3.5-r2, and dev-lang/python-3.4.3-r1, I get the following assertion error:

python3: psycopg/cursor_type.c:333: _psyco_curs_merge_query_args: Assertion `((((((PyObject*)(str))->ob_type))->tp_flags & ((1UL << 27))) != 0)' failed.
Aborted

On Python 2.7, this raises a TypeError as it should:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
TypeError: not all arguments converted during string formatting

I can reproduce the assertion error even inside a virtualenv, with any version of psycopg2 that supports Python 3. However, it does not happen with a vanilla build of Python from mercurial; in that case, I get the expected TypeError. I can, however, reproduce the assertion error with upstream Python built with --with-pydebug.

I have first reported this upstream to psycopg2 (https://github.com/psycopg/psycopg2/issues/414), but upon further inspection, it appears to be specific to Gentoo builds of Python 3.


Here's emerge --info:

Portage 2.2.26 (python 3.4.3-final-0, default/linux/amd64/13.0/desktop/kde, gcc-4.9.3, glibc-2.21-r2, 4.1.15-gentoo-r1 x86_64)
=================================================================
System uname: Linux-4.1.15-gentoo-r1-x86_64-Intel-R-_Core-TM-_i7-3610QM_CPU_@_2.30GHz-with-gentoo-2.2
KiB Mem:     8066760 total,    477352 free
KiB Swap:   10485752 total,   8558840 free
Timestamp of repository gentoo: Sat, 12 Mar 2016 14:15:01 +0000
sh bash 4.3_p42-r1
ld GNU ld (Gentoo 2.25.1 p1.1) 2.25.1
app-shells/bash:          4.3_p42-r1::gentoo
dev-java/java-config:     2.2.0::gentoo
dev-lang/perl:            5.20.2::gentoo
dev-lang/python:          2.7.10-r1::gentoo, 3.3.5-r2::gentoo, 3.4.3-r1::gentoo
dev-util/cmake:           3.3.1-r1::gentoo
dev-util/pkgconfig:       0.28-r2::gentoo
sys-apps/baselayout:      2.2::gentoo
sys-apps/openrc:          0.19.1::gentoo
sys-apps/sandbox:         2.10-r1::gentoo
sys-devel/autoconf:       2.13::gentoo, 2.69::gentoo
sys-devel/automake:       1.11.6-r1::gentoo, 1.14.1::gentoo, 1.15::gentoo
sys-devel/binutils:       2.25.1-r1::gentoo
sys-devel/gcc:            4.9.3::gentoo
sys-devel/gcc-config:     1.7.3::gentoo
sys-devel/libtool:        2.4.6::gentoo
sys-devel/make:           4.1-r1::gentoo
sys-kernel/linux-headers: 4.3::gentoo (virtual/os-headers)
sys-libs/glibc:           2.21-r2::gentoo
Repositories:

gentoo
    location: /usr/portage
    sync-type: rsync
    sync-uri: rsync://rsync.sk.gentoo.org/gentoo-portage
    priority: -1000

vlastne
    location: /usr/local/portage/vlastne
    masters: gentoo
    priority: 0

bumblebee
    location: /usr/local/portage/layman/bumblebee
    masters: gentoo
    priority: 1

steam-overlay
    location: /usr/local/portage/layman/steam-overlay
    masters: gentoo
    priority: 2

ACCEPT_KEYWORDS="amd64"
ACCEPT_LICENSE="* -@EULA PUEL dlj-1.1 ut2003 google-chrome googleearth Google-TOS AdobeFlash-10 AdobeFlash-10.1 AdobeFlash-10.3 AdobeFlash-11.x LOKI-EULA DOOM3 Oracle-BCLA-JavaSE skype-eula skype-4.0.0.7-copyright NVIDIA-CUDA Vivaldi"
CBUILD="x86_64-pc-linux-gnu"
CFLAGS="-march=native -O2 -pipe"
CHOST="x86_64-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/lib64/libreoffice/program/sofficerc /usr/share/alsa /usr/share/config /usr/share/gnupg/qualified.txt"
CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/dconf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /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 -O2 -pipe"
DISTDIR="/media/storage/distfiles"
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 splitdebug strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox u
sersync xattr"
FFLAGS="-O2 -pipe"
GENTOO_MIRRORS=" http://mirror.mdfnet.se/gentoo/ http://ftp.df.lth.se/pub/gentoo/ "
INSTALL_MASK="nvidia-modprobe"
LANG="en_US.UTF-8"
LDFLAGS="-Wl,-O1 -Wl,--as-needed"
MAKEOPTS="-j7"
PKGDIR="/usr/portage/packages"
PORTAGE_CONFIGROOT="/"
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"
PORTAGE_TMPDIR="/var/tmp"
USE="X a52 aac aalib acl acpi aes alsa amd64 ass avahi avx bash-completion berkdb bluetooth bluray bonjour branding bzip2 cairo cdda cdr chroma cli consolekit cracklib crypt cups cxx dbus declarative dirac dri dts dvb dvd dvdr emboss encode exif fam ffmpeg firefox flac fortran gdbm gif glamor gpm gtk iconv icu idn ieee1394 imagemagick ipv6 jpeg kde kdepim kipi lame laptop lastfm lcms ldap libass libcaca libnotify lm_sensors lzma mad matroska mmx mmxext mng modules mp3 mp4 mpeg mplayer mtp multilib musepack musicbrainz ncurses networkmanager nls nptl ogg opengl openmp pam pango pcre pdf phonon plasma png policykit popcnt ppds pulseaudio qt3support qt4 readline rtsp samba sdl seccomp session spell sse sse2 sse3 sse4_1 sse4_2 ssl ssse3 startup-notification svg tcpd theora threads tiff truetype udev udisks unicode upower usb v4l v4l2 vcd vim-syntax vorbis wifi win32codecs wxwidgets x264 x265 xattr xcb xcomposite xinerama xml xscreensaver xv xvid zeroconf zip zlib" ABI_X86="32 64" 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" 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="stage" CAMERAS="*" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" FOO2ZJS_DEVICES="km2200 km2300 km2430 km2480 km2490 km2530 kmcpwl lm500 oki3200 oki3300 oki3400 oki3530 oki5100 oki5200 oki5500 oki5600 oki5800 sa2160 sa300 sa315 sa3160 xp6110 xp6115" 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" GRUB_PLATFORMS="pc" INPUT_DEVICES="keyboard mouse evdev mutouch synaptics citron wacom" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en en_US sk" LIRC_DEVICES="all" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_3 python3_4 pypy pypy3" QEMU_USER_TARGETS="x86_64" RUBY_TARGETS="ruby20 ruby21" STEAMGAMES="trine2" USERLAND="GNU" VIDEO_CARDS="intel i915 i965 nvidia nouveau" 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"
Unset:  CC, CPPFLAGS, CTARGET, CXX, EMERGE_DEFAULT_OPTS, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS, PORTAGE_RSYNC_EXTRA_OPTS, USE_PYTHON
Comment 1 Pacho Ramos gentoo-dev 2016-03-14 16:02:52 UTC
What package is providing psycopg2 in your system?
Comment 2 Michal Petrucha 2016-03-14 16:16:32 UTC
I have dev-python/psycopg-2.5.3 installed as the system-wide package, but the assertion error also happens with any version of psycopg2 I pip-install into a virtualenv created using any system-installed version of Python 3.
Comment 3 Aaron W. Swenson gentoo-dev 2018-08-14 15:19:45 UTC
Does this issue persist?
Comment 4 Michal Petrucha 2018-08-14 15:56:10 UTC
I can't reproduce with 3.6.6 anymore, so I'll just close this.
Comment 5 WGH 2021-03-29 17:41:53 UTC
I can reproduce it with Python 3.8. The error message is a little bit different, though:

python3.8: psycopg/cursor_type.c:345: _psyco_curs_merge_query_args: Assertion `PyBytes_Check(str)' failed.
Comment 6 WGH 2021-07-29 15:36:42 UTC
Still have it as of Python 3.9