[Xfce4-commits] [bindings/thunarx-python] 01/01: Add support for building with python3

noreply at xfce.org noreply at xfce.org
Sat Dec 23 01:57:07 CET 2017


This is an automated email from the git hooks/post-receive script.

a   d   a   m   p   l   u   m   b       p   u   s   h   e   d       a       c   o   m   m   i   t       t   o       b   r   a   n   c   h       m   a   s   t   e   r   
   in repository bindings/thunarx-python.

commit 9522c19cb0f5eeb394f87eba650bf85c6403f997
Author: Adam Plumb <adamplumb at gmail.com>
Date:   Fri Dec 22 19:56:58 2017 -0500

    Add support for building with python3
---
 INSTALL                                  | 320 +++++++++++++++----------------
 NEWS                                     |   3 +
 README                                   |  11 +-
 configure.ac.in                          |  19 +-
 examples/thunarx-preferences-plugin.py   |   1 +
 examples/thunarx-property-page-plugin.py |  13 +-
 examples/thunarx-renamer-plugin.py       |   7 +-
 examples/thunarx-submenu-plugin.py       |   4 +-
 m4/python.m4                             | 228 ++++++++++++++++++----
 src/Makefile.am                          |  10 +-
 src/thunarx-python-object.c              |  51 ++++-
 src/thunarx-python.c                     |  39 ++--
 12 files changed, 460 insertions(+), 246 deletions(-)

diff --git a/INSTALL b/INSTALL
index 2099840..8865734 100644
--- a/INSTALL
+++ b/INSTALL
@@ -1,8 +1,8 @@
 Installation Instructions
 *************************
 
-Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation,
-Inc.
+   Copyright (C) 1994-1996, 1999-2002, 2004-2016 Free Software
+Foundation, Inc.
 
    Copying and distribution of this file, with or without modification,
 are permitted in any medium without royalty provided the copyright
@@ -12,97 +12,96 @@ without warranty of any kind.
 Basic Installation
 ==================
 
-   Briefly, the shell command `./configure && make && make install'
+   Briefly, the shell command './configure && make && make install'
 should configure, build, and install this package.  The following
-more-detailed instructions are generic; see the `README' file for
+more-detailed instructions are generic; see the 'README' file for
 instructions specific to this package.  Some packages provide this
-`INSTALL' file but do not implement all of the features documented
+'INSTALL' file but do not implement all of the features documented
 below.  The lack of an optional feature in a given package is not
 necessarily a bug.  More recommendations for GNU packages can be found
 in *note Makefile Conventions: (standards)Makefile Conventions.
 
-   The `configure' shell script attempts to guess correct values for
+   The 'configure' shell script attempts to guess correct values for
 various system-dependent variables used during compilation.  It uses
-those values to create a `Makefile' in each directory of the package.
-It may also create one or more `.h' files containing system-dependent
-definitions.  Finally, it creates a shell script `config.status' that
+those values to create a 'Makefile' in each directory of the package.
+It may also create one or more '.h' files containing system-dependent
+definitions.  Finally, it creates a shell script 'config.status' that
 you can run in the future to recreate the current configuration, and a
-file `config.log' containing compiler output (useful mainly for
-debugging `configure').
+file 'config.log' containing compiler output (useful mainly for
+debugging 'configure').
 
-   It can also use an optional file (typically called `config.cache'
-and enabled with `--cache-file=config.cache' or simply `-C') that saves
-the results of its tests to speed up reconfiguring.  Caching is
-disabled by default to prevent problems with accidental use of stale
-cache files.
+   It can also use an optional file (typically called 'config.cache' and
+enabled with '--cache-file=config.cache' or simply '-C') that saves the
+results of its tests to speed up reconfiguring.  Caching is disabled by
+default to prevent problems with accidental use of stale cache files.
 
    If you need to do unusual things to compile the package, please try
-to figure out how `configure' could check whether to do them, and mail
-diffs or instructions to the address given in the `README' so they can
+to figure out how 'configure' could check whether to do them, and mail
+diffs or instructions to the address given in the 'README' so they can
 be considered for the next release.  If you are using the cache, and at
-some point `config.cache' contains results you don't want to keep, you
+some point 'config.cache' contains results you don't want to keep, you
 may remove or edit it.
 
-   The file `configure.ac' (or `configure.in') is used to create
-`configure' by a program called `autoconf'.  You need `configure.ac' if
-you want to change it or regenerate `configure' using a newer version
-of `autoconf'.
+   The file 'configure.ac' (or 'configure.in') is used to create
+'configure' by a program called 'autoconf'.  You need 'configure.ac' if
+you want to change it or regenerate 'configure' using a newer version of
+'autoconf'.
 
    The simplest way to compile this package is:
 
-  1. `cd' to the directory containing the package's source code and type
-     `./configure' to configure the package for your system.
+  1. 'cd' to the directory containing the package's source code and type
+     './configure' to configure the package for your system.
 
-     Running `configure' might take a while.  While running, it prints
+     Running 'configure' might take a while.  While running, it prints
      some messages telling which features it is checking for.
 
-  2. Type `make' to compile the package.
+  2. Type 'make' to compile the package.
 
-  3. Optionally, type `make check' to run any self-tests that come with
+  3. Optionally, type 'make check' to run any self-tests that come with
      the package, generally using the just-built uninstalled binaries.
 
-  4. Type `make install' to install the programs and any data files and
+  4. Type 'make install' to install the programs and any data files and
      documentation.  When installing into a prefix owned by root, it is
      recommended that the package be configured and built as a regular
-     user, and only the `make install' phase executed with root
+     user, and only the 'make install' phase executed with root
      privileges.
 
-  5. Optionally, type `make installcheck' to repeat any self-tests, but
+  5. Optionally, type 'make installcheck' to repeat any self-tests, but
      this time using the binaries in their final installed location.
      This target does not install anything.  Running this target as a
-     regular user, particularly if the prior `make install' required
+     regular user, particularly if the prior 'make install' required
      root privileges, verifies that the installation completed
      correctly.
 
   6. You can remove the program binaries and object files from the
-     source code directory by typing `make clean'.  To also remove the
-     files that `configure' created (so you can compile the package for
-     a different kind of computer), type `make distclean'.  There is
-     also a `make maintainer-clean' target, but that is intended mainly
+     source code directory by typing 'make clean'.  To also remove the
+     files that 'configure' created (so you can compile the package for
+     a different kind of computer), type 'make distclean'.  There is
+     also a 'make maintainer-clean' target, but that is intended mainly
      for the package's developers.  If you use it, you may have to get
      all sorts of other programs in order to regenerate files that came
      with the distribution.
 
-  7. Often, you can also type `make uninstall' to remove the installed
+  7. Often, you can also type 'make uninstall' to remove the installed
      files again.  In practice, not all packages have tested that
      uninstallation works correctly, even though it is required by the
      GNU Coding Standards.
 
-  8. Some packages, particularly those that use Automake, provide `make
+  8. Some packages, particularly those that use Automake, provide 'make
      distcheck', which can by used by developers to test that all other
-     targets like `make install' and `make uninstall' work correctly.
+     targets like 'make install' and 'make uninstall' work correctly.
      This target is generally not run by end users.
 
 Compilers and Options
 =====================
 
    Some systems require unusual options for compilation or linking that
-the `configure' script does not know about.  Run `./configure --help'
+the 'configure' script does not know about.  Run './configure --help'
 for details on some of the pertinent environment variables.
 
-   You can give `configure' initial values for configuration parameters
-by setting variables in the command line or in the environment.  Here
-is an example:
+   You can give 'configure' initial values for configuration parameters
+by setting variables in the command line or in the environment.  Here is
+an example:
 
      ./configure CC=c99 CFLAGS=-g LIBS=-lposix
 
@@ -113,21 +112,21 @@ Compiling For Multiple Architectures
 
    You can compile the package for more than one kind of computer at the
 same time, by placing the object files for each architecture in their
-own directory.  To do this, you can use GNU `make'.  `cd' to the
+own directory.  To do this, you can use GNU 'make'.  'cd' to the
 directory where you want the object files and executables to go and run
-the `configure' script.  `configure' automatically checks for the
-source code in the directory that `configure' is in and in `..'.  This
-is known as a "VPATH" build.
+the 'configure' script.  'configure' automatically checks for the source
+code in the directory that 'configure' is in and in '..'.  This is known
+as a "VPATH" build.
 
-   With a non-GNU `make', it is safer to compile the package for one
+   With a non-GNU 'make', it is safer to compile the package for one
 architecture at a time in the source code directory.  After you have
-installed the package for one architecture, use `make distclean' before
+installed the package for one architecture, use 'make distclean' before
 reconfiguring for another architecture.
 
    On MacOS X 10.5 and later systems, you can create libraries and
 executables that work on multiple system types--known as "fat" or
-"universal" binaries--by specifying multiple `-arch' options to the
-compiler but only a single `-arch' option to the preprocessor.  Like
+"universal" binaries--by specifying multiple '-arch' options to the
+compiler but only a single '-arch' option to the preprocessor.  Like
 this:
 
      ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \
@@ -136,105 +135,104 @@ this:
 
    This is not guaranteed to produce working output in all cases, you
 may have to build one architecture at a time and combine the results
-using the `lipo' tool if you have problems.
+using the 'lipo' tool if you have problems.
 
 Installation Names
 ==================
 
-   By default, `make install' installs the package's commands under
-`/usr/local/bin', include files under `/usr/local/include', etc.  You
-can specify an installation prefix other than `/usr/local' by giving
-`configure' the option `--prefix=PREFIX', where PREFIX must be an
+   By default, 'make install' installs the package's commands under
+'/usr/local/bin', include files under '/usr/local/include', etc.  You
+can specify an installation prefix other than '/usr/local' by giving
+'configure' the option '--prefix=PREFIX', where PREFIX must be an
 absolute file name.
 
    You can specify separate installation prefixes for
 architecture-specific files and architecture-independent files.  If you
-pass the option `--exec-prefix=PREFIX' to `configure', the package uses
+pass the option '--exec-prefix=PREFIX' to 'configure', the package uses
 PREFIX as the prefix for installing programs and libraries.
 Documentation and other data files still use the regular prefix.
 
    In addition, if you use an unusual directory layout you can give
-options like `--bindir=DIR' to specify different values for particular
-kinds of files.  Run `configure --help' for a list of the directories
-you can set and what kinds of files go in them.  In general, the
-default for these options is expressed in terms of `${prefix}', so that
-specifying just `--prefix' will affect all of the other directory
+options like '--bindir=DIR' to specify different values for particular
+kinds of files.  Run 'configure --help' for a list of the directories
+you can set and what kinds of files go in them.  In general, the default
+for these options is expressed in terms of '${prefix}', so that
+specifying just '--prefix' will affect all of the other directory
 specifications that were not explicitly provided.
 
    The most portable way to affect installation locations is to pass the
-correct locations to `configure'; however, many packages provide one or
+correct locations to 'configure'; however, many packages provide one or
 both of the following shortcuts of passing variable assignments to the
-`make install' command line to change installation locations without
+'make install' command line to change installation locations without
 having to reconfigure or recompile.
 
    The first method involves providing an override variable for each
-affected directory.  For example, `make install
+affected directory.  For example, 'make install
 prefix=/alternate/directory' will choose an alternate location for all
 directory configuration variables that were expressed in terms of
-`${prefix}'.  Any directories that were specified during `configure',
-but not in terms of `${prefix}', must each be overridden at install
-time for the entire installation to be relocated.  The approach of
-makefile variable overrides for each directory variable is required by
-the GNU Coding Standards, and ideally causes no recompilation.
-However, some platforms have known limitations with the semantics of
-shared libraries that end up requiring recompilation when using this
-method, particularly noticeable in packages that use GNU Libtool.
-
-   The second method involves providing the `DESTDIR' variable.  For
-example, `make install DESTDIR=/alternate/directory' will prepend
-`/alternate/directory' before all installation names.  The approach of
-`DESTDIR' overrides is not required by the GNU Coding Standards, and
+'${prefix}'.  Any directories that were specified during 'configure',
+but not in terms of '${prefix}', must each be overridden at install time
+for the entire installation to be relocated.  The approach of makefile
+variable overrides for each directory variable is required by the GNU
+Coding Standards, and ideally causes no recompilation.  However, some
+platforms have known limitations with the semantics of shared libraries
+that end up requiring recompilation when using this method, particularly
+noticeable in packages that use GNU Libtool.
+
+   The second method involves providing the 'DESTDIR' variable.  For
+example, 'make install DESTDIR=/alternate/directory' will prepend
+'/alternate/directory' before all installation names.  The approach of
+'DESTDIR' overrides is not required by the GNU Coding Standards, and
 does not work on platforms that have drive letters.  On the other hand,
 it does better at avoiding recompilation issues, and works well even
-when some directory options were not specified in terms of `${prefix}'
-at `configure' time.
+when some directory options were not specified in terms of '${prefix}'
+at 'configure' time.
 
 Optional Features
 =================
 
    If the package supports it, you can cause programs to be installed
-with an extra prefix or suffix on their names by giving `configure' the
-option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
-
-   Some packages pay attention to `--enable-FEATURE' options to
-`configure', where FEATURE indicates an optional part of the package.
-They may also pay attention to `--with-PACKAGE' options, where PACKAGE
-is something like `gnu-as' or `x' (for the X Window System).  The
-`README' should mention any `--enable-' and `--with-' options that the
+with an extra prefix or suffix on their names by giving 'configure' the
+option '--program-prefix=PREFIX' or '--program-suffix=SUFFIX'.
+
+   Some packages pay attention to '--enable-FEATURE' options to
+'configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to '--with-PACKAGE' options, where PACKAGE
+is something like 'gnu-as' or 'x' (for the X Window System).  The
+'README' should mention any '--enable-' and '--with-' options that the
 package recognizes.
 
