You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling sc.scan_instances.import_scan with str('filename') returns an empty string.
It appears that if the argument fileobj is a plain str instead of _io.TextIOWrapper than the string is simply added as the file content.
Reproduction
importjsonfromtenable.scimportTenableSCkeys=json.loads(open("keys.json").read())
defget_access_key():
returnkeys["access_key"]
defget_secret_key():
returnkeys["secret_key"]
sc=TenableSC(
url="https://tenablesc.localdomain",
verify=False,
access_key=get_access_key(),
secret_key=get_secret_key(),
)
r=sc.scan_instances.import_scan('<file-that-does-not-exist>', 40)
assertr=='',"R is not empty"
Expected Behavior
I expected something like TypeError(f'{fileobj} is not of type <expected type>')
As defined in the Python Glossary file objects expose "a file-oriented API (with methods such as read() or write())" like the handle returned from calling open(). Since str does not implement read() or write() I argue that this function should raise TypeError.
Sysinfo
OS: Ubuntu20
Architecture x86_64
Version 1.4.13
Memory 32GiB
The text was updated successfully, but these errors were encountered:
Description
Calling
sc.scan_instances.import_scan
withstr('filename')
returns an empty string.It appears that if the argument
fileobj
is a plainstr
instead of_io.TextIOWrapper
than the string is simply added as the file content.Reproduction
Expected Behavior
I expected something like
TypeError(f'{fileobj} is not of type <expected type>')
As defined in the Python Glossary file objects expose "a file-oriented API (with methods such as
read()
orwrite()
)" like the handle returned from callingopen()
. Sincestr
does not implementread()
orwrite()
I argue that this function shouldraise TypeError
.Sysinfo
The text was updated successfully, but these errors were encountered: