sftp open error: TypeError: catching classes that do not inherit from BaseException is not allowed
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 9.9k
- Forks
- 2.1k
- PR merge metrics
- No merged PRs in 30d
Description
I am running on CentOS 7.7.1908, Python 3.6.8-13.el7, and paramiko 2.7.2.
I have this script that attempts to open a file open on a remote server:
#!/usr/bin/env python3
import paramiko
server = 'serverName'
user = 'userName'
ssh_hosts_file = '/path/.ssh/known_hosts'
ssh_key = '/path/.ssh/id_rsa'
client = paramiko.SSHClient()
client.load_host_keys(ssh_hosts_file)
client.connect(server, port=22, username=user, password="None", key_filename=ssh_key)
sftp_client = client.open_sftp()
remote_file = sftp_client.open('/tmp/test-file', 'r')
When I execute I get this error:
Exception ignored in: <bound method SFTPFile.__del__ of <paramiko.sftp_file.SFTPFile object at 0x7fbc8a3dbcf8>>
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/paramiko/sftp_file.py", line 76, in __del__
File "/usr/local/lib/python3.6/site-packages/paramiko/sftp_file.py", line 108, in _close
TypeError: catching classes that do not inherit from BaseException is not allowed
If I open the file for appending it does succeed. I can add a new line to that file. However, the error is still generated.
Can someone help me to understand how I can solve this, so an error is not returned?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the script on the reported Python and Paramiko versions, then inspect paramiko/sftp_file.py around del and _close, where the traceback occurs. Compare read and append handling and identify why cleanup produces the TypeError; done means opening the remote file and allowing cleanup without this error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100