internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: nltk/nltk

Issue:
NotImplementedError in lambda DRT simplification.
The following piece of code gives NotImplementedError on line 264 of drt.py (3.6.4)

    import nltk
    expr="\P.\Q.\R.(([X], []) + R(X) + ((P(\Y.([],[ (X=Y) ]))) + (Q(\Z.([], [ (X=Z) ])))))(\X.(\P.(([X],[named(X, karla)]) + P(X) )(\X1.(X(X1)))))(\Y.(\P.\Q. (([X],[ant(X)]) + P(X) + Q(X) )(\Y1.(\X.([],[owner(X) ] )(Y1)))(\Z1.(Y(Z1)))))(\Z.(\P.\X.\F.(P(\E.(([],[nsubj(E,X)]) + F(E))))(\X2.(\F.(([E][arrive(E)]) + F(E) )(\Z2.(X2(Z2)))))(Z)(\Y2.(\F.( [],[] )(Y2)))))"
    dexpr = nltk.sem.drt.DrtExpression.fromstring(r"{}".format(expr))
    dexpr.simplify()
    print(str(dexpr))

When I track the cause, I find that it is happening when  get_refs is called in DrtLambdaExpression. Since it does not exist, the  get_refs function of the abstract class is called (line 264) giving a not implemented error.


Discussion:

Resolving patch:
diff --git a/nltk/sem/drt.py b/nltk/sem/drt.py
--- a/nltk/sem/drt.py
+++ b/nltk/sem/drt.py
@@ -717,6 +717,12 @@ def _pretty(self):
             + ["    " + blank + line for line in term_lines[3:]]
         )
 
+    def get_refs(self, recursive=False):
+        """:see: AbstractExpression.get_refs()"""
+        return (
+            [self.variable] + self.term.get_refs(True) if recursive else [self.variable]
+        )
+
 
 class DrtBinaryExpression(DrtExpression, BinaryExpression):
     def get_refs(self, recursive=False):


Test patch:
Repository: nltk/nltk

Issue:
TypeError: _pretty() takes 1 positional argument but 2 were given in sem/drt.py
The following code

    import nltk
    expr="\ P.\Q.([ ],[ ((([X],[]) + P(X)) => (Q(X))) ])(\Y1.(\X.([],[dog(X) ] )(Y1)))(\Z1.(\P.\X.\F.(P(\E.(([],[nsubj(E,X)]) + F(E))))(\X2.(\P.\Q.(([X],[]) + P(X) + Q(X) )(\X.(\X.([],[cow(X) ] )(X)))(\Y.(\P.\X.\F.(P(\E.(([],[obj(E,X)]) + F(E))))(\Z.(\F.(([E][help(E)]) + F(E) )(\Z2.(Z(Z2)))))(Y)(\X1.(X2(X1)))))))(Z1)(\Y2.(\F.( [],[] )(Y2)))))"
    dexpr = nltk.sem.drt.DrtExpression.fromstring(r"{}".format(expr))
    dexpr.simplify()
    dexpr.pretty_print()

gives the following error:

    File "nltk/sem/drt.py", line 901, in _pretty
    drs, DrtTokens.IMP, self._pretty(self.consequent)
    TypeError: _pretty() takes 1 positional argument but 2 were given

When I track the cause, I see that the _pretty function of self.consequent is called incorrectly.



Discussion:

Resolving patch:
diff --git a/nltk/sem/drt.py b/nltk/sem/drt.py
--- a/nltk/sem/drt.py
+++ b/nltk/sem/drt.py
@@ -898,7 +898,7 @@ def _pretty(self):
         )
         if self.consequent:
             drs = DrtBinaryExpression._assemble_pretty(
-                drs, DrtTokens.IMP, self._pretty(self.consequent)
+                drs, DrtTokens.IMP, self.consequent._pretty()
             )
         return drs
 


Test patch:
Repository: nltk/nltk

Issue:
Rewind Wordnet data files?
Before the recent merge of #2860, _wordnet.get_version()_ would fail whenever a read had already occurred from the _data.adj_ file:

> import nltk
> from nltk.corpus import wordnet as wn
> print(wn.get_version())

3.0

> print(wn.synset_from_pos_and_offset('a',1740))

Synset('able.a.01')

> print(wn.get_version())

None

The cause of the problem is that _synset_from_pos_and_offset_ goes to a given offset in a data file, reads a line, and stays there. This function is called all the time by other functions in the wordnet module. For ex., in wordnet.doctest, _synset_from_pos_and_offset_ is called indirectly over 10,000 times. 

But now that _get_version_ ensures that reading the data.adj starts at byte offset 0, it probably doesn't matter anywhere else, because there may not be another function that needs to read from the beginning of the data file.

It might be safer to add _data_file.seek(0)_ at the end of _synset_from_pos_and_offset_, but I am not sure that it is worth the additional processing. On the other hand, seek(0) is so cheap an operation that the time penalty would hardly be noticeable.



Discussion:
I wouldn't worry much about additional processing costs of adding `seek(0)`. I'm more concerned about correct program execution here.

Resolving patch:
diff --git a/nltk/corpus/reader/wordnet.py b/nltk/corpus/reader/wordnet.py
--- a/nltk/corpus/reader/wordnet.py
+++ b/nltk/corpus/reader/wordnet.py
@@ -1423,6 +1423,7 @@ def synset_from_pos_and_offset(self, pos, offset):
             raise WordNetError(
                 f"No WordNet synset found for pos={pos} at offset={offset}."
             )
+        data_file.seek(0)
         return synset
 
     @deprecated("Use public method synset_from_pos_and_offset() instead")


Test patch:
Repository: nltk/nltk

Issue:
Non parents initialization 
There are several classes that inherits from `SyntaxCorpusReader` but are calling `CorpusReader` for the `__init__()`:

- KNBCorpusReader
- BracketParseCorpusReader
- DependencyCorpusReader

**Why are they inheritting from `SyntaxCorpusReader` but initializing from `CorpusReader`?** Should they be fixed and initialize using SyntaxCorpusReader's init?




Discussion:

Resolving patch:
diff --git a/nltk/corpus/reader/bracket_parse.py b/nltk/corpus/reader/bracket_parse.py
--- a/nltk/corpus/reader/bracket_parse.py
+++ b/nltk/corpus/reader/bracket_parse.py
@@ -53,9 +53,7 @@ def __init__(
             for normalizing or converting the POS tags returned by the
             ``tagged_...()`` methods.
         """
-        # FIXME: Why is it inheritting from SyntaxCorpusReader but initializing
-        #       from CorpusReader?
-        CorpusReader.__init__(self, root, fileids, encoding)
+        SyntaxCorpusReader.__init__(self, root, fileids, encoding)
         self._comment_char = comment_char
         self._detect_blocks = detect_blocks
         self._tagset = tagset
diff --git a/nltk/corpus/reader/dependency.py b/nltk/corpus/reader/dependency.py
--- a/nltk/corpus/reader/dependency.py
+++ b/nltk/corpus/reader/dependency.py
@@ -23,9 +23,7 @@ def __init__(
         sent_tokenizer=RegexpTokenizer("\n", gaps=True),
         para_block_reader=read_blankline_block,
     ):
-        # FIXME: Why is it inheritting from SyntaxCorpusReader but initializing
-        #       from CorpusReader?
-        CorpusReader.__init__(self, root, fileids, encoding)
+        SyntaxCorpusReader.__init__(self, root, fileids, encoding)
 
     #########################################################
 
diff --git a/nltk/corpus/reader/knbc.py b/nltk/corpus/reader/knbc.py
--- a/nltk/corpus/reader/knbc.py
+++ b/nltk/corpus/reader/knbc.py
@@ -58,9 +58,7 @@ def __init__(self, root, fileids, encoding="utf8", morphs2str=_morphs2str_defaul
         morphs2str is a function to convert morphlist to str for tree representation
         for _parse()
         """
-        # FIXME: Why is it inheritting from SyntaxCorpusReader but initializing
-        #       from CorpusReader?
-        CorpusReader.__init__(self, root, fileids, encoding)
+        SyntaxCorpusReader.__init__(self, root, fileids, encoding)
         self.morphs2str = morphs2str
 
     def _read_block(self, stream):


Test patch:
Repository: nltk/nltk

Issue:
Link to book in python documentation wrong
Not sure if this is a bug in the documentation or in the DNS/web server setup.
The python documentation for nltk says:
```
    Steven Bird, Ewan Klein, and Edward Loper (2009).
    Natural Language Processing with Python.  O'Reilly Media Inc.
    http://nltk.org/book
```
but this link does not work, `https://www.nltk.org/book/` does.


Discussion:
You're right, thanks! We recently revamped our website, and this must have slipped through the cracks. Not to worry, it's an easy fix :)

