appendfilename icon indicating copy to clipboard operation
appendfilename copied to clipboard

Compatibility Issue with collections.Callable on Python 3.10+

Open jonathanpow opened this issue 8 months ago • 2 comments

Hi Karl,

First off, thank you for developing such a great tool! As a non-ish-technical user, I appreciate tools like appendfilename that help streamline file management tasks (coming from trying TagSpaces et al)

I recently attempted to use appendfilename on my Windows machine and encountered an issue related to Python 3.10 compatibility. I'm not very technical, and it took me a little effort to get everything working, but I wanted to share my experience in case it helps others.

Environment:

Operating System: Windows Python Version: 3.13 Issue: When I ran the script, I encountered the following error:

TEXT AttributeError: module 'collections' has no attribute 'Callable' Steps to Resolve: After some research and trial and error, I fixed the issue by editing the py3k_compat.py file in the pyreadline package. Here's what I did:

Locate the File:

Path: C:\Users\jp\AppData\Roaming\Python\Python313\site-packages\pyreadline\py3k_compat.py Edit the File:

I changed the line: PYTHON return isinstance(x, collections.Callable) To: PYTHON return isinstance(x, collections.abc.Callable) This resolved the error, and I was able to use the script successfully. As someone who is a bit lazy, it took some effort to make the most of this efficiency-saving tool, but it was worth it!

I hope this information is helpful. If there's anything more I can provide or if you have plans to update the script for compatibility with newer Python versions, please let me know.

Thanks again for your hard work on appendfilename!

Best regards,

Jonathan

07/05/2025:

Hi @nbehrnd,

Thanks for the follow-up.

I installed appendfilename using pip install appendfilename from PowerShell on my Windows 10 machine. I didn’t specify a source, so it would have been installed from PyPI by default (I think… based on my limited understanding)

Let me know if you’d like any additional info.

jonathanpow avatar May 05 '25 15:05 jonathanpow

@jonathanpow May you complement your report by a note how you installed appendfilename?

Going back in commit history, requirements.txt as provided by the GitHub page was edited on October 2024 to replace pyreadline by pyreadline3 to address issue #18. Since then, appendfilename worked well (e.g., Windows 2022 & Python 3.12 as documented in the last automated test [behind the green check mark] on GitHub in November 2024). However, by inspection of the metadata in the .whl as currently distributed on PyPI, the requirement of pyreadline3 isn't retained/wasn't updated the way it should.

Recommendation: 1) uninstall appendfilename, 2) for now, fetch a copy from GitHub, 3) install it from this copy (resolve dependencies for now by pip install -r requirements.txt).

I'll have a closer look on it tomorrow.

nbehrnd avatar May 05 '25 22:05 nbehrnd

@jonathanpow I was able to replicate your issue in Windows 10. The installation with pip install appendfilename reaches out for appendfilename on the Python Package Index. At present, it is an old version by 2022 (see here) which is outdated.

Parts of the work of appendfilename is delegated to other packages which evolve over time, or get stuck for one cause, or an other. Here, pyreadline initially written for Python 2 doesn't interact reliably with Python 3. But pyreadline3 is written and continuously maintained for the newer syntax and environment. At its home (GitHub) appendfilename thus was updated, the copy on PyPI still is an old one (the motivation of #26).

Uninstall your instance of appendfilename. If you used python -m pip install appendfilename to install, this runs by the command of python -m uninstall appendfilename. You can monitor your success by the command python -m pip list prior / after this operation to see additionally installed Python packages. Pending Karl's review, use then the Python wheel attached below to run pip install appendfilename-2025.5.7-py3-none-any.whl. (To allow an upload and share in a discussion on GitHub, it was necessary to enclose it in a .zip archive.)

appendfilename-2025.5.7-py3-none-any.whl.zip


Edits in #26 did not change the inner source code of appendfilename. For working with appendfilename, the dependencies are still the same as in the commits to in fall 2024 merged to GitHub. The change is about how they are described -- once in a requirements.txt file, now in a pyproject.toml file to equally congregate other details of the appendfilename project in one file.

nbehrnd avatar May 07 '25 17:05 nbehrnd