-   For packages that use the X Window System, `configure' can usually
+   For packages that use the X Window System, 'configure' can usually
 find the X include and library files automatically, but if it doesn't,
-you can use the `configure' options `--x-includes=DIR' and
-`--x-libraries=DIR' to specify their locations.
+you can use the 'configure' options '--x-includes=DIR' and
+'--x-libraries=DIR' to specify their locations.
 
    Some packages offer the ability to configure how verbose the
-execution of `make' will be.  For these packages, running `./configure
+execution of 'make' will be.  For these packages, running './configure
 --enable-silent-rules' sets the default to minimal output, which can be
-overridden with `make V=1'; while running `./configure
+overridden with 'make V=1'; while running './configure
 --disable-silent-rules' sets the default to verbose, which can be
-overridden with `make V=0'.
+overridden with 'make V=0'.
 
 Particular systems
 ==================
 
-   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU
-CC is not installed, it is recommended to use the following options in
+   On HP-UX, the default C compiler is not ANSI C compatible.  If GNU CC
+is not installed, it is recommended to use the following options in
 order to use an ANSI C compiler:
 
      ./configure CC="cc -Ae -D_XOPEN_SOURCE=500"
 
 and if that doesn't work, install pre-built binaries of GCC for HP-UX.
 
-   HP-UX `make' updates targets which have the same time stamps as
-their prerequisites, which makes it generally unusable when shipped
-generated files such as `configure' are involved.  Use GNU `make'
-instead.
+   HP-UX 'make' updates targets which have the same time stamps as their
+prerequisites, which makes it generally unusable when shipped generated
+files such as 'configure' are involved.  Use GNU 'make' instead.
 
    On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot
-parse its `<wchar.h>' header file.  The option `-nodtk' can be used as
-a workaround.  If GNU CC is not installed, it is therefore recommended
-to try
+parse its '<wchar.h>' header file.  The option '-nodtk' can be used as a
+workaround.  If GNU CC is not installed, it is therefore recommended to
+try
 
      ./configure CC="cc"
 
@@ -242,26 +240,26 @@ and if that doesn't work, try
 
      ./configure CC="cc -nodtk"
 
-   On Solaris, don't put `/usr/ucb' early in your `PATH'.  This
+   On Solaris, don't put '/usr/ucb' early in your 'PATH'.  This
 directory contains several dysfunctional programs; working variants of
-these programs are available in `/usr/bin'.  So, if you need `/usr/ucb'
-in your `PATH', put it _after_ `/usr/bin'.
+these programs are available in '/usr/bin'.  So, if you need '/usr/ucb'
+in your 'PATH', put it _after_ '/usr/bin'.
 
-   On Haiku, software installed for all users goes in `/boot/common',
-not `/usr/local'.  It is recommended to use the following options:
+   On Haiku, software installed for all users goes in '/boot/common',
+not '/usr/local'.  It is recommended to use the following options:
 
      ./configure --prefix=/boot/common
 
 Specifying the System Type
 ==========================
 
-   There may be some features `configure' cannot figure out
+   There may be some features 'configure' cannot figure out
 automatically, but needs to determine by the type of machine the package
 will run on.  Usually, assuming the package is built to be run on the
-_same_ architectures, `configure' can figure that out, but if it prints
+_same_ architectures, 'configure' can figure that out, but if it prints
 a message saying it cannot guess the machine type, give it the
-`--build=TYPE' option.  TYPE can either be a short name for the system
-type, such as `sun4', or a canonical name which has the form:
+'--build=TYPE' option.  TYPE can either be a short name for the system
+type, such as 'sun4', or a canonical name which has the form:
 
      CPU-COMPANY-SYSTEM
 
@@ -270,101 +268,101 @@ where SYSTEM can have one of these forms:
      OS
      KERNEL-OS
 
-   See the file `config.sub' for the possible values of each field.  If
-`config.sub' isn't included in this package, then this package doesn't
+   See the file 'config.sub' for the possible values of each field.  If
+'config.sub' isn't included in this package, then this package doesn't
 need to know the machine type.
 
    If you are _building_ compiler tools for cross-compiling, you should
-use the option `--target=TYPE' to select the type of system they will
+use the option '--target=TYPE' to select the type of system they will
 produce code for.
 
    If you want to _use_ a cross compiler, that generates code for a
 platform different from the build platform, you should specify the
 "host" platform (i.e., that on which the generated programs will
-eventually be run) with `--host=TYPE'.
+eventually be run) with '--host=TYPE'.
 
 Sharing Defaults
 ================
 
-   If you want to set default values for `configure' scripts to share,
-you can create a site shell script called `config.site' that gives
-default values for variables like `CC', `cache_file', and `prefix'.
-`configure' looks for `PREFIX/share/config.site' if it exists, then
-`PREFIX/etc/config.site' if it exists.  Or, you can set the
-`CONFIG_SITE' environment variable to the location of the site script.
-A warning: not all `configure' scripts look for a site script.
+   If you want to set default values for 'configure' scripts to share,
+you can create a site shell script called 'config.site' that gives
+default values for variables like 'CC', 'cache_file', and 'prefix'.
+'configure' looks for 'PREFIX/share/config.site' if it exists, then
+'PREFIX/etc/config.site' if it exists.  Or, you can set the
+'CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all 'configure' scripts look for a site script.
 
 Defining Variables
 ==================
 
    Variables not defined in a site shell script can be set in the
-environment passed to `configure'.  However, some packages may run
+environment passed to 'configure'.  However, some packages may run
 configure again during the build, and the customized values of these
 variables may be lost.  In order to avoid this problem, you should set
