treyhunner
Repos
260
Followers
799
Following
78

Trey's preferred style for writing Python code and more

65
14

EditorConfig universal issue tracker and wiki

2839
99

Create default configurations for your named tmux sessions

135
8

Random name generator

427
107

Store model history and view/revert changes from admin site.

1771
391

My dotfiles

22
6

Events

Created at 1 day ago
Remove python 3.6

Merged. Let's hope it passes! 🤞

Created at 2 days ago

Remove python 3.6

Use github for flake8

Merge pull request #39 from spapas/remove-python3.6

Remove python 3.6

Created at 2 days ago
pull request closed
Remove python 3.6
Created at 2 days ago
Tests are failing for python 3.6 on ubuntu latest

I agree. 👍 Let's drop support for anything that's been EOL'd for over a year.

Created at 5 days ago
issue comment
datetime.strptime becomes None after first run in WASM environment

To re-initialize I'm posting a run message to the web worker, which calls callMain(event.data.args) again.

Created at 6 days ago
closed issue
unittest.mock does not work on WebAssembly build of CPython

Bug report

Use CPython compiled for WebAssembly and then import unittest.mock

Or visit this page and click the "Run in Browser" button to see the error.

The error shown is:

Traceback (most recent call last):
  File "//__main__.py", line 2, in <module>
    import unittest.mock
  File "/home/runner/work/cpython-wasm-test/cpython-wasm-test/cpython/Lib/unittest/mock.py", line 26, in <module>
  File "/home/runner/work/cpython-wasm-test/cpython-wasm-test/cpython/Lib/asyncio/__init__.py", line 8, in <module>
  File "/home/runner/work/cpython-wasm-test/cpython-wasm-test/cpython/Lib/asyncio/base_events.py", line 18, in <module>
ModuleNotFoundError: No module named 'concurrent'

This error seems to only occur on the WebAssembly build for the browser (the Node build allows unittest.mock to be imported as expected).

Your environment

  • CPython versions tested on: 3.11.0rc2
  • Operating system and architecture: WebAssembly
Created at 6 days ago
issue comment
unittest.mock does not work on WebAssembly build of CPython

Closing, as unittest.mock works for me now

Created at 6 days ago
closed issue
unittest.mock.patch does not work on WASM build

Bug report

When importing unittest.mock, an exception is raised due to unittest.mock importing asyncio.

It seems the asyncio library is only used in unittest.mock when mocking async functions.

I believe delaying the import of asyncio until the moment it's needed would make unittest.mock functional for most use cases on WASM builds.

A demonstration of the error: https://www.pythonmorsels.com/r/35fv2/

Your environment

CPython 3.11.0rc1 built with Emscripten for the web browser

Created at 6 days ago
issue comment
unittest.mock.patch does not work on WASM build

Duplicate of #96883. I accidentally opened this issue twice.

Created at 6 days ago
treyhunner delete branch add-links
Created at 1 week ago
pull request opened
Add relative links to related documents
Created at 1 week ago
treyhunner create branch add-links
Created at 1 week ago
opened issue
datetime.strptime becomes None after first run in WASM environment

Bug report

The following code runs correctly the first time but then complains that datetime.strptime is of type NoneType the second time the code is run within the same browser session.

"""Demonstrates WASM issue with datetime.strptime."""
from datetime import datetime

print(datetime.strptime("2023-01-13", "%Y-%m-%d"))
print(datetime.strptime("2023-01-13", "%Y-%m-%d"))

Live example here: https://pym.dev/p/2g6wn/

Note that running datetime.strptime twice doesn't cause an issue. The issue seems to be due to exiting Python and then re-entering it. For example in an interactive session, one would need to call exit() and then start the interactive session again in the same browser window (example here).

>>> from datetime import datetime
>>> datetime.strptime("2023", "%Y")
datetime.datetime(2023, 1, 1, 0, 0)
>>> exit()  # The REPL is automatically re-entered after this
>>> from datetime import datetime
>>> datetime.strptime("2023", "%Y")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'NoneType' object is not callable

Your environment

CPython 3.11.0 compiled to Emscripten for the browser.

Created at 2 weeks ago
using override_settings(CACHALOT_ENABLED=False) has no effect

What happened?

I'm using freezegun, so I'm affected by #126.

When I set CACHALOT_ENABLED= False in my settings, my tests pass.

I'd prefer to use cachalot for most of my tests and only disable it for the tests where freezegun is used. When I use override_settings(CACHALOT_ENABLED=False), the setting does change but the queries with the test are still cached.

What should've happened instead?

Using the override_settings decorator to disable CACHALOT_ENABLED should have disabled caching during the decorated test.

Steps to reproduce

Use the @override_settings(CACHALOT_ENABLED=False) decorator on a test that uses freezegun.freeze_time for a long past date. When calling the refresh_from_db() method on a model instance, the instance will not refresh even if it has been changed.

I'm using Docker with Postgres and on Django 3.2.7.

Created at 2 weeks ago
Created at 1 month ago
Created at 1 month ago
Use editorconfig.org subdomain

@xuhdev @ffes I added the CNAME record. It looks like there's an SSL error now though.

Created at 1 month ago

Site updated at 2022-12-02 18:38:00 UTC

Created at 1 month ago