Bug 784431 - isodate formatting of datetime instances with local timezone fails
Summary: isodate formatting of datetime instances with local timezone fails
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: python-isodate
Version: rawhide
Hardware: Unspecified
OS: Linux
unspecified
medium
Target Milestone: ---
Assignee: James Laska
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-01-24 22:03 UTC by Jason Connor
Modified: 2014-03-31 01:39 UTC (History)
4 users (show)

Fixed In Version: python-isodate-0.4.7-1.fc16
Clone Of:
Environment:
Last Closed: 2012-02-08 02:27:09 UTC
Type: ---
Embargoed:


Attachments (Terms of Use)
patch that detects None datetime instance and substitutes now() (659 bytes, patch)
2012-01-24 22:04 UTC, Jason Connor
no flags Details | Diff
quick python script that demonstrates the bug (140 bytes, text/plain)
2012-01-25 17:11 UTC, Jason Connor
no flags Details

Description Jason Connor 2012-01-24 22:03:34 UTC
User-Agent:       Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/535.7 (KHTML, like Gecko) Chrome/16.0.912.75 Safari/535.7

None is passed into the LocalTimezone instance methods for the datetime object, which is not supported in the _isdst method

Reproducible: Always

Steps to Reproduce:
1.create datetime instance with isodate.LOCAL tzinfo
2.pass instance into isodate.strftime method
3.get traceback
Actual Results:  
tracback

Expected Results:  
iso8601 formatted datetime instance with local timezone

patch provided

Comment 1 Jason Connor 2012-01-24 22:04:35 UTC
Created attachment 557330 [details]
patch that detects None datetime instance and substitutes now()

should be submitted upstream

Comment 2 James Laska 2012-01-25 12:57:55 UTC
Thanks for the bug report.  Surprisingly, I'm not incredibly familiar with the isodate codebase, but from what I can tell, with or without the provided patch, the result is unchanged.  

# python -c 'import isodate ; isodate.strftime(isodate.LOCAL, "%Y")'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "isodate/isostrf.py", line 207, in strftime
    return _strfdt(tdt, format, yeardigits)
  File "isodate/isostrf.py", line 182, in _strfdt
    format)
  File "/usr/lib64/python2.7/re.py", line 151, in sub
    return _compile(pattern, flags).sub(repl, string, count)
  File "isodate/isostrf.py", line 179, in repl
    return STRF_DT_MAP[match.group(0)](tdt, yeardigits)
  File "isodate/isostrf.py", line 97, in <lambda>
    (('%%0%dd' % yds) % tdt.year),
AttributeError: 'LocalTimezone' object has no attribute 'year'

I'm likely not triggering the failure you've reported.  Can you supply the reproducer?  And yes, this suggested patch should likely go upstream.  I can help with that in this bug report if you like.

Comment 3 Jason Connor 2012-01-25 17:11:34 UTC
Created attachment 557487 [details]
quick python script that demonstrates the bug

Comment 4 Fedora Update System 2012-01-26 20:53:14 UTC
python-isodate-0.4.7-1.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/FEDORA-2012-0889/python-isodate-0.4.7-1.fc16

Comment 5 Fedora Update System 2012-01-28 03:27:21 UTC
Package python-isodate-0.4.7-1.fc16:
* should fix your issue,
* was pushed to the Fedora 16 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing python-isodate-0.4.7-1.fc16'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2012-0889/python-isodate-0.4.7-1.fc16
then log in and leave karma (feedback).

Comment 6 Fedora Update System 2012-02-08 02:27:09 UTC
python-isodate-0.4.7-1.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.