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

Does not fall back to default wordlist if INFILE doesn't exist #43

Closed
bhavin192 opened this issue Dec 29, 2017 · 3 comments · Fixed by #44
Closed

Does not fall back to default wordlist if INFILE doesn't exist #43

bhavin192 opened this issue Dec 29, 2017 · 3 comments · Fixed by #44

Comments

@bhavin192
Copy link
Contributor

$ diceware nonexistingfile
Traceback (most recent call last):
  File "/home/bgandhi/diceware/py36/bin/diceware", line 11, in <module>
    load_entry_point('diceware==0.9.4.dev0', 'console_scripts', 'diceware')()
  File "/home/bgandhi/diceware/diceware/__init__.py", line 211, in main
    print(get_passphrase(options))
  File "/home/bgandhi/diceware/diceware/__init__.py", line 184, in get_passphrase
    word_list = WordList(options.infile)
  File "/home/bgandhi/diceware/diceware/wordlist.py", line 126, in __init__
    self.fd = open(self.path, "r")
FileNotFoundError: [Errno 2] No such file or directory: 'nonexistingfile'
Exception ignored in: <bound method WordList.__del__ of <diceware.wordlist.WordList object at 0x7f94008f2dd8>>
Traceback (most recent call last):
  File "/home/bgandhi/diceware/diceware/wordlist.py", line 131, in __del__
    self.fd.close()
AttributeError: 'WordList' object has no attribute 'fd'

I'm working on a patch for this.

@ulif
Copy link
Owner

ulif commented Dec 30, 2017

Thank you @bhavin192 for your observation!

I agree that the error message looks confusing and should be more concise in case of "file-not-found".

But an error message is IMHO the correct way to signal a missing file to the user. Especially, if a file path was explicitly given. Therefore I'd oppose to fall back here to any default INFILE.

In my view, the right fix would be to make the error message better understandable. But please do not make the error disappear entirely.

@bhavin192
Copy link
Contributor Author

bhavin192 commented Dec 31, 2017

Got your point, will it be better if we show an error like this?

The file <INFILE> not found, using default wordlist

or just show the error something like this one and stop?

The file <INFILE> does not exist!

@ulif
Copy link
Owner

ulif commented Jan 1, 2018

I think the latter will be correct.

A user requesting myfile does not want any default file, he wants myfile. If it does not exist, let's tell him. I do not thinkl, we should try to be smart in that case.

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

Successfully merging a pull request may close this issue.

2 participants