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

Issue:
Building with Python 3.11.4 fails
# Steps to repro
1. Upgrade to Python 3.11.4
2. Compile a sample app with PyInstaller 5.11.0

```
import urllib.parse
print('hello world')
```

# Expected result
Compiled app works

# Actual result
Script compiles but dies at runtime with:

```
./test 
[20089] Module object for pyimod02_importers is NULL!
Traceback (most recent call last):
  File "PyInstaller/loader/pyimod02_importers.py", line 22, in <module>
  File "pathlib.py", line 14, in <module>
  File "urllib/parse.py", line 40, in <module>
ModuleNotFoundError: No module named 'ipaddress'
Traceback (most recent call last):
  File "PyInstaller/loader/pyiboot01_bootstrap.py", line 17, in <module>
ModuleNotFoundError: No module named 'pyimod02_importers'
[20089] Failed to execute script 'pyiboot01_bootstrap' due to unhandled exception!
```

# Other details
Python 3.11.4 has a patch which imports ipaddress from urllib.parse:

https://github.com/python/cpython/commit/b2171a2fd41416cf68afd67460578631d755a550


Discussion:
I did some more testing and this fails in the same fashion when I import `ipaddress` directly also:

```
import ipaddress
print('hello world')
```
The same thing happened to Python 3.12. Looks like we'll need a change a bit like https://github.com/pyinstaller/pyinstaller/pull/7670/commits/ce6b0db739184ba544208ea7b7aaa8e3dbb4f731. I wonder if CPython will keep barkporting the offending change to 3.10, 3.9 and 3.8...

If you need a dirty fix now, find the `_PY3_BASE_MODULES` set in `lib/python3.11/site-packages/PyInstaller/compat.py` and add `"ipaddress"` there.
Actually it shouldn't. Python 3.10 and below are all in security fixes only mode.

Resolving patch:
diff --git a/PyInstaller/compat.py b/PyInstaller/compat.py
--- a/PyInstaller/compat.py
+++ b/PyInstaller/compat.py
@@ -657,6 +657,10 @@ def importlib_load_source(name: str, pathname: str):
 if not is_py310:
     PY3_BASE_MODULES.add('_bootlocale')
 
