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

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

Open
goetzc opened this issue Jul 6, 2016 · 8 comments
Open

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

goetzc opened this issue Jul 6, 2016 · 8 comments

Comments

@goetzc
Copy link

@goetzc 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

@thomasballinger thomasballinger commented Jul 29, 2016

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 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 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 thomasballinger commented Aug 5, 2016

Proposed solution in #629

@gerryjenkinslb
Copy link

@gerryjenkinslb gerryjenkinslb commented Dec 16, 2017

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

@rpdelaney rpdelaney commented Mar 14, 2019

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

@tiffanyb tiffanyb commented Jun 13, 2020

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

@alisianoi alisianoi commented Aug 17, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.