Skip to content

Commit

Permalink
Version 1.2.0
Browse files Browse the repository at this point in the history
Upgraded PyO3 and chrono to the latest versions.
  • Loading branch information
gukoff committed Dec 2, 2020
1 parent cb6baf4 commit 0b9452b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
authors = ["Konstantin Gukov <gukkos@gmail.com>"]
name = "python-dtparse"
version = "1.0.0"
version = "1.2.0"

[dependencies]
pyo3 = "0.11.1"
chrono = "0.4.13"
pyo3 = "0.12.4"
chrono = "0.4.19"

[lib]
name = "dtparse"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def run(self):

setup(
name='dtparse',
version='1.1.1',
version='1.2.0',
classifiers=[
'License :: OSI Approved :: MIT License',
'Development Status :: 3 - Alpha',
Expand Down
10 changes: 5 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ extern crate pyo3;
extern crate chrono;

use chrono::prelude::*;
use pyo3::exceptions;
use pyo3::exceptions::*;
use pyo3::prelude::*;
use pyo3::types::*;

// https://pyo3.rs/v0.11.1/module.html
// https://pyo3.rs/v0.12.4/module.html
// This macro makes Rust compile a _dtparse.so binary in Python-compatible format.
// Such a binary can be imported from Python just like a regular Python module.
#[pymodule(_dtparse)]
Expand All @@ -20,11 +20,11 @@ fn init_mod(_py: Python, m: &PyModule) -> PyResult<()> {
let chrono_dt = Utc.datetime_from_str(str_datetime.as_str(), fmt.as_str());

// In case chrono couldn't parse a datetime, raise a ValueError with chrono's error message.
// Because there are no exceptions in Rust, we return a ValueError instance here.
// Because there are no exceptions in Rust, we return a PyValueError instance here.
// By convention, it will make PyO3 wrapper raise an exception in Python interpreter.
// https://pyo3.rs/v0.11.1/exception.html
// https://pyo3.rs/v0.12.4/exception.html
if chrono_dt.is_err() {
return Err(exceptions::ValueError::py_err(
return Err(PyValueError::new_err(
chrono_dt.err().unwrap().to_string().to_owned(),
));
}
Expand Down

0 comments on commit 0b9452b

Please sign in to comment.