Subject: adamwill pushed to pyatspi (master). "Rename
enum module and class that conflict with
stdlib"



From db0b6ae479e9bb99a47438b90c6b71e48e098ca1 Mon Sep 17 00:00:00 2001
From: Adam Williamson <[email protected]>
Date: Wed, 21 Dec 2016 17:04:11 -0800
Subject: Rename enum module and class that conflict with stdlib

---
...-module-and-Enum-class-not-to-conflict-wi.patch | 375 +++++++++++++++++++++
pyatspi.spec | 51 ++-
2 files changed, 416 insertions(+), 10 deletions(-)
create mode 100644
0001-Rename-enum-module-and-Enum-class-not-to-conflict-wi.patch

diff --git a/0001-Rename-enum-module-and-Enum-class-not-to-conflict-wi.patch
b/0001-Rename-enum-module-and-Enum-class-not-to-conflict-wi.patch
new file mode 100644
index 0000000..8cd85a9
--- /dev/null
+++ b/0001-Rename-enum-module-and-Enum-class-not-to-conflict-wi.patch
@@ -0,0 +1,375 @@
+From b4074f8ff80ca380ea4c6a2695fe38d180682240 Mon Sep 17 00:00:00 2001
+From: Adam Williamson <[email protected]>
+Date: Wed, 21 Dec 2016 16:38:40 -0800
+Subject: [PATCH] Rename enum module and Enum class not to conflict with stdlib
+
+Python 3 stdlib has an enum module with an Enum class...and so
+do we. They do not work at all the same. This is a bad thing,
+and causes modules which rely on the Python stdlib version to
+blow up when they're used with pyatspi in the Python path, like
+re:
+
+https://bugzilla.redhat.com/show_bug.cgi?id=1406946
+
+To avoid this, let's rename our 'enum' module to 'atspienum'
+and our 'Enum' class to 'AtspiEnum'. This is an API change, but
+it's rather unavoidable, we just can't keep the name 'enum' and
+use regexes on Python 3.6. AFAICS, nothing besides pyatspi is
+actually using this module / class.
+---
+ pyatspi/Makefile.am | 2 +-
+ pyatspi/action.py | 1 -
+ pyatspi/application.py | 1 -
+ pyatspi/{enum.py => atspienum.py} | 4 ++--
+ pyatspi/collection.py | 8 ++++----
+ pyatspi/component.py | 6 +++---
+ pyatspi/deviceevent.py | 12 ++++++------
+ pyatspi/hypertext.py | 1 -
+ pyatspi/image.py | 1 -
+ pyatspi/interface.py | 1 -
+ pyatspi/role.py | 4 ++--
+ pyatspi/state.py | 4 ++--
+ pyatspi/table.py | 1 -
+ pyatspi/tablecell.py | 1 -
+ pyatspi/text.py | 8 ++++----
+ pyatspi/value.py | 1 -
+ 16 files changed, 24 insertions(+), 32 deletions(-)
+ rename pyatspi/{enum.py => atspienum.py} (96%)
+
+diff --git a/pyatspi/Makefile.am b/pyatspi/Makefile.am
+index c7605c6..1361690 100644
+--- a/pyatspi/Makefile.am
++++ b/pyatspi/Makefile.am
+@@ -5,7 +5,7 @@ pyatspi_PYTHON = \
+ appevent.py \
+ constants.py \
+ deviceevent.py \
+- enum.py \
++ atspienum.py \
+ __init__.py \
+ action.py \
+ application.py \
+diff --git a/pyatspi/action.py b/pyatspi/action.py
+index ac69e25..cc38639 100644
+--- a/pyatspi/action.py
++++ b/pyatspi/action.py
+@@ -14,7 +14,6 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
+ from pyatspi.utils import *
+ from pyatspi.interface import *
+
+diff --git a/pyatspi/application.py b/pyatspi/application.py
+index 33876db..fccbfcb 100644
+--- a/pyatspi/application.py
++++ b/pyatspi/application.py
+@@ -14,7 +14,6 @@
+ #Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
+ from pyatspi.utils import *
+
+ __all__ = [
+diff --git a/pyatspi/enum.py b/pyatspi/atspienum.py
+similarity index 96%
+rename from pyatspi/enum.py
+rename to pyatspi/atspienum.py
+index 1a6d75f..120128a 100644
+--- a/pyatspi/enum.py
++++ b/pyatspi/atspienum.py
+@@ -13,12 +13,12 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ __all__ = [
+- "Enum",
++ "AtspiEnum",
+ ]
+
+
#------------------------------------------------------------------------------
+
+-class Enum(int):
++class AtspiEnum(int):
+ def __str__(self):
+ return self._enum_lookup[int(self)]
+
+diff --git a/pyatspi/collection.py b/pyatspi/collection.py
+index 9723e30..c1bada2 100644
+--- a/pyatspi/collection.py
++++ b/pyatspi/collection.py
+@@ -14,7 +14,7 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
++from pyatspi.atspienum import *
+ from pyatspi.utils import *
+
+ __all__ = [
+@@ -26,7 +26,7 @@ __all__ = [
+
+
#------------------------------------------------------------------------------
+
+-class MatchType(Enum):
++class MatchType(AtspiEnum):
+ _enum_lookup = {
+ 0:'MATCH_INVALID',
+ 1:'MATCH_ALL',
+@@ -36,7 +36,7 @@ class MatchType(Enum):
+ 5:'MATCH_LAST_DEFINED',
+ }
+
+-class SortOrder(Enum):
++class SortOrder(AtspiEnum):
+ _enum_lookup = {
+ 0:'SORT_ORDER_INVALID',
+ 1:'SORT_ORDER_CANONICAL',
+@@ -48,7 +48,7 @@ class SortOrder(Enum):
+ 7:'SORT_ORDER_LAST_DEFINED',
+ }
+
+-class TreeTraversalType(Enum):
++class TreeTraversalType(AtspiEnum):
+ _enum_lookup = {
+ 0:'TREE_RESTRICT_CHILDREN',
+ 1:'TREE_RESTRICT_SIBLING',
+diff --git a/pyatspi/component.py b/pyatspi/component.py
+index 3153e81..04be988 100644
+--- a/pyatspi/component.py
++++ b/pyatspi/component.py
+@@ -14,7 +14,7 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
++from pyatspi.atspienum import *
+ from pyatspi.utils import *
+ from pyatspi.interface import *
+
+@@ -37,7 +37,7 @@ __all__ = [
+
+
#------------------------------------------------------------------------------
+
+-class CoordType(Enum):
++class CoordType(AtspiEnum):
+ _enum_lookup = {
+ 0:'XY_SCREEN',
+ 1:'XY_WINDOW',
+@@ -48,7 +48,7 @@ XY_WINDOW = CoordType(1)
+
+
#------------------------------------------------------------------------------
+
+-class ComponentLayer(Enum):
++class ComponentLayer(AtspiEnum):
+ _enum_lookup = {
+ 0:'LAYER_INVALID',
+ 1:'LAYER_BACKGROUND',
+diff --git a/pyatspi/deviceevent.py b/pyatspi/deviceevent.py
+index 7b93df8..e24fd42 100644
+--- a/pyatspi/deviceevent.py
++++ b/pyatspi/deviceevent.py
+@@ -14,13 +14,13 @@
+
+ import pyatspi.registry as registry
+
+-from pyatspi.enum import Enum as _Enum
++from pyatspi.atspienum import *
+
+ import traceback
+
+
#------------------------------------------------------------------------------
+
+-class PressedEventType(_Enum):
++class PressedEventType(AtspiEnum):
+ _enum_lookup = {
+ 0:'KEY_PRESSED_EVENT',
+ 1:'KEY_RELEASED_EVENT',
+@@ -35,7 +35,7 @@ BUTTON_RELEASED_EVENT = PressedEventType(3)
+
+
#------------------------------------------------------------------------------
+
+-class ControllerEventMask(_Enum):
++class ControllerEventMask(AtspiEnum):
+ _enum_lookup = {
+ 1:'KEY_PRESSED_EVENT_MASK',
+ 2:'KEY_RELEASED_EVENT_MASK',
+@@ -50,7 +50,7 @@ BUTTON_RELEASED_EVENT_MASK = ControllerEventMask(8)
+
+
#------------------------------------------------------------------------------
+
+-class KeyEventType(_Enum):
++class KeyEventType(AtspiEnum):
+ _enum_lookup = {
+ 0:'KEY_PRESSED',
+ 1:'KEY_RELEASED',
+@@ -60,7 +60,7 @@ KEY_RELEASED = KeyEventType(1)
+
+
#------------------------------------------------------------------------------
+
+-class KeySynthType(_Enum):
++class KeySynthType(AtspiEnum):
+ _enum_lookup = {
+ 0:'KEY_PRESS',
+ 1:'KEY_RELEASE',
+@@ -77,7 +77,7 @@ KEY_SYM = KeySynthType(3)
+
+
#------------------------------------------------------------------------------
+
+-class ModifierType(_Enum):
++class ModifierType(AtspiEnum):
+ _enum_lookup = {
+ 0:'MODIFIER_SHIFT',
+ 1:'MODIFIER_SHIFTLOCK',
+diff --git a/pyatspi/hypertext.py b/pyatspi/hypertext.py
+index 6912224..740192e 100644
+--- a/pyatspi/hypertext.py
++++ b/pyatspi/hypertext.py
+@@ -14,7 +14,6 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
+ from pyatspi.utils import *
+ from pyatspi.interface import *
+
+diff --git a/pyatspi/image.py b/pyatspi/image.py
+index ef5f866..38d8a73 100644
+--- a/pyatspi/image.py
++++ b/pyatspi/image.py
+@@ -14,7 +14,6 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
+ from pyatspi.utils import *
+
+ __all__ = [
+diff --git a/pyatspi/interface.py b/pyatspi/interface.py
+index 891b811..7df9e13 100644
+--- a/pyatspi/interface.py
++++ b/pyatspi/interface.py
+@@ -13,7 +13,6 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
+ from pyatspi.utils import *
+ #from pyatspi.component import *
+
+diff --git a/pyatspi/role.py b/pyatspi/role.py
+index 900988b..2c35e00 100644
+--- a/pyatspi/role.py
++++ b/pyatspi/role.py
+@@ -12,11 +12,11 @@
+ #along with this program; if not, write to the Free Software
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+-from pyatspi.enum import Enum as _Enum
++from pyatspi.atspienum import *
+
+
#------------------------------------------------------------------------------
+
+-class Role(_Enum):
++class Role(AtspiEnum):
+ _enum_lookup = {
+ 0:'ROLE_INVALID',
+ 1:'ROLE_ACCELERATOR_LABEL',
+diff --git a/pyatspi/state.py b/pyatspi/state.py
+index 67a5243..986431a 100644
+--- a/pyatspi/state.py
++++ b/pyatspi/state.py
+@@ -21,11 +21,11 @@
+
+ from gi.repository import Atspi
+ from gi.repository import GObject
+-from pyatspi.enum import Enum as _Enum
++from pyatspi.atspienum import *
+
+
#------------------------------------------------------------------------------
+
+-class StateType(_Enum):
++class StateType(AtspiEnum):
+ _enum_lookup = {
+ 0:'STATE_INVALID',
+ 1:'STATE_ACTIVE',
+diff --git a/pyatspi/table.py b/pyatspi/table.py
+index f67cc97..f676aa1 100644
+--- a/pyatspi/table.py
++++ b/pyatspi/table.py
+@@ -14,7 +14,6 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
+ from pyatspi.utils import *
+ from pyatspi.interface import *
+
+diff --git a/pyatspi/tablecell.py b/pyatspi/tablecell.py
+index 4ae59e9..fcbb84b 100644
+--- a/pyatspi/tablecell.py
++++ b/pyatspi/tablecell.py
+@@ -13,7 +13,6 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
+ from pyatspi.utils import *
+ from pyatspi.interface import *
+
+diff --git a/pyatspi/text.py b/pyatspi/text.py
+index 0cdff67..1f0c1f2 100644
+--- a/pyatspi/text.py
++++ b/pyatspi/text.py
+@@ -14,7 +14,7 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
++from pyatspi.atspienum import *
+ from pyatspi.utils import *
+ from pyatspi.interface import *
+
+@@ -43,7 +43,7 @@ __all__ = [
+
+
#------------------------------------------------------------------------------
+
+-class TEXT_BOUNDARY_TYPE(Enum):
++class TEXT_BOUNDARY_TYPE(AtspiEnum):
+ _enum_lookup = {
+ 0:'TEXT_BOUNDARY_CHAR',
+ 1:'TEXT_BOUNDARY_WORD_START',
+@@ -64,7 +64,7 @@ TEXT_BOUNDARY_WORD_START = TEXT_BOUNDARY_TYPE(1)
+
+
#------------------------------------------------------------------------------
+
+-class TEXT_CLIP_TYPE(Enum):
++class TEXT_CLIP_TYPE(AtspiEnum):
+ _enum_lookup = {
+ 0:'TEXT_CLIP_NONE',
+ 1:'TEXT_CLIP_MIN',
+@@ -79,7 +79,7 @@ TEXT_CLIP_NONE = TEXT_CLIP_TYPE(0)
+
+
#------------------------------------------------------------------------------
+
+-class TEXT_GRANULARITY_TYPE(Enum):
++class TEXT_GRANULARITY_TYPE(AtspiEnum):
+ _enum_lookup = {
+ 0:'TEXT_GRANULARITY_CHAR',
+ 1:'TEXT_GRANULARITY_WORD',
+diff --git a/pyatspi/value.py b/pyatspi/value.py
+index 08843b3..cb15bc0 100644
+--- a/pyatspi/value.py
++++ b/pyatspi/value.py
+@@ -14,7 +14,6 @@
+ #Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
USA.
+
+ from gi.repository import Atspi
+-from pyatspi.enum import *
+ from pyatspi.utils import *
+ from pyatspi.interface import *
+
+--
+2.11.0
+
diff --git a/pyatspi.spec b/pyatspi.spec
index 0535178..75e809d 100644
--- a/pyatspi.spec
+++ b/pyatspi.spec
@@ -1,5 +1,14 @@
%global debug_package %{nil}

+# Enable Python 3 builds for Fedora
+%if 0%{?fedora}
+# If the definition isn't available for python3_pkgversion, define it
+%{?!python3_pkgversion:%global python3_pkgversion 3}
+%bcond_without python3
+%else
+%bcond_with python3
+%endif
+
Name: pyatspi
Version: 2.20.2
Release: 3%{?dist}
@@ -10,15 +19,33 @@ License: LGPLv2 and GPLv2
URL: http://www.linuxfoundation.org/en/AT-SPI_on_D-Bus
#VCS: git:git://git.gnome.org/pyatspi
Source0:
http://download.gnome.org/sources/pyatspi/2.20/%{name}-%{version}.tar.xz
+# Rename home-grown enum/Enum not to conflict with stdlib version
+# https://bugzilla.gnome.org/show_bug.cgi?id=776366
+Patch0: 0001-Rename-enum-module-and-Enum-class-not-to-conflict-wi.patch

BuildRequires: python2-devel
-%if !0%{?rhel}
+# For tests
+BuildRequires: pkgconfig(dbus-1) >= 1.0
+BuildRequires: pkgconfig(glib-2.0)
+BuildRequires: pkgconfig(dbus-glib-1) >= 0.7.0
+BuildRequires: pkgconfig(gobject-2.0) >= 2.0.0
+BuildRequires: pkgconfig(gmodule-2.0) >= 2.0.0
+BuildRequires: pkgconfig(libxml-2.0) >= 2.0.0
+BuildRequires: pkgconfig(atk) >= 2.11.2
+BuildRequires: pkgconfig(gtk+-2.0) >= 2.10.0
+BuildRequires: pkgconfig(pygobject-3.0) >= 2.90.1
+BuildRequires: python-dbus
+BuildRequires: python-enum34
+
+%if %{with python3}
BuildRequires: python3-devel
+BuildRequires: python3-dbus
%endif
-BuildRequires: pygobject3-devel >= 2.90.1

Requires: at-spi2-core
Requires: pygobject3
+Requires: python-enum34
+Requires: python-dbus

BuildArch: noarch

@@ -31,7 +58,7 @@ scripting interfaces can query and interact with GUI controls.
This package includes a python2 client library for at-spi.


-%if !0%{?rhel}
+%if %{with python3}
%package -n python3-pyatspi
Summary: Python3 bindings for at-spi
Requires: at-spi2-core
@@ -44,28 +71,28 @@ automation, so tools such as screen readers, magnifiers, or
even
scripting interfaces can query and interact with GUI controls.

This package includes a python3 client library for at-spi.
-%endif
+%endif # with_python3


%prep
-%setup -q
+%autosetup -p1

-%if !0%{?rhel}
+%if %{with python3}
# Make a copy of the source tree for building the python3 module
rm -rf %{py3dir}
cp -a . %{py3dir}
-%endif
+%endif #with_python3


%build
# Build the python2 module
-%configure --with-python=python2
+%configure --with-python=python2 --enable-tests
make

%if !0%{?rhel}
# Build the python3 module
pushd %{py3dir}
-%configure --with-python=python3
+%configure --with-python=python3 --enable-tests
make
popd
%endif
@@ -84,12 +111,15 @@ cp -a examples python3-examples
sed -i '1s|^#!/usr/bin/python|#!%{__python3}|'
python3-examples/magFocusTracker.py
%endif

+%check
+# Done by the 'build' step, with --enable-tests
+

%files
%license COPYING COPYING.GPL
%doc AUTHORS README
%doc examples/magFocusTracker.py
-%{python_sitelib}/pyatspi/
+%{python2_sitelib}/pyatspi/

%if !0%{?rhel}
%files -n python3-pyatspi
@@ -103,6 +133,7 @@ sed -i '1s|^#!/usr/bin/python|#!%{__python3}|'
python3-examples/magFocusTracker.
%changelog
* Mon Dec 19 2016 Miro Hrončok <[email protected]> - 2.20.2-3
- Rebuild for Python 3.6
+- Rename enum module and Enum class not to conflict with stdlib - BGO #776366

* Tue Jul 19 2016 Fedora Release Engineering <[email protected]>
- 2.20.2-2
-
https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages
--
cgit v0.12



http://pkgs.fedoraproject.org/cgit/pyatspi.git/commit/?h=master&id=db0b6ae479e9bb99a47438b90c6b71e48e098ca1
_______________________________________________
scm-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]



Programming list archiving by: Enterprise Git Hosting