gentoo/dev-python/couchdb-python/files/0.10-exec-compat.patch
Robin H. Johnson 56bd759df1
proj/gentoo: Initial commit
This commit represents a new era for Gentoo:
Storing the gentoo-x86 tree in Git, as converted from CVS.

This commit is the start of the NEW history.
Any historical data is intended to be grafted onto this point.

Creation process:
1. Take final CVS checkout snapshot
2. Remove ALL ChangeLog* files
3. Transform all Manifests to thin
4. Remove empty Manifests
5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$
5.1. Do not touch files with -kb/-ko keyword flags.

Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests
X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project
X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration
X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn
X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts
X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration
X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging
X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
2015-08-08 17:38:18 -07:00

88 lines
2.9 KiB
Diff

commit 8fdba0f09df00d69618858c70d11ddbeecd30026
Author: Dirkjan Ochtman <dirkjan@ochtman.nl>
Date: Thu Jul 24 11:43:52 2014 +0200
Use a single pyexec() utility function to fix compatibility issues
While the current setup (where 2.x uses the exec statement and 3.x uses the
exec() function) works at run-time, it causes problem while byte-compiling
the util modules for their non-appropriate interpreter versions:
File "/usr/lib64/python2.7/site-packages/couchdb/util3.py", line 17
pyexec = exec
^
SyntaxError: invalid syntax
File "/usr/lib64/python3.3/site-packages/couchdb/util2.py", line 19
exec code in gns, lns
^
SyntaxError: invalid syntax
There doesn't appear to be an easy way to exclude some files from installation
based on the installing Python version, but it turns out the 2.x exec
statement can also take its arguments as a tuple, such that the 2.x and 3.x
versions can be used with the same syntax.
However, Python 2.7 has a bug (#21591) that prevents this from working in the
context we use exec in (in a function that also contains a nested function),
due to a bad implementation that enables the arguments-as-tuple functionality.
We thus need a helper function after all, to pull it out of that context.
diff --git a/couchdb/util.py b/couchdb/util.py
index bdd52f3..d111a6b 100644
--- a/couchdb/util.py
+++ b/couchdb/util.py
@@ -4,3 +4,7 @@ if sys.version_info[0] < 3:
from couchdb.util2 import *
else:
from couchdb.util3 import *
+
+def pyexec(code, gns, lns):
+ # http://bugs.python.org/issue21591
+ exec(code, gns, lns)
diff --git a/couchdb/util2.py b/couchdb/util2.py
index ad1b0a8..03fd558 100644
--- a/couchdb/util2.py
+++ b/couchdb/util2.py
@@ -1,8 +1,7 @@
__all__ = [
'StringIO', 'urlsplit', 'urlunsplit', 'urlquote', 'urlunquote',
- 'urlencode', 'utype', 'ltype', 'pyexec', 'strbase', 'funcode',
- 'urlparse',
+ 'urlencode', 'utype', 'ltype', 'strbase', 'funcode', 'urlparse',
]
utype = unicode
@@ -15,8 +14,5 @@ from urllib import quote as urlquote
from urllib import unquote as urlunquote
from urllib import urlencode
-def pyexec(code, gns, lns):
- exec code in gns, lns
-
def funcode(fun):
return fun.func_code
diff --git a/couchdb/util3.py b/couchdb/util3.py
index c2e46d6..6bf84f0 100644
--- a/couchdb/util3.py
+++ b/couchdb/util3.py
@@ -1,8 +1,7 @@
__all__ = [
'StringIO', 'urlsplit', 'urlunsplit', 'urlquote', 'urlunquote',
- 'urlencode', 'utype', 'ltype', 'pyexec', 'strbase', 'funcode',
- 'urlparse',
+ 'urlencode', 'utype', 'ltype', 'strbase', 'funcode', 'urlparse',
]
utype = str
@@ -14,7 +13,5 @@ from urllib.parse import urlsplit, urlunsplit, urlencode, urlparse
from urllib.parse import quote as urlquote
from urllib.parse import unquote as urlunquote
-pyexec = exec
-
def funcode(fun):
return fun.__code__