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

Issue:
Unsupported language codes passed to Docutils
Even though https://github.com/getpelican/pelican-plugins/issues/1087 was moved from here to pelican-plugins, if I understand it correctly the original error was due to https://github.com/getpelican/pelican/pull/2256 , and @avaris suggested something may need to be done about it here. (@mosra)


Discussion:

Resolving patch:
diff --git a/pelican/readers.py b/pelican/readers.py
--- a/pelican/readers.py
+++ b/pelican/readers.py
@@ -9,6 +9,7 @@
 import docutils
 import docutils.core
 import docutils.io
+from docutils.parsers.rst.languages import get_language as get_docutils_lang
 from docutils.writers.html4css1 import HTMLTranslator, Writer
 
 import six
@@ -218,6 +219,14 @@ def __init__(self, *args, **kwargs):
     def __init__(self, *args, **kwargs):
         super(RstReader, self).__init__(*args, **kwargs)
 
+        lang_code = self.settings.get('DEFAULT_LANG', 'en')
+        if get_docutils_lang(lang_code):
+            self._language_code = lang_code
+        else:
+            logger.warning("Docutils has no localization for '%s'."
+                           " Using 'en' instead.", lang_code)
+            self._language_code = 'en'
+
     def _parse_metadata(self, document, source_path):
         """Return the dict containing document metadata"""
         formatted_fields = self.settings['FORMATTED_FIELDS']
