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

Uses time.clock() on Windows which is gone with Python 3.8 #301

Closed
lazka opened this issue Jul 23, 2019 · 5 comments

Comments

@lazka
Copy link
Contributor

commented Jul 23, 2019

time_func = time.clock

Traceback (most recent call last):
  File "C:\Python38\venv\cpython3.8-2459c2ec2c3d\lib\site-packages\pyperformance\benchmarks\bm_mako.py", line 20, in <module>
    from mako.template import Template   # noqa
  File "C:\Python38\venv\cpython3.8-2459c2ec2c3d\lib\site-packages\mako\template.py", line 10, in <module>
    from mako.lexer import Lexer
  File "C:\Python38\venv\cpython3.8-2459c2ec2c3d\lib\site-packages\mako\lexer.py", line 11, in <module>
    from mako import parsetree, exceptions, compat
  File "C:\Python38\venv\cpython3.8-2459c2ec2c3d\lib\site-packages\mako\parsetree.py", line 9, in <module>
    from mako import exceptions, ast, util, filters, compat
  File "C:\Python38\venv\cpython3.8-2459c2ec2c3d\lib\site-packages\mako\exceptions.py", line 11, in <module>
    from mako import util, compat
  File "C:\Python38\venv\cpython3.8-2459c2ec2c3d\lib\site-packages\mako\util.py", line 11, in <module>
    from mako import compat
  File "C:\Python38\venv\cpython3.8-2459c2ec2c3d\lib\site-packages\mako\compat.py", line 123, in <module>
    time_func = time.clock
AttributeError: module 'time' has no attribute 'clock'

Using timeit.default_timer() instead would work as far as I can see.

@zzzeek

This comment has been minimized.

Copy link
Member

commented Jul 23, 2019

can we deprecate windows ? :) haha. OK, first I'm seeing about "default_timer" but it's documetned as always "perf_counter()" and in 3.3 on above. Can we use perf_counter() on all platforms ?

@zzzeek

This comment has been minimized.

Copy link
Member

commented Jul 23, 2019

also are you available to send a PR using perf_counter() for Python 3.3 and above ? it would help a lot.

lazka added a commit to lazka/mako that referenced this issue Jul 24, 2019

compat: use timeit.default_timer instead of time.clock which is gone …
…in Python 3.8

Python 3.8 has dropped the deprecated time.clock() function which makes mako fail
with an AttributeError on import on Windows.

The way time_func was defined (clock() on Windows and time() everywhere else) made it
return a high precision wall clock time without a defined reference. This is exactly
what timeit.default_timer() does for all versions of Python on all platforms,
so just use that instead.

Fixes sqlalchemy#301
@lazka

This comment has been minimized.

Copy link
Contributor Author

commented Jul 24, 2019

Sure -> #302

@sqla-tester

This comment has been minimized.

Copy link
Collaborator

commented Jul 26, 2019

Christoph Reiter has proposed a fix for this issue in the master branch:

compat: use timeit.default_timer instead of time.clock which is gone in Python 3.8 https://gerrit.sqlalchemy.org/1377

@sqla-tester

This comment has been minimized.

Copy link
Collaborator

commented Jul 27, 2019

Christoph Reiter has proposed a fix for this issue in the master branch:

use timeit.default_timer instead of time.clock() / time.time() https://gerrit.sqlalchemy.org/1377

lazka added a commit to lazka/pyperformance that referenced this issue Aug 9, 2019

Update mako to 1.1.0 for Python 3.8 on Windows fixes
The last release allows mako to run on Windows with Python 3.8, see
sqlalchemy/mako#301 for details

Fixes python#63

vstinner added a commit to python/pyperformance that referenced this issue Aug 12, 2019

Update mako to 1.1.0 for Python 3.8 on Windows fixes (#72)
The last release allows mako to run on Windows with Python 3.8, see
sqlalchemy/mako#301 for details

Fixes #63
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.