Skip to content

AttributeError: 'FakeOutput' object has no attribute 'encoding' #622

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

Closed
goetzc opened this issue Jul 6, 2016 · 11 comments
Closed

AttributeError: 'FakeOutput' object has no attribute 'encoding' #622

goetzc opened this issue Jul 6, 2016 · 11 comments
Milestone

Comments

@goetzc
Copy link

goetzc commented Jul 6, 2016

sys.stdout.encoding gives this error.
Also sys.stdin.encoding gives 'UTF8', while python gives 'UTF-8' for both cases.

This commit makes bpython work (naturally stdin is still different than in standard python):

bpython version 0.15 on top of Python 3.5.2 /usr/bin/python
>>> import sys
>>> sys.stdin.encoding
'UTF8'
>>> sys.stdout.encoding
'UTF-8'
@thomasballinger
Copy link
Member

Hm, I guess this should just be a property that returns whatever sys.stdout.encoding is, since that's how strings are actually being decoded. What are you using this for? (asking to try to understand if this is the right solution)

@goetzc
Copy link
Author

goetzc commented Jul 29, 2016

I guess this should just be a property that returns whatever sys.stdout.encoding is

This is a much better solution!

What are you using this for?

I don't remember that :D

@goetzc
Copy link
Author

goetzc commented Jul 30, 2016

I found another AttributeError for 'FakeOutput', this time for 'fileno'. I was using PyQtGraph. Issue #628.

@thomasballinger
Copy link
Member

thomasballinger commented Aug 5, 2016

Proposed solution in #629

@gerryjenkinslb
Copy link

I ran into the problem in bpython import as well.
I would look at what idle does in its code base:
see cpython run.py PseudoFile class for example. if FakeOutput only encodes 'utf-8' then just return that.

@rpdelaney
Copy link

Here's my +1:

$ python3
Python 3.7.2 (default, Feb 12 2019, 08:16:38) 
[Clang 10.0.0 (clang-1000.11.45.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pipenv
>>> 
$ bpython
bpython version 0.17.1 on top of Python 3.7.2 /usr/local/opt/python/bin/python3.7
>>> import pipenv
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    import pipenv
  File "/Users/ryan.delaney/Library/Python/3.7/lib/python/site-packages/pipenv/__init__.py", line 47, in <module>
    from .cli import cli
  File "/Users/ryan.delaney/Library/Python/3.7/lib/python/site-packages/pipenv/cli/__init__.py", line 3, in <module>
    from .command import cli
  File "/Users/ryan.delaney/Library/Python/3.7/lib/python/site-packages/pipenv/cli/command.py", line 19, in <module>
    from .options import (
  File "/Users/ryan.delaney/Library/Python/3.7/lib/python/site-packages/pipenv/cli/options.py", line 11, in <module>
    from .. import environments
  File "/Users/ryan.delaney/Library/Python/3.7/lib/python/site-packages/pipenv/environments.py", line 7, in <module>
    from ._compat import fix_utf8
  File "/Users/ryan.delaney/Library/Python/3.7/lib/python/site-packages/pipenv/_compat.py", line 96, in <module>
    OUT_ENCODING, ERR_ENCODING = force_encoding()
  File "/Users/ryan.delaney/Library/Python/3.7/lib/python/site-packages/pipenv/_compat.py", line 60, in force_encoding
    stdout_encoding = sys.stdout.encoding
AttributeError: 'FakeOutput' object has no attribute 'encoding'
>>> 

@tiffanyb
Copy link

The encoding issue exists in bpython 0.19 and Python 3.8.0

$ bpython
bpython version 0.19 on top of Python 3.8.0
>>> import sys
>>> sys.stdout.encoding
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    sys.stdout.encoding
AttributeError: 'FakeOutput' object has no attribute 'encoding'
`

@alisianoi
Copy link

The encoding issue still exists in bpython 0.19 and Python 3.8.2, my use case is Z3 solver:

>>> from z3 import *
>>> Tie, Shirt = Bools('Tie Shirt')
>>> s = Solver()
>>> s.add(Or(Tie, Shirt), Or(Not(Tie), Shirt), Or(Not(Shirt), Not(Tie)))
>>> s.check()
sat
>>> s.model()
Traceback (most recent call last):

The Z3 example comes from here: https://theory.stanford.edu/~nikolaj/programmingz3.html#sec-logical-interface

@deadeert
Copy link

deadeert commented Sep 7, 2020

Hello, I confim @alisianoi I have the same issue with python 3.8.5 and bpython 0.19.

@itsfarseen
Copy link

I was trying to use Z3 and is affected by this.
I am using this as a workaround:

sys.stdout.encoding='utf-8'

@sebastinas
Copy link
Contributor

Fixes by #629.

@sebastinas sebastinas added this to the release-0.20 milestone Oct 11, 2020
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

No branches or pull requests

9 participants