Resolving patch:
diff --git a/nltk/__init__.py b/nltk/__init__.py
--- a/nltk/__init__.py
+++ b/nltk/__init__.py
@@ -13,7 +13,7 @@
 
 Steven Bird, Ewan Klein, and Edward Loper (2009).
 Natural Language Processing with Python.  O'Reilly Media Inc.
-https://www.nltk.org/book
+https://www.nltk.org/book/
 
 isort:skip_file
 """


Test patch:
diff --git a/nltk/test/portuguese_en.doctest b/nltk/test/portuguese_en.doctest
--- a/nltk/test/portuguese_en.doctest
+++ b/nltk/test/portuguese_en.doctest
@@ -7,7 +7,7 @@ Examples for Portuguese Processing
 
 This HOWTO contains a variety of examples relating to the Portuguese language.
 It is intended to be read in conjunction with the NLTK book
-(``https://www.nltk.org/book``).  For instructions on running the Python
+(``https://www.nltk.org/book/``).  For instructions on running the Python
 interpreter, please see the section *Getting Started with Python*, in Chapter 1.
 
 --------------------------------------------
Repository: nltk/nltk

Issue:
Hack to keep NLTK's "tokenize" module fails 
in decorators.py file line 24:
`sys.path = [p for p in sys.path if  "nltk" not in p]`
causes an error while importing nltk when there are other objects than strings in the path variable(such as pathlib.Posixpath)
this issue can be solved simply just by replacing the above code with:
`sys.path = [p for p in sys.path if (type(p) == str and "nltk" not in p)]`



Discussion:
Perhaps simpler to read:

```python
[p for p in sys.path if "nltk" not in str(p)]
```

Resolving patch:
diff --git a/nltk/decorators.py b/nltk/decorators.py
--- a/nltk/decorators.py
+++ b/nltk/decorators.py
@@ -20,7 +20,7 @@
 # Hack to keep NLTK's "tokenize" module from colliding with the "tokenize" in
 # the Python standard library.
 OLD_SYS_PATH = sys.path[:]
-sys.path = [p for p in sys.path if p and "nltk" not in p]
+sys.path = [p for p in sys.path if p and "nltk" not in str(p)]
 import inspect
 
 sys.path = OLD_SYS_PATH


Test patch:
Repository: nltk/nltk

Issue:
Downloader fails when download_dir is a nested folder that doesn't exist
### Problem
When the download folder doesn't exist, it is created by the downloader. But when that folder is nested, the creation fails.

### Code example

```python
nltk.download("punkt", force=True, download_dir="some/nested/folder")
```

Will give the following error:

```
File "my_env/lib/python3.7/site-packages/nltk/downloader.py", line 776, in download
    for msg in self.incr_download(info_or_id, download_dir, force):
  File "my_env/lib/python3.7/site-packages/nltk/downloader.py", line 641, in incr_download
    yield from self._download_package(info, download_dir, force)
  File "my_env/lib/python3.7/site-packages/nltk/downloader.py", line 698, in _download_package
    os.mkdir(download_dir)
FileNotFoundError: [Errno 2] No such file or directory: 'some/nested/folder'
```

### Suggested solution

The following line throws the error: https://github.com/nltk/nltk/blob/develop/nltk/downloader.py#L698

`os.makedirs(download_dir)` could be used instead of `os.mkdir(download_dir)`




Discussion:

Resolving patch:
diff --git a/nltk/downloader.py b/nltk/downloader.py
--- a/nltk/downloader.py
+++ b/nltk/downloader.py
@@ -695,9 +695,9 @@ def _download_package(self, info, download_dir, force):
 
         # Ensure the download_dir exists
         if not os.path.exists(download_dir):
-            os.mkdir(download_dir)
+            os.makedirs(download_dir)
         if not os.path.exists(os.path.join(download_dir, info.subdir)):
-            os.mkdir(os.path.join(download_dir, info.subdir))
+            os.makedirs(os.path.join(download_dir, info.subdir))
 
         # Download the file.  This will raise an IOError if the url
         # is not found.


Test patch:
diff --git a/nltk/test/unit/test_downloader.py b/nltk/test/unit/test_downloader.py
new file mode 100644
--- /dev/null
+++ b/nltk/test/unit/test_downloader.py
@@ -0,0 +1,19 @@
+from nltk import download
+
+
+def test_downloader_using_existing_parent_download_dir(tmp_path):
+    """Test that download works properly when the parent folder of the download_dir exists"""
+
+    download_dir = str(tmp_path.joinpath("another_dir"))
+    download_status = download("mwa_ppdb", download_dir)
+    assert download_status is True
+
+
+def test_downloader_using_non_existing_parent_download_dir(tmp_path):
+    """Test that download works properly when the parent folder of the download_dir does not exist"""
+
+    download_dir = str(
+        tmp_path.joinpath("non-existing-parent-folder", "another-non-existing-folder")
+    )
+    download_status = download("mwa_ppdb", download_dir)
+    assert download_status is True
Repository: nltk/nltk

Issue:
Sentence tokenizer fails when sentence.startswith('. ')
```
from nltk.tokenize import sent_tokenize
sent_tokenize('. a')
```
will trigger IndexError from `punkt.py:_realign_boundaries`. But `sent_tokenize('. ')` will not.

Envs:
python=3.6
nltk=3.6.6


Discussion:

Resolving patch:
diff --git a/nltk/tokenize/punkt.py b/nltk/tokenize/punkt.py
--- a/nltk/tokenize/punkt.py
+++ b/nltk/tokenize/punkt.py
@@ -1379,7 +1379,7 @@ def _match_potential_end_contexts(self, text):
             # Find the word before the current match
             split = text[: match.start()].rsplit(maxsplit=1)
             before_start = len(split[0]) if len(split) == 2 else 0
-            before_words[match] = split[-1]
+            before_words[match] = split[-1] if split else ""
             matches.append(match)
 
         return [


Test patch:
diff --git a/nltk/test/tokenize.doctest b/nltk/test/tokenize.doctest
--- a/nltk/test/tokenize.doctest
+++ b/nltk/test/tokenize.doctest
@@ -310,6 +310,11 @@ Testing mutable default arguments for https://github.com/nltk/nltk/pull/2067
     >>> type(pst._lang_vars)
     <class 'nltk.tokenize.punkt.PunktLanguageVars'>
 
+Testing that inputs can start with dots.
+
+    >>> pst = PunktSentenceTokenizer(lang_vars=None)
+    >>> pst.tokenize(". This input starts with a dot. This used to cause issues.")
+    ['.', 'This input starts with a dot.', 'This used to cause issues.']
 
 Regression Tests: align_tokens
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Repository: nltk/nltk

Issue:
Nonexistent OMW offsets
In a few cases, the Open Multilingual Wordnet refers to synset offsets, which do not actually exist in WordNet. This issue has been known for some time (https://github.com/omwn/omw-data/issues/24#issuecomment-974789720), and it is not clear whether and when the OMW data will be fixed.

But from the point of view of NLTK, the issue is not harmless,
because it leads to fatal errors:
```
from nltk.corpus import wordnet as wn

print(wn.synsets('osim', lang='hrv'))
```
```
File "nltk/corpus/reader/wordnet.py", line 1539, in synset_from_pos_and_offset
    f"No WordNet synset found for pos={pos} at offset={offset}."
nltk.corpus.reader.wordnet.WordNetError: No WordNet synset found for pos=a at offset=2002046.
```

This behaviour is unfortunate, because the Croatian word 'osim' is linked to two synset offsets, where only one is nonexistent, so it would be preferrable to return at least the good synset, instead of aborting the whole processing pipeline.
It doesn't help much to wrap the call in a try-except construct
because, although a batch would be allowed to continue,
the user would still miss the good 'osim' offset. 


Discussion:

Resolving patch:
diff --git a/nltk/corpus/reader/wordnet.py b/nltk/corpus/reader/wordnet.py
--- a/nltk/corpus/reader/wordnet.py
+++ b/nltk/corpus/reader/wordnet.py
@@ -1532,9 +1532,7 @@ def synset_from_pos_and_offset(self, pos, offset):
             self._synset_offset_cache[pos][offset] = synset
         else:
             synset = None
-            raise WordNetError(
-                f"No WordNet synset found for pos={pos} at offset={offset}."
-            )
+            warnings.warn(f"No WordNet synset found for pos={pos} at offset={offset}.")
         data_file.seek(0)
         return synset
 


Test patch:
Repository: nltk/nltk

Issue:
Issue with synset_from_sense_key function to access adjective satellites
I tried to use the synset_from_sense_key function and here is the error:

File "/home/izorar/anaconda3/lib/python3.7/site-packages/nltk/corpus/reader/wordnet.py", line 1356, in synset raise WordNetError(message % lemma)

WordNetError: adjective satellite requested but only plain adjective found for lemma 'first'

Any idea on how to fix the error?


Discussion:
Please provide a fully reproducible code snippet, with imports, etc.

@Izorar Which synset/lemma are you look at? Please do post a code snippet as advised by @jnothman so that we can help you better.
@jnothman @alvations. See the snippet and the error message:
```
 import nltk
 from nltk import stem
 from nltk.corpus import wordnet as wn
 sense=wn.synset_from_sense_key("first%5:00:00:ordinal:00")
 sense2=synset_from_sense_key("more%5:00:00:added:00")
 print(sense, sense2)
```
Here is the error message
```
Traceback (most recent call last):
  File "/home/izorar/Documents/adjsat.py", line 4, in <module>
    sense=wn.synset_from_sense_key("first%5:00:00:ordinal:00")
  File "/home/izorar/.local/lib/python3.6/site-packages/nltk/corpus/reader/wordnet.py", line 1562, in synset_from_sense_key
    return self.synset(synset_id)
  File "/home/izorar/.local/lib/python3.6/site-packages/nltk/corpus/reader/wordnet.py", line 1356, in synset
    raise WordNetError(message % lemma)
nltk.corpus.reader.wordnet.WordNetError: adjective satellite requested but only plain adjective found for lemma 'first'
```

Thanks

Resolving patch:
diff --git a/nltk/corpus/reader/wordnet.py b/nltk/corpus/reader/wordnet.py
--- a/nltk/corpus/reader/wordnet.py
+++ b/nltk/corpus/reader/wordnet.py
@@ -1705,7 +1705,7 @@ def synset_from_sense_key(self, sense_key):
         >>> print(wn.synset_from_sense_key("driving%1:04:03::"))
         Synset('drive.n.06')
         """
