2

Has it changed? I am just using it as import pdb; pdb.set_trace() but in the line the pdb is used it throws now:

NameError: name 'raw_input' is not defined

For those asking for full traceback:

My app traceback and then:
    if not serializer.is_valid():
  vi +48  /usr/lib/python3.5/bdb.py  # trace_dispatch
    return self.dispatch_line(frame)
  vi +66  /usr/lib/python3.5/bdb.py  # dispatch_line
    self.user_line(frame)
  vi +259 /usr/lib/python3.5/pdb.py  # user_line
    self.interaction(frame, None)
  vi +346 /usr/lib/python3.5/pdb.py  # interaction
    self._cmdloop()
  vi +319 /usr/lib/python3.5/pdb.py  # _cmdloop
    self.cmdloop()
  vi +32  /home/user/.virtualenvs/myapp/lib/python3.5/site-packages/noseprogressive/wrapping.py  # cmdloop
    orig_raw_input = raw_input
NameError: name 'raw_input' is not defined

Looks very python3.5 pdb to me, nothing about 2.7 pdb

lapinkoira
  • 8,320
  • 9
  • 51
  • 94
  • Possible duplicate of [How do I use raw\_input in Python 3](https://stackoverflow.com/questions/954834/how-do-i-use-raw-input-in-python-3) – The Pjot Jul 01 '19 at 09:49
  • I am not using directly raw_input, I think that's used internally when I call import pdb; pdb.set_trace – lapinkoira Jul 01 '19 at 09:52
  • I am using python 3.5.2 – lapinkoira Jul 01 '19 at 09:55
  • Is `pdb.__file__` location in the same location as the python interpreter? It would probably be useful to show us the entire stack trace – bentheiii Jul 01 '19 at 10:03
  • Full traceback is there, it's everything 3.5 – lapinkoira Jul 01 '19 at 11:00
  • @ThePjot how can this be duplicated? have you even read the question? – lapinkoira Jul 01 '19 at 11:01
  • nose-progressive==1.5.1 – lapinkoira Jul 01 '19 at 11:10
  • 1
    Have you tried updating the `noseprogressive` version? because I see the latest is `1.5.2` And I guess if you are using `Python3` in the `wrapping.py` file you can remove lines from `32` to `34`. But not sure. DYOR. and also I'm not sure why they didn't mention `3.5.2` in `setup.py` file - https://github.com/erikrose/nose-progressive/blob/master/setup.py – Underoos Jul 01 '19 at 11:12
  • didnt think about a minor version have breaking changes but will update it now – lapinkoira Jul 01 '19 at 11:13
  • 2
    @lapinkoira apologies, I indeed did not fully read your question. Problem indeed seems to be the `noseprogressive` package you're using as @Sukumar Rdjf mentioned. – The Pjot Jul 01 '19 at 11:23
  • Well, actually, that was it, 1.5.1 doesnt work but 1.5.2 does – lapinkoira Jul 01 '19 at 11:34
  • @lapinkoira you could have solved this issue by yourself quite easily by reading the traceback and checking noseprogressive's git page. – bruno desthuilliers Jul 01 '19 at 11:42
  • @brunodesthuilliers hindsight every issue here is always cleaner though I didnt see your comment here helping to solve it, what's the point of your not asked feedback? – lapinkoira Jul 01 '19 at 11:49
  • @lapinkoira I didn't post an answer because by the time I finished checking nosetest's code Sukumar Rdjf already posted the solution. And the point of my "not asked" feedback was to help you and everyone reading this question solve similar issues by themselves. Oh and yes: no "hindsight" required here, reading traceback and the related code is the very first obvious thing to do when you get an exception. That's what both Sukumar and me did, and that's what you should have done before posting here (cf https://stackoverflow.com/help/how-to-ask) – bruno desthuilliers Jul 01 '19 at 11:55
  • @brunodesthuilliers If you had take 5 minutes to read the responses, something you didnt even do, you would have seen the chain of thoughts where I say I wouldnt check the changelog of a minor change version, 1.5.1 to 1.5.2 as enabling python3.5 support. I dont see your comment as helpful because someone landing here will check the accepted response and not your "check traceback, told you so" comments. – lapinkoira Jul 01 '19 at 12:05
  • @lapinkoira as I said, Sukumar hadn't posted his answer (nor comment) yet when I first read the question. – bruno desthuilliers Jul 01 '19 at 12:17

2 Answers2

3

Here's the issue.

You are using noseprogressive library with 1.5.1 version which is too old around 6 years ago (26 Mar 2013 which is developed for Python 2.7 I guess).

https://github.com/erikrose/nose-progressive/blob/1.5.1/noseprogressive/wrapping.py#L32

They didn't handle the exception where they are assigning raw_input to a variable orig_raw_input which is why you are getting the NameError when using raw_input


But in the latest version 1.5.2, they handled it properly using try and catch.

https://github.com/erikrose/nose-progressive/blob/1.5.2/noseprogressive/wrapping.py#L33

Try updating the noseprogressive library to the latest version which is 1.5.2 and it should be fine.

Hope this helps.

Underoos
  • 4,708
  • 8
  • 42
  • 85
  • 1
    Yes, that was it, didnt think about that because it was a minor version, but 1.5.1 doesnt support python3.5 – lapinkoira Jul 01 '19 at 11:36
0

For Python 3.x, use input() . For Python 2.x, use raw_input() . Don't forget you can add a prompt string in your input() call to create one less print statement. input("GUESS THAT NUMBER!") here is the documentation https://docs.python.org/3/whatsnew/3.0.html

  • I am neither using input or raw_input, I use import pdb; pdb.set_trace() as it's documented here https://docs.python.org/3.2/library/pdb.html, I beleive it uses internally raw_input – lapinkoira Jul 01 '19 at 09:52
  • 2
    You can rest assured that the `pdb` that comes with your Python is not itself going to use functions that don't exist. Are you sure you're importing the correct `pdb`? Try `import pdb; print(pdb.__file__)` and make sure you're not just importing some random module on your path also named `pdb`. Also check `sys.path` and make sure you're not mixing up standard libraries of different Python versions. – Iguananaut Jul 01 '19 at 10:23
  • In [2]: import pdb; print(pdb.__file__) /usr/lib/python3.5/pdb.py – lapinkoira Jul 01 '19 at 10:44
  • I added the full traceback – lapinkoira Jul 01 '19 at 11:01