+if sys.version_info >= (3, 11, 4):
+    # required by loader/pymod02_importers.py -> pathlib -> urllib
+    PY3_BASE_MODULES.add('ipaddress')
+
 # Object types of Pure Python modules in modulegraph dependency graph.
 # Pure Python modules have code object (attribute co_code).
 PURE_PYTHON_MODULE_TYPES = {


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
Bootloader still not properly extracting VCRUNTIME140.dll in pysintaller 5.13.2
## Description of the issue

### Context information (for bug reports)

* Output of `pyinstaller --version`: 5.13.2 as loaded from https://files.pythonhosted.org/packages/1a/74/c65be869ae47649b98a928b3122c27d72fe372138aab4dc6cdd42e217d8a/pyinstaller-5.13.2-py3-none-win_amd64.whl.metadata
* Version of Python: 3.11
* Platform: Windows
* How you installed Python: Github action for python 3.11
* Did you also try this on another platform? Does it work there? Yes it does work under windows and when I copy the `VCRUNTIME140.dll` file into the same directory the onefile-exe resides in

I'm packaging the application as --onefile using `pyinstaller --clean --log-level DEBUG --name "sph_uploader" --add-data "conf;conf" --add-data "ui/*.ui;ui" --add-data "../art/icon.png;art" --splash ../art/splash.png --specpath src --icon ../art/icon.png --onefile --debug bootloader src/main.py`  in this workflow: https://github.com/tmolitor-stud-tu/sph_uploader/blob/master/.github/workflows/pyinstaller-all.yaml

**When I watch the __splash directory when the error dialog box pops up, the dll file is not extracted there, like in #6284**



Discussion:

Resolving patch:
diff --git a/PyInstaller/building/splash.py b/PyInstaller/building/splash.py
--- a/PyInstaller/building/splash.py
+++ b/PyInstaller/building/splash.py
@@ -215,7 +215,11 @@ def __init__(self, image_file, binaries, datas, **kwargs):
         # existing spec files depend on this naming). We specify these binary dependencies (which include the
         # Tcl and Tk shared libaries themselves) even if the user's program uses tkinter and they would be collected
         # anyway; let the collection mechanism deal with potential duplicates.
+        #
+        # NOTE: make sure to clear `bindepend.seen` and force a "clean" dependency analysis - otherwise we will miss
+        # the binaries that were already seen during the main analysis.
         tcltk_libs = [(dest_name, src_name, 'BINARY') for dest_name, src_name in (self.tcl_lib, self.tk_lib)]
+        bindepend.seen.clear()
         self.binaries = bindepend.Dependencies(tcltk_libs)
 
         # Put all shared library dependencies in `splash_requirements`, so they are made available in onefile mode.


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
TypeError: UpdateResource() takes no keyword arguments
引用了python 3.10.9·pyinstaller 6.1.0·imagehash 4.3.1·pyperclip 1.8.2和pyautogui 0.9.54模块，但是报错，打包的程序也用不了


Discussion:
At least provide a stacktrace please.
Nevermind, presumably it's this line:

https://github.com/pyinstaller/pyinstaller/blob/d9c6a9ee8511609727d468d85205e0c5a8dd1760/PyInstaller/utils/win32/winresource.py#L151
那应该如何修改呢，我还想是不是python版本问题

```
  File "E:\python\抢课\抢课.spec", line 18, in <module>
    exe = EXE(
  File "C:\python\lib\site-packages\PyInstaller\building\api.py", line 628, in __init__
    self.__postinit__()
  File "C:\python\lib\site-packages\PyInstaller\building\datastruct.py", line 184, in __postinit__
    self.assemble()
  File "C:\python\lib\site-packages\PyInstaller\building\api.py", line 752, in assemble
    self._retry_operation(winmanifest.write_manifest_to_executable, build_name, self.manifest)
  File "C:\python\lib\site-packages\PyInstaller\building\api.py", line 995, in _retry_operation
    return func(*args)
  File "C:\python\lib\site-packages\PyInstaller\utils\win32\winmanifest.py", line 210, in write_manifest_to_executable
    winresource.add_or_update_resource(filename, manifest_xml, RT_MANIFEST, names, languages)
  File "C:\python\lib\site-packages\PyInstaller\utils\win32\winresource.py", line 151, in add_or_update_resource
    win32api.UpdateResource(module_handle, res_type, res_name, data, language=res_lang)
TypeError: UpdateResource() takes no keyword arguments
```
What version of `pywin32-ctypes` do you have installed?

That keyword argument has been there [since `pywin32-ctypes` 0.1.0](https://github.com/enthought/pywin32-ctypes/commit/bdb3e2e664ffb2155e567f581101b7327ac8281e), and [PyInstaller >= 5.13 explicitly requires `pywin32-ctypes >= 0.2.1`](https://github.com/pyinstaller/pyinstaller/commit/92c8fe4e94c708f625aa28bb9541a2a4976a5f76).

---

Does it work if you edit `C:\python\lib\site-packages\PyInstaller\utils\win32\winresource.py` and change line 151 from

```
win32api.UpdateResource(module_handle, res_type, res_name, data, language=res_lang)
```

to 

```
win32api.UpdateResource(module_handle, res_type, res_name, data, res_lang)
```
pywin32-ctypes的版本为0.2.2
改了之后，能够很好的完成打包，非常感谢

Resolving patch:
diff --git a/PyInstaller/utils/win32/winresource.py b/PyInstaller/utils/win32/winresource.py
--- a/PyInstaller/utils/win32/winresource.py
+++ b/PyInstaller/utils/win32/winresource.py
@@ -148,7 +148,7 @@ def add_or_update_resource(filename, data, res_type, names=None, languages=None)
     module_handle = win32api.BeginUpdateResource(filename, 0)
     for res_name in resources.keys():
         for res_lang in resources[res_name].keys():
-            win32api.UpdateResource(module_handle, res_type, res_name, data, language=res_lang)
+            win32api.UpdateResource(module_handle, res_type, res_name, data, res_lang)
     win32api.EndUpdateResource(module_handle, 0)
 
 


Test patch:
Repository: pyinstaller/pyinstaller

Issue:
Update hook module loading to PEP-451
Currently, the way hooks are loaded is through `importlib_load_source(self.hook_module_name, self.hook_filename)` found in `compat.py` which ends up using `importlib.Loader.load_module`. Unfortunately this way of loading modules is deprecated since 3.4 and, according to the warning and the documentation, is set to be removed in python 3.12.

The new way of loading modules from source is to use `importlib.abc.Loader.exec_module`, which requires a base ModuleType created using `types.ModuleType(loader.name)`. The function `importlib.abc.Loader.create_module` also exists to create a base ModuleType from a spec but this function returns `None` when "default module creation semantics should take place" which is the case for `SourceFileLoader` and, as far as I can tell, means using `types.ModuleType`.

I am not able to make the change and test it to open a pull request but the changes _should_ look a bit like this in `compat.py`:

Current
```
def importlib_load_source(name: str, pathname: str):
    # Import module from a file.
    mod_loader = importlib.machinery.SourceFileLoader(name, pathname)
    return mod_loader.load_module()
```

New
```
def importlib_load_source(name: str, pathname: str):
    # Import module from a file.
    mod_loader = importlib.machinery.SourceFileLoader(name, pathname)
    base_mod_type =  types.ModuleType(loader.name)
    return mod_loader.exec_module(base_mod_type)
```

This was causing an issue to me since the `load_module` function was throwing a silent warning which ended up as an error due to me using `warnings.simplefilter('error')` somewhere in my code. I do believe this is a _me_ issue, but also I believe that this is relevant to the project since it looks like the function is scheduled to be removed at one point in python 3.12


Discussion:
Thanks for digging through to find the non deprecated version. Given that the 3.12 release has come and gone, we're presumably safe for another 10 months or so but there's no harm in getting it out the way.

Resolving patch:
diff --git a/PyInstaller/compat.py b/PyInstaller/compat.py
--- a/PyInstaller/compat.py
+++ b/PyInstaller/compat.py
@@ -23,6 +23,7 @@
 import subprocess
 import sys
 import shutil
+import types
 
 from PyInstaller._shared_with_waf import _pyi_machine
 from PyInstaller.exceptions import ExecCommandFailed
@@ -623,7 +624,10 @@ def getsitepackages(prefixes: list | None = None):
 def importlib_load_source(name: str, pathname: str):
     # Import module from a file.
     mod_loader = importlib.machinery.SourceFileLoader(name, pathname)
-    return mod_loader.load_module()
+    mod = types.ModuleType(mod_loader.name)
+    mod.__file__ = mod_loader.get_filename()  # Some hooks require __file__ attribute in their namespace
+    mod_loader.exec_module(mod)
+    return mod
 
 
 # Patterns of module names that should be bundled into the base_library.zip to be available during bootstrap.


Test patch:
Repository: modoboa/modoboa

Issue:
Can't act on on message when current user has aliases
It is not possible to release/delete a message from the quarantine when the connecter user has aliases.



Discussion:

Resolving patch:
diff --git a/modoboa/extensions/amavis/views.py b/modoboa/extensions/amavis/views.py
--- a/modoboa/extensions/amavis/views.py
+++ b/modoboa/extensions/amavis/views.py
@@ -205,16 +205,15 @@ def check_mail_id(request, mail_id):
 
 def get_user_valid_addresses(user):
     """Retrieve all valid addresses of a user."""
+    valid_addresses = []
     if user.group == 'SimpleUsers':
-        valid_addresses = user.email
+        valid_addresses.append(user.email)
         try:
             mb = Mailbox.objects.get(user=user)
         except Mailbox.DoesNotExist:
             pass
         else:
             valid_addresses += mb.alias_addresses
-    else:
-        valid_addresses = None
     return valid_addresses
 
 
@@ -240,7 +239,7 @@ def delete(request, mail_id):
     valid_addresses = get_user_valid_addresses(request.user)
     for mid in mail_id:
         r, i = mid.split()
-        if valid_addresses is not None and r not in valid_addresses:
+        if valid_addresses and r not in valid_addresses:
             continue
         connector.set_msgrcpt_status(r, i, 'D')
     message = ungettext("%(count)d message deleted successfully",
@@ -290,7 +289,7 @@ def release(request, mail_id):
     valid_addresses = get_user_valid_addresses(request.user)
     for mid in mail_id:
         r, i = mid.split()
-        if valid_addresses is not None and r not in valid_addresses:
+        if valid_addresses and r not in valid_addresses:
             continue
         msgrcpts += [connector.get_recipient_message(r, i)]
     if request.user.group == "SimpleUsers" and \


Test patch:
Repository: modoboa/modoboa

Issue:
in the To:, Cc: and Bcc: fields, generate an error when email and/or delimiter is invalid
**Originally created by Fabrice Flore-Thébault on 2013-06-05T13:11:42Z**

In the webmail, if you add multiple emails with a wrong separator, or invalid emails, the application should report that you mistyped something, cancel the sending of the message, and ask you to correct the input.

Additionnaly some advice about the correct formatting of an email / a list of emails could be a nice feature.



Discussion:

Resolving patch:
diff --git a/modoboa/extensions/webmail/forms.py b/modoboa/extensions/webmail/forms.py
--- a/modoboa/extensions/webmail/forms.py
+++ b/modoboa/extensions/webmail/forms.py
@@ -14,6 +14,7 @@
     ImapEmail, create_mail_attachment
 )
 
+from validators import validate_email_list
 
 def html2plaintext(content):
     """HTML to plain text translation.
@@ -76,13 +77,14 @@ def make_body_images_inline(body):
     return lxml.html.tostring(html), parts
 
 
+
 class ComposeMailForm(forms.Form):
 
     """Compose mail form."""
 
-    to = forms.CharField(label=_("To"))
-    cc = forms.CharField(label=_("Cc"), required=False)
-    cci = forms.CharField(label=_("Cci"), required=False)
+    to = forms.CharField(label=_("To"), validators=[validate_email_list])
+    cc = forms.CharField(label=_("Cc"), required=False, validators=[validate_email_list])
+    cci = forms.CharField(label=_("Cci"), required=False, validators=[validate_email_list])
     subject = forms.CharField(
         label=_("Subject"),
         max_length=255,
diff --git a/modoboa/extensions/webmail/validators.py b/modoboa/extensions/webmail/validators.py
new file mode 100644
--- /dev/null
+++ b/modoboa/extensions/webmail/validators.py
@@ -0,0 +1,17 @@
+from django.utils.encoding import force_text
+from django.utils.deconstruct import deconstructible
+from django.core.validators import validate_email
+from email.utils import getaddresses
+
+class EmailListValidator(object):
+    """
+    Validate a comma separated list of email
+    """
+    def __call__(self, value):
+        value = force_text(value)
+        emails = map(unicode.strip, value.split(','))
+        addresses = getaddresses(emails)
+        [ validate_email(e) for r, e in addresses ]
+
+validate_email_list = EmailListValidator()
+


Test patch:
Repository: modoboa/modoboa

Issue:
In auto-reply message form, some issue around AM/PM datetime picker
In auto-reply message form, some issue around AM/PM datetime picker
![capture d ecran 2015-04-29 a 15 18 23](https://cloud.githubusercontent.com/assets/230143/7391824/07cfbbfa-ee84-11e4-950c-a3a34fd2c6e4.png)

I can't select AM or PM.

Suggest : enable 24h format



Discussion:
I want to test to upgrade "eonasdan-bootstrap-datetimepicker" but I've that issue #716 


Resolving patch:
diff --git a/modoboa/extensions/postfix_autoreply/forms.py b/modoboa/extensions/postfix_autoreply/forms.py
--- a/modoboa/extensions/postfix_autoreply/forms.py
+++ b/modoboa/extensions/postfix_autoreply/forms.py
@@ -11,7 +11,7 @@ class ARmessageForm(forms.ModelForm):
         required=False,
         help_text=ugettext_lazy("Activate your auto reply from this date"),
         widget=forms.TextInput(
-            attrs={'class': 'datefield form-control', 'readonly': 'readonly'}
+            attrs={'class': 'datefield form-control'}
         )
     )
     untildate = forms.DateTimeField(
@@ -19,7 +19,7 @@ class ARmessageForm(forms.ModelForm):
         required=False,
         help_text=ugettext_lazy("Activate your auto reply until this date"),
         widget=forms.TextInput(
-            attrs={'class': 'datefield form-control', 'readonly': 'readonly'}
+            attrs={'class': 'datefield form-control'}
         )
     )
     subject = forms.CharField(
diff --git a/modoboa/extensions/postfix_autoreply/general_callbacks.py b/modoboa/extensions/postfix_autoreply/general_callbacks.py
--- a/modoboa/extensions/postfix_autoreply/general_callbacks.py
+++ b/modoboa/extensions/postfix_autoreply/general_callbacks.py
@@ -9,7 +9,7 @@
 def extra_js(user):
     return ["""function autoreply_cb() {
     $('.datefield').datetimepicker({
-        format: 'YYYY-MM-DD hh:mm:ss',
+        format: 'YYYY-MM-DD HH:mm:ss',
         language: '%(lang)s'
     });
 }


Test patch:
Repository: modoboa/modoboa

Issue:
Passwords complexity
We must ensure passwords respect a minimum complexity.

See https://github.com/modoboa/modoboa-admin/issues/27



Discussion:

Resolving patch:
diff --git a/modoboa/core/dev_settings.py b/modoboa/core/dev_settings.py
--- a/modoboa/core/dev_settings.py
+++ b/modoboa/core/dev_settings.py
@@ -8,7 +8,7 @@
 BOWER_INSTALLED_APPS = (
     "jquery#1.9",
     "jquery-ui#1.11",
-    "bootstrap#3.3.1",
+    "bootstrap#3.3.5",
     "bootstrap-select#1.6",
     "d3#3.5.0",
     "eonasdan-bootstrap-datetimepicker#3.1.3",
diff --git a/modoboa/core/forms.py b/modoboa/core/forms.py
--- a/modoboa/core/forms.py
+++ b/modoboa/core/forms.py
@@ -5,6 +5,8 @@
 from django import forms
 from django.utils.translation import ugettext as _, ugettext_lazy
 
+from passwords.fields import PasswordField
+
 from modoboa.core.models import User
 from modoboa.lib import parameters
 
@@ -29,11 +31,11 @@ class ProfileForm(forms.ModelForm):
         label=ugettext_lazy("Old password"), required=False,
         widget=forms.PasswordInput(attrs={"class": "form-control"})
     )
-    newpassword = forms.CharField(
+    newpassword = PasswordField(
         label=ugettext_lazy("New password"), required=False,
         widget=forms.PasswordInput(attrs={"class": "form-control"})
     )
-    confirmation = forms.CharField(
+    confirmation = PasswordField(
         label=ugettext_lazy("Confirmation"), required=False,
         widget=forms.PasswordInput(attrs={"class": "form-control"})
     )


Test patch:
diff --git a/modoboa/core/tests.py b/modoboa/core/tests.py
--- a/modoboa/core/tests.py
+++ b/modoboa/core/tests.py
@@ -23,11 +23,11 @@ def test_update_password(self):
         """
         self.ajax_post(reverse("core:user_profile"),
                        {"oldpassword": "password",
-                        "newpassword": "titi", "confirmation": "titi"})
+                        "newpassword": "12345Toi", "confirmation": "12345Toi"})
         self.clt.logout()
 
         self.assertEqual(
-            self.clt.login(username="admin", password="titi"), True
+            self.clt.login(username="admin", password="12345Toi"), True
         )
         self.assertEqual(
             self.clt.login(username="user@test.com", password="toto"), True
@@ -36,9 +36,16 @@ def test_update_password(self):
         self.ajax_post(
             reverse("core:user_profile"),
             {"oldpassword": "toto",
-             "newpassword": "tutu", "confirmation": "tutu"}
+             "newpassword": "tutu", "confirmation": "tutu"},
+            status=400
+        )
+
+        self.ajax_post(
+            reverse("core:user_profile"),
+            {"oldpassword": "toto",
+             "newpassword": "Toto1234", "confirmation": "Toto1234"}
         )
         self.clt.logout()
         self.assertTrue(
-            self.clt.login(username="user@test.com", password="tutu")
+            self.clt.login(username="user@test.com", password="Toto1234")
         )
Repository: modoboa/modoboa

Issue:
Test failure when using tox
This is because tox use sqlite and has no user set

```
======================================================================
ERROR: test_map_upgrade (modoboa.admin.tests.test_mapfiles.MapFilesTestCase)
Check that map content is used.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/gawel/bear/modoboa/.tox/py27/lib/python2.7/site-packages/modoboa/admin/tests/test_mapfiles.py", line 45, in test_map_upgrade
    self.assertEqual(mapcontent["user"], dbsettings["USER"])
KeyError: 'user'

----------------------------------------------------------------------
Ran 178 tests in 44.553s
```



Discussion:

Resolving patch:
diff --git a/modoboa/core/management/commands/generate_postfix_maps.py b/modoboa/core/management/commands/generate_postfix_maps.py
--- a/modoboa/core/management/commands/generate_postfix_maps.py
+++ b/modoboa/core/management/commands/generate_postfix_maps.py
@@ -125,10 +125,13 @@ def __render_map_file(
             mapcontent = utils.parse_map_file(fullpath)
             context = copy.deepcopy(context)
             context["dbtype"] = self.__checksums[mapobject.filename]["dbtype"]
-            context["dbuser"] = mapcontent["user"]
-            context["dbpass"] = mapcontent["password"]
-            context["dbname"] = mapcontent["dbname"]
-            context["dbhost"] = mapcontent["hosts"]
+            if context["dbtype"] == "sqlite":
+                context["dbname"] = mapcontent["dbpath"]
+            else:
+                context["dbuser"] = mapcontent["user"]
+                context["dbpass"] = mapcontent["password"]
+                context["dbname"] = mapcontent["dbname"]
+                context["dbhost"] = mapcontent["hosts"]
         content = self.get_template(context["dbtype"]).render(
             Context(
                 dict(context.items(),


Test patch:
diff --git a/modoboa/admin/tests/test_mapfiles.py b/modoboa/admin/tests/test_mapfiles.py
--- a/modoboa/admin/tests/test_mapfiles.py
+++ b/modoboa/admin/tests/test_mapfiles.py
@@ -42,9 +42,13 @@ def test_map_upgrade(self):
         dbsettings = settings.DATABASES["default"]
         for f in self.MAP_FILES:
             mapcontent = parse_map_file(os.path.join(self.workdir, f))
-            self.assertEqual(mapcontent["user"], dbsettings["USER"])
-            self.assertEqual(mapcontent["password"], dbsettings["PASSWORD"])
-            self.assertEqual(mapcontent["dbname"], dbsettings["NAME"])
+            if dbsettings["ENGINE"] == "django.db.backends.sqlite3":
+                self.assertEqual(mapcontent["dbpath"], dbsettings["NAME"])
+            else:
+                self.assertEqual(mapcontent["user"], dbsettings["USER"])
+                self.assertEqual(
+                    mapcontent["password"], dbsettings["PASSWORD"])
+                self.assertEqual(mapcontent["dbname"], dbsettings["NAME"])
 
         # Now modify a file manually
         path = os.path.join(self.workdir, "sql-domains.cf")