-them in the `configure' command line, using `VAR=value'.  For example:
+them in the 'configure' command line, using 'VAR=value'.  For example:
 
      ./configure CC=/usr/local2/bin/gcc
 
-causes the specified `gcc' to be used as the C compiler (unless it is
+causes the specified 'gcc' to be used as the C compiler (unless it is
 overridden in the site shell script).
 
-Unfortunately, this technique does not work for `CONFIG_SHELL' due to
-an Autoconf limitation.  Until the limitation is lifted, you can use
-this workaround:
+Unfortunately, this technique does not work for 'CONFIG_SHELL' due to an
+Autoconf limitation.  Until the limitation is lifted, you can use this
+workaround:
 
      CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash
 
-`configure' Invocation
+'configure' Invocation
 ======================
 
-   `configure' recognizes the following options to control how it
+   'configure' recognizes the following options to control how it
 operates.
 
-`--help'
-`-h'
-     Print a summary of all of the options to `configure', and exit.
+'--help'
+'-h'
+     Print a summary of all of the options to 'configure', and exit.
 
-`--help=short'
-`--help=recursive'
+'--help=short'
+'--help=recursive'
      Print a summary of the options unique to this package's
-     `configure', and exit.  The `short' variant lists options used
-     only in the top level, while the `recursive' variant lists options
-     also present in any nested packages.
+     'configure', and exit.  The 'short' variant lists options used only
+     in the top level, while the 'recursive' variant lists options also
+     present in any nested packages.
 
-`--version'
-`-V'
-     Print the version of Autoconf used to generate the `configure'
+'--version'
+'-V'
+     Print the version of Autoconf used to generate the 'configure'
      script, and exit.
 
-`--cache-file=FILE'
+'--cache-file=FILE'
      Enable the cache: use and save the results of the tests in FILE,
-     traditionally `config.cache'.  FILE defaults to `/dev/null' to
+     traditionally 'config.cache'.  FILE defaults to '/dev/null' to
      disable caching.
 
-`--config-cache'
-`-C'
-     Alias for `--cache-file=config.cache'.
+'--config-cache'
+'-C'
+     Alias for '--cache-file=config.cache'.
 
-`--quiet'
-`--silent'
-`-q'
+'--quiet'
+'--silent'
+'-q'
      Do not print messages saying which checks are being made.  To
-     suppress all normal output, redirect it to `/dev/null' (any error
+     suppress all normal output, redirect it to '/dev/null' (any error
      messages will still be shown).
 
-`--srcdir=DIR'
+'--srcdir=DIR'
      Look for the package's source code in directory DIR.  Usually
-     `configure' can determine that directory automatically.
+     'configure' can determine that directory automatically.
 
-`--prefix=DIR'
-     Use DIR as the installation prefix.  *note Installation Names::
-     for more details, including other options available for fine-tuning
-     the installation locations.
+'--prefix=DIR'
+     Use DIR as the installation prefix.  *note Installation Names:: for
+     more details, including other options available for fine-tuning the
+     installation locations.
 
-`--no-create'
-`-n'
+'--no-create'
+'-n'
      Run the configure checks, but stop before creating any output
      files.
 
-`configure' also accepts some other, not widely useful, options.  Run
-`configure --help' for more details.
+'configure' also accepts some other, not widely useful, options.  Run
+'configure --help' for more details.
diff --git a/NEWS b/NEWS
index 62b147f..2650a37 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,6 @@
+0.5.0:
+    - Updated to work with python3 or python2
+
 0.4.0:
    - Updated to work with Thunarx-3 which requires uses gobject introspection 
         and requires Gtk+3 and PyGObject3.
diff --git a/README b/README
index 217694d..a05018b 100644
--- a/README
+++ b/README
@@ -1,8 +1,13 @@
 Thunarx Python Bindings
 
-These bindings allow one to create python plugins for Thunar.  As of v0.4.0
-the thunarx-python bindings will only work with Gtk+3 and Thunar v1.7.  To use these 
-with Gtk+2, make sure to use thunarx-python v0.3.0.
+These bindings allow one to create python plugins for Thunar.
+
+As of v0.4.0 the thunarx-python bindings will only work with Gtk+3
+and Thunar v1.7.  To use these with Gtk+2, make sure to use thunarx-python v0.3.0.
+
+As of v0.5.0 the thunarx-python bindings can be built with either python3
+or python2 support.  The $PYTHON environment variable should be pointed
+at your preferred python executable before running configure or autogen.
 
 Install
 -----------
diff --git a/configure.ac.in b/configure.ac.in
index f942f85..76fd5a5 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -59,16 +59,12 @@ dnl **************************
 LT_PREREQ([2.4])
 LT_INIT([disable-static])
 
-
-dnl **************************************************
-dnl * Check for Python
-dnl **************************************************
-AM_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
-AM_CHECK_PYTHON_LIBS(,[AC_MSG_ERROR(could not find Python lib)])
-
 dnl Check for gtk-doc
 GTK_DOC_CHECK(1.14)
 
+PYG_CHECK_PYTHON_HEADERS(,[AC_MSG_ERROR(could not find Python headers)])
+PYG_CHECK_PYTHON_LIBS(,[AC_MSG_ERROR(could not find Python lib)])
+
 dnl ***************************
 dnl *** Determine the installed thunarx version ***
 dnl ***************************
@@ -86,14 +82,6 @@ else
 fi
 AC_SUBST(THUNARX_API_VERSION)
 
-PYTHON_CFLAGS="`python-config --includes`"
-PYTHON_LIBS="`python-config --libs`"
-PYTHON_LDFLAGS="`python-config --ldflags`"
-
-AC_SUBST(PYTHON_CFLAGS)
-AC_SUBST(PYTHON_LIBS)
-AC_SUBST(PYTHON_LDFLAGS)
-
 THUNARX_LIBDIR=`pkg-config --variable=libdir thunarx-${THUNARX_API_VERSION}`
 AC_SUBST(THUNARX_LIBDIR)
 AC_DEFINE_UNQUOTED(THUNARX_LIBDIR, "$THUNARX_LIBDIR", [Thunarx libdir])
@@ -145,4 +133,5 @@ echo
 
 echo "      Prefix: $prefix"
 echo "      Documentation: ${enable_gtk_doc}"
+echo "      Python Version: ${PYTHON_LIB_NAME}"
 echo