@@ -256,7 +265,7 @@ def _get_publisher(self, source_path):
         extra_params = {'initial_header_level': '2',
                         'syntax_highlight': 'short',
                         'input_encoding': 'utf-8',
-                        'language_code': self.settings.get('DEFAULT_LANG'),
+                        'language_code': self._language_code,
                         'halt_level': 2,
                         'traceback': True,
                         'warning_stream': StringIO(),


Test patch:
Repository: getpelican/pelican

Issue:
WARNING: Docutils has no localization for 'english'. Using 'en' instead.
1. pipenv install pelican markdown
2. pelican-quickstart
3. create an article in content
4. run pelican

**Expected**: Clean run and output created 
**Observed**: Warning 

> WARNING: Docutils has no localization for 'english'. Using 'en' instead.

When I change DEFAULT_LANG = 'English' in my seetings to DEFAULT_LANG = 'en' it runs fine.

Should I PR that as a fix or is there some reason it is English and not en.



Discussion:
Related: https://github.com/getpelican/pelican/issues/2481 

Resolving patch:
diff --git a/pelican/tools/pelican_quickstart.py b/pelican/tools/pelican_quickstart.py
--- a/pelican/tools/pelican_quickstart.py
+++ b/pelican/tools/pelican_quickstart.py
@@ -34,7 +34,7 @@
     # Don't fail on macosx: "unknown locale: UTF-8"
     _DEFAULT_LANGUAGE = None
 if _DEFAULT_LANGUAGE is None:
-    _DEFAULT_LANGUAGE = 'English'
+    _DEFAULT_LANGUAGE = 'en'
 else:
     _DEFAULT_LANGUAGE = _DEFAULT_LANGUAGE.split('_')[0]
 


Test patch:
Repository: getpelican/pelican

Issue:
Use published as default status
Hi,

at https://github.com/getpelican/pelican/blob/master/pelican/contents.py#L144 the `status` of a content is set to `None` is `default_status` is not specified. This deterministically causes an error as soon as `lower` is called on it at https://github.com/getpelican/pelican/blob/master/pelican/contents.py#L426. Wouldn't it more sensible to take `published` as default status?

Thanks for Pelican, it's really nice.


Discussion:
BTW, I found the bug in action here: https://github.com/bstpierre/pelican-comments/pull/4
Yes and no. `Content` isn't meant to be used by itself. It's up to the [subclass to define that](https://github.com/getpelican/pelican/blob/master/pelican/contents.py#L505).
Ok. In that case I suggest to error our as soon as no `status` and no `default_status` is found, so that the cause of the error is clear.
Actually, looking at it again, `getattr` fall back being `None` doesn't make much sense. `''` or `'published'` is probably OK:

```python
self.status = getattr(self, 'default_status', '')
```

Or, `setter` can deal with that.
I can conifrm that 

````
self.status = getattr(self, 'default_status', '')
````

or

````
self.status = getattr(self, 'default_status', 'published')
````

or

````
    @status.setter
    def status(self, value):
        if value is None:
            self._status = value.lower()
        else:
            self._status = None
````

all get the "pelican comment system" plugin working again.
Who would be so kind as to submit a pull request that changes the default status from `None` to `''`? 😁 

Resolving patch:
diff --git a/pelican/contents.py b/pelican/contents.py
--- a/pelican/contents.py
+++ b/pelican/contents.py
@@ -141,7 +141,9 @@ def __init__(self, content, metadata=None, settings=None,
 
         # manage status
         if not hasattr(self, 'status'):
-            self.status = getattr(self, 'default_status', None)
+            # using None as the default here breaks comment plugins (and
+            # probably others)
+            self.status = getattr(self, 'default_status', '')
 
         # store the summary metadata if it is set
         if 'summary' in metadata:


Test patch:
Repository: getpelican/pelican

Issue:
Pelican binds to 0.0.0.0 instead of 127.0.0.1 when --bind is omitted
### Problem

When starting Pelican like
`$ pelican --listen`

it binds to all network interfaces. However:

```
$ pelican --help
...
  -b BIND, --bind BIND  IP to bind to when serving files via HTTP (default:
                        127.0.0.1) (default: None)
```

When ommiting --bind, it should bind to 127.0.0.1 only.


### Observation

My macOS machine presents a pop-up with the question if I want to allow '_The application "Python.app" to accept incoming network connections?_'. Typically, macOS only asks this question if a service is being bound to a public network interface and not the loop back interface.

After clicking allow, a netstat shows Pelican is bound to all available interfaces (note: one should first visit the site on the IP number of the public network interface, otherwise netstat won't show this):

```
$ netstat -an|grep '*.8000'
tcp4       0      0  *.8000                 *.*                    LISTEN

```


### Cause

When pelican is started with --listen, but --bind is ommited, default settings from pelican/settings.py are used. In the DEFAULT_CONFIG dictionary, we find: 'BIND': '',

BIND is then passed to listen(), RootedHTTPServer(), BaseHTTPServer() and finally to socket()

The socket documentation states:

> For IPv4 addresses, two special forms are accepted instead of a host address: '' represents INADDR_ANY, which is used to bind to all interfaces, and the string '<broadcast>' represents INADDR_BROADCAST.


Thus, because the default setting of BIND is '', Pelican is bound to all interfaces and not, as documented and promised, 127.0.0.1 only.


### Solution

The solution is to set BIND to '127.0.0.1' in pelican/settings.py. As a workaround, it is also possible to set BIND = '127.0.0.1' in pelicanconf.py



Discussion:
While the documentation could be changed to reflect the current actual effective default of `0.0.0.0` (all interfaces), I agree it makes more sense from a security perspective to default to localhost. Do other @getpelican/reviewers agree?

If so, would anyone care to volunteer and implement a fix for this issue?
i m working on it

Resolving patch:
diff --git a/pelican/settings.py b/pelican/settings.py
--- a/pelican/settings.py
+++ b/pelican/settings.py
@@ -170,7 +170,7 @@ def load_source(name, path):
     'WRITE_SELECTED': [],
     'FORMATTED_FIELDS': ['summary'],
     'PORT': 8000,
-    'BIND': '',
+    'BIND': '127.0.0.1',
 }
 
 PYGMENTS_RST_OPTIONS = None


Test patch:
Repository: getpelican/pelican

Issue:
KeyboardInterrupt
If you run:

~~~
pelican --listen
~~~

Pelican does not tell you how to stop. Compare with other projects:

~~~
Press Ctrl+C to stop
~~~

I assume that Pelican accepts the same key, but this is produced:

~~~
Traceback (most recent call last):
  File "/usr/bin/pelican", line 10, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/pelican/__init__.py", line 559, in main
    settings.get("OUTPUT_PATH"))
  File "/usr/lib/python3.6/site-packages/pelican/__init__.py", line 495, in listen
    httpd.serve_forever()
  File "/usr/lib/python3.6/socketserver.py", line 236, in serve_forever
    ready = selector.select(poll_interval)
  File "/usr/lib/python3.6/selectors.py", line 376, in select
    fd_event_list = self._poll.poll(timeout)
KeyboardInterrupt
~~~



Discussion:
Here is fix:

~~~diff
diff --git a/pelican/__init__.py b/pelican/__init__.py
index 17f4f92..d3889b2 100644
--- a/pelican/__init__.py
+++ b/pelican/__init__.py
@@ -474,6 +474,9 @@ def listen(server, port, output, excqueue=None):
             excqueue.put(traceback.format_exception_only(type(e), e)[-1])
         return

+    except KeyboardInterrupt:
+        logger.info("Shutting down server.")
+        httpd.socket.close()

 def main(argv=None):
     args = parse_arguments(argv)
~~~

Copied from here:

https://github.com/getpelican/pelican/blob/70c8d2a47431cc5de29b08a830d1af4f8e6f6e30/pelican/server.py#L138-L140

at any rate, I built my own server until a new Pelican build is available:

https://github.com/cup/sunday/blob/master/file-server/serve.go
Hi @cup, thanks for the bug report! I agree that it would be more user-friendly to have a nice error message instead of just the raw `KeyboardInterrupt` event. If you submit a pull request, I think the @getpelican team would be happy to merge it.

Resolving patch:
diff --git a/pelican/__init__.py b/pelican/__init__.py
--- a/pelican/__init__.py
+++ b/pelican/__init__.py
@@ -466,14 +466,19 @@ def listen(server, port, output, excqueue=None):
             excqueue.put(traceback.format_exception_only(type(e), e)[-1])
         return
 
-    logging.info("Serving at port %s, server %s.", port, server)
     try:
+        print("\nServing site at: {}:{} - Tap CTRL-C to stop".format(
+            server, port))
         httpd.serve_forever()
     except Exception as e:
         if excqueue is not None:
             excqueue.put(traceback.format_exception_only(type(e), e)[-1])
         return
 
+    except KeyboardInterrupt:
+        print("\nKeyboard interrupt received. Shutting down server.")
+        httpd.socket.close()
+
 
 def main(argv=None):
     args = parse_arguments(argv)


Test patch:
Repository: getpelican/pelican

Issue:
Fix for the erasing of an output directory
Hi,

It's another try...
This patch is about checking if a directory from 'output_path' is a part of a directory from 'path'. It basically, gets the most common part of both directories and compares if it equals to a directory specified for erasing. The erasing is possible only if it's allowed and an output directory is not a part of a content's path.

This is an example where the current check doesn't work:

PATH = '/path/to/repo/docs.src/content'
OUTPUT_PATH = '/path/to/repo/docs'


Discussion:
Hi Kevin, 
You're right, it definitely has to be done in other way.
Thanks for the link, I'll try to come up with a better solution.
Hi Kevin,

As you suggested, I've replaced os.path.commonpath by an equivalent one-liner which works similar in that situation. I checked it in Py27. I also squashed all intermediate commits.

How do you think, what else should be done to get it merged? 

Thanks!

Resolving patch:
diff --git a/pelican/__init__.py b/pelican/__init__.py
--- a/pelican/__init__.py
+++ b/pelican/__init__.py
@@ -99,10 +99,11 @@ def run(self):
             ) for cls in self.get_generator_classes()
         ]
 
