Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixes tzname return type #7705

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 29, 2016
Merged

Fixes tzname return type #7705

merged 1 commit into from
Dec 29, 2016

Conversation

Kojoley
Copy link
Member

@Kojoley Kojoley commented Dec 29, 2016

Closes #7630

@Kojoley Kojoley added this to the 2.0.1 (next bug fix release) milestone Dec 29, 2016
@@ -465,6 +465,11 @@ def test_DayLocator():
mdates.DayLocator(interval=1.0)


def test_tz_utc():
dt = datetime.datetime(1970, 1, 1, tzinfo=mdates.UTC)
dt.tzname()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not check the return value of dt.tzname() rather than making this just a smoke test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should add that my big complaint here is that this test, while exercising the method, does nothing to actually catch the original problem.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does, the exception is coming out of datetime

Python 2.7.13 |Continuum Analytics, Inc.| (default, Dec 20 2016, 23:09:15)                                                                                                                                                                                                                                                                                                                                                              
[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2                                                                                                                                                                                                                                                                                                                                                                                        
Type "help", "copyright", "credits" or "license" for more information.                                                                                                                                                                                                                                                                                                                                                                  
Anaconda is brought to you by Continuum Analytics.                                                                                                                                                                                                                                                                                                                                                                                      
Please check out: http://continuum.io/thanks and https://anaconda.org                                                                                                                                                                                                                                                                                                                                                                   
>>> import matplotlib.dates as mdates                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         
>>> import datetime                                                                                                                                                                                                                                                                                                                                                                                                                     
>>> dt = datetime.datetime(1970, 1, 1, tzinfo=mdates.UTC)                                                                                                                                                                                                                                                                                                                                                                               
>>> dt.tzname()                                                                                                                                                                                                                                                                                                                                                                                                                         
Traceback (most recent call last):                                                                                                                                                                                                                                                                                                                                                                                                      
  File "<stdin>", line 1, in <module>                                                                                                                                                                                                                                                                                                                                                                                                   
TypeError: tzinfo.tzname() must return None or a string, not 'unicode'                                                                                                                                                                                                                                                                                                                                                                  
>>>                                                                                                                                                                                                                                                                                                                                                                                                                                     
        

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AH. I see now. My mistake.

@codecov-io
Copy link

codecov-io commented Dec 29, 2016

Current coverage is 62.07% (diff: 100%)

Merging #7705 into master will increase coverage by <.01%

@@             master      #7705   diff @@
==========================================
  Files           174        174          
  Lines         56022      56022          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          34776      34777     +1   
+ Misses        21246      21245     -1   
  Partials          0          0          

Powered by Codecov. Last update d8f535c...e2a39ed

@tacaswell tacaswell merged commit 22708ef into matplotlib:master Dec 29, 2016
tacaswell added a commit that referenced this pull request Dec 29, 2016
FIX: Fixes tzname return type
@tacaswell
Copy link
Member

Thanks!

Backported to v2.x as c602d82

@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Dec 29, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants