Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect overriding of sys.stdout #2283

Merged
merged 1 commit into from Aug 8, 2013
Merged

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented Aug 6, 2013

setupext.py temporarily overrides sys.stdout in way incompatible with Python 3, which results in traceback:

$ python3.3 setup.py build
...
Traceback (most recent call last):
  File "setup.py", line 145, in <module>
    result = package.check()
  File "/tmp/matplotlib-1.3.0/setupext.py", line 687, in check
    import CXX
  File "/usr/lib64/python3.3/site-packages/CXX/__init__.py", line 41, in <module>
    """)
TypeError: 'str' does not support the buffer interface
$

Patch:

--- setupext.py
+++ setupext.py
@@ -682,7 +682,10 @@

         self.__class__.found_external = True
         old_stdout = sys.stdout
-        sys.stdout = io.BytesIO()
+        if sys.version_info[0] >= 3:
+            sys.stdout = io.StringIO()
+        else:
+            sys.stdout = io.BytesIO()
         try:
             import CXX
         except ImportError:

@mdboom
Copy link
Member

mdboom commented Aug 6, 2013

How are you reaching this block on Python 3? It should have already returned at this point due to:

        if sys.version_info[0] >= 3:
            # There is no version of PyCXX in the wild that will work
            # with Python 3.x
            self.__class__.found_external = False
            return ("Official versions of PyCXX are not compatible with "
                    "Python 3.x.  Using local copy")

Does Gentoo's PyCXX already include the patches (not in any upstream release) that allow matplotlib to build on Python 3?

@mdboom
Copy link
Member

mdboom commented Aug 6, 2013

Ah, ok -- makes sense. And that will be removed from matplotlib upstream eventually as well, once PyCXX has another release with these patches.

mdboom added a commit that referenced this pull request Aug 8, 2013
Incorrect overriding of sys.stdout
@mdboom mdboom merged commit 71ed192 into matplotlib:v1.3.x Aug 8, 2013
@mdboom mdboom deleted the stdout_override branch March 3, 2015 18:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants