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

from collections import Iterable fails on Python 3.10 #171

Closed
regeya opened this issue Dec 22, 2021 · 2 comments
Closed

from collections import Iterable fails on Python 3.10 #171

regeya opened this issue Dec 22, 2021 · 2 comments
Assignees
Labels

Comments

@regeya
Copy link

regeya commented Dec 22, 2021

Hello, I'm partly writing to post my results here, and partly to ask what the best course of action is. :-) I'm an idiot when it comes to git, and if I'm fair that may be par for the course.

I'm running PC-BASIC on Fedora 35, which uses Python v3.10.1 To get the interpreter up and running, I needed to edit extensions.py and iostreams.py to import Iterable from collections.abc instead of collections i.e. 'from collections.abc import Iterable'. After that, it works perfectly.

I was considering making a comparison/contrast of a simple graphics demo on Tandy 1000 GW-BASIC vs PyGame and am stunned at how close PC-BASIC is to running GW-BASIC on a vintage PC. Thank you for your hard work.

@robhagemans
Copy link
Owner

Thanks for reporting! Looks like the abstract type Iterable has been moved to collections.abc at least in 3.5+ but apparently some of the 3.x versions are still downward compatible. Version 2.7 only has it in collections

I should be able to fairly easily resolve this - e.g. by moving the import into compat like other Python2/3 differences.

However, need to check why I'm using Iterable at all, below section from the Python docs suggests it may be better to use iter() instead.

class collections.abc.Iterable

ABC for classes that provide the iter() method.

Checking isinstance(obj, Iterable) detects classes that are registered as Iterable or that have an iter() method, but it does not detect classes that iterate with the getitem() method. The only reliable way to determine whether an object is iterable is to call iter(obj).

@robhagemans robhagemans changed the title Running pcbasic on Fedora 35/Python 3.10 from collections import Iterable fails on Python 3.10 Dec 23, 2021
@robhagemans robhagemans self-assigned this Dec 23, 2021
@robhagemans
Copy link
Owner

Fixed with commit bf97cb3

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

No branches or pull requests

2 participants