[reportlab-users] deprecation warning

Jürgen Gmach juergen.gmach at apis.de
Fri Mar 19 07:34:44 EDT 2021


Hi Robin,

sorry for not providing enough information.

I ran the test suite for a proprietary python app of my company when I saw the deprecation warning.

I am on Ubuntu 18.04 and I run Python 3.8.8 (via dead snakes ppa https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa ) and pytest 6.2.2

Maybe you have turned off warnings in your test suite?



I usually provide a reproducer when I report issues, but ... huh... I hope you do not mind me being honest, compared to other open source projects, this project does not make it very easy to contribute.

First, it took me a while to find the repository ( https://hg.reportlab.com/hg-public/reportlab/file/tip/src/reportlab/platypus/paraparser.py ), then.. uhm... no hg installed here 🙂

I then found the mirror https://github.com/MrBitBucket/reportlab-mirror !! 👍

Most open source projects I contribute to use tox - so running tests for different python versions is super easy.

Nevermind, I found how to run tests in the readme.. and all pass, no deprecation warning.

Running your test suite with pytest or with `python -m unittest discover` shows quite some warnings.

e.g.

❯ python -m unittest discover
......../home/jugmac00/Projects/reportlab-mirror/tests/test_graphics_barcode.py:306: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/jugmac00/Projects/reportlab-mirror/barcode-out/index.html' mode='w' encoding='UTF-8'>
  open(os.path.join(outDir,'index.html'),'w').write('\n'.join(html))
ResourceWarning: Enable tracemalloc to get the object allocation traceback
................./home/jugmac00/Projects/reportlab-mirror/src/reportlab/graphics/shapes.py:526: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
  args, varargs, varkw, defaults = getargspec(self.__init__)
.........E.............../home/jugmac00/Projects/reportlab-mirror/tests/test_graphics_speed.py:57: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/jugmac00/Projects/reportlab-mirror/test_graphics_speed_test1.log' mode='w' encoding='UTF-8'>
  open(outputfile('test_graphics_speed_test%s.log' % (isFast+1)), 'w').write(result)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
./home/jugmac00/Projects/reportlab-mirror/tests/test_graphics_speed.py:57: ResourceWarning: unclosed file <_io.TextIOWrapper name='/home/jugmac00/Projects/reportlab-mirror/test_graphics_speed_test2.log' mode='w' encoding='UTF-8'>
  open(outputfile('test_graphics_speed_test%s.log' % (isFast+1)), 'w').write(result)
ResourceWarning: Enable tracemalloc to get the object allocation traceback
.../usr/lib/python3.8/unittest/case.py:633: ResourceWarning: unclosed file <_io.BufferedReader name='/home/jugmac00/Projects/reportlab-mirror/tests/pythonpowered.gif'>
  method()
ResourceWarning: Enable tracemalloc to get the object allocation traceback

... tons more...

or

reportlab-mirror/tests on  master [!?] via 🐍 v3.8.8 (venv)❯ python -m pytest


==================================================== warnings summary ====================================================
tests/test_graphics_charts.py: 3493 warnings
tests/test_graphics_render.py: 444 warnings
  /home/jugmac00/Projects/reportlab-mirror/src/reportlab/graphics/shapes.py:526: DeprecationWarning: inspect.getargspec() is deprecated since Python 3.0, use inspect.signature() or inspect.getfullargspec()
    args, varargs, varkw, defaults = getargspec(self.__init__)

tests/test_lib_utils.py::ImporterTestCase::test2
  /home/jugmac00/Projects/reportlab-mirror/tools/pythonpoint/stdparser.py:10: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
    import string, imp, sys, os, copy


Please note, that both pytest and unittest have some failures, because I think you use some path manipulation magic when doing a `python setup.py tests` run.

(Another note: `python setup.py tests` is deprecated - actually, python setup.py anything is deprecated -> quote from a python core dev, who refuses to write a blog post about it, which I could link to so often 🙂 )

My conclusion ... your current way of running tests suppresses warnings (and is deprecated).

pytest is super awesome, but it is an external dependency. unittest discover is pretty ok, too 🙂


Jürgen

________________________________
Von: Robin Becker <robin at reportlab.com>
Gesendet: Freitag, 19. März 2021 10:45
An: reportlab-users <reportlab-users at lists2.reportlab.com>; Christoph Zwerschke <cito at online.de>; Jürgen Gmach <juergen.gmach at apis.de>
Betreff: Re: [reportlab-users] deprecation warning

Thanks  Jürgen,

I don't know how many tests I have to run, but I don't see this warning in 2.7.18, 3.7.5, 3.8.6, 3.9.2 & 3.10.0a6. It
doesn't show in the various github action / appveyor wheel builds.

Jürgen can you say what OS, exact version of python 3.8 and what command line options if any were used?

I will put this into the latest release.

On 19/03/2021 09:21, Christoph Zwerschke wrote:
>
> On 19.03.2021 10:15, Jürgen Gmach wrote:
>> just updated to the latest reportalb version and now I get the
>> following deprecation warning on Python 3.8 >
>  > DeprecationWarning: invalid escape sequence \s
>  >      _re_unit = re.compile('^\s*(.*)(i|in|cm|mm|pt|pica)\s*$'),
>
> The warning is shown because this should be either a raw string or the "\s" needs double escaping.
>
> -- Christoph
> _______________________________________________
> reportlab-users mailing list
> reportlab-users at lists2.reportlab.com
> https://pairlist2.pair.net/mailman/listinfo/reportlab-users


--
Robin Becker
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist2.pair.net/pipermail/reportlab-users/attachments/20210319/477d23bb/attachment-0001.html>


More information about the reportlab-users mailing list