Commit Graph

65 Commits

Author SHA1 Message Date
Serhiy Storchaka fec35c99aa
bpo-33710: Deprecate l*gettext() and related functions in the gettext module. (GH-10139)
They return encoded bytes and are Python 2 artifacts.
2018-10-27 08:00:41 +03:00
Serhiy Storchaka 81108375d9 bpo-30152: Reduce the number of imports for argparse. (#1269) 2017-09-26 00:55:55 +03:00
Serhiy Storchaka 26cb4657bc bpo-29755: Fixed the lgettext() family of functions in the gettext module. (#2266)
They now always return bytes.

Updated the gettext documentation.
2017-06-20 17:13:29 +03:00
Victor Stinner d6debb24e0 bpo-29919: Remove unused imports found by pyflakes (#137)
Make also minor PEP8 coding style fixes on modified imports.
2017-03-27 16:05:26 +02:00
Serhiy Storchaka f6595983e0 bpo-28692: Deprecate using non-integer value for selecting a plural form in gettext. (#507) 2017-03-12 13:15:01 +02:00
Serhiy Storchaka 5ae6c776a8 Issue #28563: Make plural form selection more lenient and accepting
non-integer numbers.  Django tests depend on this.
2016-11-14 19:29:59 +02:00
Serhiy Storchaka 5ca92ab3d2 Issue #28563: Make plural form selection more lenient and accepting
non-integer numbers.  Django tests depend on this.
2016-11-14 19:25:56 +02:00
Serhiy Storchaka 60ac989d6f Issue #28563: Make plural form selection more lenient and accepting
non-integer numbers.  Django tests depend on this.
2016-11-14 19:22:12 +02:00
Serhiy Storchaka eb20fcae14 Issue #28563: Fixed possible DoS and arbitrary code execution when handle
plural form selections in the gettext module.  The expression parser now
supports exact syntax supported by GNU gettext.
2016-11-08 21:26:14 +02:00
Serhiy Storchaka 1c3fdd900d Issue #28563: Fixed possible DoS and arbitrary code execution when handle
plural form selections in the gettext module.  The expression parser now
supports exact syntax supported by GNU gettext.
2016-11-08 21:20:09 +02:00
Serhiy Storchaka 07bcf05fcf Issue #28563: Fixed possible DoS and arbitrary code execution when handle
plural form selections in the gettext module.  The expression parser now
supports exact syntax supported by GNU gettext.
2016-11-08 21:17:46 +02:00
Andrew Kuchling 8b963c5853 #17898: reset k and v so that the loop doesn't use an old value 2015-04-13 10:38:56 -04:00
Andrew Kuchling 770b08e8e2 #23883: add names missing from __all__ (l*gettext, bind_textdomain_codeset) 2015-04-13 09:58:36 -04:00
Andrew Svetlov f7a17b48d7 Replace IOError with OSError (#16715) 2012-12-25 16:47:37 +02:00
Vinay Sajip 7ded1f0f69 Implemented PEP 405 (Python virtual environments). 2012-05-26 03:45:29 +01:00
Andrew Kuchling 19ddaf6d40 Merge from 3.4 2015-04-14 10:35:43 -04:00
Andrew Kuchling 467a546b5e Merge from 3.4 2015-04-14 09:59:09 -04:00
Antoine Pitrou be8d06f523 Issue #18216: gettext now raises an error when a .mo file has an unsupported major version number. Patch by Aaron Hill. 2014-10-28 20:17:51 +01:00
Ezio Melotti 4969f709cc #11515: Merge with 3.1. 2011-03-15 05:59:46 +02:00
Ezio Melotti 42da663e6f #11515: fix several typos. Patch by Piotr Kasprzyk. 2011-03-15 05:18:48 +02:00
Benjamin Peterson bc78e37d46 update comment 2010-12-23 23:45:39 +00:00
Benjamin Peterson 31e8720324 kill some function imports 2010-12-23 22:53:42 +00:00
Benjamin Peterson a91dd1e411 use native tenary condition 2010-12-23 22:49:38 +00:00
Éric Araujo 298be5161f Merged revisions 85223 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r85223 | eric.araujo | 2010-10-05 01:52:37 +0200 (mar., 05 oct. 2010) | 3 lines

  Fix interaction of custom translation classes and caching (#9042)
........
2010-10-04 23:57:46 +00:00
Éric Araujo 6108bf5ed0 Fix interaction of custom translation classes and caching (#9042) 2010-10-04 23:52:37 +00:00
Benjamin Peterson fa0d703433 Merged revisions 72506,72525-72526,72551,72558,72616,72654-72655,72689,72745,72750,72802,72812,72822,72824,72826-72827,72833,72876,72890,72923,72946,73026,73042,73045,73047,73065,73068-73069 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r72506 | vinay.sajip | 2009-05-09 07:07:17 -0500 (Sat, 09 May 2009) | 1 line

  Issue #5971: StreamHandler.handleError now swallows IOErrors which occur when trying to print a traceback.
........
  r72525 | benjamin.peterson | 2009-05-09 20:38:02 -0500 (Sat, 09 May 2009) | 1 line

  close file explicitly
........
  r72526 | benjamin.peterson | 2009-05-09 21:29:00 -0500 (Sat, 09 May 2009) | 1 line

  make sure files are closed using the with statement
........
  r72551 | benjamin.peterson | 2009-05-10 09:16:47 -0500 (Sun, 10 May 2009) | 1 line

  use isinstance
........
  r72558 | benjamin.peterson | 2009-05-10 18:52:09 -0500 (Sun, 10 May 2009) | 1 line

  sys.setdefaultencoding() strikes me as a bad example
........
  r72616 | benjamin.peterson | 2009-05-13 19:33:10 -0500 (Wed, 13 May 2009) | 1 line

  importlib.import_module is better these days
........
  r72654 | benjamin.peterson | 2009-05-14 17:37:49 -0500 (Thu, 14 May 2009) | 1 line

  prevent refleaks from threads
........
  r72655 | benjamin.peterson | 2009-05-14 17:40:34 -0500 (Thu, 14 May 2009) | 1 line

  a useful decorator for cleaning up threads
........
  r72689 | benjamin.peterson | 2009-05-16 13:44:34 -0500 (Sat, 16 May 2009) | 1 line

  use skipTest()
........
  r72745 | benjamin.peterson | 2009-05-17 09:16:29 -0500 (Sun, 17 May 2009) | 1 line

  ignore .rst files in sphinx its self
........
  r72750 | benjamin.peterson | 2009-05-17 11:59:27 -0500 (Sun, 17 May 2009) | 1 line

  chop off slash
........
  r72802 | georg.brandl | 2009-05-20 13:35:27 -0500 (Wed, 20 May 2009) | 1 line

  #6051: refer to email examples for better way to construct email messages.
........
  r72812 | michael.foord | 2009-05-21 17:57:02 -0500 (Thu, 21 May 2009) | 1 line

  Rename TestCase._result to _resultForDoCleanups to avoid potential clashes in TestCase subclasses. Issue 6072.
........
  r72822 | georg.brandl | 2009-05-22 04:33:25 -0500 (Fri, 22 May 2009) | 1 line

  #6084: fix example.
........
  r72824 | georg.brandl | 2009-05-22 04:43:17 -0500 (Fri, 22 May 2009) | 1 line

  Fix references to file-related functions and methods (os.* vs file.*).
........
  r72826 | georg.brandl | 2009-05-22 04:49:42 -0500 (Fri, 22 May 2009) | 1 line

  Fix confusing wording.
........
  r72827 | georg.brandl | 2009-05-22 04:50:30 -0500 (Fri, 22 May 2009) | 1 line

  s/use/call/
........
  r72833 | georg.brandl | 2009-05-22 12:00:17 -0500 (Fri, 22 May 2009) | 1 line

  #6078: _warnings is a builtin module and has no standard init_warnings function.
........
  r72876 | benjamin.peterson | 2009-05-23 15:59:09 -0500 (Sat, 23 May 2009) | 1 line

  remove mention of old ctypes version
........
  r72890 | gregory.p.smith | 2009-05-24 13:00:13 -0500 (Sun, 24 May 2009) | 2 lines

  add a versionadded tag for set_tunnel
........
  r72923 | michael.foord | 2009-05-25 15:36:56 -0500 (Mon, 25 May 2009) | 1 line

  Make assertSequenceEqual error messages less cryptic, particularly for nested sequences.
........
  r72946 | ronald.oussoren | 2009-05-26 13:44:48 -0500 (Tue, 26 May 2009) | 2 lines

  Fixes issue 6110
........
  r73026 | r.david.murray | 2009-05-29 14:30:27 -0500 (Fri, 29 May 2009) | 3 lines

  Issue 6141: document that the first item of args is still the
  command name even when executable is specified.
........
  r73042 | benjamin.peterson | 2009-05-29 22:10:52 -0500 (Fri, 29 May 2009) | 1 line

  no fdatasync on macos
........
  r73045 | georg.brandl | 2009-05-30 02:26:04 -0500 (Sat, 30 May 2009) | 1 line

  #6146: fix markup bug.
........
  r73047 | georg.brandl | 2009-05-30 05:33:23 -0500 (Sat, 30 May 2009) | 1 line

  Fix some more small markup problems.
........
  r73065 | antoine.pitrou | 2009-05-30 16:39:25 -0500 (Sat, 30 May 2009) | 3 lines

  The test for #5330 wasn't correct.
........
  r73068 | antoine.pitrou | 2009-05-30 16:45:40 -0500 (Sat, 30 May 2009) | 3 lines

  Update ACKS
........
  r73069 | benjamin.peterson | 2009-05-30 19:42:42 -0500 (Sat, 30 May 2009) | 1 line

  fix signature
........
2009-06-01 22:42:33 +00:00
Georg Brandl cd86925b3b Use true booleans. 2009-05-17 12:50:58 +00:00
Georg Brandl bded4d3ba1 Make gettext Unicode interface consistent and clean up the docs. 2008-07-17 18:15:35 +00:00
Benjamin Peterson 801844d6fc #2512 implement the 3.0 gettext API
All the u* gettext variants were renamed to their
none u* variants, since there's no point in translating
to byte strings. I also killed off the unicode parameters
for install
2008-07-14 14:32:15 +00:00
Georg Brandl 1a3284ed69 #1535: rename __builtin__ module to builtins. 2007-12-02 09:40:06 +00:00
Guido van Rossum 98297ee781 Merging the py3k-pep3137 branch back into the py3k branch.
No detailed change log; just check out the change log for the py3k-pep3137
branch.  The most obvious changes:

  - str8 renamed to bytes (PyString at the C level);
  - bytes renamed to buffer (PyBytes at the C level);
  - PyString and PyUnicode are no longer compatible.

I.e. we now have an immutable bytes type and a mutable bytes type.

The behavior of PyString was modified quite a bit, to make it more
bytes-like.  Some changes are still on the to-do list.
2007-11-06 21:34:58 +00:00
Christian Heimes 6ae5d7f2a1 Fixed gettext module for Windows. The metadata lines always end in \n and not in os.linesep 2007-10-31 18:53:44 +00:00
Collin Winter ce36ad8a46 Raise statement normalization in Lib/. 2007-08-30 01:19:48 +00:00
Guido van Rossum 9600f93db6 Make gettext work with strict str/bytes. 2007-08-29 03:08:55 +00:00
Guido van Rossum 652f446d42 Fixes for str/uni/bytes for gettext.py. test_gettext.py passes.
Fix by Christian Heimes, SF# 1751958, who writes:

  I tested the fixes with the Zope3 zope.app.locales packages.
  The mo files are loaded and parsed w/o any problem.
  The translation with gettext.gettext is working as expected.
2007-07-12 08:04:06 +00:00
Guido van Rossum 68937b4cbc Change some uses of cStringIO.StringIO to io.StringIO.
This is undoubtedly insufficient and in some cases just as broken as before.
2007-05-18 00:51:22 +00:00
Guido van Rossum 805365ee39 Merged revisions 55007-55179 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk

........
  r55077 | guido.van.rossum | 2007-05-02 11:54:37 -0700 (Wed, 02 May 2007) | 2 lines

  Use the new print syntax, at least.
........
  r55142 | fred.drake | 2007-05-04 21:27:30 -0700 (Fri, 04 May 2007) | 1 line

  remove old cruftiness
........
  r55143 | fred.drake | 2007-05-04 21:52:16 -0700 (Fri, 04 May 2007) | 1 line

  make this work with the new Python
........
  r55162 | neal.norwitz | 2007-05-06 22:29:18 -0700 (Sun, 06 May 2007) | 1 line

  Get asdl code gen working with Python 2.3.  Should continue to work with 3.0
........
  r55164 | neal.norwitz | 2007-05-07 00:00:38 -0700 (Mon, 07 May 2007) | 1 line

  Verify checkins to p3yk (sic) branch go to 3000 list.
........
  r55166 | neal.norwitz | 2007-05-07 00:12:35 -0700 (Mon, 07 May 2007) | 1 line

  Fix this test so it runs again by importing warnings_test properly.
........
  r55167 | neal.norwitz | 2007-05-07 01:03:22 -0700 (Mon, 07 May 2007) | 8 lines

  So long xrange.  range() now supports values that are outside
  -sys.maxint to sys.maxint.  floats raise a TypeError.

  This has been sitting for a long time.  It probably has some problems and
  needs cleanup.  Objects/rangeobject.c now uses 4-space indents since
  it is almost completely new.
........
  r55171 | guido.van.rossum | 2007-05-07 10:21:26 -0700 (Mon, 07 May 2007) | 4 lines

  Fix two tests that were previously depending on significant spaces
  at the end of a line (and before that on Python 2.x print behavior
  that has no exact equivalent in 3.0).
........
2007-05-07 22:24:25 +00:00
Guido van Rossum ef87d6ed94 Rip out all the u"..." literals and calls to unicode(). 2007-05-02 19:09:54 +00:00
Guido van Rossum e2a383d062 Rip out 'long' and 'L'-suffixed integer literals.
(Rough first cut.)
2007-01-15 16:59:06 +00:00
Georg Brandl 602b9ba6b3 Patch #1349274: gettext.install() now optionally installs additional
translation functions other than _() in the builtin namespace.
2006-02-19 13:26:36 +00:00
Raymond Hettinger a617271dbd Use cStringIO where available. 2004-12-31 19:15:26 +00:00
Gustavo Niemeyer 7bd33c5e22 This change implements the following gettext features, as
discussed recently in python-dev:

In _locale module:

- bind_textdomain_codeset() binding

In gettext module:

- bind_textdomain_codeset() function
- lgettext(), lngettext(), ldgettext(), ldngettext(),
  which return translated strings encoded in
  preferred system encoding, if
  bind_textdomain_codeset() was not used.
- Added equivalent functionality in translate()
  function and catalog classes.

Every change was also documented.
2004-07-22 18:44:01 +00:00
Raymond Hettinger bac788a3cd Replace str.find()!=1 with the more readable "in" operator. 2004-05-04 09:21:43 +00:00
Barry Warsaw b8c787606c GNUTranslations._parse(): Initialize local variable k so that if the
first line of a header section isn't an RFC-ish header, it's just
ignored instead of throwing an UnboundLocalError.

Backport candidate.
2003-10-04 02:28:31 +00:00
Barry Warsaw 7de63f57c8 GNUTranslations._parse(): Fix SF bug #658233, where continuation lines
in .po metadata caused a crash.

Backport candidate.
2003-05-20 17:26:48 +00:00
Barry Warsaw c4acc2bd32 GNUTranslations:
__init__(): Removed since we no longer need the coerce flag.
    Message ids and strings are now always coerced to Unicode, /if/
    the catalog specified a charset parameter.

    gettext(), ngettext(): Since the message strings are Unicodes in
    the catalog, coerce back to encoded 8-bit strings on return.

    ugettext(), ungettext(): Coerce the message ids to Unicode when
    there's no entry for the id in the catalog.

Minor code cleanups; use booleans where appropriate.
2003-04-24 18:13:39 +00:00
Barry Warsaw 6008cbd4c2 NullTranslations.__init__(): Back out of setting the default charset
to iso-8859-1.

GNUTranslations._parse(): Back out the addition of a test for
Project-ID-Version in the metadata.  This was deliberately removed in
response to SF patch #700839.

Also, re-organize the code in _parse() so we parse the metadata header
containing the charset parameter before we try to decode any strings
using charset.
2003-04-11 20:26:47 +00:00
Barry Warsaw a1ce93f87c From http://mail.python.org/pipermail/i18n-sig/2003-April/001557.html
- Expose NullTranslations and GNUTranslations to __all__

- Set the default charset to iso-8859-1.  It used to be None, which
would cause problems with .ugettext() if the file had no charset
parameter.  Arguably, the po/mo file would be broken, but I still think
iso-8859-1 is a reasonable default.

- Add a "coerce" default argument to GNUTranslations's constructor.  The
reason for this is that in Zope, we want all msgids and msgstrs to be
Unicode.  For the latter, we could use .ugettext() but there isn't
currently a mechanism for Unicode-ifying msgids.

The plan then is that the charset parameter specifies the encoding for
both the msgids and msgstrs, and both are decoded to Unicode when read.
For example, we might encode po files with utf-8. I think the GNU
gettext tools don't care.

Since this could potentially break code [*] that wants to use the
encoded interface .gettext(), the constructor flag is added, defaulting
to False.  Most code I suspect will want to set this to True and use
.ugettext().

- A few other minor changes from the Zope project, including asserting
that a zero-length msgid must have a Project-ID-Version header for it to
be counted as the metadata record.
2003-04-11 18:36:43 +00:00
Martin v. Löwis a57dccdcd4 Patch #700839: Fix bugs in the plural handling. 2003-03-10 16:01:43 +00:00
Martin v. Löwis d899605e30 Patch #633547: Support plural forms. Do TODOs in test suite. 2002-11-21 21:45:32 +00:00