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

Issue:
Remove verify_interface
Now that `register_interface` is gone we have no use for `verify_interface`, but https://github.com/aws/aws-encryption-sdk-python/issues/464 is a blocker for removing it.


Discussion:
[Link for metrics](https://pepy.tech/project/aws-encryption-sdk?versions=3.1.1&versions=*).

gap between them is the installs that would be impacted when this happens

Digging into this again, it appears they've released versions of v1 and v2 that pinned cryptography versions (concurrent with deprecating them). The vast majority of v3 downloads are on 3.1.1 (the version that removes verify_interface). This is not true of v1 and v2 users, but based on the last 8 months it appears those users simply do not upgrade since very few are on the final v1/v2 releases anyway.

I propose we go ahead and remove verify_interface in 40.
Fine with me, want to submit a PR for it?

Resolving patch:
diff --git a/src/cryptography/utils.py b/src/cryptography/utils.py
--- a/src/cryptography/utils.py
+++ b/src/cryptography/utils.py
@@ -3,7 +3,6 @@
 # for complete details.
 
 
-import abc
 import enum
 import sys
 import types
@@ -48,16 +47,6 @@ class InterfaceNotImplemented(Exception):
     pass
 
 
-# DeprecatedIn39 -- Our only known consumer is aws-encryption-sdk, but we've
-# made this a no-op to avoid breaking old versions.
-def verify_interface(
-    iface: abc.ABCMeta, klass: object, *, check_annotations: bool = False
-):
-    # Exists exclusively for `aws-encryption-sdk` which relies on it existing,
-    # even though it was never a public API.
-    pass
-
-
 class _DeprecatedValue:
     def __init__(self, value: object, message: str, warning_class):
         self.value = value


Test patch:
diff --git a/tests/test_interfaces.py b/tests/test_interfaces.py
deleted file mode 100644
--- a/tests/test_interfaces.py
+++ /dev/null
@@ -1,20 +0,0 @@
-# This file is dual licensed under the terms of the Apache License, Version
-# 2.0, and the BSD License. See the LICENSE file in the root of this repository
-# for complete details.
-
-import abc
-
-from cryptography.utils import verify_interface
-
-
-class TestVerifyInterface:
-    def test_noop(self):
-        class SimpleInterface(metaclass=abc.ABCMeta):
-            @abc.abstractmethod
-            def method(self):
-                """A simple method"""
-
-        class NonImplementer:
-            pass
-
-        verify_interface(SimpleInterface, NonImplementer)
Repository: pyca/cryptography

Issue:
Incorrect docstrings in x25519 and x448 `.public_key()` methods
See:

https://github.com/pyca/cryptography/blob/127a2860740c77f45362e68e0ed7d2d108a39033/src/cryptography/hazmat/primitives/asymmetric/x25519.py#L60-L64

https://github.com/pyca/cryptography/blob/127a2860740c77f45362e68e0ed7d2d108a39033/src/cryptography/hazmat/primitives/asymmetric/x448.py#L60-L64

In both instances, the method does not return serialised bytes, but a public key object. The full [generated documentation](https://cryptography.io/en/latest/hazmat/primitives/asymmetric/x25519/#cryptography.hazmat.primitives.asymmetric.x25519.X25519PrivateKey.public_key) is correct, as are the Ed* docstrings.


Discussion:
Thanks!

Resolving patch:
diff --git a/src/cryptography/hazmat/primitives/asymmetric/x25519.py b/src/cryptography/hazmat/primitives/asymmetric/x25519.py
--- a/src/cryptography/hazmat/primitives/asymmetric/x25519.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/x25519.py
@@ -60,7 +60,7 @@ def from_private_bytes(cls, data: bytes) -> "X25519PrivateKey":
     @abc.abstractmethod
     def public_key(self) -> X25519PublicKey:
         """
-        The serialized bytes of the public key.
+        Returns the public key assosciated with this private key
         """
 
     @abc.abstractmethod


Test patch:
Repository: pyca/cryptography

Issue:
Incorrect docstrings in x25519 and x448 `.public_key()` methods
See:

https://github.com/pyca/cryptography/blob/127a2860740c77f45362e68e0ed7d2d108a39033/src/cryptography/hazmat/primitives/asymmetric/x25519.py#L60-L64

https://github.com/pyca/cryptography/blob/127a2860740c77f45362e68e0ed7d2d108a39033/src/cryptography/hazmat/primitives/asymmetric/x448.py#L60-L64

In both instances, the method does not return serialised bytes, but a public key object. The full [generated documentation](https://cryptography.io/en/latest/hazmat/primitives/asymmetric/x25519/#cryptography.hazmat.primitives.asymmetric.x25519.X25519PrivateKey.public_key) is correct, as are the Ed* docstrings.


Discussion:
Thanks!

Resolving patch:
diff --git a/src/cryptography/hazmat/primitives/asymmetric/x448.py b/src/cryptography/hazmat/primitives/asymmetric/x448.py
--- a/src/cryptography/hazmat/primitives/asymmetric/x448.py
+++ b/src/cryptography/hazmat/primitives/asymmetric/x448.py
@@ -60,7 +60,7 @@ def from_private_bytes(cls, data: bytes) -> "X448PrivateKey":
     @abc.abstractmethod
     def public_key(self) -> X448PublicKey:
         """
-        The serialized bytes of the public key.
+        Returns the public key associated with this private key
         """
 
     @abc.abstractmethod


Test patch:
Repository: pyca/cryptography

Issue:
remove X509_V_FLAG_NOTIFY_POLICY
This is being removed in an upcoming pyOpenSSL release as well (see: https://github.com/pyca/pyopenssl/pull/1213)


Discussion:
@reaperhulk this can be rebased at this point, we've done a pyopenssl release.

Resolving patch:
diff --git a/src/_cffi_src/openssl/x509_vfy.py b/src/_cffi_src/openssl/x509_vfy.py
--- a/src/_cffi_src/openssl/x509_vfy.py
+++ b/src/_cffi_src/openssl/x509_vfy.py
@@ -103,7 +103,6 @@
 static const long X509_V_FLAG_POLICY_CHECK;
 static const long X509_V_FLAG_EXPLICIT_POLICY;
 static const long X509_V_FLAG_INHIBIT_MAP;
-static const long X509_V_FLAG_NOTIFY_POLICY;
 static const long X509_V_FLAG_CHECK_SS_SIGNATURE;
 static const long X509_V_FLAG_PARTIAL_CHAIN;
 


Test patch:
Repository: pyca/cryptography

Issue:
SSL_session_reused bindings not available
Hi,

I might be missing something here.

I see that `SSL_session_reused` is defined here, but I can't acess it via the bindings

https://github.com/pyca/cryptography/blob/f69f27b1dd20ad2d24f48053a72545527e808104/src/_cffi_src/openssl/ssl.py#L410-L412

I am using Ubuntu 23.10 , with default py3 and latest cryptography installed in a virtualenv

```
$ virtualenv venv
$ . venv/bin/activate
$ pip install cryptography
$ python
Python 3.11.6 (main, Oct  8 2023, 05:06:43) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from cryptography.hazmat.bindings.openssl.binding import Binding
>>> binding = Binding()
>>> binding.init_static_locks()

>>> binding.lib.SSL_session_reused
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'lib' has no attribute 'SSL_session_reused'

>>> binding.lib.SSL_select_next_proto
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: module 'lib' has no attribute 'SSL_select_next_proto'

>>> binding.lib.SSL_CTX_set_alpn_protos
<built-in method SSL_CTX_set_alpn_protos of _cffi_backend.Lib object at 0x7fe38561bab0>
>>> 
```


```
$ python -m pip freeze
cffi==1.16.0
cryptography==41.0.7
pycparser==2.21
```

--------

I don't know why `SSL_CTX_set_alpn_protos` is available but `SSL_session_reused` and other functions are not available.

This was working in `cryptography==39.0.2`

I guess that this might be part of 40.0.0 

> Removed many unused CFFI OpenSSL bindings. This will not impact you unless you are using cryptography to directly invoke OpenSSL's C API. Note that these have never been considered a stable, supported, public API by cryptography, this note is included as a courtesy.

--------

I think that `SSL_session_reused` is very important as it is critical for implemeting FTPS server-side session reusal validation.

The `SSL_set_session` that is already avaiable, is used for the FTPS client-side part.

----------


Thanks


Discussion:
I will follow up with a PR for this. 
It took a bit longer to get the dev env up and running.

But I got the patch and also an automated test.

Resolving patch:
diff --git a/src/_cffi_src/openssl/ssl.py b/src/_cffi_src/openssl/ssl.py
--- a/src/_cffi_src/openssl/ssl.py
+++ b/src/_cffi_src/openssl/ssl.py
@@ -142,6 +142,7 @@
 const char *SSL_state_string_long(const SSL *);
 SSL_SESSION *SSL_get1_session(SSL *);
 int SSL_set_session(SSL *, SSL_SESSION *);
+int SSL_session_reused(const SSL *);
 SSL *SSL_new(SSL_CTX *);
 void SSL_free(SSL *);
 int SSL_set_fd(SSL *, int);


Test patch:
Repository: catalyst-team/catalyst

Issue:
[fix] fix registry exception for duplicate factory
@TODO:
- return exception for duplicate factory
- check that all registries usage are correct: both in `__init__.py` and `model.py` for example
[fix] fix registry exception for duplicate factory
@TODO:
- return exception for duplicate factory
- check that all registries usage are correct: both in `__init__.py` and `model.py` for example


Discussion:

Resolving patch:
diff --git a/catalyst/utils/registry.py b/catalyst/utils/registry.py
--- a/catalyst/utils/registry.py
+++ b/catalyst/utils/registry.py
@@ -94,12 +94,15 @@ def add(
         if len(named_factories) == 0:
             warnings.warn("No factories were provided!")
 
-        # @TODO: return warning
-        # for name in named_factories:
-        #     if name in self._factories:
-        #         raise RegistryException(
-        #             f"Factory with name '{name}' is already present"
-        #         )
+        for name, f in named_factories.items():
+            # self._factories[name] != f is a workaround for
+            # https://github.com/catalyst-team/catalyst/issues/135
+            if name in self._factories and self._factories[name] != f:
+                raise RegistryException(
+                    f"Factory with name '{name}' is already present\n"
+                    f"Already registered: '{self._factories[name]}'\n"
+                    f"New: '{f}'"
+                )
 
         self._factories.update(named_factories)
 


Test patch:
diff --git a/catalyst/utils/tests/test_registry.py b/catalyst/utils/tests/test_registry.py
--- a/catalyst/utils/tests/test_registry.py
+++ b/catalyst/utils/tests/test_registry.py
@@ -44,12 +44,24 @@ def test_fail_multiple_with_name():
         r.add(foo, foo, name="bar")
 
 
-# def test_fail_double_add():
-#     r = Registry("")
-#     r.add(foo)
-#
-#     with pytest.raises(RegistryException):
-#         r.add(foo)
+def test_fail_double_add_different():
+    r = Registry("")
+    r.add(foo)
+
+    with pytest.raises(RegistryException):
+        def bar():
+            pass
+
+        r.add(foo=bar)
+
+
+def test_double_add_same_nofail():
+    r = Registry("")
+    r.add(foo)
+    # It's ok to add same twice, forced by python relative import
+    # implementation
+    # https://github.com/catalyst-team/catalyst/issues/135
+    r.add(foo)
 
 
 def test_instantiations():
diff --git a/examples/_tests_mnist_stages/config_finder.yml b/examples/_tests_mnist_stages/config_finder.yml
--- a/examples/_tests_mnist_stages/config_finder.yml
+++ b/examples/_tests_mnist_stages/config_finder.yml
@@ -31,4 +31,4 @@ stages:
       finder:
         callback: LRFinder
         final_lr: 0.1
-        n_steps: 1000
+        num_steps: 1000
diff --git a/examples/_tests_mnist_stages2/config_finder.yml b/examples/_tests_mnist_stages2/config_finder.yml
--- a/examples/_tests_mnist_stages2/config_finder.yml
+++ b/examples/_tests_mnist_stages2/config_finder.yml
@@ -31,4 +31,4 @@ stages:
       finder:
         callback: LRFinder
         final_lr: 0.1
-        n_steps: 1000
+        num_steps: 1000
Repository: catalyst-team/catalyst

Issue:
Autoresume from "logdir/last_full.pth"
In some systems, like slurm, task is time limited. Usually it is about 10-20 hours. Large tasks, like ImageNet, require running several small tasks. This feature helps automate this process.


Discussion:

Resolving patch:
diff --git a/catalyst/dl/scripts/run.py b/catalyst/dl/scripts/run.py
--- a/catalyst/dl/scripts/run.py
+++ b/catalyst/dl/scripts/run.py
@@ -44,18 +44,26 @@ def build_args(parser: ArgumentParser):
         metavar="PATH",
         help="path to latest checkpoint"
     )
+    utils.boolean_flag(
+        parser,
+        "autoresume",
+        default=False,
+        help=(
+            "try automatically resume from logdir//last_full.pth "
+            "if --resume is empty"
+        )
+    )
     parser.add_argument("--seed", type=int, default=42)
     utils.boolean_flag(parser, "verbose", default=None)
     utils.boolean_flag(parser, "check", default=None)
     utils.boolean_flag(
-        parser, "deterministic",
+        parser,
+        "deterministic",
         default=None,
         help="Deterministic mode if running in CuDNN backend"
     )
     utils.boolean_flag(
-        parser, "benchmark",
-        default=None,
-        help="Use CuDNN benchmark"
+        parser, "benchmark", default=None, help="Use CuDNN benchmark"
     )
 
     return parser
diff --git a/catalyst/utils/config.py b/catalyst/utils/config.py
--- a/catalyst/utils/config.py
+++ b/catalyst/utils/config.py
@@ -254,6 +254,13 @@ def parse_config_args(*, config, args, unknown_args):
                 continue
             config["args"][key] = value
 
+    if safitty.get(config, "args", "autoresume", default=False) and \
+            safitty.get(config, "args", "logdir") is not None and \
+            safitty.get(config, "args", "resume") is None:
+        logdir = Path(safitty.get(config, "args", "logdir"))
+        checkpoint_filename = logdir / "checkpoints" / "last_full.pth"
+        if checkpoint_filename.is_file():
+            config["args"]["resume"] = str(checkpoint_filename)
     return config, args
 
 


Test patch:
Repository: catalyst-team/catalyst

Issue:
RMS Normalization
**Is your feature request related to a problem? Please describe.**
RMS Normalization https://openreview.net/pdf?id=SygkZ3MTJE is a normalization technique proposed for normalizing CNN and LSTM.

**Describe the solution you'd like**
I have experimented Layer Normalization and RMS Normalization using LSTM on IMDB dataset. Experiment results can be found here: https://github.com/avinashsai/All-you-need-to-know-about-Normalization/blob/master/Experiments/Normalization_IMDB.ipynb. I would like to include this normalization technique in the framework. Please share your thoughts on this. 

Thank you


Discussion:
@Scitator Please share your thoughts on this.
Hi @avinashsai,
Thanks for your proposal, we are definitely would be grateful for your contribution,
you can add your implementation to [https://github.com/catalyst-team/catalyst/tree/master/catalyst/contrib/nn/modules/rms_norm.py](https://github.com/catalyst-team/catalyst/tree/master/catalyst/contrib/nn/modules) for example :)
Thank you. will surely work on it.

Resolving patch:
diff --git a/catalyst/contrib/nn/modules/__init__.py b/catalyst/contrib/nn/modules/__init__.py
--- a/catalyst/contrib/nn/modules/__init__.py
+++ b/catalyst/contrib/nn/modules/__init__.py
@@ -10,3 +10,4 @@
     GlobalMaxPool2d
 )
 from .real_nvp import CouplingLayer, SquashingLayer
+from .rms_norm import RMSNorm
diff --git a/catalyst/contrib/nn/modules/rms_norm.py b/catalyst/contrib/nn/modules/rms_norm.py
new file mode 100644
--- /dev/null
+++ b/catalyst/contrib/nn/modules/rms_norm.py
@@ -0,0 +1,33 @@
+import torch
+import torch.nn as nn
+
+
+class RMSNorm(nn.Module):
+    """
+    An implementation of RMS Normalization
+
+    Args:
+        dimension (int, required): The dimension of the layer
+            output to normalize
+        epsilon (float, optional): An epsilon to prevent dividing by
+            zero in case the layer has zero variance. (default = 1e-8)
+        is_bias (bool, optional) :  A boolean value whether to include
+            bias term while normalization (default = False)
+    Returns:
+        tensor: The normalized layer output
+    """
+    def __init__(self, dimension, epsilon=1e-8, is_bias=False):
+        super().__init__()
+        self.dimension = dimension
+        self.epsilon = epsilon
+        self.is_bias = is_bias
+        self.scale = nn.Parameter(torch.ones(self.dimension))
+        if(self.is_bias):
+            self.bias = nn.Parameter(torch.zeros(self.dimension))
+
+    def forward(self, x: torch.Tensor):
+        x_std = torch.sqrt(torch.mean(x**2, -1, keepdim=True))
+        x_norm = x / (x_std + self.epsilon)
+        if(self.is_bias):
+            return self.scale * x_norm + self.bias
+        return self.scale * x_norm


Test patch:
Repository: django-wiki/django-wiki

Issue:
Default slug formatting is not correct 
I've just installed django-wiki with pip pointing at the master branch.
Ive noticed that the slug URLS areLikeThis rather than like_this or like-this.

Upon further investigation, it appears that the URLify function is not being called.

https://github.com/benjaoming/django-wiki/blob/master/wiki/templates/wiki/create.html#L32



Discussion:

Resolving patch:
diff --git a/wiki/forms.py b/wiki/forms.py
--- a/wiki/forms.py
+++ b/wiki/forms.py
@@ -264,6 +264,8 @@ def clean_slug(self):
             else:
                 raise forms.ValidationError(_(u'A slug named "%s" already exists.') % already_urlpath.slug)
         
+        slug = slug.lower()
+        slug = slug.replace('-', '_')
         return slug
     
     def clean(self):
diff --git a/wiki/views/article.py b/wiki/views/article.py
--- a/wiki/views/article.py
+++ b/wiki/views/article.py
@@ -60,7 +60,7 @@ def get_form(self, form_class):
         initial['slug'] = self.request.GET.get('slug', None)
         kwargs['initial'] = initial
         form = form_class(self.request, self.urlpath, **kwargs)
-        form.fields['slug'].widget = forms.TextInputPrepend(prepend='/'+self.urlpath.path)
+        form.fields['slug'].widget = forms.TextInputPrepend(prepend='/'+self.urlpath.path, attrs={'pattern': '[^-A-Z]+', 'title': 'Please only use lowercase alphanumeric characters and underscores'})
         return form
 
     def form_valid(self, form):


Test patch:
Repository: django-wiki/django-wiki

Issue:
Multiple Attachment Links Disable Each Other
If I attach two files to a wiki page - or if I just reference the same attachment multiple times... only the last reference actually works.

So - let's say I attach a file and it gets ID `16`.  If I do this:

```
[attachment:16] stuff [attachment:16] junk [attachment:16]
```

Only that last one actually gets turned into a link to the file... the others show up as actual text `[attachment:16]`.

Pertinent info:

Django: 1.6.2
Python: 2.7.3
Wiki: 0.0.23



Discussion:
Thanks for the bug report! Currently, I'm looking at Python 3 support and Django 1.7, and it's taking a lot of efforts.

If anyone's willing to grab this,  don't be shy :)


Resolving patch:
diff --git a/wiki/plugins/attachments/markdown_extensions.py b/wiki/plugins/attachments/markdown_extensions.py
--- a/wiki/plugins/attachments/markdown_extensions.py
+++ b/wiki/plugins/attachments/markdown_extensions.py
@@ -27,8 +27,8 @@ def run(self, lines):
             m = ATTACHMENT_RE.match(line)
             if m:
                 attachment_id = m.group('id').strip()
-                before = m.group('before')
-                after = m.group('after')
+                before = self.run([m.group('before')])[0]
+                after = self.run([m.group('after')])[0]
                 try:
                     attachment = models.Attachment.objects.get(
                         articles__current_revision__deleted=False,
@@ -36,7 +36,7 @@ def run(self, lines):
                     )
                     url = reverse('wiki:attachments_download', kwargs={'article_id': self.markdown.article.id,
                                                                        'attachment_id':attachment.id,})
-                    
+
                     # The readability of the attachment is decided relative
                     # to the owner of the original article.
                     # I.e. do not insert attachments in other articles that
@@ -47,14 +47,14 @@ def run(self, lines):
                     html = render_to_string(
                         "wiki/plugins/attachments/render.html",
                         Context({
-                            'url': url, 
+                            'url': url,
                             'filename': attachment.original_filename,
                             'attachment_can_read': attachment_can_read,
                         }))
                     line = self.markdown.htmlStash.store(html, safe=True)
                 except models.Attachment.DoesNotExist:
                     line = line.replace(m.group(1), """<span class="attachment attachment-deleted">Attachment with ID #%s is deleted.</span>""" % attachment_id)
-                line = before + line + after                    
+                line = before + line + after
             new_text.append(line)
         return new_text
-    
+


Test patch:
Repository: django-wiki/django-wiki

Issue:
Travis requirements should import requirements from the requirements to be distributed
This file:

https://github.com/django-wiki/django-wiki/blob/master/.travis/requirements.txt

Should automatically include same requirements as main distribution, perhaps `-r ../requirements.txt` will work.



Discussion:

Resolving patch:
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -18,18 +18,41 @@ def read(fname):
     return open(get_path(fname)).read()
 
 
-def dynamic_requirements(requirements):
-    
-    try:
-        from django import VERSION
-        if VERSION < (1, 7):
-            requirements.append("South>=0.8,!=0.8.3")
-    except ImportError:
-        # No django so assuming that a new one will
-        # get installed...
-        pass
-    return requirements
+requirements = [
+    "Django>=1.4,<1.7",
+    "django-sekizai>=0.7",
+    "Pillow",
+    "django-nyt>=0.9.3",
+    "django-mptt==0.6.0", # 0.6.1 broken: https://github.com/django-mptt/django-mptt/issues/316
+    "six"
+    ]
 
+# Requirements that depend on Django version: South and sorl-thumbnail
+try:
+    from django import VERSION as DJANGO_VERSION
+except ImportError:
+    # No django so assuming that a new one will get installed...
+    # TODO/FIXME: Remove the South req line here when Django>=1.7 is accepted
+    requirements.append("South>=0.8.4")
+    requirements.append("sorl-thumbnail>=11.12.1b")
+else:
+    if DJANGO_VERSION < (1, 7):
+        requirements.append("South>=0.8.4")
+    if DJANGO_VERSION < (1, 5):
+        # For Django 1.4, use sorl-thumbnail<11.12.1:
+        # https://github.com/mariocesar/sorl-thumbnail/issues/255
+        requirements.append("sorl-thumbnail<11.12.1")
+    else:
+        requirements.append("sorl-thumbnail>=11.12.1b")
+
+# Requirements that depend on Python version: Markdown
+from sys import version_info as PYTHON_VERSION
+if PYTHON_VERSION < (2, 7):
+    # For Python 2.6, use Markdown<2.5.0, see
+    # https://github.com/waylan/Python-Markdown/issues/349
+    requirements.append("Markdown>2.2.0,<2.5.0")
+else:
+    requirements.append("Markdown>2.2.0")
 
 packages = find_packages()
 
@@ -58,7 +81,7 @@ def dynamic_requirements(requirements):
     packages=find_packages(exclude=["testproject", "testproject.*"]),
     # long_description=long_description,
     zip_safe=False,
-    install_requires=dynamic_requirements(read('requirements.txt').split("\n")),
+    install_requires=requirements,
     classifiers=[
         'Development Status :: 3 - Alpha',
         'License :: OSI Approved :: GNU General Public License v3 (GPLv3)',


Test patch: