← Back to team overview

touch-packages team mailing list archive

[Bug 1398033] Re: python breaks gdb

 

Hmm, it seems now the update system is also affected by the $PYTHONPATH environment variable setting -
with PYTHONPATH=/usr/lib/python2.7:/usr/local/lib/python2.7 :

$ apt-get dist-upgrade
fails with :

Fetched 41.2 MB in 15s (2,623 kB/s)                                            
(Reading database ... 552135 files and directories currently installed.)
Preparing to unpack .../python3-problem-report_2.14.1-0ubuntu3.6_all.deb ...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/usr/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax
Aborted
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/usr/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax
Aborted
dpkg: error processing archive /var/cache/apt/archives/python3-problem-report_2.14.1-0ubuntu3.6_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/usr/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax
Aborted
dpkg: error while cleaning up:
 subprocess installed post-installation script returned error exit status 134
Preparing to unpack .../python3-apport_2.14.1-0ubuntu3.6_all.deb ...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/usr/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax
Aborted
dpkg: warning: subprocess old pre-removal script returned error exit status 134
dpkg: trying script from the new package instead ...
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/usr/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax
Aborted
dpkg: error processing archive /var/cache/apt/archives/python3-apport_2.14.1-0ubuntu3.6_all.deb (--unpack):
 subprocess new pre-removal script returned error exit status 134
Fatal Python error: Py_Initialize: Unable to get the locale encoding
  File "/usr/lib/python2.7/encodings/__init__.py", line 123
    raise CodecRegistryError,\
                            ^
SyntaxError: invalid syntax
Aborted
dpkg: error while cleaning up:

I really think that tools such as gdb and dpkg should take care of managing critical environment variable settings 
like $PYTHONPATH if they intend to use python .
It is only because I knew of  this bug in advance that I did not spend ages determining the cause of the problem was $PYTHONPATH .
To solve this issue in the past, I did write a /usr/bin/python wrapper that , dependant on environment variable settings, would run 
either the i686 or x86_64 python binary of the required $PYTHON_VERSION .   I could attach this "C" program to this bug report if you want...

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to apport in Ubuntu.
https://bugs.launchpad.net/bugs/1398033

Title:
  python breaks gdb

Status in apport package in Ubuntu:
  Confirmed

Bug description:
  The gdb program fails with settings such as PYTHONPATH in the
  environment.

  I have no interest in using python or in using gdb to debug python
  programs .

  I want to use GDB to debug a normal GCC built executable,  yet these internal
  gdb python dependencies prevent me from doing so .

  GDB should be shipped without python support ;   python support should be an
  optional add-on sub-package for python programmers.

  I have to compile GDB without python support to overcome this problem.

  
  For instance, with a setting of PYTHONPATH=/usr/lib/python2.7:/usr/local/lib/python2.7/site-packages ,
  because I have some python packages installed in /usr/local/lib/python2.7/site-packages,  GDB refuses to initialize:
  $ export LANG=C
  $ export LC_ALL=POSIX
  $ gdb --args $MY_C_PROGRAMS_COMMAND_LINE
  Fatal Python error: Py_Initialize: Unable to get the locale encoding
    File "/usr/lib/python2.7/encodings/__init__.py", line 123
      raise CodecRegistryError,\
                              ^
  SyntaxError: invalid syntax
  Aborted

  The same python sickness infects ubuntu-bug :

  $ ubuntu-bug
  Fatal Python error: Py_Initialize: Unable to get the locale encoding
    File "/usr/lib/python2.7/encodings/__init__.py", line 123
      raise CodecRegistryError,\
                              ^
  SyntaxError: invalid syntax
  Aborted

  However, python and python programs run fine with my $PYTHONPATH
  setting - only gdb and ubuntu-bug do not .

  If I could, I'd remove python entirely from my system,  but I have to
  use a system set up by work which includes python .

  But I expect to be able to use GDB without python being installed ,
  and regardless of any environment variable setting .

  This problem obliges me to recompile gdb without python support and install it over the system gdb , which I have to do
  after each apt-get  'dist-upgrade' , or carefully remove gdb from the dist-upgrade every time.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/apport/+bug/1398033/+subscriptions


References