Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Error message wrong???
#1
First of all, my English is poor. So please forgive me.

I was coding with python3. Specific version → Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
when I used 'urllib.parse.unquote' to unquote data, it throw a exception like this:
Error:
Error: Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> parse.unquote(bytes_test) File "D:\Python3\lib\urllib\parse.py", line 609, in unquote if '%' not in string: TypeError: a bytes-like object is required, not 'str'
In my understanding, this message told me: "I need a 'bytes-like object' but you give me a 'str'. So it's wrong."
So I tried to make the variable to 'bytes-like object', but it did not work.
In the end, I found that this function actually needed a 'str' but not a 'bytes-like object'.
Is this error message wrong? Or I just misunderstand what it means. Huh Huh Huh
Reply
#2
The error is referring to the if '%' not in string: part, which is in urllib code, so it is correct.

I do agree that it would probably be less confusing if the error was thrown when calling the function with a wrong type, instead of it happening when the function was already being executed...
Reply
#3
(Sep-13-2018, 09:22 AM)stranac Wrote: The error is referring to the if '%' not in string: part, which is in urllib code, so it is correct.

I do agree that it would probably be less confusing if the error was thrown when calling the function with a wrong type, instead of it happening when the function was already being executed...

I see, thanks~~ Smile
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Error message about iid from RandomizedSearchCV Visiting 2 1,043 Aug-17-2023, 07:53 PM
Last Post: Visiting
  Receiving this error in my "response" and causes script to return wrong status cubangt 18 2,105 Aug-13-2023, 12:16 AM
Last Post: cubangt
  Wrong type error rowan_bradley 6 1,278 Aug-07-2023, 10:44 AM
Last Post: rowan_bradley
  Compiles Python code with no error but giving out no output - what's wrong with it? pythonflea 6 1,592 Mar-27-2023, 07:38 AM
Last Post: buran
  Another Error message. the_jl_zone 2 995 Mar-06-2023, 10:23 PM
Last Post: the_jl_zone
  Am I wrong or is Udemy wrong? String Slicing! Mavoz 3 2,599 Nov-05-2022, 11:33 AM
Last Post: Mavoz
  Mysql error message: Lost connection to MySQL server during query tomtom 6 16,177 Feb-09-2022, 09:55 AM
Last Post: ibreeden
  understanding error message krlosbatist 1 1,924 Oct-24-2021, 08:34 PM
Last Post: Gribouillis
  Error message pybits 1 43,186 May-29-2021, 10:26 AM
Last Post: snippsat
  Message is going at wrong time quest 0 1,548 Apr-07-2021, 01:35 PM
Last Post: quest

Forum Jump:

User Panel Messages

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