[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2020-10-18 Thread Tal Einat


Tal Einat  added the comment:

Thanks for the report and the PR, Stein!

And thanks for the PR for 3.8, Irit!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2020-10-18 Thread Tal Einat


Tal Einat  added the comment:


New changeset 1a3f7c042a32fb813835243bd7f96e47c665bfdc by Irit Katriel in 
branch '3.8':
[3.8] bpo-32498: Improve exception message on passing bytes to 
urllib.parse.unquote (GH-22746)
https://github.com/python/cpython/commit/1a3f7c042a32fb813835243bd7f96e47c665bfdc


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2020-10-18 Thread Irit Katriel


Irit Katriel  added the comment:

Ah yes, I missed that. I've pushed a PR for 3.8 that does this:

>>> urllib.parse.unquote(b'abc%20def')
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Users\User\src\cpython\lib\urllib\parse.py", line 635, in unquote
raise TypeError('Expected str, got bytes')
TypeError: Expected str, got bytes

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2020-10-18 Thread Irit Katriel


Change by Irit Katriel :


--
pull_requests: +21709
pull_request: https://github.com/python/cpython/pull/22746

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2020-10-18 Thread Tal Einat


Tal Einat  added the comment:

Thanks for the reminder Irit!

No, this should not be closed yet, as there is still the possibility of 
improving the exception in version 3.8.

--
versions: +Python 3.8

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2020-10-16 Thread Irit Katriel


Irit Katriel  added the comment:

Can this be closed? (It's intended as a 3.9-only change).

--
nosy: +iritkatriel

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2019-10-14 Thread Tal Einat


Tal Einat  added the comment:


New changeset aad2ee01561f260c69af1951c0d6fcaf75c4d41b by Tal Einat (Stein 
Karlsen) in branch 'master':
bpo-32498: urllib.parse.unquote also accepts bytes (GH-7768)
https://github.com/python/cpython/commit/aad2ee01561f260c69af1951c0d6fcaf75c4d41b


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2019-10-14 Thread Tal Einat


Tal Einat  added the comment:

So urllib.parse.unquote() will accept bytes in addition to str starting with 
3.9.

The unclear exception remains in prior versions. Would someone like to add a 
better exception for 3.7 and 3.8?

(I'm marking this as "newcomer friendly", referring only to improving the 
exception for 3.7 and 3.8.)

--
keywords: +newcomer friendly
nosy: +taleinat

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2019-10-14 Thread Tal Einat


Change by Tal Einat :


--
versions: +Python 3.9 -Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2019-10-11 Thread Joannah Nanjekye


Joannah Nanjekye  added the comment:

> Should I update the Status and Resolution of the issue here, or wait for some 
> kind of confirmation?

The status is changed after the patch is merged. The person that merges will 
usually change the status of the issue or If he/she forgets, anyone with 
developer role can update the status too.

--
nosy: +nanjekyejoannah

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-07-08 Thread stein-k


stein-k  added the comment:

I have made the News Entry and created the Pull request as described here: 
https://devguide.python.org/pullrequest/. Should I update the Status and 
Resolution of the issue here, or wait for some kind of confirmation?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-06-17 Thread stein-k


Change by stein-k :


--
pull_requests: +7376
stage:  -> patch review

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-06-17 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

@stein-k Thanks for the patch and tests. The patches apply cleanly on master 
branch. The project accepts pull requests and it will be helpful if you can 
make a PR for this on GitHub to get this merged. Since this is a bug fix I 
think it would require a News entry. Please find the below links for reference

PR workflow : https://devguide.python.org/pullrequest/
News entry reference : 
https://devguide.python.org/committing/?highlight=blurb#what-s-new-and-news-entries

Thanks

--
nosy: +xtreak

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-21 Thread stein-k

stein-k  added the comment:

Patch for tests.

Added test for calling unquote with bytes input and removed Exception raised in 
original test.

--
Added file: 
https://bugs.python.org/file47397/urllib_parse_unquote_handle_bytes_test.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-18 Thread stein-k

stein-k  added the comment:

Added a patch containing the fix, is this the proper way or should I create a 
pull request?

--
keywords: +patch
Added file: 
https://bugs.python.org/file47395/urllib_parse_unquote_handle_bytes.patch

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-07 Thread Nick Coghlan

Nick Coghlan  added the comment:

As David noted, we updated all the URL parsing functions to be polymorphic back 
in 3.2: 
https://docs.python.org/3/library/urllib.parse.html#parsing-ascii-encoded-bytes

We left the quoting functions alone, because they already had their own way of 
dealing with the bytes-vs-str distinction (quote_from_bytes, unquote_to_bytes, 
etc) that meant the polymorphic approach we adopted for the parsing functions 
didn't make sense.

That said, I think it would be reasonable to enhance unquote() to accept a 
bytes object, processing it as follows:

unquote_to_bytes(string).decode(encoding, errors)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-07 Thread R. David Murray

R. David Murray  added the comment:

I think Nick was the last one who touched the byte/string issues in urllib, so 
I've nosied him.  We'll see what he thinks (but this tracker accepts 
enhancement proposals as long as they are smallish ones).

--
nosy: +ncoghlan

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-07 Thread stein-k

stein-k  added the comment:

The unquote function does take an encoding argument, but I am more worried 
about unquote_to_to_bytes which just assumes utf-8. (But this might be an 
implementation detail of its intended usage.)

I must agree that a polymorphic implementation would be better. Do you think 
this tracker is the correct place for such a change, or would an enhancement 
proposal be more suited?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-07 Thread R. David Murray

R. David Murray  added the comment:

We generally don't do type checking (see discussions of "duck typing"). We 
generally do just let the implementation detail bubble up.  I don't think the 
encoding suggestion works, since we can't know what encoding the byte string is 
in, or even if it is a valid one.

I wonder if unquote should be polymorphic: accept both bytes and strings and 
produce the same type of output as its input.  I think there are other urllib 
methods that are, but I haven't checked.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-06 Thread stein-k

stein-k  added the comment:

The message is incorrect for the input to the function, and confusing because 
the caller did supply a bytes-like object.

The exception is from an implementation detail, and if the implementation 
changes the exception could as well. 

I suggest the implementation is changed to follow the example of  
urllib.parse.unquote_to_bytes, which encodes its string parameter to bytes if 
it receives a str object.

Alternatively, a check for required type should be implemented and raise a 
TypeError with the correct error-message.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-05 Thread R. David Murray

R. David Murray  added the comment:

If you read the traceback the message is "correct" for some definition of 
correct: the right hand side controls the type of the expression, so it is 
objecting to trying to look for the string '%' in a bytes object.

There are probably ways this could be improved, but I'm not sure it is worth 
it, since this is just a general behavior of the 'in' operator.

--
nosy: +r.david.murray

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue32498] urllib.parse.unquote raises incorrect errormessage when string parameter is bytes

2018-01-05 Thread stein-k

New submission from stein-k :

urllib.parse.unquote(b'abc%20def')
...
TypeError: a bytes-like object is required, not 'str'

--
components: Library (Lib)
messages: 309517
nosy: stein-k
priority: normal
severity: normal
status: open
title: urllib.parse.unquote raises incorrect errormessage when string parameter 
is bytes
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com