Bug 784431

Summary: isodate formatting of datetime instances with local timezone fails
Product: [Fedora] Fedora Reporter: Jason Connor <jconnor>
Component: python-isodateAssignee: James Laska <jlaska>
Status: CLOSED ERRATA QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: unspecified    
Version: rawhideCC: jlaska, jmatthew, jturner, mmccune
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: python-isodate-0.4.7-1.fc16 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-02-08 02:27:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
patch that detects None datetime instance and substitutes now()
none
quick python script that demonstrates the bug none

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.