Coder Social home page Coder Social logo

backports.datetime_fromisoformat's People

Contributors

dependabot[bot] avatar movermeyer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

backports.datetime_fromisoformat's Issues

Add support for building wheels?

I noticed that this backport currently only provides a source distribution.

It'd be handy to have precompiled wheels to avoid having to build the C extension at install time.

Add Windows support

Currently, compilation fails on Windows.

Work through the compilation errors and get backports.datetime_fromisoformat working for the Windows compiler

Version 2 on conda-forge

Hi,
I was wondering why the v2.0.0 is not available on conda-forge, even though the recipe was updated here.
A package I am currently creating on bioconda requires backports-datetime-fromisoformat but is not compatible with version 1.
Could you update the package retrievable via conda-forge to version 2 or do you know why it's not available?

Greetings,
Mark

Add python 3.8 wheels

Installation under python 3.8 requires compiling this package, which requires python development headers, which is annoying in CI, so please support the latest python versions with a pre-built wheel.

Add Python 2.7 support

Extend the capability of backports.datetime_fromisoformat to allow usage within Python 2.7 projects.

error on install

Python 3.10.13, ubuntu on ARM64

In file included from backports/datetime_fromisoformat/_datetimemodule.c:66:
      backports/datetime_fromisoformat/_datetimemodule.h:1:10: fatal error: Python.h: No such file or directory
          1 | #include <Python.h>
            |          ^~~~~~~~~~
      compilation terminated.
      error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1
      [end of output]

Add Hypothesis fuzz testing

There is a nice invariant we can use Hypothesis to test.

datetime.fromisoformat is the inverse of datetime.isoformat

In other words, for every datetime object, dt, dt == datetime.fromisoformat(dt.isoformat())

Hypothesis can be used to test this invariant, using its "datetimes strategy".

import not working with user install

python3 -m pip install --user backports.datetime_fromisoformat

from backports.datetime_fromisoformat import MonkeyPatch

ModuleNotFoundError: No module named 'backports.datetime_fromisoformat'

username@hostname:/home/username/.local/lib/python3.6/site-packages/backports $ ls -l *
-rwxrwxr-x. 1 username username 54136 Oct 5 10:47 _datetime_fromisoformat.cpython-36m-x86_64-linux-gnu.so
username@hostname:/home/username/.local/lib/python3.6/site-packages/backports $

Cannot pickle datetime object with timezone

Thanks for providing this awesome backport! Today I ran into the issue that a datetime object can't be pickled when it includes a timezone. Please find the example below:

$ python
Python 3.6.5 (default, Mar 30 2018, 06:41:53)
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.39.2)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import pickle
>>> import datetime
>>> from backports.datetime_fromisoformat import MonkeyPatch
>>> MonkeyPatch.patch_fromisoformat()
>>> moment = datetime.datetime.fromisoformat('2018-11-01 20:42:09.058000+00:00')
>>> pickle.dumps(moment)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
_pickle.PicklingError: Can't pickle <class 'FixedOffset_type'>: attribute lookup FixedOffset_type on builtins failed
>>> moment = datetime.datetime.fromisoformat('2018-11-01 20:42:09.058000')
>>> pickle.dumps(moment)
b'\x80\x03cdatetime\ndatetime\nq\x00C\n\x07\xe2\x0b\x01\x14*\t\x00\xe2\x90q\x01\x85q\x02Rq\x03.'

Unfortunately, I lack the skills to create a PR to resolve this.

Monkeypatch `datetime` to add `fromisoformat`

Currently, backports.datetime_fromisoformat only exposes a method that is equivalent to datetime.fromisoformat.

Really, it should monkey-patch datetime so that usage becomes something like:

from datetime import datetime

import backports.datetime_fromisoformat
backports.datetime_fromisoformat.monkey_patch()

now = datetime.utcnow().isoformat()
now_again = datetime.fromisoformat(now)

For Python 3.7+, this should be a no-op so that it doesn't change the built-in behaviour.

Add support for PyPy

It would be nice if this library also worked with PyPy.
It might not be that hard to get it working.

Known issues

  • Py_UNICODE_IS_SURROGATE doesn't exist in PyPy
    • Easy to vendor
  • _PyUnicode_Copy doesn't exist in PyPy
  • The way we monkeypatch the methods is very cPython specific
    • Figure out the proper PyPy way

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.