-        # erase the directory if it is not the source and if that's
-        # explicitly asked
-        if (self.delete_outputdir and not
-                os.path.realpath(self.path).startswith(self.output_path)):
+        # Delete the output directory if (1) the appropriate setting is True
+        # and (2) that directory is not the parent of the source directory
+        if (self.delete_outputdir
+                and os.path.commonpath([self.output_path]) !=
+                os.path.commonpath([self.output_path, self.path])):
             clean_output_dir(self.output_path, self.output_retention)
 
         for p in generators:


Test patch:
Repository: getpelican/pelican

Issue:
slugify is no longer hyphenating 
- [x] I have read the [Filing Issues](https://docs.getpelican.com/en/latest/contribute.html#filing-issues) and subsequent “How to Get Help” sections of the documentation.
- [x] I have searched the [issues](https://github.com/getpelican/pelican/issues?q=is%3Aissue) (including closed ones) and believe that this is not a duplicate.

- **Pelican version**: pelican @ git+https://github.com/getpelican/pelican.git@8bb5f1b786b6f2b22d1dc4501796d6df9a658a05

## Issue
slugify seems to no longer make hyphens out of spaces:
```python
from pelican.utils import slugify

assert slugify("asdf fdsa") == "asdf-fdsa"
```

This is breaking plugins that depend on that behaviour.

Either change the docstring to indicate that hyphenating is no longer happening or restore old behaviour.


Discussion:
I think the default for the substitution handling changed, making it not take the default config but instead not replacing. Will be able to handle it plugin side.

But maybe still take action and change the docstring.
Most of the old default processing is [moved to settings](https://github.com/getpelican/pelican/blob/8bb5f1b786b6f2b22d1dc4501796d6df9a658a05/pelican/settings.py#L147-L152) and controlled from there for more flexibility (via #2326). So old behavior still there but you need to pass the settings entry for it:

```python
>>> from pelican.utils import slugify
>>> from pelican.settings import DEFAULT_CONFIG
>>> assert slugify("asdf fdsa", regex_subs=DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS']) == "asdf-fdsa"
```

But, yeah, docstring could use an update.

PS: long time no see :)
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your participation and understanding.


Resolving patch:
diff --git a/pelican/utils.py b/pelican/utils.py
--- a/pelican/utils.py
+++ b/pelican/utils.py
@@ -230,6 +230,9 @@ def slugify(value, regex_subs=(), preserve_case=False, use_unicode=False):
     and converts spaces to hyphens.
 
     Took from Django sources.
+
+    For a set of sensible default regex substitutions to pass to regex_subs
+    look into pelican.settings.DEFAULT_CONFIG['SLUG_REGEX_SUBSTITUTIONS'].
     """
 
     import unicodedata


Test patch:
Repository: getpelican/pelican

Issue:
A dead link on PyPI for the contributions and feedback
I just stumbled upon [Pelican's page in PyPI](https://pypi.org/project/pelican/) and found that the l[ink for the contributions and feedback](https://pypi.org/project/pelican/CONTRIBUTING.rst) is dead.  Perhaps, it needs to be updated?


Discussion:
Nice catch. If you look at the [`README.rst` source](https://github.com/getpelican/pelican/blame/b777bedce30a624b689b5dc0b034ff8d18675747/README.rst#L33), you'll see that the link isn't exactly _dead_ but refers to a local file (`CONTRIBUTING.rst`) that sits alongside the `README.rst` file. I'm sure there is a better way to handle that link such that it works well in all cases, including on the PyPI project page, but I don't use reStructuredText enough to know how to handle that well.

Anyone know how to fix it appropriately?
`README.rst` is injected into the package while `setup.py` is running.

The contents could be transformed using something like `README.replace("<CONTRIBUTING.rst>", "$ABSOLUTE_URL")` or similar. (Likely `$ABSOLUTE_URL` will be the rendered file on Read the Docs.)
Thanks for the suggestion, Kurt. Any chance you might be willing to submit a pull request for this fix? 😊 

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -25,6 +25,13 @@
 README = open('README.rst', encoding='utf-8').read()
 CHANGELOG = open('docs/changelog.rst', encoding='utf-8').read()
 
+# Relative links in the README must be converted to absolute URL's
+# so that they render correctly on PyPI.
+README = README.replace(
+    "<CONTRIBUTING.rst>",
+    "<https://docs.getpelican.com/en/latest/contribute.html>",
+)
+
 description = '\n'.join([README, CHANGELOG])
 
 setup(


Test patch:
Repository: django-compressor/django-compressor

Issue:
GzipCompressorFileStorage returns URLs ending in .gz
In addition to creating a gzipped version of the compressed files, `GzipCompressorFileStorage` appends a .gz at the end of URLs.

This behavior is not documented, and I don't understand it.

I want the gzipped version so that the webserver doesn't have to re-compress the file every time it's requested by a client that supports gzip, but I still want the original URLs in the HTML.

Did I miss something? Or is it a bug?

See also http://wiki.nginx.org/HttpGzipStaticModule



Discussion:
Yeah, this is a bug, the storage should create the file, but not return it to the template.


Resolving patch:
diff --git a/compressor/storage.py b/compressor/storage.py
--- a/compressor/storage.py
+++ b/compressor/storage.py
@@ -47,9 +47,6 @@ class GzipCompressorFileStorage(CompressorFileStorage):
     The standard compressor file system storage that gzips storage files
     additionally to the usual files.
     """
-    def url(self, name):
-        return u'%s.gz' % super(GzipCompressorFileStorage, self).url(name)
-
     def save(self, filename, content):
         filename = super(GzipCompressorFileStorage, self).save(filename, content)
         out = gzip.open(u'%s.gz' % self.path(filename), 'wb')


Test patch:
diff --git a/compressor/tests/tests.py b/compressor/tests/tests.py
--- a/compressor/tests/tests.py
+++ b/compressor/tests/tests.py
@@ -422,7 +422,7 @@ def test_css_tag_with_storage(self):
         {% endcompress %}
         """
         context = { 'MEDIA_URL': settings.COMPRESS_URL }
-        out = u'<link rel="stylesheet" href="/media/CACHE/css/1d4424458f88.css.gz" type="text/css">'
+        out = u'<link rel="stylesheet" href="/media/CACHE/css/1d4424458f88.css" type="text/css">'
         self.assertEqual(out, render(template, context))
Repository: django-compressor/django-compressor

Issue:
CompilerFilter fails with UnicodeDecodeError
I'm having some problems when trying to compress CSS/JS files with YUICompressor.  The files are generated by LESS/CoffeeScript compilers, and the following exception happens with both filetypes. Everything goes smoothly in development where I'm using only CSSAbsoluteFilter, but when trying to compress the files with aforementioned compressor, the following happens (inside CompilerFilter):

```
> $VENV/lib/python2.7/site-packages/compressor/filters/base.py(120)input()
-> filtered, err = proc.communicate(self.content.encode('utf8'))
(Pdb) type(self.content)
<type 'str'>
(Pdb) s
UnicodeDecodeError: UnicodeD...ge(128)')
> $VENV/lib/python2.7/site-packages/compressor/filters/base.py(120)input()
-> filtered, err = proc.communicate(self.content.encode('utf8'))
(Pdb) 

Resulting error:
ascii' codec can't decode byte 0xc3 in position 8005: ordinal not in range(128)
```

As you can see, the content that was passed into CompilerFilter is a bytetstring, not an unicode one, and when the bytestring is encoded, Python tries to convert it first to Unicode with ascii codec, and this fails when there are non-ascii characters inside the string.

I guess this issue has something to do with precompilers, since ordinary JS/CSS files don't seem to produce this error (I tried with different characters). Maybe at line https://github.com/jezdez/django_compressor/blob/develop/compressor/base.py#L167 the resulting output has to be converted to unicode before passing it to filters?

This issue might also be related to #110.



Discussion:

Resolving patch:
diff --git a/compressor/filters/base.py b/compressor/filters/base.py
--- a/compressor/filters/base.py
+++ b/compressor/filters/base.py
@@ -6,6 +6,7 @@
 from django.core.exceptions import ImproperlyConfigured
 from django.core.files.temp import NamedTemporaryFile
 from django.utils.importlib import import_module
+from django.utils.encoding import smart_unicode
 
 from compressor.conf import settings
 from compressor.exceptions import FilterError
@@ -142,4 +143,5 @@ def input(self, **kwargs):
             if self.outfile is not None:
                 filtered = self.outfile.read()
                 self.outfile.close()
-        return filtered
+
+        return smart_unicode(filtered)


Test patch:
diff --git a/compressor/tests/test_filters.py b/compressor/tests/test_filters.py
--- a/compressor/tests/test_filters.py
+++ b/compressor/tests/test_filters.py
@@ -67,6 +67,11 @@ def test_precompiler_stdin_stdout_filename(self):
         compiler = CompilerFilter(content=self.content, filename=self.filename, command=command)
         self.assertEqual(u"body { color:#990; }%s" % os.linesep, compiler.input())
 
+    def test_precompiler_output_unicode(self):
+        command = '%s %s' % (sys.executable, self.test_precompiler)
+        compiler = CompilerFilter(content=self.content, filename=self.filename, command=command)
+        self.assertEqual(type(compiler.input()), unicode)
+
 
 class CssMinTestCase(TestCase):
     def test_cssmin_filter(self):
Repository: django-compressor/django-compressor

Issue:
No template paths found
Got exception:

```
compressor.exceptions.OfflineGenerationError: No template paths found. None of the configured template loaders provided template paths. See http://django.me/template-loaders for more information on template loaders.
```

With settings:

```
  TEMPLATE_LOADERS = (
      ('pyjade.ext.django.Loader', (
          'django.template.loaders.filesystem.Loader',
          'django.template.loaders.app_directories.Loader',
          'django.template.loaders.eggs.Loader',
      )),
  )
```



Discussion:

Resolving patch:
diff --git a/compressor/management/commands/compress.py b/compressor/management/commands/compress.py
--- a/compressor/management/commands/compress.py
+++ b/compressor/management/commands/compress.py
@@ -13,11 +13,6 @@
 from django.utils.importlib import import_module
 from django.template.loader import get_template  # noqa Leave this in to preload template locations
 
-try:
-    from django.template.loaders.cached import Loader as CachedLoader
-except ImportError:
-    CachedLoader = None  # noqa
-
 from compressor.cache import get_offline_hexdigest, write_offline_manifest
 from compressor.conf import settings
 from compressor.exceptions import (OfflineGenerationError, TemplateSyntaxError,
@@ -87,8 +82,10 @@ def get_loaders(self):
         # )
         # The loaders will return django.template.loaders.filesystem.Loader
         # and django.template.loaders.app_directories.Loader
+        # The cached Loader and similar ones include a 'loaders' attribute
+        # so we look for that.
         for loader in template_source_loaders:
-            if CachedLoader is not None and isinstance(loader, CachedLoader):
+            if hasattr(loader, 'loaders'):
                 loaders.extend(loader.loaders)
             else:
                 loaders.append(loader)


Test patch:
Repository: django-compressor/django-compressor

Issue:
compress management command is still using django.utils.importlib
#608



Discussion:

Resolving patch:
diff --git a/compressor/management/commands/compress.py b/compressor/management/commands/compress.py
--- a/compressor/management/commands/compress.py
+++ b/compressor/management/commands/compress.py
@@ -11,7 +11,10 @@
 from django.template import Context
 from django.utils import six
 from django.utils.datastructures import SortedDict
-from django.utils.importlib import import_module
+try:
+    from importlib import import_module
+except:
+    from django.utils.importlib import import_module
 from django.template.loader import get_template  # noqa Leave this in to preload template locations
 
 from compressor.cache import get_offline_hexdigest, write_offline_manifest


Test patch: