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

better deprecation warning for Response.body_as_unicode() #4579

Merged
merged 1 commit into from May 18, 2020

Conversation

kmike
Copy link
Member

@kmike kmike commented May 15, 2020

A follow-up to #4555.
In Scrapy master the following warning is logged:

[py.warnings] WARNING: /Users/kmike/envs/foo/lib/python3.8/site-packages/scrapy/http/response/text.py:66: ScrapyDeprecationWarning: Response.body_as_unicode() is deprecated, please use Response.text instead.
  warnings.warn('Response.body_as_unicode() is deprecated, '

It is not easily actionable because it doesn't point to the user code; it is unclear where the problem is actually happening. Adding stacklevel=2 fixes it:

[py.warnings] WARNING: /Users/kmike/svn/myspider/foo/bar/spiders/newsmonitor.py:53: ScrapyDeprecationWarning: Response.body_as_unicode() is deprecated, please use Response.text instead.
  print(response.body_as_unicode())

@codecov
Copy link

codecov bot commented May 15, 2020

Codecov Report

Merging #4579 into master will decrease coverage by 0.02%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master    #4579      +/-   ##
==========================================
- Coverage   84.57%   84.55%   -0.03%     
==========================================
  Files         164      164              
  Lines        9931     9931              
  Branches     1477     1477              
==========================================
- Hits         8399     8397       -2     
- Misses       1266     1267       +1     
- Partials      266      267       +1     
Impacted Files Coverage Δ
scrapy/http/response/text.py 100.00% <ø> (ø)
scrapy/core/downloader/__init__.py 89.47% <0.00%> (-1.51%) ⬇️

Copy link
Member

@elacuesta elacuesta left a comment

Nice catch!

@Gallaecio Gallaecio merged commit bcc40c4 into master May 18, 2020
2 checks passed
@elacuesta elacuesta deleted the body_as_unicode_warning branch May 18, 2020
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 this pull request may close these issues.

None yet

3 participants