Skip to content

AttributeError: 'LogOutputStream' object has no attribute 'line_buffering' #654

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
sheeyang opened this issue Jul 25, 2022 · 3 comments
Closed
Labels
Milestone

Comments

@sheeyang
Copy link

Chaquopy version

12.0.0

Devices or emulators where the issue happens

Emulator (Pixel 3a in android studio)

Relevant parts of your code

main.py:

from gallery_dl import job
import os


def main():

    os.chdir("/sdcard")
    return job.DownloadJob("https://www.instagram.com/instagram/").run()

the error:

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.sheeyang.gallerydownloader, PID: 8150
    com.chaquo.python.PyException: AttributeError: 'LogOutputStream' object has no attribute 'line_buffering'
        at <python>.gallery_dl.output.<module>(output.py:225)
        at <python>.java.chaquopy.import_override(import.pxi:26)
        at <python>.gallery_dl.job.<module>(job.py:17)
        at <python>.java.chaquopy.import_override(import.pxi:26)
        at <python>.gallery_dl.option.<module>(option.py:15)
        at <python>.java.chaquopy.import_override(import.pxi:26)
        at <python>.gallery_dl.<module>(__init__.py:12)
        at <python>.java.chaquopy.import_override(import.pxi:26)
        at <python>.main.<module>(main.py:12)
        at <python>.importlib._bootstrap._call_with_frames_removed(<frozen importlib._bootstrap>:219)
        at <python>.importlib._bootstrap_external.exec_module(<frozen importlib._bootstrap_external>:843)
        at <python>.java.android.importer.exec_module(importer.py:532)
        at <python>.java.android.importer.exec_module(importer.py:581)
        at <python>.importlib._bootstrap._load_unlocked(<frozen importlib._bootstrap>:671)
        at <python>.importlib._bootstrap._find_and_load_unlocked(<frozen importlib._bootstrap>:975)
        at <python>.importlib._bootstrap._find_and_load(<frozen importlib._bootstrap>:991)
        at <python>.importlib._bootstrap._gcd_import(<frozen importlib._bootstrap>:1014)
        at <python>.importlib.import_module(__init__.py:127)
        at <python>.chaquopy_java.Java_com_chaquo_python_Python_getModuleNative(chaquopy_java.pyx:155)
        at com.chaquo.python.Python.getModuleNative(Native Method)
        at com.chaquo.python.Python.getModule(Python.java:84)
        at com.sheeyang.gallerydownloader.ui.download.DownloadFragment.onCreateView(DownloadFragment.kt:35)
        at androidx.fragment.app.Fragment.performCreateView(Fragment.java:2995)
        at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:523)
        at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:261)
        at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1840)
        at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1764)
        at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1701)
        at androidx.fragment.app.FragmentManager$4.run(FragmentManager.java:488)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

Describe your issue

When I run main.callAttrThrows("main") it throws the error
I think it might have something to do with line(241) gallery-dl/gallery_dl/output.py

@mhsmith
Copy link
Member

mhsmith commented Jul 25, 2022

Thanks for the report: we'll fix this in the next version of Chaquopy. Meanwhile, you can work around it by running the following code before importing gallery_dl:

import sys
sys.stdout.line_buffering = sys.stderr.line_buffering = True

@mhsmith
Copy link
Member

mhsmith commented Jul 25, 2022

This is caused by gallery_dl assuming that stdout and stderr are instances of TextIOWrapper, which I guess is implied by their documentation:

These streams are regular text files like those returned by the open() function.

But they're currently implemented by inheriting the superclass, TextIOBase.

Related: #746.

@mhsmith
Copy link
Member

mhsmith commented Jan 29, 2023

This issue was fixed in Chaquopy 14.0.2. To upgrade, edit your app's top-level build.gradle file and change the version number of com.chaquo.python.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants