mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 07:31:38 +00:00 
			
		
		
		
	bpo-28692: Deprecate using non-integer value for selecting a plural form in gettext. (#507)
This commit is contained in:
		
							parent
							
								
									1989763f0d
								
							
						
					
					
						commit
						f6595983e0
					
				
					 4 changed files with 17 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -180,6 +180,10 @@ Deprecated
 | 
			
		|||
  both deprecated in Python 3.4 now emit :exc:`DeprecationWarning`. (Contributed
 | 
			
		||||
  by Matthias Bussonnier in :issue:`29576`)
 | 
			
		||||
 | 
			
		||||
- Using non-integer value for selecting a plural form in :mod:`gettext` is
 | 
			
		||||
  now deprecated.  It never correctly worked.
 | 
			
		||||
  (Contributed by Serhiy Storchaka in :issue:`28692`.)
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
Removed
 | 
			
		||||
=======
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -164,6 +164,10 @@ def _as_int(n):
 | 
			
		|||
    except TypeError:
 | 
			
		||||
        raise TypeError('Plural value must be an integer, got %s' %
 | 
			
		||||
                        (n.__class__.__name__,)) from None
 | 
			
		||||
    import warnings
 | 
			
		||||
    warnings.warn('Plural value must be an integer, got %s' %
 | 
			
		||||
                  (n.__class__.__name__,),
 | 
			
		||||
                  DeprecationWarning, 4)
 | 
			
		||||
    return n
 | 
			
		||||
 | 
			
		||||
def c2py(plural):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -443,8 +443,11 @@ def test_plural_number(self):
 | 
			
		|||
        f = gettext.c2py('n != 1')
 | 
			
		||||
        self.assertEqual(f(1), 0)
 | 
			
		||||
        self.assertEqual(f(2), 1)
 | 
			
		||||
        with self.assertWarns(DeprecationWarning):
 | 
			
		||||
            self.assertEqual(f(1.0), 0)
 | 
			
		||||
        with self.assertWarns(DeprecationWarning):
 | 
			
		||||
            self.assertEqual(f(2.0), 1)
 | 
			
		||||
        with self.assertWarns(DeprecationWarning):
 | 
			
		||||
            self.assertEqual(f(1.1), 1)
 | 
			
		||||
        self.assertRaises(TypeError, f, '2')
 | 
			
		||||
        self.assertRaises(TypeError, f, b'2')
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -270,6 +270,9 @@ Extension Modules
 | 
			
		|||
Library
 | 
			
		||||
-------
 | 
			
		||||
 | 
			
		||||
- bpo-28692: Using non-integer value for selecting a plural form in gettext is
 | 
			
		||||
  now deprecated.
 | 
			
		||||
 | 
			
		||||
- bpo-26121: Use C library implementation for math functions:
 | 
			
		||||
  tgamma(), lgamma(), erf() and erfc().
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue