Boost logo

Boost Users :

Subject: [Boost-users] [Boost.DateTime][Boost.Python] Year out of valid range error when streaming via Python module
From: SamuelG (sam.gundry_at_[hidden])
Date: 2010-08-31 02:11:55

This problem occurs at a higher level but I've tried to strip it back. I've
reproduced this problem GCC 4.3.4, Python 2.6.5 and Boost 1.41.0 32bit and
64bit Debians/Ubuntu. The problem does not seem to happen on Windows XP.

I have embedded the Python interpreter in the attached run_python.cpp . When
running this with the attached script and which uses a test
test_date_time.cpp , the following Boost.DateTime error occurs:

$ run_python
out() - entry
out() - to_simple_string(): 2010-Aug-31 14:30:33.439172000
out() - manual format: 2010-Aug-31 14509:17:19.172000
out() - oss.str(): 2010-Aug-31 14509:17:19.172000
out() - now: Traceback (most recent call last):
  File "", line 6, in <module>
IndexError: Year is out of valid range: 1400..10000

However, when running the same script via python it is fine:
$ python
out() - entry
out() - to_simple_string(): 2010-Aug-31 14:30:31.208160000
out() - manual format: 2010-Aug-31 14:30:31.208160000
out() - oss.str(): 2010-Aug-31 14:30:31.208160000
out() - now: 2010-Aug-31 14:30:31.208160000
out() - exit

Note that the time stamp in the first example is corrupt. Note also that the
valid range error does not occur when using the date and time facets
manually but when streaming the ptime object to std::cerr.

The problem first arose for me when using Boost.Log with separate Python
modules via *both* run_python and /usr/bin/python. See

For this simple case, /usr/bin/python seems okay but the run_python error is
identical to what happens in our proper application (where Boost.Log is used
and multiple Python modules loaded).

Has anyone witnessed similar behaviour? Or can they please test my example

Thanks for any help,

View this message in context:
Sent from the Boost - Users mailing list archive at

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at