Skip to content

Python complains about lru_cache (Python versions compatibility issues) #114

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
BloodyFoxy opened this issue Sep 28, 2020 · 4 comments
Closed

Comments

@BloodyFoxy
Copy link

How does the problem look like and what steps reproduce it?

Trying to launch a sample tm.py from root of repository:

Traceback (most recent call last):
  File "./tm.py", line 3, in <module>
    from pytm import TM, Actor, Boundary, Dataflow, Datastore, Lambda, Server, Data, Classification  
  File "/usr/lib/python3.6/site-packages/pytm-1.1.1-py3.6.egg/pytm/__init__.py", line 3, in <module> 
    from .pytm import Element, Server, ExternalEntity, Dataflow, Datastore, Actor, Process, SetOfProcesses, Boundary, TM, Action, Lambda, Threat, Classification, Data 
  File "/usr/lib/python3.6/site-packages/pytm-1.1.1-py3.6.egg/pytm/pytm.py", line 487, in <module>
    class TM():
  File "/usr/lib/python3.6/site-packages/pytm-1.1.1-py3.6.egg/pytm/pytm.py", line 781, in TM
    @lru_cache
  File "/usr/lib64/python3.6/functools.py", line 477, in lru_cache
    raise TypeError('Expected maxsize to be an integer or None')
TypeError: Expected maxsize to be an integer or None

Can you reproduce it using the latest master?

Yes

What is your running environment?

OS: SUSE SLES 15 SP1
Python version: Python 3.6.10

Also reproduced in Docker container python:3.7.9-alpine

What have you already tried to solve the problem?

Change @lru_cache on line 487 to @lru_cache().
https://github.com/izar/pytm/blob/5db9b2e69db7c2aca43ae7d5bb6de9a3ebd2b9a6/pytm/pytm.py#L781
See this Python bug
After changing to @lru_cache still works in Docker container python:3.8.6-alpine which is current stable version of Python 3.8

@izar
Copy link
Collaborator

izar commented Sep 28, 2020

Thanks for the report! I don't think we tried with anything earlier than 3.8, but this doesn't seem to break anything. Would you like to wait until October and submit a PR (just in case you're into #hacktoberfest)?

@BloodyFoxy
Copy link
Author

Yeah, I wish I could always use latest Python too.

I'm not into #hacktoberfest (at least yet) but I can try to contribute OSS in October 😄 I will submit a PR in October then.

@izar
Copy link
Collaborator

izar commented Sep 28, 2020 via email

@nineinchnick
Copy link
Collaborator

@BloodyFoxy sorry, that was overlooked. We don't specify which particular Python 3 versions we support so I assume all of them. We can try adding an action for some older version (oldest still supported, 3.5?) to catch issues like this.

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

3 participants