-        return lemma_from_key(self, key).synset()
+        return self.lemma_from_key(sense_key).synset()
 
     #############################################################
     # Retrieve synsets and lemmas.


Test patch:
diff --git a/nltk/test/wordnet.doctest b/nltk/test/wordnet.doctest
--- a/nltk/test/wordnet.doctest
+++ b/nltk/test/wordnet.doctest
@@ -129,6 +129,11 @@ in NLTK:
     >>> wn.synset_from_pos_and_offset('n', 4543158)
     Synset('wagon.n.01')
 
+Likewise, instantiate a synset from a known sense key:
+    >>> wn.synset_from_sense_key("driving%1:04:03::")
+    Synset('drive.n.06')
+
+
 ------
 Lemmas
 ------
Repository: nltk/nltk

Issue:
CHILDES Corpus Reader doesn't parse data correctly
### Steps to reproduce
1. Download and unpack the CHILDES dataset
2. Follow the instructions at [Sample usage of childes](https://www.nltk.org/howto/childes.html)

### Expected outcome
Output is as shown on the sample usage page.

### Actual outcome
No words, sentences, etc. are parsed and are empty.

### Cause
- The reader tries to find the nodes using the wrong namespace.
- The namespace (NS) was accidentally changed to use the HTTPS scheme in #2852.


Discussion:

Resolving patch:
diff --git a/nltk/corpus/reader/childes.py b/nltk/corpus/reader/childes.py
--- a/nltk/corpus/reader/childes.py
+++ b/nltk/corpus/reader/childes.py
@@ -20,7 +20,7 @@
 from nltk.util import LazyConcatenation, LazyMap, flatten
 
 # to resolve the namespace issue
-NS = "https://www.talkbank.org/ns/talkbank"
+NS = "http://www.talkbank.org/ns/talkbank"
 
 
 class CHILDESCorpusReader(XMLCorpusReader):


Test patch:
Repository: nltk/nltk

Issue:
nltk.chat.chatbot() endless loop
When I type `import nltk` followed by `nltk.chat.chatbots()`, it lists/asks which one I want to talk to, and then endlessly scrolls the following: ` Enter a number in the range 1-5:     Error: bad chatbot number`, in both Jupyter and Spyder.


Discussion:

Resolving patch:
diff --git a/nltk/chat/__init__.py b/nltk/chat/__init__.py
--- a/nltk/chat/__init__.py
+++ b/nltk/chat/__init__.py
@@ -33,15 +33,12 @@
 
 
 def chatbots():
-    import sys
-
     print("Which chatbot would you like to talk to?")
     botcount = len(bots)
     for i in range(botcount):
         print("  %d: %s" % (i + 1, bots[i][1]))
     while True:
-        print("\nEnter a number in the range 1-%d: " % botcount, end=" ")
-        choice = sys.stdin.readline().strip()
+        choice = input(f"\nEnter a number in the range 1-{botcount}: ").strip()
         if choice.isdigit() and (int(choice) - 1) in range(botcount):
             break
         else:


Test patch:
Repository: nltk/nltk

Issue:
Incorrect encoding in `UdhrCorpusReader` corpus reader
There are problems with encoding of Polish characters in `Polish-Latin2` and `Polish_Polski-Latin2` files in the `udhr` corpus. When importing the text using the corpus reader, one obtains the improperly rendered characters. For example

```python
>>> from nltk.corpus import udhr
>>> udhr.raw('Polish-Latin2')[141:164]
'jednomy\x9clnie Powszechnš'
```
The character `\x9c` should be rendered correctly as `ś`, while the character `š` as `ą`. The encoding that `nltk` reader uses for those files is `ISO-8859`:

```python
>>> udhr.encoding('Polish-Latin2')
'ISO-8859-2'
```

However, the files themselves are encoded in `WINDOWS 1250`, as can be seen by re-encoding them with that encoding.

```python
>>> bytes(udhr.raw('Polish-Latin2'), 'ISO-8859-2').decode('cp1250')[141:164]
'jednomyślnie Powszechną'
```

While the code above invloves to `Polish-Latin2` same issue concerns `Polish_Polski-Latin2`.

Modifying `UdhrCorpusReader.ENCODINGS` in `nltk/corpus/reader/udhr.py` resolves the issue.


Discussion:

Resolving patch:
diff --git a/nltk/corpus/reader/udhr.py b/nltk/corpus/reader/udhr.py
--- a/nltk/corpus/reader/udhr.py
+++ b/nltk/corpus/reader/udhr.py
@@ -13,6 +13,8 @@ class UdhrCorpusReader(PlaintextCorpusReader):
         (".*-Hebrew$", "hebrew"),
         (".*-Arabic$", "cp1256"),
         ("Czech_Cesky-UTF8", "cp1250"),  # yeah
+        ("Polish-Latin2", "cp1250"),
+        ("Polish_Polski-Latin2", "cp1250"),
         (".*-Cyrillic$", "cyrillic"),
         (".*-SJIS$", "SJIS"),
         (".*-GB2312$", "GB2312"),
diff --git a/nltk/downloader.py b/nltk/downloader.py
--- a/nltk/downloader.py
+++ b/nltk/downloader.py
@@ -1497,7 +1497,11 @@ def _init_widgets(self):
         for (i, (key, label, callback)) in enumerate(info):
             Label(infoframe, text=label).grid(column=0, row=i, sticky="e")
             entry = Entry(
-                infoframe, font="courier", relief="groove", disabledforeground="black"
+                infoframe,
+                font="courier",
+                relief="groove",
+                disabledforeground="#007aff",
+                foreground="#007aff",
             )
             self._info[key] = (entry, callback)
             entry.bind("<Return>", self._info_save)


Test patch:
diff --git a/nltk/test/unit/test_corpora.py b/nltk/test/unit/test_corpora.py
--- a/nltk/test/unit/test_corpora.py
+++ b/nltk/test/unit/test_corpora.py
@@ -26,6 +26,16 @@ def test_raw_unicode(self):
             txt = udhr.raw(name)
             assert not isinstance(txt, bytes), name
 
+    def test_polish_encoding(self):
+        text_pl = udhr.raw("Polish-Latin2")[:164]
+        text_ppl = udhr.raw("Polish_Polski-Latin2")[:164]
+        expected = """POWSZECHNA DEKLARACJA PRAW CZŁOWIEKA
+[Preamble]
+Trzecia Sesja Ogólnego Zgromadzenia ONZ, obradująca w Paryżu, \
+uchwaliła 10 grudnia 1948 roku jednomyślnie Powszechną"""
+        assert text_pl == expected, "Polish-Latin2"
+        assert text_ppl == expected, "Polish_Polski-Latin2"
+
 
 class TestIndian(unittest.TestCase):
     def test_words(self):