Python Forum
Name error : name 'honey' is not defined
Thread Rating:
  • 1 Vote(s) - 1 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Name error : name 'honey' is not defined
#1
I have no idea how to get rid of this error. I did read about changing the sys.path but I don't understand how to do it because it's not working at all. Can someone help me fix this error?

hashes.py :

def encode(self, password, salt, iterations=None):
sweetwords = ['road,models,table']
honeywordtweak = 3
sweetwords_len = len(sweetwords)
if iterations is None:
iterations = self.iterations
sweetwords.extend(honey.gen(password, base64, ["passfiles.txt"]))
for i in range(0, 3):
sweetwords.extend(honeywordtweak.tweak(password, 3))
random.shuffle(sweetwords)

hashes =
for swd in sweetwords:
hashes.append(self.hash(swd, salt, iterations))
self.honeydetector.update_index(salt, sweetwords.index(password))
h = Sweetwords(salt=salt, sweetwords = pickle.dumps(hashes))
h.save()
return "%s$%d$%s$%s" %(self.algorithm, iterations, salt, hashes[0])

the error is from that line consists of honey that i bold .

honey is a python file that i created to generate my custom password hasher
honey is in same directory as hashers.py which is honeywordHasher

i already import :

from honeywordHasher.honey import HoneywordsGenerator

in hashers.py .

i cant find where is my mistakes . i have been trying to fix this error for 2 days . this error makes me cannot submit my registration form .
Reply
#2
When you re-post your code listing, also include the error traceback.
Reply
#3
I have no idea how to get rid of this error. I did read about changing the sys.path but I don't understand how to do it because it's not working at all. Can someone help me fix this error?

Quote:Traceback:

File "C:\Users\Adila\Envs\tryFOUR\lib\site-packages\django\core\handlers\exception.py" in inner
41. response = get_response(request)

File "C:\Users\Adila\Envs\tryFOUR\lib\site-packages\django\core\handlers\base.py" in _get_response
187. response = self.process_exception_by_middleware(e, request)

File "C:\Users\Adila\Envs\tryFOUR\lib\site-packages\django\core\handlers\base.py" in _get_response
185. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "C:\Users\Adila\Documents\tryFOUR\src\register\views.py" in register
13. user = form.save(commit=False)

File "C:\Users\Adila\Documents\tryFOUR\src\custom_user\forms.py" in save
50. user.set_password(self.cleaned_data["password1"])

File "C:\Users\Adila\Envs\tryFOUR\lib\site-packages\django\contrib\auth\base_user.py" in set_password
105. self.password = make_password(raw_password)

File "C:\Users\Adila\Envs\tryFOUR\lib\site-packages\django\contrib\auth\hashers.py" in make_password
84. return hasher.encode(password, salt)

File "C:\Users\Adila\Documents\tryFOUR\src\honeywordHasher\hashers.py" in encode
50. sweetwords.extend(honey.gen(password, base64, ["passfiles.txt"]))

Exception Type: NameError at /accounts/register/
Exception Value: name 'honey' is not defined

hashers.py :
def encode(self, password, salt, iterations=None):
sweetwords = ['road,models,table']
honeywordtweak = 3
sweetwords_len = len(sweetwords)
if iterations is None:
iterations = self.iterations
sweetwords.extend(honey.gen(password, base64, ["passfiles.txt"]))
for i in range(0, 3):
sweetwords.extend(honeywordtweak.tweak(password, 3))
random.shuffle(sweetwords)

hashes =
for swd in sweetwords:
hashes.append(self.hash(swd, salt, iterations))
self.honeydetector.update_index(salt, sweetwords.index(password))
h = Sweetwords(salt=salt, sweetwords = pickle.dumps(hashes))
h.save()
return "%s$%d$%s$%s" %(self.algorithm, iterations, salt, hashes[0])
honey is a python file that i created to generate my custom password hasher
honey is in same directory as hashers.py which is honeywordHasher

i already import
from honeywordHasher.honey import HoneywordsGenerator
in hashers.py .

i cant find where is my mistakes . i have been trying to fix this error for 2 days . this error makes me cannot submit my registration form .
Reply
#4
The error message is saying that honey is not defined, and it's not,
at least not in the code you are showing.
Did you forget to instantiate an import?
Reply
#5
(Oct-25-2017, 10:34 PM)Larz60+ Wrote: The error message is saying that honey is not defined, and it's not,
at least not in the code you are showing.
Did you forget to instantiate an import?

how to import a file that i created ? i have tried before this and it give me an error Cry
Reply
#6
What have you tried? If your file is called honey.py you import it like this: import honey. Without the file extension. Also, you define 'hashes' without a value. It have to be hashes = []
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply
#7
(Oct-31-2017, 08:21 AM)wavic Wrote: What have you tried? If your file is called honey.py you import it like this: import honey. Without the file extension. Also, you define 'hashes' without a value. It have to be hashes = []

i have tried
Quote: import honey
and it give me an import error : no module named honey

i also tried
Quote:import honeywordHasher.honey as honey
and it give me an attribute error : module named 'honeywordHasher.honey' has no attribute 'gen'
(honey.py is in honeywordHasher file) the traceback is still in the same line btw
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020