diff --git a/examples/thunarx-preferences-plugin.py b/examples/thunarx-preferences-plugin.py
index 30868c1..9a667dc 100644
--- a/examples/thunarx-preferences-plugin.py
+++ b/examples/thunarx-preferences-plugin.py
@@ -7,6 +7,7 @@ class DialogExample(Gtk.Dialog):
              Gtk.STOCK_OK, Gtk.ResponseType.OK))
 
         self.set_default_size(150, 100)
+        self.set_transient_for(parent)
 
         label = Gtk.Label("This is a dialog to display additional information")
 
diff --git a/examples/thunarx-property-page-plugin.py b/examples/thunarx-property-page-plugin.py
index 5a15cf2..bb1a55c 100644
--- a/examples/thunarx-property-page-plugin.py
+++ b/examples/thunarx-property-page-plugin.py
@@ -1,5 +1,10 @@
 import hashlib
-import urllib
+
+# A way to get unquote working with python 2 and 3
+try:
+    from urllib import unquote
+except ImportError:
+    from urllib.parse import unquote
 
 from gi.repository import GObject, Gtk, Thunarx
 
@@ -17,8 +22,8 @@ class ThunarxPropertyPagePlugin(GObject.GObject, Thunarx.PropertyPageProvider):
 
         if file.is_directory():
             return
-
-        filename = urllib.unquote(file.get_uri()[7:])
+        
+        filename = unquote(file.get_uri()[7:])
 
         hbox = Gtk.HBox(0, False)
         hbox.show()
@@ -30,7 +35,7 @@ class ThunarxPropertyPagePlugin(GObject.GObject, Thunarx.PropertyPageProvider):
         value_label = Gtk.Label()
         hbox.pack_start(value_label, True, True, 0)
 
-        md5sum = hashlib.md5(filename).hexdigest()
+        md5sum = hashlib.md5(filename.encode("utf-8")).hexdigest()
         value_label.set_text(md5sum)
         value_label.show()
 
diff --git a/examples/thunarx-renamer-plugin.py b/examples/thunarx-renamer-plugin.py
index 9c3be64..4974d6a 100644
--- a/examples/thunarx-renamer-plugin.py
+++ b/examples/thunarx-renamer-plugin.py
@@ -27,7 +27,11 @@ class ThunarxPythonRenamer(Thunarx.Renamer):
         self.entry.show()
         self.add(hbox)
         hbox.show()
-    
+
+    def do_process(self, file, text, index):
+        prefix = self.entry.get_text()
+        return prefix + text
+
     def entry_changed(self, widget):
         self.set_property("prefix", widget.get_text())
         
@@ -35,7 +39,6 @@ class ThunarxPythonRenamer(Thunarx.Renamer):
         self.emit("changed")
 
     def do_get_menu_items(self, window, files):
-        print "python get menu items"
         return [Thunarx.MenuItem(name="TPR:SomeAction", label="Some Action", tooltip=None, icon=Gtk.STOCK_OPEN)]
 
     def do_load(self, settings):
diff --git a/examples/thunarx-submenu-plugin.py b/examples/thunarx-submenu-plugin.py
index 1f7a6ec..c41ec8a 100644
--- a/examples/thunarx-submenu-plugin.py
+++ b/examples/thunarx-submenu-plugin.py
@@ -32,7 +32,7 @@ class ThunarxSubMenuProviderPlugin(GObject.GObject, Thunarx.MenuProvider):
         return item,item2
 
     def __subitem1_callback(self, item, window):
-        print "Subitem1 call"
+        print("Subitem1 call")
         
     def __subitem2_callback(self, item, window):
-        print "Subitem2 call"
+        print("Subitem2 call")
diff --git a/m4/python.m4 b/m4/python.m4
index 27d3ab0..ebacfb2 100644
--- a/m4/python.m4
+++ b/m4/python.m4
@@ -1,7 +1,7 @@
 ## this one is commonly used with AM_PATH_PYTHONDIR ...
-dnl AM_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
+dnl PYG_CHECK_PYMOD(MODNAME [,SYMBOL [,ACTION-IF-FOUND [,ACTION-IF-NOT-FOUND]]])
 dnl Check if a module containing a given symbol is visible to python.
-AC_DEFUN(AM_CHECK_PYMOD,
+AC_DEFUN([PYG_CHECK_PYMOD],
 [AC_REQUIRE([AM_PATH_PYTHON])
 py_mod_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
 AC_MSG_CHECKING(for ifelse([$2],[],,[$2 in ])python module $1)
@@ -36,30 +36,6 @@ else
 fi
 ])
 
-dnl a macro to check for ability to create python extensions
-dnl  AM_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
-dnl function also defines PYTHON_INCLUDES
-AC_DEFUN([AM_CHECK_PYTHON_HEADERS],
-[AC_REQUIRE([AM_PATH_PYTHON])
-AC_MSG_CHECKING(for headers required to compile python extensions)
-dnl deduce PYTHON_INCLUDES
-py_prefix=`$PYTHON -c "import sys; print(sys.prefix)"`
-py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
-PYTHON_INCLUDES="-I${py_prefix}/include/python${PYTHON_VERSION}"
-if test "$py_prefix" != "$py_exec_prefix"; then
-  PYTHON_INCLUDES="$PYTHON_INCLUDES -I${py_exec_prefix}/include/python${PYTHON_VERSION}"
-fi
-AC_SUBST(PYTHON_INCLUDES)
-dnl check if the headers exist:
-save_CPPFLAGS="$CPPFLAGS"
-CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
-AC_TRY_CPP([#include <Python.h>],dnl
-[AC_MSG_RESULT(found)
-$1],dnl
-[AC_MSG_RESULT(not found)
-$2])
-CPPFLAGS="$save_CPPFLAGS"
-])
 
 # The AC_MULTILIB macro was extracted and modified from
 # gettext-0.15's AC_LIB_PREPARE_MULTILIB macro in the lib-prefix.m4 file
@@ -121,25 +97,67 @@ AC_DEFUN([AC_MULTILIB],
   AC_SUBST(libdirsuffix)
 ])
 
+dnl a macro to check for ability to create python extensions
+dnl  PYG_CHECK_PYTHON_HEADERS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
+dnl function also defines PYTHON_INCLUDES
+AC_DEFUN([PYG_CHECK_PYTHON_HEADERS],
+[AC_REQUIRE([AM_PATH_PYTHON])
+AC_MSG_CHECKING(for headers required to compile python extensions)
+dnl deduce PYTHON_INCLUDES
+AC_MULTILIB(yes)
+if test "x$PYTHON_INCLUDES" = x; then
+  PYTHON_CONFIG=`which $PYTHON`-config
+  if test -x "$PYTHON_CONFIG"; then
+    PYTHON_INCLUDES=`$PYTHON_CONFIG --includes 2>/dev/null`
+  else
+    PYTHON_INCLUDES=`$PYTHON -c "import distutils.sysconfig, sys; sys.stdout.write(distutils.sysconfig.get_python_inc(True))"`
+    PYTHON_INCLUDES="-I$PYTHON_INCLUDES"
+  fi
+fi
+AC_SUBST(PYTHON_INCLUDES)
+AC_SUBST(PYTHON_LIB_NAME)
+dnl check if the headers exist:
+save_CPPFLAGS="$CPPFLAGS"
+CPPFLAGS="$CPPFLAGS $PYTHON_INCLUDES"
+AC_TRY_CPP([#include <Python.h>],dnl
+[AC_MSG_RESULT(found)
+$1],dnl
+[AC_MSG_RESULT(not found)
+$2])
+CPPFLAGS="$save_CPPFLAGS"
+])
+
 dnl a macro to check for ability to embed python
-dnl  AM_CHECK_PYTHON_LIBS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
+dnl  PYG_CHECK_PYTHON_LIBS([ACTION-IF-POSSIBLE], [ACTION-IF-NOT-POSSIBLE])
 dnl function also defines PYTHON_LIBS
-AC_DEFUN([AM_CHECK_PYTHON_LIBS],
-[AC_REQUIRE([AM_CHECK_PYTHON_HEADERS])
+AC_DEFUN([PYG_CHECK_PYTHON_LIBS],
+[AC_REQUIRE([AM_PATH_PYTHON])
 AC_MSG_CHECKING(for libraries required to embed python)
 dnl deduce PYTHON_LIBS
-py_exec_prefix=`$PYTHON -c "import sys; print(sys.exec_prefix)"`
-AC_MULTILIB(yes)
-
+py_prefix=`$PYTHON -c "import sys; sys.stdout.write(sys.prefix)"`
+py_include_path=`$PYTHON -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())"`
+py_lib_name=`basename $py_include_path`
 if test "x$PYTHON_LIBS" = x; then
-	PYTHON_LIBS="-L${py_prefix}/lib${libdirsuffix} -lpython${PYTHON_VERSION}"
+  PYTHON_CONFIG=`which $PYTHON`-config
+  if test -x "$PYTHON_CONFIG"; then
+    PYTHON_LIBS=`$PYTHON_CONFIG --ldflags 2>/dev/null`
+  else
+    PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}"
+  fi
 fi
+AC_SUBST(PYTHON_LIBS)
 
 if test "x$PYTHON_LIB_LOC" = x; then
 	PYTHON_LIB_LOC="${py_prefix}/lib${libdirsuffix}" 
 fi
-AC_SUBST(PYTHON_LIBS)
+
+if test "x$PYTHON_LIB_NAME" = x; then
+  PYTHON_LIB_NAME=$py_lib_name
+fi
+
 AC_SUBST(PYTHON_LIB_LOC)
+AC_SUBST(PYTHON_LIB_NAME)
+
 dnl check if the headers exist:
 save_LIBS="$LIBS"
 LIBS="$LIBS $PYTHON_LIBS"
@@ -148,3 +166,145 @@ AC_TRY_LINK_FUNC(Py_Initialize, dnl
          [LIBS="$save_LIBS"; AC_MSG_RESULT(no); $2])
 
 ])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+#
+# This file is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# JD_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# ---------------------------------------------------------------------------
+# Adds support for distributing Python modules and packages.  To
+# install modules, copy them to $(pythondir), using the python_PYTHON
+# automake variable.  To install a package with the same name as the
+# automake package, install to $(pkgpythondir), or use the
+# pkgpython_PYTHON automake variable.
+#
+# The variables $(pyexecdir) and $(pkgpyexecdir) are provided as
+# locations to install python extension modules (shared libraries).
+# Another macro is required to find the appropriate flags to compile
+# extension modules.
+#
+# If your package is configured with a different prefix to python,
+# users will have to add the install directory to the PYTHONPATH
+# environment variable, or create a .pth file (see the python
+# documentation for details).
+#
+# If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will
+# cause an error if the version of python installed on the system
+# doesn't meet the requirement.  MINIMUM-VERSION should consist of
+# numbers and dots only.
+AC_DEFUN([JD_PATH_PYTHON],
+ [
+  dnl Find a Python interpreter.  Python versions prior to 2.0 are not
+  dnl supported
+  m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
+                    [python3 python3.3 python3.2 python3.1 python2 python2.7 python])
+
+  m4_if([$1],[],[
+    dnl No version check is needed.
+    # Find any Python interpreter.
+    if test -z "$PYTHON"; then
+      AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :)
+    fi
+    am_display_PYTHON=python
+  ], [
+    dnl A version check is needed.
+    if test -n "$PYTHON"; then
+      # If the user set $PYTHON, use it and don't search something else.
+      AC_MSG_CHECKING([whether $PYTHON version >= $1])
+      AM_PYTHON_CHECK_VERSION([$PYTHON], [$1],
+			      [AC_MSG_RESULT(yes)],
+			      [AC_MSG_ERROR(too old)])
+      am_display_PYTHON=$PYTHON
+    else
+      # Otherwise, try each interpreter until we find one that satisfies
+      # VERSION.
+      AC_CACHE_CHECK([for a Python interpreter with version >= $1],
+	[am_cv_pathless_PYTHON],[
+	for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do
+	  test "$am_cv_pathless_PYTHON" = none && break
+	  AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break])
+	done])
+      # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON.
+      if test "$am_cv_pathless_PYTHON" = none; then
+	PYTHON=:
+      else
+        AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON])
+      fi
+      am_display_PYTHON=$am_cv_pathless_PYTHON
+    fi
+  ])
+
+  if test "$PYTHON" = :; then
+  dnl Run any user-specified action, or abort.
+    m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])])
+  else
+
+  dnl Query Python for its version number.  Getting [:3] seems to be
+  dnl the best way to do this; it's what "site.py" does in the standard
+  dnl library.
+
+  AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version],
+    [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`])
+  AC_SUBST([PYTHON_VERSION], [$am_cv_python_version])
+
+  dnl Use the values of $prefix and $exec_prefix for the corresponding
+  dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX.  These are made
+  dnl distinct variables so they can be overridden if need be.  However,
+  dnl general consensus is that you shouldn't need this ability.
+
+  AC_SUBST([PYTHON_PREFIX], ['${prefix}'])
+  AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}'])
+
+  dnl At times (like when building shared libraries) you may want
+  dnl to know which OS platform Python thinks this is.
+
+  AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform],
+    [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`])
+  AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform])
+
+
+  dnl Set up 4 directories:
+
+  dnl pythondir -- where to install python scripts.  This is the
+  dnl   site-packages directory, not the python standard library
+  dnl   directory like in previous automake betas.  This behavior
+  dnl   is more consistent with lispdir.m4 for example.
+  dnl Query distutils for this directory.  distutils does not exist in
+  dnl Python 1.5, so we fall back to the hardcoded directory if it
+  dnl doesn't work.
+  AC_CACHE_CHECK([for $am_display_PYTHON script directory],
+    [am_cv_python_pythondir],
+    [am_cv_python_pythondir=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib(0,0,prefix='$PYTHON_PREFIX'))" 2>/dev/null ||
+     echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"`])
+  AC_SUBST([pythondir], [$am_cv_python_pythondir])
+
+  dnl pkgpythondir -- $PACKAGE directory under pythondir.  Was
+  dnl   PYTHON_SITE_PACKAGE in previous betas, but this naming is
+  dnl   more consistent with the rest of automake.
+
+  AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE])
+
+  dnl pyexecdir -- directory for installing python extension modules
+  dnl   (shared libraries)
+  dnl Query distutils for this directory.  distutils does not exist in
+  dnl Python 1.5, so we fall back to the hardcoded directory if it
+  dnl doesn't work.
+  AC_CACHE_CHECK([for $am_display_PYTHON extension module directory],
+    [am_cv_python_pyexecdir],
+    [am_cv_python_pyexecdir=`$PYTHON -c "from distutils import sysconfig; print(sysconfig.get_python_lib(1,0,prefix='$PYTHON_EXEC_PREFIX'))" 2>/dev/null ||
+     echo "${PYTHON_EXEC_PREFIX}/lib/python${PYTHON_VERSION}/site-packages"`])
+  AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir])
+
+  dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE)
+
+  AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE])
+
+  dnl Run any user-specified action.
+  $2
+  fi
+
+])
diff --git a/src/Makefile.am b/src/Makefile.am
index 53c72c3..df0bf0e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,8 +6,7 @@ AM_CPPFLAGS =								\
 	-DEXO_API_SUBJECT_TO_CHANGE					\
 	-DLIBEXECDIR=\"$(libexecdir)\"					\
 	-DPY_LIB_LOC=\"$(PYTHON_LIB_LOC)\"				\
-	-DPYTHON_VERSION=\"$(PYTHON_VERSION)\"				\
-	$(THUNARX_PYTHON_CFLAGS)					\
+	-DPYTHON_LIB_NAME=\"$(PYTHON_LIB_NAME)\"				\
 	-DTHUNARX_API_VERSION=$(THUNARX_API_VERSION) \
 	-DGI_TYPELIB_PATH=\"$(libdir)/girepository-1.0\"
 
@@ -25,6 +24,7 @@ thunarx_python_la_SOURCES =						\
 thunarx_python_la_CFLAGS =						\
 	$(THUNARX_CFLAGS)						\
 	$(PYTHON_CFLAGS)						\
+	$(PYTHON_INCLUDES)						\
 	$(PYGOBJECT_CFLAGS)							
 
 thunarx_python_la_LDFLAGS =						\
@@ -35,6 +35,6 @@ thunarx_python_la_LDFLAGS =						\
 	$(PYGOBJECT_CFLAGS)						
 
 thunarx_python_la_LIBADD =						\
-	$(THUNARX_CFLAGS)						\
-	$(PYTHON_CFLAGS)						\
-	$(PYGOBJECT_CFLAGS)						
+	$(THUNARX_LIBS)						\
+	$(PYTHON_LIBS)						\
+	$(PYGOBJECT_LIBS)						
diff --git a/src/thunarx-python-object.c b/src/thunarx-python-object.c
index b2e4b0c..d7758a6 100644
--- a/src/thunarx-python-object.c
+++ b/src/thunarx-python-object.c
@@ -72,6 +72,22 @@ static GList *thunarx_python_object_get_renamers                (ThunarxRenamerP
  *   the return value is called ret
  */
 
+int __PyString_Check(PyObject *obj) {
+#if PY_MAJOR_VERSION >= 3
+    return PyUnicode_Check(obj);
+#else
+    return PyString_Check(obj);
+#endif
+}
+
+char* __PyString_AsString(PyObject *obj) {
+#if PY_MAJOR_VERSION >= 3
+    return PyUnicode_AsUTF8(obj);
+#else
+    return PyString_AsString(obj);
+#endif
+}
+
 #define CHECK_METHOD_NAME(self)                                             \
 	if (!PyObject_HasAttrString(self, METHOD_NAME))                         \
 		goto beach;
@@ -107,7 +123,7 @@ static GList *thunarx_python_object_get_renamers                (ThunarxRenamerP
 #define HANDLE_LIST(py_ret, type, type_name)                                \
     {                                                                       \
         Py_ssize_t i = 0;                                                   \
-    	if (!PySequence_Check(py_ret) || PyString_Check(py_ret))            \
+    	if (!PySequence_Check(py_ret) || __PyString_Check(py_ret))            \
     	{                                                                   \
     		PyErr_SetString(PyExc_TypeError,                                \
     						METHOD_NAME " must return a sequence");         \
@@ -157,6 +173,10 @@ thunarx_python_object_get_file_menu_items (ThunarxMenuProvider *provider,
     HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
 
 beach:
+    if (PyErr_Occurred()) {
+	PyErr_Print();
+    }
+    
     Py_XDECREF(py_ret);
     pyg_gil_state_release(state);
     return ret;
@@ -191,6 +211,10 @@ thunarx_python_object_get_folder_menu_items (ThunarxMenuProvider   *provider,
     HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
 	
 beach:
+    if (PyErr_Occurred()) {
+	PyErr_Print();
+    }
+    
     Py_XDECREF(py_ret);
     pyg_gil_state_release(state);
     return ret;
@@ -229,6 +253,10 @@ thunarx_python_object_get_dnd_menu_items (ThunarxMenuProvider  *provider,
     HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
 
 beach:
+    if (PyErr_Occurred()) {
+	PyErr_Print();
+    }
+    
     Py_XDECREF(py_ret);
     pyg_gil_state_release(state);
     return ret;
@@ -269,9 +297,13 @@ thunarx_python_object_get_property_pages (ThunarxPropertyPageProvider *provider,
 
     HANDLE_RETVAL(py_ret);
 
-    HANDLE_LIST(py_ret, ThunarxPropertyPage, "thunarx.PropertyPage");
+    HANDLE_LIST(py_ret, ThunarxPropertyPage, "Thunarx.PropertyPage");
 	
 beach:
+    if (PyErr_Occurred()) {
+	PyErr_Print();
+    }
+    
     Py_XDECREF(py_ret);
     pyg_gil_state_release(state);
     return ret;
@@ -298,9 +330,13 @@ thunarx_python_object_get_renamers (ThunarxRenamerProvider *provider)
 
     HANDLE_RETVAL(py_ret);
 
-    HANDLE_LIST(py_ret, ThunarxRenamer, "thunarx.Renamer");
+    HANDLE_LIST(py_ret, ThunarxRenamer, "Thunarx.Renamer");
 
 beach:
+    if (PyErr_Occurred()) {
+	PyErr_Print();
+    }
+    
     Py_XDECREF(py_ret);
     pyg_gil_state_release(state);
     return ret;
@@ -348,6 +384,10 @@ thunarx_python_object_get_preferences_menu_items (ThunarxPreferencesProvider *pr
     HANDLE_LIST(py_ret, ThunarxMenuItem, "Thunarx.MenuItem");
 	
 beach:
+    if (PyErr_Occurred()) {
+	PyErr_Print();
+    }
+    
     Py_XDECREF(py_ret);
     pyg_gil_state_release(state);
     return ret;
@@ -433,7 +473,8 @@ thunarx_python_object_get_type (ThunarxProviderPlugin   *plugin,
 		NULL
 	};
 
-	debug_enter_args("type=%s", PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+	debug_enter_args("type=%s", __PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+
 	info = g_new0 (GTypeInfo, 1);
 	
 	info->class_size = sizeof (ThunarxPythonObjectClass);
@@ -445,7 +486,7 @@ thunarx_python_object_get_type (ThunarxProviderPlugin   *plugin,
 	Py_INCREF(type);
 
 	type_name = g_strdup_printf("%s+ThunarxPython",
-								PyString_AsString(PyObject_GetAttrString(type, "__name__")));
+	    __PyString_AsString(PyObject_GetAttrString(type, "__name__")));
 
 	gtype = thunarx_provider_plugin_register_type (plugin, 
 										 G_TYPE_OBJECT,
diff --git a/src/thunarx-python.c b/src/thunarx-python.c
index a06dc1f..1662814 100644
--- a/src/thunarx-python.c
+++ b/src/thunarx-python.c
@@ -48,7 +48,7 @@ static gboolean thunarx_python_init_python (void);
 static inline gboolean 
 thunarx_python_init_pygobject(void)
 {
-    PyObject *gobject = pygobject_init (3, 0, 0);
+	PyObject *gobject = pygobject_init (3, 0, 0);
 
     if (gobject == NULL) {
         PyErr_Print ();
@@ -63,23 +63,23 @@ static gboolean
 thunarx_python_init_python (void)
 {
 	PyObject *thunarx;
-    GModule *libpython;
-    char *argv[] = { "thunarx", NULL };
+	GModule *libpython;
 
     debug_enter();
 
     if (Py_IsInitialized())
         return TRUE;
     
-    debug("Setting GI_TYPELIB_PATH to " GI_TYPELIB_PATH); 
+    debug("Setting GI_TYPELIB_PATH to " GI_TYPELIB_PATH);
     gchar *typelib_env = g_strdup_printf("GI_TYPELIB_PATH=$GI_TYPELIB_PATH:%s", GI_TYPELIB_PATH);
     putenv(typelib_env);
 
-    debug ("g_module_open " PY_LIB_LOC "/libpython" PYTHON_VERSION "." G_MODULE_SUFFIX ".1.0");  
-    libpython = g_module_open (PY_LIB_LOC "/libpython" PYTHON_VERSION "." G_MODULE_SUFFIX ".1.0", 0);
-    if (!libpython)
+    debug ("g_module_open " PY_LIB_LOC "/lib" PYTHON_LIB_NAME "." G_MODULE_SUFFIX ".1.0");  
+    libpython = g_module_open (PY_LIB_LOC "/lib" PYTHON_LIB_NAME "." G_MODULE_SUFFIX ".1.0", 0);
+    if (!libpython) {
         g_warning ("g_module_open libpython failed: %s", g_module_error());
-  
+	}
+
     debug ("Py_Initialize");
     Py_Initialize();
     if (PyErr_Occurred())
@@ -89,6 +89,11 @@ thunarx_python_init_python (void)
     }
 
     debug ("PySys_SetArgv");
+#if PY_MAJOR_VERSION >= 3
+    wchar_t *argv[] = { L"thunar", NULL };
+#else
+    char *argv[] = { "thunar", NULL };
+#endif
     PySys_SetArgv (1, argv);
     if (PyErr_Occurred())
     {
@@ -96,12 +101,13 @@ thunarx_python_init_python (void)
         return FALSE;
     }
 
-    debug ("Sanitizing python sys.path");
-    PyRun_SimpleString("import sys; sys.path = filter(None, sys.path)");
-    if (PyErr_Occurred()) {
-	    PyErr_Print();
-	    return FALSE;
-    }
+	debug("Sanitize the python search path");
+	PyRun_SimpleString("import sys; sys.path = [path for path in sys.path if path]");
+	if (PyErr_Occurred())
+	{
+		PyErr_Print();
+		return FALSE;
+	}
 
 	/* import gobject */
     debug("init_pygobject");
@@ -127,7 +133,6 @@ thunarx_python_init_python (void)
 #define IMPORT(x, y) \
     _PyThunarx##x##_Type = (PyTypeObject *)PyObject_GetAttrString(thunarx, y); \
 	if (_PyThunarx##x##_Type == NULL) { \
-        debug("hi " y); \
 		PyErr_Print(); \
 		return FALSE; \
 	}
@@ -235,7 +240,11 @@ thunarx_python_load_dir (ThunarxProviderPlugin  *plugin,
                 
                 /* sys.path.insert(0, dirname) */
 				sys_path = PySys_GetObject("path");
+#if PY_MAJOR_VERSION >= 3
+				py_path = PyUnicode_FromString(dirname);
+#else
 				py_path = PyString_FromString(dirname);
+#endif
 				PyList_Insert(sys_path, 0, py_path);
 				Py_DECREF(py_path);
 			}

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the Xfce4-commits mailing list